Spade
Mini Shell
index.html000064400000000054151162054050006537 0ustar00<html><body
bgcolor="#FFFFFF"></body></html>src/Abstraction/ActiveRegistry.php000064400000016120151162054050013260
0ustar00<?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\Abstraction;
use VDM\Joomla\Interfaces\Activeregistryinterface;
/**
* Active Storage Registry.
*
* Don't use this beyond 10 dimensional depth for best performance.
*
* @since 3.2.0
*/
abstract class ActiveRegistry implements Activeregistryinterface
{
/**
* The registry array.
*
* @var array
* @since 3.2.0
**/
protected array $active = [];
/**
* Base switch to add values as string or array
*
* @var boolean
* @since 3.2.0
**/
protected bool $addAsArray = false;
/**
* Base switch to keep array values unique
*
* @var boolean
* @since 3.2.2
**/
protected bool $uniqueArray = false;
/**
* Check if the registry has any content.
*
* @return bool Returns true if the active array is not empty, false
otherwise.
* @since 3.2.0
*/
public function isActive(): bool
{
return !empty($this->active);
}
/**
* Get all value from the active registry.
*
* @return array The values or empty array.
* @since 3.2.0
*/
public function allActive(): array
{
return $this->active;
}
/**
* Sets a value into the registry using multiple keys.
*
* @param mixed $value The value to set.
* @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 setActive($value, string ...$keys): void
{
if (!$this->validActiveKeys($keys))
{
throw new \InvalidArgumentException("Keys must only be strings or
numbers to set any value.");
}
$array = &$this->active;
foreach ($keys as $key)
{
if (!isset($array[$key]))
{
if (!is_array($array))
{
$path = '[' . implode('][', $keys) .
']';
throw new \InvalidArgumentException("Attempted to use key
'{$key}' on a non-array value: {$array}. Path: {$path} Value:
{$value}");
}
$array[$key] = [];
}
$array = &$array[$key];
}
$array = $value;
}
/**
* 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|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
{
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)
{
if (!isset($array[$key]))
{
if (!is_array($array))
{
$path = '[' . implode('][', $keys) .
']';
throw new \InvalidArgumentException("Attempted to use key
'{$key}' on a non-array value: {$array}. Path: {$path} Value:
{$value}");
}
$array[$key] = [];
}
$array = &$array[$key];
}
// add string
if (!$asArray && $array === [])
{
$array = '';
}
// Handle the adding logic at the tip of the array
if (is_array($array) || $asArray)
{
if (!is_array($array))
{
// Convert to array if it's not already an array
$array = [$array];
}
if ($this->uniqueArray && in_array($value, $array))
{
// we do nothing
return;
}
else
{
$array[] = $value;
}
}
else
{
if (is_string($value) || is_numeric($value))
{
$array .= (string) $value;
}
else
{
$array = $value;
}
}
}
/**
* Retrieves a value (or sub-array) from the registry using multiple
keys.
*
* @param mixed $default The default value if not set.
* @param string ...$keys The keys to determine the location.
*
* @throws \InvalidArgumentException If any of the keys are not a number
or string.
* @return mixed The value or sub-array from the storage. Null if the
location doesn't exist.
* @since 3.2.0
*/
public function getActive($default, string ...$keys)
{
if (!$this->validActiveKeys($keys))
{
throw new \InvalidArgumentException("Keys must only be strings or
numbers to get any value.");
}
$array = $this->active;
foreach ($keys as $key)
{
if (!isset($array[$key]))
{
return $default;
}
$array = $array[$key];
}
return $array;
}
/**
* Removes a value (or sub-array) from the registry using multiple keys.
*
* @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 removeActive(string ...$keys): void
{
if (!$this->validActiveKeys($keys))
{
throw new \InvalidArgumentException("Keys must only be strings or
numbers to remove any value.");
}
$array = &$this->active;
$lastKey = array_pop($keys);
foreach ($keys as $key)
{
if (!isset($array[$key]))
{
return; // Exit early if the key doesn't exist
}
$array = &$array[$key];
}
unset($array[$lastKey]);
}
/**
* Checks the existence of a particular location in the registry using
multiple keys.
*
* @param string ...$keys The keys to determine the location.
*
* @throws \InvalidArgumentException If any of the keys are not a number
or string.
* @return bool True if the location exists, false otherwise.
* @since 3.2.0
*/
public function existsActive(string ...$keys): bool
{
if (!$this->validActiveKeys($keys))
{
throw new \InvalidArgumentException("Keys must only be strings or
numbers to check if any value exist.");
}
$array = $this->active;
foreach ($keys as $key)
{
if (!isset($array[$key]))
{
return false;
}
$array = $array[$key];
}
return true;
}
/**
* Checks that the keys are valid
*
* @param array $keys The keys to determine the location.
*
* @return bool False if any of the keys are not a number or string.
* @since 3.2.0
*/
protected function validActiveKeys(array $keys): bool
{
foreach ($keys as $key)
{
if ($key === '' || (!is_string($key) &&
!is_numeric($key)))
{
return false;
}
}
return true;
}
}
src/Abstraction/BaseConfig.php000064400000005464151162054050012325
0ustar00<?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\Abstraction;
use Joomla\Registry\Registry as JoomlaRegistry;
use VDM\Joomla\Utilities\String\ClassfunctionHelper;
/**
* Config
*
* @since 3.2.0
*/
abstract class BaseConfig extends JoomlaRegistry
{
/**
* Constructor
*
* @since 3.2.0
*/
public function __construct()
{
// Instantiate the internal data object.
$this->data = new \stdClass();
}
/**
* setting any config value
*
* @param string $key The value's key/path name
* @param mixed $value Optional default value, returned if the
internal value is null.
*
* @since 3.2.0
*/
public function __set($key, $value)
{
$this->set($key, $value);
}
/**
* getting any valid value
*
* @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($key)
{
// check if it has been set
if (($value = $this->get($key, '__N0T_S3T_Y3T_')) !==
'__N0T_S3T_Y3T_')
{
return $value;
}
throw new \InvalidArgumentException(sprintf('Argument %s could not
be found as function or path.', $key));
}
/**
* Get a config value.
*
* @param string $path Registry path (e.g.
joomla_content_showauthor)
* @param mixed $default Optional default value, returned if the
internal value is null.
*
* @return mixed Value of entry or null
*
* @since 3.2.0
*/
public function get($path, $default = null)
{
// function name with no underscores
$method = 'get' . ucfirst((string)
ClassfunctionHelper::safe(str_replace('_', '',
$path)));
// check if it has been set
if (($value = parent::get($path, '__N0T_S3T_Y3T_')) !==
'__N0T_S3T_Y3T_')
{
return $value;
}
elseif (method_exists($this, $method))
{
$value = $this->{$method}($default);
$this->set($path, $value);
return $value;
}
return $default;
}
/**
* Append value to a path in registry of an array
*
* @param string $path Parent registry Path (e.g.
joomla.content.showauthor)
* @param mixed $value Value of entry
*
* @return mixed The value of the that has been set.
*
* @since 3.2.0
*/
public function appendArray(string $path, $value)
{
// check if it does not exist
if (!$this->exists($path))
{
$this->set($path, []);
}
return $this->append($path, $value);
}
}
src/Abstraction/BaseTable.php000064400000025110151162054050012135
0ustar00<?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\Abstraction;
use VDM\Joomla\Interfaces\Tableinterface;
/**
* Base Table
*
* @since 3.2.0
*/
abstract class BaseTable implements Tableinterface
{
/**
* All areas/views/tables with their field details
*
* @var array
* @since 3.2.0
**/
protected array $tables;
/**
* All default fields
*
* @var array
* @since 3.2.1
**/
protected array $defaults = [
'id' => [
'order' => -1,
'name' => 'id',
'label' => 'ID',
'type' => 'text',
'title' => false,
'list' => NULL,
'store' => NULL,
'tab_name' => NULL,
'db' => [
'type' => 'INT(11)',
'default' => 'EMPTY',
'auto_increment' => true,
'primary_key' => true,
'null_switch' => 'NOT NULL'
]
],
'asset_id' => [
'name' => 'asset_id',
'label' => NULL,
'type' => NULL,
'title' => false,
'list' => NULL,
'store' => NULL,
'tab_name' => NULL,
'db' => [
'type' => 'INT(10) unsigned',
'default' => '0',
'null_switch' => 'NULL',
'comment' => 'FK to the #__assets table.'
]
],
'ordering' => [
'name' => 'ordering',
'label' => 'Ordering',
'type' => 'number',
'title' => false,
'list' => NULL,
'store' => NULL,
'tab_name' => NULL,
'db' => [
'type' => 'INT(11)',
'default' => '0',
'null_switch' => 'NULL'
]
],
'published' => [
'name' => 'published',
'label' => 'Status',
'type' => 'list',
'title' => false,
'list' => NULL,
'store' => NULL,
'tab_name' => NULL,
'db' => [
'type' => 'TINYINT(3)',
'default' => '1',
'null_switch' => 'NULL',
'key' => true,
'key_name' => 'state'
]
],
'modified_by' => [
'name' => 'modified_by',
'label' => 'Modified by',
'type' => 'user',
'title' => false,
'list' => NULL,
'store' => NULL,
'tab_name' => NULL,
'db' => [
'type' => 'INT(10) unsigned',
'default' => '0',
'null_switch' => 'NULL',
'key' => true,
'key_name' => 'modifiedby'
]
],
'modified' => [
'name' => 'modified',
'label' => 'Modified',
'type' => 'calendar',
'title' => false,
'list' => NULL,
'store' => NULL,
'tab_name' => NULL,
'db' => [
'type' => 'DATETIME',
'default' => '0000-00-00 00:00:00',
'null_switch' => 'NULL'
]
],
'created_by' => [
'name' => 'created_by',
'label' => 'Created by',
'type' => 'user',
'title' => false,
'list' => NULL,
'store' => NULL,
'tab_name' => NULL,
'db' => [
'type' => 'INT(10) unsigned',
'default' => '0',
'null_switch' => 'NULL',
'key' => true,
'key_name' => 'createdby'
]
],
'created' => [
'name' => 'created',
'label' => 'Created',
'type' => 'calendar',
'title' => false,
'list' => NULL,
'store' => NULL,
'tab_name' => NULL,
'db' => [
'type' => 'DATETIME',
'default' => '0000-00-00 00:00:00',
'null_switch' => 'NULL'
]
],
'checked_out' => [
'name' => 'checked_out',
'label' => NULL,
'type' => NULL,
'title' => false,
'list' => NULL,
'store' => NULL,
'tab_name' => NULL,
'db' => [
'type' => 'INT(10) unsigned',
'default' => '0',
'null_switch' => 'NULL',
'key' => true,
'key_name' => 'checkout'
]
],
'checked_out_time' => [
'name' => 'checked_out_time',
'label' => NULL,
'type' => NULL,
'title' => false,
'list' => NULL,
'store' => NULL,
'tab_name' => NULL,
'db' => [
'type' => 'DATETIME',
'default' => '0000-00-00 00:00:00',
'null_switch' => 'NULL'
]
],
'hits' => [
'name' => 'hits',
'label' => 'Hits',
'type' => 'number',
'title' => false,
'list' => NULL,
'store' => NULL,
'tab_name' => NULL,
'db' => [
'type' => 'INT(10) unsigned',
'default' => '0',
'null_switch' => 'NULL'
]
],
'version' => [
'name' => 'version',
'label' => 'Version',
'type' => 'text',
'title' => false,
'list' => NULL,
'store' => NULL,
'tab_name' => NULL,
'db' => [
'type' => 'INT(10) unsigned',
'default' => '1',
'null_switch' => 'NULL'
]
],
'params' => [
'name' => 'params',
'label' => NULL,
'type' => NULL,
'title' => false,
'list' => NULL,
'store' => 'json',
'tab_name' => NULL,
'db' => [
'type' => 'TEXT',
'default' => 'EMPTY',
'null_switch' => 'NULL'
]
]
];
/**
* Get any value from a item/field/column of an area/view/table
* Example: $this->get('table_name',
'field_name', 'value_key');
* Get an item/field/column of an area/view/table
* Example: $this->get('table_name',
'field_name');
* Get all items/fields/columns of an area/view/table
* Example: $this->get('table_name');
* Get all areas/views/tables with all their item/field/column details
* Example: $this->get('All');
* Example: $this->get();
*
* @param string|null $table The table
* @param string|null $field The field
* @param string|null $key The value key
*
* @return mixed
* @since 3.2.1
*/
public function get(?string $table = null, ?string $field = null, ?string
$key = null)
{
// Return specific value
if ($table && $field && $key)
{
return $this->tables[$table][$field][$key] ??
$this->getDefaultKey($field, $key);
}
// Return field within table
if ($table && $field)
{
return $this->tables[$table][$field] ??
$this->getDefault($field);
}
// Return all fields in a table or all tables if 'All' is
passed
if ($table)
{
if (strtoupper($table) === 'ALL')
{
return $this->tables;
}
return $this->tables[$table] ?? null;
}
// Return all tables
return $this->tables;
}
/**
* Get title field from an area/view/table
*
* @param string $table The area
*
* @return ?array
* @since 3.2.0
*/
public function title(string $table): ?array
{
// return the title item/field/column of an area/view/table
if (($table = $this->get($table)) !== null)
{
foreach ($table as $item)
{
if ($item['title'])
{
return $item;
}
}
}
// none found
return null;
}
/**
* Get title field name
*
* @param string $table The area
*
* @return string
* @since 3.2.0
*/
public function titleName(string $table): string
{
// return the title name of an area/view/table
if (($field = $this->title($table)) !== null)
{
return $field['name'];
}
// none found default to ID
return 'id';
}
/**
* Get all tables
*
* @return array
* @since 3.2.0
*/
public function tables(): array
{
// return all areas/views/tables
return array_keys($this->tables);
}
/**
* Check if a table (and field) exist
*
* @param string $table The area
* @param string|null $field The area
*
* @return bool
* @since 3.2.0
*/
public function exist(string $table, ?string $field = null): bool
{
if (isset($this->tables[$table]))
{
// if we have a field
if (is_string($field))
{
if (isset($this->tables[$table][$field]))
{
return true;
}
}
else
{
return true;
}
}
return $this->isDefault($field);
}
/**
* Get all fields of an area/view/table
*
* @param string $table The area
* @param bool $default Add the default fields
* @param bool $details Add/Leave fields the details
*
* @return array|null On success an array of fields
* @since 3.2.0
*/
public function fields(string $table, bool $default = false, bool $details
= false): ?array
{
// Retrieve fields from the specified table
$fields = $this->get($table);
if ($fields === null)
{
return null;
}
// Determine the fields output based on the $default and $details flags
if ($details)
{
return $default ? $this->addDefaultDetails($fields) : $fields;
}
$fieldKeys = array_keys($fields);
return $default ? $this->addDefault($fieldKeys) : $fieldKeys;
}
/**
* Add the default fields
*
* @param array $fields The table dynamic fields
*
* @return array Fields (with defaults added)
* @since 3.2.0
*/
protected function addDefault(array $fields): array
{
// add default fields
foreach ($this->defaults as $default)
{
if (in_array($default['name'], $fields))
{
continue;
}
// used just for loading the fields
$order = $default['order'] ?? 1;
unset($default['order']);
if ($order < 0)
{
array_unshift($fields, $default['name']);
}
else
{
$fields[] = $default['name'];
}
}
return $fields;
}
/**
* Add the default fields
*
* @param array $fields The table dynamic fields
*
* @return array Fields (with defaults details added)
* @since 3.2.0
*/
protected function addDefaultDetails(array $fields): array
{
// add default fields
foreach ($this->defaults as $default)
{
// remove ordering for now
unset($default['order']);
if (!isset($fields[$default['name']]))
{
$fields[$default['name']] = $default;
}
}
return $fields;
}
/**
* Check if the field is a default field
*
* @param string $field The field to check
*
* @return bool True if a default field
* @since 3.2.0
*/
protected function isDefault(string $field): bool
{
return isset($this->defaults[$field]);
}
/**
* Get a default field
*
* @param string $field The field to check
*
* @return array|null True if a default field
* @since 3.2.0
*/
protected function getDefault(string $field): ?array
{
return $this->defaults[$field] ?? null;
}
/**
* Get a default field property
*
* @param string $field The field to check
* @param string $key The field key/property to check
*
* @return mixed String value if a default field property exist
* @since 3.2.0
*/
protected function getDefaultKey(string $field, string $key)
{
return $this->defaults[$field][$key] ?? null;
}
}
src/Abstraction/Database.php000064400000004340151162054050012021
0ustar00<?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\Abstraction;
use Joomla\CMS\Factory as JoomlaFactory;
use VDM\Joomla\Utilities\Component\Helper;
/**
* Database
*
* @since 3.2.0
*/
abstract class Database
{
/**
* Database object to query local DB
*
* @since 3.2.0
*/
protected $db;
/**
* Core Component Table Name
*
* @var string
* @since 3.2.0
*/
protected string $table;
/**
* Constructor
*
* @throws \Exception
* @since 3.2.0
*/
public function __construct()
{
$this->db = JoomlaFactory::getDbo();
// set the component table
$this->table = '#__' . Helper::getCode();
}
/**
* Set a value based on data type
*
* @param mixed $value The value to set
*
* @return mixed
* @since 3.2.0
**/
protected function quote($value)
{
if ($value === null) // hmm the null does pose an issue (will keep an eye
on this)
{
return 'NULL';
}
if (is_numeric($value))
{
if (filter_var($value, FILTER_VALIDATE_INT))
{
return (int) $value;
}
elseif (filter_var($value, FILTER_VALIDATE_FLOAT))
{
return (float) $value;
}
}
elseif (is_bool($value)) // not sure if this will work well (but its
correct)
{
return $value ? 'TRUE' : 'FALSE';
}
// For date and datetime values
if ($value instanceof \DateTime)
{
return $this->db->quote($value->format('Y-m-d
H:i:s'));
}
// For other data types, just escape it
return $this->db->quote($value);
}
/**
* Set a table name, adding the
* core component as needed
*
* @param string $table The table string
*
* @return string
* @since 3.2.0
**/
protected function getTable(string $table): string
{
if (strpos($table, '#__') === false)
{
return $this->table . '_' . $table;
}
return $table;
}
}
src/Abstraction/Factory.php000064400000004435151162054050011731
0ustar00<?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\Abstraction;
use Joomla\DI\Container;
use VDM\Joomla\Interfaces\FactoryInterface;
/** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** **
** ** ** **
** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** **
** ** ** **
**
** In realms of code where purists frown, the anti-pattern wears a
crown,
** A paradox of chaos bright, where complex paths lose all its slight.
** For in its tangled, wild embrace, lies raw creativity's face,
** No rigid forms, no strict decree, just boundless, daring artistry.
** In flaws, we find the freedom's key, where messy code and
brilliance spree,
** A dance of thought, unchained, unbound, in anti-pattern,
beauty's found.
**
** Perfect Paradox and True Nature of the Anti-Pattern by ChatGPT
**
** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** **
** ** ** **
** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** **
** ** ** **
**
** @since 0.0.0
**/
abstract class Factory implements FactoryInterface
{
/**
* Global Package Container
*
* @var Container|null
* @since 0.0.0
**/
protected static ?Container $container = null;
/**
* Get any class from the package container
*
* @param string $key The container class key
*
* @return Mixed
* @since 0.0.0
*/
public static function _($key)
{
return static::getContainer()->get($key);
}
/**
* Get the global package container
*
* @return Container
* @since 0.0.0
*/
public static function getContainer(): Container
{
if (!static::$container)
{
static::$container = static::createContainer();
}
return static::$container;
}
/**
* Create a container object
*
* @return Container
* @since 0.0.0
*/
abstract protected static function createContainer(): Container;
}
src/Abstraction/Grep.php000064400000040315151162054050011214
0ustar00<?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\Abstraction;
use Joomla\CMS\Factory;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Filesystem\Folder;
use Joomla\CMS\Application\CMSApplication;
use VDM\Joomla\Gitea\Repository\Contents;
use VDM\Joomla\Utilities\FileHelper;
use VDM\Joomla\Utilities\JsonHelper;
use VDM\Joomla\Interfaces\GrepInterface;
/**
* Global Resource Empowerment Platform
*
* The Grep feature will try to find your power in the repositories
listed in the global
* Options of JCB in the super powers tab, and if it can't be found
there will try the global core
* Super powers of JCB. All searches are performed according the
[algorithm:cascading]
* See documentation for more details:
https://git.vdm.dev/joomla/super-powers/wiki
*
* @since 3.2.1
*/
abstract class Grep implements GrepInterface
{
/**
* The local path
*
* @var string|null
* @since 3.2.0
**/
public ?string $path;
/**
* All approved paths
*
* @var array|null
* @since 3.2.0
**/
public ?array $paths;
/**
* Order of global search
*
* @var array
* @since 3.2.1
**/
protected array $order = ['local', 'remote'];
/**
* The target branch field name ['read_branch',
'write_branch']
*
* @var string
* @since 3.2.2
**/
protected string $branch_field = 'read_branch';
/**
* The target default branch name
*
* @var string|null
* @since 3.2.2
**/
protected ?string $branch_name = null;
/**
* The index file path
*
* @var string
* @since 3.2.2
*/
protected string $index_path = 'index.json';
/**
* Gitea Repository Contents
*
* @var Contents
* @since 3.2.0
**/
protected Contents $contents;
/**
* Joomla Application object
*
* @var CMSApplication
* @since 3.2.0
**/
protected CMSApplication $app;
/**
* Constructor.
*
* @param Contents $contents The Gitea Repository Contents
object.
* @param array $paths The approved paths
* @param string|null $path The local path
* @param CMSApplication|null $app The CMS Application object.
*
* @throws \Exception
* @since 3.2.0
*/
public function __construct(Contents $contents, array $paths, ?string
$path = null, ?CMSApplication $app = null)
{
$this->contents = $contents;
$this->paths = $paths;
$this->path = $path;
$this->app = $app ?: Factory::getApplication();
$this->initializeInstances();
}
/**
* Get an item
*
* @param string $guid The global unique id of the item
* @param array|null $order The search order
* @param object|null $repo The repository object to search. If null,
all repos will be searched.
*
* @return object|null
* @since 3.2.2
*/
public function get(string $guid, ?array $order = null, ?object $repo =
null): ?object
{
$order = $order ?? $this->order;
if ($repo !== null)
{
return $this->searchSingleRepo($guid, $order, $repo);
}
return $this->searchAllRepos($guid, $order);
}
/**
* Check if an item exists in any repo or in a specific repo.
*
* @param string $guid The unique identifier for the item.
* @param object|null $repo The repository object to check against. If
null, all repos will be checked.
* @param array|null $order The order of the targets to check. If null,
the default order will be used.
*
* @return bool True if the item exists, false otherwise.
* @since 3.2.2
*/
public function exists(string $guid, ?object $repo = null, ?array $order =
null): bool
{
$order = $order ?? $this->order;
if ($repo !== null)
{
return $this->itemExistsInRepo($guid, $repo, $order);
}
return $this->itemExistsInAllRepos($guid, $order);
}
/**
* Get all remote GUID's
*
* @return array|null
* @since 3.2.0
*/
public function getRemoteGuid(): ?array
{
if (!is_array($this->paths) || $this->paths === [])
{
return null;
}
$powers = [];
foreach ($this->paths as $path)
{
// Get remote index
$this->indexRemote($path);
if (isset($path->index) && is_object($path->index))
{
$powers = array_merge($powers, array_keys((array) $path->index));
}
}
return empty($powers) ? null : array_unique($powers);
}
/**
* Set the branch field
*
* @param string $field The field to use to get the branch name from
the data set
*
* @return void
* @since 3.2.2
*/
public function setBranchField(string $field): void
{
$this->branch_field = $field;
}
/**
* Set the DEFAULT branch name (only used if branch field is not found)
*
* @param string|null $name The default branch to use if no name
could be found
*
* @return void
* @since 3.2.2
*/
public function setBranchDefaultName(?string $name): void
{
$this->branch_name = $name;
}
/**
* Set the index path
*
* @param string $indexPath The repository index path
*
* @return void
* @since 3.2.2
*/
public function setIndexPath(string $indexPath): void
{
$this->index_path = $indexPath;
}
/**
* Get the index of a repo
*
* @param string $guid The unique identifier for the repo.
*
* @return object|null
* @since 3.2.2
*/
public function getRemoteIndex(string $guid): ?object
{
if (!is_array($this->paths) || $this->paths === [] ||
empty($guid))
{
return null;
}
foreach ($this->paths as $path)
{
if (!isset($path->guid) || $guid !== $path->guid)
{
continue;
}
// Get remote index
$this->indexRemote($path);
if (isset($path->index) && is_object($path->index))
{
return $path->index;
}
}
return null;
}
/**
* Set repository messages and errors based on given conditions.
*
* @param string $message The message to set (if error)
* @param string $path Path value
* @param string $repository Repository name
* @param string $organisation Organisation name
* @param string|null $base Base URL
*
* @return void
* @since 3.2.0
*/
abstract protected function setRemoteIndexMessage(string $message, string
$path, string $repository, string $organisation, ?string $base): void;
/**
* Get function name
*
* @param string $name The targeted area name
* @param string $type The type of function name
*
* @return string|null
* @since 3.2.0
*/
protected function getFunctionName(string $name, string $type =
'search'): ?string
{
$function_name = $type . ucfirst(strtolower($name));
return method_exists($this, $function_name) ? $function_name : null;
}
/**
* Search a single repository for an item
*
* @param string $guid The unique identifier for the item.
* @param array $order The order of the targets to check.
* @param object $repo The repository object to check against.
*
* @return object|null
* @since 3.2.2
*/
protected function searchSingleRepo(string $guid, array $order, object
$repo): ?object
{
foreach ($order as $target)
{
if ($this->itemExists($guid, $repo, $target))
{
$functionName = $this->getFunctionName($target, 'get');
if ($functionName !== null && ($power =
$this->{$functionName}($repo, $guid)) !== null)
{
return $power;
}
}
}
return null;
}
/**
* Search all repositories for an item
*
* @param string $guid The unique identifier for the item.
* @param object $repo The repository object to check against.
*
* @return object|null
* @since 3.2.2
*/
protected function searchAllRepos(string $guid, array $order): ?object
{
if (is_array($this->paths) && $this->paths !== [])
{
foreach ($order as $target)
{
$functionName = $this->getFunctionName($target);
if ($functionName !== null && ($power =
$this->{$functionName}($guid)) !== null)
{
return $power;
}
}
}
return null;
}
/**
* Check if an item exists in a specific repository.
*
* @param string $guid The unique identifier for the item.
* @param object $repo The repository object to check against.
* @param array $order The order of the targets to check.
*
* @return bool True if the item exists, false otherwise.
* @since 3.2.2
*/
protected function itemExistsInRepo(string $guid, object $repo, array
$order): bool
{
foreach ($order as $target)
{
if ($this->itemExists($guid, $repo, $target))
{
return true;
}
}
return false;
}
/**
* Check if an item exists in any of the repositories.
*
* @param string $guid The unique identifier for the item.
* @param array $order The order of the targets to check.
*
* @return bool True if the item exists, false otherwise.
* @since 3.2.2
*/
protected function itemExistsInAllRepos(string $guid, array $order): bool
{
// We can only search if we have paths
if (is_array($this->paths) && $this->paths !== [])
{
foreach ($order as $target)
{
foreach ($this->paths as $path)
{
if ($this->itemExists($guid, $path, $target))
{
return true;
}
}
}
}
return false;
}
/**
* Get the branch field
*
* @return string
* @since 3.2.2
*/
protected function getBranchField(): string
{
return $this->branch_field;
}
/**
* Get the branch default name
*
* @return string|null
* @since 3.2.2
*/
protected function getBranchDefaultName(): ?string
{
return $this->branch_name;
}
/**
* Get the branch name
*
* @param object $item The item path
*
* @return string|null
* @since 3.2.2
*/
protected function getBranchName(object $item): ?string
{
// get the branch field name
$branch_field = $this->getBranchField();
return $item->{$branch_field} ?? $this->getBranchDefaultName();
}
/**
* Get the index path
*
* @return string
* @since 3.2.2
*/
protected function getIndexPath(): string
{
return $this->index_path;
}
/**
* Check if an item exists in a specific repo and target.
*
* @param string $guid The unique identifier for the item.
* @param object $repo The repository object to check against.
* @param string $target The target to check within the repo.
*
* @return bool True if the item exists, false otherwise.
* @since 3.2.2
*/
protected function itemExists(string $guid, object &$repo, string
$target): bool
{
if (($function_name = $this->getFunctionName($target,
'index')) !== null)
{
$this->{$function_name}($repo);
if (($function_name = $this->getFunctionName($target,
'exists')) !== null &&
$this->{$function_name}($guid, $repo))
{
return true;
}
}
return false;
}
/**
* Check if item exists locally
*
* @param string $guid The global unique id of the item
*
* @return object|null return path object
* @since 3.2.2
*/
protected function existsLocally(string $guid): ?object
{
// we can only search if we have paths
if ($this->path && $this->paths)
{
foreach ($this->paths as $path)
{
// get local index
$this->indexLocal($path);
if ($this->existsLocal($guid, $path))
{
return $path;
}
}
}
return null;
}
/**
* Check if item exists remotely
*
* @param string $guid The global unique id of the item
*
* @return object|null return path object
* @since 3.2.2
*/
protected function existsRemotely(string $guid): ?object
{
// we can only search if we have paths
if ($this->paths)
{
foreach ($this->paths as $path)
{
// get local index
$this->indexRemote($path);
if ($this->existsRemote($guid, $path))
{
return $path;
}
}
}
return null;
}
/**
* Check if item exists locally
*
* @param string $guid The global unique id of the item
* @param object $path The path object
*
* @return bool true if it exists
* @since 3.2.2
*/
protected function existsLocal(string $guid, object $path): bool
{
if (!empty($path->local) &&
isset($path->local->{$guid}))
{
return true;
}
return false;
}
/**
* Check if item exists remotely
*
* @param string $guid The global unique id of the item
* @param object $path The path object
*
* @return bool true if it exists
* @since 3.2.2
*/
protected function existsRemote(string $guid, object $path): bool
{
if (!empty($path->index) &&
isset($path->index->{$guid}))
{
return true;
}
return false;
}
/**
* Load the remote repository index of powers
*
* @param object $path The repository path details
*
* @return void
* @since 3.2.0
*/
protected function indexRemote(object &$path): void
{
if (isset($path->index))
{
return; // already set
}
try
{
// load the base and token if set
$this->contents->load_($path->base ?? null, $path->token ??
null);
$path->index = $this->contents->get($path->organisation,
$path->repository, $this->getIndexPath(),
$this->getBranchName($path));
}
catch (\Exception $e)
{
$path->index = null;
$this->setRemoteIndexMessage($e->getMessage(), $path->path,
$path->repository, $path->organisation, $path->base ?? null);
}
finally
{
// reset back to the global base and token
$this->contents->reset_();
}
}
/**
* Load the local repository index of powers
*
* @param object $path The repository path details
*
* @return void
* @since 3.2.0
*/
protected function indexLocal(object &$path): void
{
if (isset($path->local) || !isset($path->full_path))
{
return;
}
if (($content = FileHelper::getContent($path->full_path .
'/' . $this->getIndexPath(), null)) !== null &&
JsonHelper::check($content))
{
$path->local = json_decode($content);
return;
}
$path->local = null;
}
/**
* Set path details
*
* @return void
* @since 3.2.0
*/
protected function initializeInstances(): void
{
if (is_array($this->paths) && $this->paths !== [])
{
foreach ($this->paths as $n => &$path)
{
if (isset($path->organisation) &&
strlen($path->organisation) > 1 &&
isset($path->repository) && strlen($path->repository)
> 1)
{
// build the path
$path->path = trim($path->organisation) . '/' .
trim($path->repository);
// get the branch field name
$branch_field = $this->getBranchField();
// get the branch name
$branch = $this->getBranchName($path);
if ($branch === 'default' || empty($branch))
{
// will allow us to target the default branch as set by the git
system
$path->{$branch_field} = null;
}
// set local path
if ($this->path && Folder::exists($this->path .
'/' . $path->path))
{
$path->full_path = $this->path . '/' .
$path->path;
}
}
else
{
unset($this->paths[$n]);
}
}
}
}
/**
* Load the remote file
*
* @param string $organisation The repository organisation
* @param string $repository The repository name
* @param string $path The repository path to file
* @param string|null $branch The repository branch name
*
* @return mixed
* @since 3.2.0
*/
protected function loadRemoteFile(string $organisation, string
$repository, string $path, ?string $branch)
{
try
{
$data = $this->contents->get($organisation, $repository, $path,
$branch);
}
catch (\Exception $e)
{
$this->app->enqueueMessage(
Text::sprintf('COM_COMPONENTBUILDER_PFILE_AT_BSSB_GAVE_THE_FOLLOWING_ERRORBR_SP',
$this->contents->api(), $path, $e->getMessage()),
'Error'
);
return null;
}
return $data;
}
}
src/Abstraction/index.html000064400000000054151162054050011577
0ustar00<html><body
bgcolor="#FFFFFF"></body></html>src/Abstraction/Model.php000064400000024613151162054050011362
0ustar00<?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\Abstraction;
use VDM\Joomla\Utilities\StringHelper;
use VDM\Joomla\Utilities\ArrayHelper;
use VDM\Joomla\Interfaces\Tableinterface as Table;
use VDM\Joomla\Interfaces\ModelInterface;
/**
* Base Model
*
* @since 3.2.0
*/
abstract class Model implements ModelInterface
{
/**
* Last ID
*
* @var array
* @since 3.2.0
*/
protected array $last;
/**
* Search Table
*
* @var Table
* @since 3.2.0
*/
protected Table $table;
/**
* Table Name
*
* @var string
* @since 3.2.0
*/
protected string $tableName;
/**
* The switch to control the behaviour of empty values
*
* @var bool
* @since 3.2.2
*/
protected bool $allowEmpty = true;
/**
* Constructor
*
* @param Table $table The search table object.
* @param string|null $tableName The table
* @param bool|null $allowEmpty The switch to control the
behaviour of empty values (default true)
*
* @since 3.2.0
*/
public function __construct(Table $table, ?string $tableName = null, bool
$allowEmpty = null)
{
$this->table = $table;
if ($tableName !== null)
{
$this->setTable($tableName);
}
if ($allowEmpty !== null)
{
$this->setAllowEmpty($allowEmpty);
}
}
/**
* Set the current active table
*
* @param string $table The table that should be active
*
* @return self
* @since 3.2.2
*/
public function table(string $table): self
{
$this->setTable($table);
return $this;
}
/**
* Model the value
* Example: $this->value(value, 'value_key',
'table_name');
*
* @param mixed $value The value to model
* @param string $field The field key
* @param string|null $table The table
*
* @return mixed
* @since 3.2.0
*/
abstract public function value($value, string $field, ?string $table =
null);
/**
* Model a value of multiple items
* Example: $this->items(Array, 'value_key',
'table_name');
*
* @param array|null $items The array of values
* @param string $field The field key
* @param string|null $table The table
*
* @return array|null
* @since 3.2.2
*/
public function values(?array $items, string $field, ?string $table =
null): ?array
{
// check if this is a valid table
if (ArrayHelper::check($items))
{
// set the table name
if (empty($table))
{
$table = $this->getTable();
}
// validate if field exist in table
if (!$this->table->exist($table, $field))
{
return null;
}
// value counter
$value_number = 0;
// check if this is a valid table
$item_bucket = [];
foreach ($items as $value)
{
if (!$this->validateBefore($value, $field, $table))
{
continue;
}
$value = $this->value($value, $field, $table);
if (!$this->validateAfter($value, $field, $table))
{
continue;
}
$item_bucket[] = $value;
$value_number++;
}
// do we have any values left
if ($value_number > 0)
{
return $item_bucket;
}
}
return null;
}
/**
* Model the values of an item
* Example: $this->item(Object, 'table_name');
*
* @param object|null $item The item object
* @param string|null $table The table
*
* @return object|null
* @since 3.2.0
*/
public function item(?object $item, ?string $table = null): ?object
{
// we must have an object
if (empty($item))
{
return null;
}
// set the table name
if (empty($table))
{
$table = $this->getTable();
}
if (($fields = $this->getTableFields($table, true)) !== null)
{
// field counter
$field_number = 0;
// check if this is a valid table
$item_bucket = new \stdClass();
foreach ($fields as $field)
{
// model a value if it exists
if(isset($item->{$field}))
{
if (!$this->validateBefore($item->{$field}, $field, $table))
{
continue;
}
$item->{$field} = $this->value($item->{$field}, $field,
$table);
if (!$this->validateAfter($item->{$field}, $field, $table))
{
continue;
}
$item_bucket->{$field} = $item->{$field};
$field_number++;
}
}
// all items must have more than one field or its empty (1 = key)
if ($field_number > 1)
{
return $item_bucket;
}
}
return null;
}
/**
* Model the values of multiple items
* Example: $this->items(Array, 'table_name');
*
* @param array|null $items The array of item objects
* @param string|null $table The table
*
* @return array|null
* @since 3.2.0
*/
public function items(?array $items = null, ?string $table = null):
?array
{
// check if this is a valid table
if (ArrayHelper::check($items))
{
// set the table name
if (empty($table))
{
$table = $this->getTable();
}
foreach ($items as $id => &$item)
{
// model the item
if (($item = $this->item($item, $table)) !== null)
{
// add the last ID
$this->last[$table] = $item->id ?? $this->last[$table] ??
null;
}
else
{
unset($items[$id]);
}
}
if (ArrayHelper::check($items))
{
return $items;
}
}
return null;
}
/**
* Model the values of an row
* Example: $this->item(Array, 'table_name');
*
* @param array|null $item The item array
* @param string|null $table The table
*
* @return array|null
* @since 3.2.0
*/
public function row(?array $item, ?string $table = null): ?array
{
// we must have an array
if (empty($item))
{
return null;
}
// set the table name
if (empty($table))
{
$table = $this->getTable();
}
if (($fields = $this->getTableFields($table, true)) !== null)
{
// field counter
$field_number = 0;
// check if this is a valid table
$item_bucket = [];
foreach ($fields as $field)
{
// model a value if it exists
if(isset($item[$field]))
{
if (!$this->validateBefore($item[$field], $field, $table))
{
continue;
}
$item[$field] = $this->value($item[$field], $field, $table);
if (!$this->validateAfter($item[$field], $field, $table))
{
continue;
}
$item_bucket[$field] = $item[$field];
$field_number++;
}
}
// all items must have more than one field or its empty (1 = id or
guid)
if ($field_number > 1)
{
return $item_bucket;
}
}
return null;
}
/**
* Model the values of multiple rows
* Example: $this->items(Array, 'table_name');
*
* @param array|null $items The array of item array
* @param string|null $table The table
*
* @return array|null
* @since 3.2.0
*/
public function rows(?array $items = null, ?string $table = null): ?array
{
// check if this is a valid table
if (ArrayHelper::check($items))
{
// set the table name
if (empty($table))
{
$table = $this->getTable();
}
foreach ($items as $id => &$item)
{
// model the item
if (($item = $this->row($item, $table)) !== null)
{
// add the last ID
$this->last[$table] = $item['id'] ??
$this->last[$table] ?? null;
}
else
{
unset($items[$id]);
}
}
if (ArrayHelper::check($items))
{
return $items;
}
}
return null;
}
/**
* Get last modeled ID
* Example: $this->last('table_name');
*
* @param string|null $table The table
*
* @return int|null
* @since 3.2.0
*/
public function last(?string $table = null): ?int
{
// set the table name
if (empty($table))
{
$table = $this->getTable();
}
// check if this is a valid table
if ($table && isset($this->last[$table]))
{
return $this->last[$table];
}
return null;
}
/**
* Set the current active table
*
* @param string $tableName The table name
*
* @return void
* @since 3.2.2
*/
public function setTable(string $tableName): void
{
$this->tableName = $tableName;
}
/**
* Set the switch to control the behaviour of empty values
*
* @param bool $allowEmpty The switch
*
* @return void
* @since 3.2.2
*/
public function setAllowEmpty(bool $allowEmpty): void
{
$this->allowEmpty = $allowEmpty;
}
/**
* Get the current active table
*
* @return string
* @since 3.2.0
*/
protected function getTable(): string
{
return $this->tableName;
}
/**
* Get the switch to control the behaviour of empty values
*
* @return bool
* @since 3.2.2
*/
protected function getAllowEmpty(): bool
{
return $this->allowEmpty;
}
/**
* Get the current active table's fields (including defaults)
*
* @param string $table The area
* @param bool $default Add the default fields
*
* @return array
* @since 3.2.0
*/
protected function getTableFields(string $table, bool $default = false):
?array
{
return $this->table->fields($table, $default);
}
/**
* Validate before the value is modelled (basic, override in child class)
*
* @param mixed $value The field value
* @param string|null $field The field key
* @param string|null $table The table
*
* @return bool
* @since 3.2.0
*/
abstract protected function validateBefore(&$value, ?string $field =
null, ?string $table = null): bool;
/**
* Validate after the value is modelled (basic, override in child class)
*
* @param mixed $value The field value
* @param string|null $field The field key
* @param string|null $table The table
*
* @return bool
* @since 3.2.0
*/
abstract protected function validateAfter(&$value, ?string $field =
null, ?string $table = null): bool;
}
src/Abstraction/PHPConfigurationChecker.php000064400000016310151162054050014761
0ustar00<?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\Abstraction;
use Joomla\CMS\Factory;
use VDM\Joomla\Interfaces\PHPConfigurationCheckerInterface;
use VDM\Joomla\Abstraction\Registry;
/**
* PHP Configuration Checker
*
* @since 5.0.2
*/
abstract class PHPConfigurationChecker extends Registry implements
PHPConfigurationCheckerInterface
{
/**
* The upload max filesize value
*
* @var string
* @since 5.0.2
**/
protected string $upload_max_filesize;
/**
* The post max size value
*
* @var string
* @since 5.0.2
**/
protected string $post_max_size;
/**
* The max execution time value
*
* @var int
* @since 5.0.2
**/
protected int $max_execution_time;
/**
* The max input vars value
*
* @var int
* @since 5.0.2
**/
protected int $max_input_vars;
/**
* The max input time value
*
* @var int
* @since 5.0.2
**/
protected int $max_input_time;
/**
* The memory limit value
*
* @var string
* @since 5.0.2
**/
protected string $memory_limit;
/**
* The registry array.
*
* @var array
* @since 5.0.2
**/
protected array $active = [
'php' => [
'upload_max_filesize' => [
'success' => 'The upload_max_filesize is
appropriately set to handle large files, which is essential for uploading
substantial components and media.',
'warning' => 'The current upload_max_filesize may not
support large file uploads effectively, potentially causing failures during
component installation.'
],
'post_max_size' => [
'success' => 'The post_max_size setting is sufficient
to manage large data submissions, ensuring smooth data processing within
forms and uploads.',
'warning' => 'An insufficient post_max_size can lead
to truncated data submissions, affecting form functionality and data
integrity.'
],
'max_execution_time' => [
'success' => 'Max execution time is set high enough
to execute complex operations without premature termination, which is
crucial for lengthy operations.',
'warning' => 'A low max execution time could lead to
script timeouts, especially during intensive operations, which might
interrupt execution and cause failures during the compiling of a large
extension.'
],
'max_input_vars' => [
'success' => 'The max_input_vars setting supports a
high number of input variables, facilitating complex forms and detailed
component configurations.',
'warning' => 'Too few max_input_vars may result in
lost data during processing complex forms, which can lead to incomplete
configurations and operational issues.'
],
'max_input_time' => [
'success' => 'Max input time is adequate for
processing inputs efficiently during high-load operations, ensuring no
premature timeouts.',
'warning' => 'An insufficient max input time could
result in incomplete data processing during input-heavy operations,
potentially leading to errors and data loss.'
],
'memory_limit' => [
'success' => 'The memory limit is set high to
accommodate extensive operations and data processing, which enhances
overall performance and stability.',
'warning' => 'A low memory limit can lead to frequent
crashes and performance issues, particularly when processing large amounts
of data or complex calculations.'
]
],
'environment' => [
'name' => 'extension environment',
'objective' => 'These settings are crucial for
ensuring the successful installation and stable functionality of the
extension.',
'wiki_name' => 'PHP Settings Wiki',
'wiki_url' => '#'
]
];
/**
* Application object.
*
* @since 5.0.2
**/
protected $app;
/**
* Constructor.
*
* @param $app The app object.
*
* @since 5.0.2
*/
public function __construct($app = null)
{
$this->app = $app ?: Factory::getApplication();
// set the required PHP Configures
$this->set('php.upload_max_filesize.value',
$this->upload_max_filesize);
$this->set('php.post_max_size.value',
$this->post_max_size);
$this->set('php.max_execution_time.value',
$this->max_execution_time);
$this->set('php.max_input_vars.value',
$this->max_input_vars);
$this->set('php.max_input_time.value',
$this->max_input_time);
$this->set('php.memory_limit.value',
$this->memory_limit);
}
/**
* Check that the required configurations are set for PHP
*
* @return void
* @since 5.0.2
**/
public function run(): void
{
$showHelp = false;
// Check each configuration and provide detailed feedback
$configurations = $this->active['php'] ?? [];
foreach ($configurations as $configName => $configDetails)
{
$currentValue = ini_get($configName);
if ($currentValue === false)
{
$this->app->enqueueMessage("Error: Unable to retrieve
current setting for '{$configName}'.", 'error');
continue;
}
$requiredValue = $configDetails['value'] ?? 0;
$isMemoryValue = strpbrk($requiredValue, 'KMG') !== false;
$requiredValueBytes = $isMemoryValue ?
$this->convertToBytes($requiredValue) : (int) $requiredValue;
$currentValueBytes = $isMemoryValue ?
$this->convertToBytes($currentValue) : (int) $currentValue;
$conditionMet = $currentValueBytes >= $requiredValueBytes;
$messageType = $conditionMet ? 'message' :
'warning';
$messageText = $conditionMet ?
"Success: {$configName} is set to {$currentValue}. " .
$configDetails['success'] ?? '':
"Warning: {$configName} configuration should be at least
{$requiredValue} but is currently {$currentValue}. " .
$configDetails['warning'] ?? '';
$showHelp = ($showHelp || $messageType === 'warning') ? true :
false;
$this->app->enqueueMessage($messageText, $messageType);
}
if ($showHelp)
{
$this->app->enqueueMessage("To optimize your
{$this->get('environment.name', 'extension')},
specific PHP settings must be
enhanced.<br>{$this->get('environment.objective',
'')}<br>We've identified that certain configurations
currently do not meet the recommended standards.<br>To adjust these
settings and prevent potential issues, please consult our detailed guide
available at <a
href=\"https://{$this->get('environment.wiki_url',
'#')}\"
target=\"_blank\">{$this->get('environment.wiki_name',
'PHP Settings Wiki')}</a>.", 'notice');
}
}
/**
* Helper function to convert PHP INI memory values to bytes
*
* @param string $value The value to convert
*
* @return int The bytes value
* @since 5.0.2
*/
protected function convertToBytes(string $value): int
{
$value = trim($value);
$lastChar = strtolower($value[strlen($value) - 1]);
$numValue = substr($value, 0, -1);
switch ($lastChar)
{
case 'g':
return $numValue * 1024 * 1024 * 1024;
case 'm':
return $numValue * 1024 * 1024;
case 'k':
return $numValue * 1024;
default:
return (int) $value;
}
}
}
src/Abstraction/Registry/Traits/Count.php000064400000002147151162054050014466
0ustar00<?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\Abstraction\Registry\Traits;
/**
* Count Values
*
* @since 3.2.0
*/
trait Count
{
/**
* Retrieves number of values (or sub-array) from the storage using
multiple keys.
*
* @param string $path Storage path (e.g. vdm.content.builder)
*
* @throws \InvalidArgumentException If any of the path values are not a
number or string.
* @return int The number of values
* @since 3.2.0
*/
public function count(string $path): int
{
if (($values = $this->get($path)) === null)
{
return 0;
}
if (is_array($values))
{
return count($values);
}
if (is_object($values))
{
return count((array) $values);
}
return 1;
}
}
src/Abstraction/Registry/Traits/GetString.php000064400000002167151162054050015306
0ustar00<?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\Abstraction\Registry\Traits;
/**
* Get String Values
*
* @since 3.2.0
*/
trait GetString
{
/**
* Get a registry path if the return value is a string
*
* @param string $path Registry path (e.g.
joomla.content.showauthor)
* @param string|null $default A default value
*
* @return string|null
* @since 3.2.0
*/
public function getString(string $path, ?string $default = null): ?string
{
// Return default value if path is empty
if (empty($path))
{
return $default;
}
// get the value
if (($node = $this->get($path)) !== null
&& is_string($node)
&& strlen((string) $node) > 0)
{
return $node;
}
return $default;
}
}
src/Abstraction/Registry/Traits/InArray.php000064400000002153151162054050014740
0ustar00<?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\Abstraction\Registry\Traits;
/**
* Check if a value is in an array
*
* @since 3.2.0
*/
trait InArray
{
/**
* Check if a value is found in an array
*
* @param mixed $value The value to check for
* @param string|null $path Registry path (e.g.
joomla.content.showauthor)
*
* @return bool
* @since 3.2.0
*/
public function inArray($value, ?string $path = null): bool
{
// Check base array if no path is given
if (empty($path))
{
return in_array($value, $this->active);
}
// get the value
if (($node = $this->get($path)) !== null
&& is_array($node)
&& in_array($value, $node))
{
return true;
}
return false;
}
}
src/Abstraction/Registry/Traits/index.html000064400000000054151162054050014655
0ustar00<html><body
bgcolor="#FFFFFF"></body></html>src/Abstraction/Registry/Traits/IsArray.php000064400000001741151162054050014747
0ustar00<?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\Abstraction\Registry\Traits;
/**
* Check if a value is in an array
*
* @since 3.2.0
*/
trait IsArray
{
/**
* Check if a path is an array
*
* @param string $path Registry path (e.g.
joomla.content.showauthor)
*
* @return bool
* @since 3.2.0
*/
public function isArray(string $path): bool
{
// Check base array if no path is given
if (empty($path))
{
return false;
}
// get the value
if (($node = $this->get($path)) !== null
&& is_array($node))
{
return true;
}
return false;
}
}
src/Abstraction/Registry/Traits/IsString.php000064400000002012151162054050015127
0ustar00<?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\Abstraction\Registry\Traits;
/**
* Is String Values
*
* @since 3.2.0
*/
trait IsString
{
/**
* Check if a registry path exists and is a string
*
* @param string $path Registry path (e.g. joomla.content.showauthor)
*
* @return boolean
* @since 3.2.0
*/
public function isString(string $path): bool
{
// Return default value if path is empty
if (empty($path)) {
return false;
}
// get the value
if (($node = $this->get($path)) !== null
&& is_string($node)
&& strlen((string) $node) > 0)
{
return true;
}
return false;
}
}
src/Abstraction/Registry/Traits/ToString.php000064400000002325151162054050015145
0ustar00<?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\Abstraction\Registry\Traits;
/**
* To String Values
*
* @since 3.2.0
*/
trait ToString
{
/**
* Convert an array of values to a string (or return string)
*
* @param string $path Registry path (e.g.
joomla.content.showauthor)
* @param string $seperator Return string separator
*
* @return string
* @since 3.2.0
*/
public function toString(string $path, string $separator = ''):
string
{
// Return default value if path is empty
if (empty($path))
{
return '';
}
// get the value
if (($node = $this->get($path)) !== null)
{
if (is_array($node) && $node !== [])
{
return implode($separator, $node);
}
elseif (is_string($node) && strlen((string) $node) > 0)
{
return $node;
}
}
return '';
}
}
src/Abstraction/Registry/Traits/VarExport.php000064400000005200151162054050015321
0ustar00<?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\Abstraction\Registry\Traits;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Indent;
/**
* Var Export Values
*
* @since 3.2.0
*/
trait VarExport
{
/**
* Default indentation value
*
* @var int
* @since 3.4.0
*/
protected int $indent = 2;
/**
* Method to export a set of values to a PHP array
*
* @param string|null $path Registry path (e.g.
joomla.content.showauthor)
* @param int $indentation The default indentation
*
* @return ?string The var set being exported as a PHP array
* @since 3.4.0
*/
public function varExport(?string $path = null, int $indentation = 2):
?string
{
// Load the data array
if ($path === null && $this->isActive())
{
$data = $this->allActive();
}
else
{
$data = $this->get($path);
}
// check if we have data
if ($data === null)
{
return null;
}
// set the default indentation value
$this->indent = $indentation;
// convert to string
$data = var_export($data, true);
// replace all space with system indentation
$data =
preg_replace_callback("/^(\s{2})(\s{2})?(\s{2})?(\s{2})?(\s{2})?(\s{2})?(\s{2})?(\s{2})?(\s{2})?(\s{2})?(\s{2})?(.*)/m",
[$this, 'convertIndent'], $data);
// convert all array to []
$array = preg_split("/\r\n|\n|\r/", $data);
$array = preg_replace(["/\s*array\s\($/",
"/\)(,)?$/", "/\s=>\s$/"], [NULL, ']$1',
' => ['], $array);
$data = implode(PHP_EOL, array_filter(["["] + $array));
// add needed indentation to the last ]
$data = preg_replace("/^(\])/m", Indent::_($indentation) .
'$1', $data);
return $data;
}
/**
* Method to convert found of grouped spaces to system indentation
*
* @param array $matches The regex array of matching values
*
* @return string The resulting string.
* @since 3.4.0
*/
protected function convertIndent(array $matches): string
{
// set number to indent by default
$indent = Indent::_($this->indent);
// update each found space (group) with one indentation
foreach (range(1, 11) as $space)
{
if (strlen((string) $matches[$space]) > 0)
{
$indent .= Indent::_(1);
}
}
return $indent . $matches[12];
}
}
src/Abstraction/Registry.php000064400000012266151162054050012133
0ustar00<?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\Abstraction;
use VDM\Joomla\Interfaces\Registryinterface;
use VDM\Joomla\Abstraction\ActiveRegistry;
/**
* VDM Basic Registry.
*
* Don't use this beyond 10 dimensional depth for best performance.
*
* @since 3.2.0
*/
abstract class Registry extends ActiveRegistry implements Registryinterface
{
/**
* Path separator
*
* @var string|null
* @since 3.2.0
*/
protected ?string $separator = '.';
/**
* Sets a value into the registry using multiple keys.
*
* @param string $path Registry path (e.g. vdm.content.builder)
* @param mixed $value Value of entry
*
* @throws \InvalidArgumentException If any of the path values are not a
number or string.
* @return self
* @since 3.2.0
*/
public function set(string $path, $value): self
{
if (($keys = $this->getActiveKeys($path)) === null)
{
throw new \InvalidArgumentException("Path must only be strings or
numbers to set any value.");
}
$this->setActive($value, ...$keys);
return $this;
}
/**
* 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|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 self
* @since 3.2.0
*/
public function add(string $path, $value, ?bool $asArray = null): self
{
if (($keys = $this->getActiveKeys($path)) === null)
{
throw new \InvalidArgumentException("Path must only be strings or
numbers to add any value.");
}
$this->addActive($value, $asArray, ...$keys);
return $this;
}
/**
* Retrieves a value (or sub-array) from the registry using multiple
keys.
*
* @param string $path Registry path (e.g. vdm.content.builder)
* @param mixed $default Optional default value, returned if the
internal doesn't exist.
*
* @throws \InvalidArgumentException If any of the path values are not a
number or string.
* @return mixed The value or sub-array from the storage. Null if the
location doesn't exist.
* @since 3.2.0
*/
public function get(string $path, $default = null)
{
if (($keys = $this->getActiveKeys($path)) === null)
{
throw new \InvalidArgumentException("Path must only be strings or
numbers to get any value.");
}
return $this->getActive($default, ...$keys);
}
/**
* Removes a value (or sub-array) from the registry using multiple keys.
*
* @param string $path Registry path (e.g. vdm.content.builder)
*
* @throws \InvalidArgumentException If any of the path values are not a
number or string.
* @return self
* @since 3.2.0
*/
public function remove(string $path): self
{
if (($keys = $this->getActiveKeys($path)) === null)
{
throw new \InvalidArgumentException("Path must only be strings or
numbers to remove any value.");
}
$this->removeActive(...$keys);
return $this;
}
/**
* Checks the existence of a particular location in the registry using
multiple keys.
*
* @param string $path Registry path (e.g. vdm.content.builder)
*
* @throws \InvalidArgumentException If any of the path values are not a
number or string.
* @return bool True if the location exists, false otherwise.
* @since 3.2.0
*/
public function exists(string $path): bool
{
if (($keys = $this->getActiveKeys($path)) === null)
{
throw new \InvalidArgumentException("Path must only be strings or
numbers to check if any value exist.");
}
return $this->existsActive(...$keys);
}
/**
* Sets a separator value
*
* @param string|null $value The value to set.
*
* @return self
* @since 3.2.0
*/
public function setSeparator(?string $value): self
{
$this->separator = $value;
return $this;
}
/**
* Get that the active keys from a path
*
* @param string $path The path to determine the location registry.
*
* @return array|null The valid array of keys
* @since 3.2.0
*/
protected function getActiveKeys(string $path): ?array
{
// empty path no allowed
if ($path === '')
{
return null;
}
// Flatten the path
if ($this->separator === null || $this->separator ===
'')
{
return [$path];
}
$keys = array_values(array_filter(explode($this->separator, $path),
'strlen'));
if (empty($keys))
{
return null;
}
return $keys;
}
}
src/Abstraction/Remote/Get.php000064400000006241151162054050012271
0ustar00<?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\Abstraction\Remote;
use VDM\Joomla\Interfaces\GrepInterface as Grep;
use VDM\Joomla\Interfaces\Data\ItemInterface as Item;
use VDM\Joomla\Interfaces\Remote\GetInterface;
/**
* Get data based on global unique ids from remote system
*
* @since 3.2.0
*/
abstract class Get implements GetInterface
{
/**
* The Grep Class.
*
* @var Grep
* @since 3.2.0
*/
protected Grep $grep;
/**
* The Item Class.
*
* @var Item
* @since 3.2.0
*/
protected Item $item;
/**
* Table Name
*
* @var string
* @since 3.2.1
*/
protected string $table;
/**
* Constructor.
*
* @param Grep $grep The GrepInterface Class.
* @param Item $item The ItemInterface Class.
* @param string|null $table The table name.
*
* @since 3.2.0
*/
public function __construct(Grep $grep, Item $item, ?string $table =
null)
{
$this->grep = $grep;
$this->item = $item;
if ($table !== null)
{
$this->table = $table;
}
}
/**
* Set the current active table
*
* @param string $table The table that should be active
*
* @return self
* @since 3.2.2
*/
public function table(string $table): self
{
$this->table = $table;
return $this;
}
/**
* Init all items not found in database
*
* @return bool
* @since 3.2.0
*/
public function init(): bool
{
if (($items = $this->grep->getRemoteGuid()) !== null)
{
foreach($items as $guid)
{
if ($this->item->table($this->getTable())->value($guid) ===
null &&
($item = $this->grep->get($guid, ['remote'])) !==
null)
{
$this->item->set($item);
}
}
return true;
}
return false;
}
/**
* Reset the items
*
* @param array $items The global unique ids of the items
*
* @return bool
* @since 3.2.0
*/
public function reset(array $items): bool
{
if ($items === [])
{
return false;
}
$success = true;
foreach($items as $guid)
{
if (!$this->item($guid, ['remote']))
{
$success = false;
}
}
return $success;
}
/**
* Load an item
*
* @param string $guid The global unique id of the item
* @param array $order The search order
* @param string|null $action The action to load power
*
* @return bool
* @since 3.2.0
*/
public function item(string $guid, array $order = ['remote',
'local'], ?string $action = null): bool
{
if (($item = $this->grep->get($guid, $order)) !== null)
{
return $this->item->table($this->getTable())->set($item);
}
return false;
}
/**
* Get the current active table
*
* @return string
* @since 3.2.2
*/
public function getTable(): string
{
return $this->table;
}
}
src/Abstraction/Remote/index.html000064400000000054151162054050013032
0ustar00<html><body
bgcolor="#FFFFFF"></body></html>src/Abstraction/Remote/Set.php000064400000040654151162054050012313
0ustar00<?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\Abstraction\Remote;
use VDM\Joomla\Interfaces\GrepInterface as Grep;
use VDM\Joomla\Interfaces\Data\ItemsInterface as Items;
use VDM\Joomla\Interfaces\Readme\ItemInterface as ItemReadme;
use VDM\Joomla\Interfaces\Readme\MainInterface as MainReadme;
use VDM\Joomla\Interfaces\Git\Repository\ContentsInterface as Git;
use VDM\Joomla\Utilities\ObjectHelper;
use VDM\Joomla\Interfaces\Remote\SetInterface;
/**
* Set data based on global unique ids to remote repository
*
* @since 3.2.2
*/
abstract class Set implements SetInterface
{
/**
* The Grep Class.
*
* @var Grep
* @since 3.2.2
*/
protected Grep $grep;
/**
* The Items Class.
*
* @var Items
* @since 3.2.2
*/
protected Items $items;
/**
* The Item Readme Class.
*
* @var ItemReadme
* @since 3.2.2
*/
protected ItemReadme $itemReadme;
/**
* The Main Readme Class.
*
* @var MainReadme
* @since 3.2.2
*/
protected MainReadme $mainReadme;
/**
* The Contents Class.
*
* @var Git
* @since 3.2.2
*/
protected Git $git;
/**
* All active repos
*
* @var array
* @since 3.2.2
**/
public array $repos;
/**
* Table Name
*
* @var string
* @since 3.2.2
*/
protected string $table;
/**
* Area Name
*
* @var string
* @since 3.2.2
*/
protected string $area;
/**
* The item map
*
* @var array
* @since 3.2.2
*/
protected array $map;
/**
* The index map
*
* @var array
* @since 3.2.2
*/
protected array $index_map;
/**
* The repo main settings
*
* @var array
* @since 3.2.2
*/
protected array $settings;
/**
* Prefix Key
*
* @var string
* @since 3.2.2
*/
protected string $prefix_key = 'Super---';
/**
* Suffix Key
*
* @var string
* @since 3.2.2
*/
protected string $suffix_key = '---Power';
/**
* The item settings file path
*
* @var string
* @since 3.2.2
*/
protected string $settings_path = 'item.json';
/**
* The index settings file path
*
* @var string
* @since 3.2.2
*/
protected string $index_settings_path = 'index.json';
/**
* Core Placeholders
*
* @var array
* @since 5.0.3
*/
protected array $placeholders = [
'[['.'[NamespacePrefix]]]' => 'VDM',
'[['.'[ComponentNamespace]]]' =>
'Componentbuilder',
'[['.'[Component]]]' =>
'Componentbuilder',
'[['.'[component]]]' =>
'componentbuilder'
];
/**
* Repo Placeholders
*
* @var array
* @since 5.0.3
*/
protected array $repoPlaceholders = [];
/**
* Constructor.
*
* @param array $repos The active repos
* @param Grep $grep The Grep Class.
* @param Items $items The Items Class.
* @param ItemReadme $itemReadme The Item Readme Class.
* @param MainReadme $mainReadme The Main Readme Class.
* @param Git $git The Contents Class.
* @param string|null $table The table name.
* @param string|null $settingsPath The settings path.
* @param string|null $settingsIndexPath The index settings path.
*
* @since 3.2.2
*/
public function __construct(array $repos, Grep $grep, Items $items,
ItemReadme $itemReadme, MainReadme $mainReadme, Git $git,
?string $table = null, ?string $settingsPath = null, ?string
$settingsIndexPath = null)
{
$this->repos = $repos;
$this->grep = $grep;
$this->items = $items;
$this->itemReadme = $itemReadme;
$this->mainReadme = $mainReadme;
$this->git = $git;
if ($table !== null)
{
$this->table = $table;
}
if ($settingsPath !== null)
{
$this->settings_path = $settingsPath;
}
if ($settingsIndexPath !== null)
{
$this->setIndexSettingsPath($settingsIndexPath);
}
if (empty($this->area))
{
$this->area = ucfirst(str_replace('_', ' ',
$this->table));
}
// set the branch to writing
$this->grep->setBranchField('write_branch');
}
/**
* Set the current active table
*
* @param string $table The table that should be active
*
* @return self
* @since 3.2.2
*/
public function table(string $table): self
{
$this->table = $table;
return $this;
}
/**
* Set the current active area
*
* @param string $area The area that should be active
*
* @return self
* @since 3.2.2
*/
public function area(string $area): self
{
$this->area = ucfirst(str_replace('_', ' ',
$area));
return $this;
}
/**
* Set the settings path
*
* @param string $settingsPath The repository settings path
*
* @return self
* @since 3.2.2
*/
public function setSettingsPath(string $settingsPath): self
{
$this->settings_path = $settingsPath;
return $this;
}
/**
* Set the index settings path
*
* @param string $settingsIndexPath The repository index settings
path
*
* @return self
* @since 3.2.2
*/
public function setIndexSettingsPath(string $settingsIndexPath): self
{
$this->index_settings_path = $settingsIndexPath;
$this->grep->setIndexPath($settingsIndexPath);
return $this;
}
/**
* Save items remotely
*
* @param array $guids The global unique id of the item
*
* @return bool
* @throws \Exception
* @since 3.2.2
*/
public function items(array $guids): bool
{
if (!$this->canWrite())
{
throw new \Exception("At least one [{$this->getArea()}] content
repository must be configured with a [Write Branch] value in the
repositories area for the push function to operate correctly.");
}
// we reset the index settings
$this->settings = [];
if (($items = $this->getLocalItems($guids)) === null)
{
throw new \Exception("At least one valid local
[{$this->getArea()}] must exist for the push function to operate
correctly.");
}
foreach ($items as $item)
{
$this->save($item);
}
// update the repos main readme and index settings
if ($this->settings !== [])
{
foreach ($this->settings as $repo)
{
$this->saveRepoMainSettings($repo);
}
}
return true;
}
/**
* update an existing item (if changed)
*
* @param object $item
* @param object $existing
* @param object $repo
*
* @return bool
* @since 3.2.2
*/
abstract protected function updateItem(object $item, object $existing,
object $repo): bool;
/**
* create a new item
*
* @param object $item
* @param object $repo
*
* @return void
* @since 3.2.2
*/
abstract protected function createItem(object $item, object $repo): void;
/**
* update an existing item readme
*
* @param object $item
* @param object $existing
* @param object $repo
*
* @return void
* @since 3.2.2
*/
abstract protected function updateItemReadme(object $item, object
$existing, object $repo): void;
/**
* create a new item readme
*
* @param object $item
* @param object $repo
*
* @return void
* @since 3.2.2
*/
abstract protected function createItemReadme(object $item, object $repo):
void;
/**
* Get the current active table
*
* @return string
* @since 3.2.2
*/
protected function getTable(): string
{
return $this->table;
}
/**
* Get the current active area
*
* @return string
* @since 3.2.2
*/
protected function getArea(): string
{
return $this->area;
}
/**
* Update/Create the repo main readme and index
*
* @param array $repoBucket
*
* @return void
* @since 3.2.2
*/
protected function saveRepoMainSettings(array $repoBucket): void
{
$repo = $repoBucket['repo'] ?? null;
$settings = $repoBucket['items'] ?? null;
if ($this->isInvalidIndexRepo($repo, $settings))
{
return;
}
$repoGuid = $repo->guid ?? null;
if (empty($repoGuid))
{
return;
}
$settings = $this->mergeIndexSettings($repoGuid, $settings);
$this->updateIndexMainFile(
$repo,
$this->getIndexSettingsPath(),
json_encode($settings, JSON_PRETTY_PRINT),
'Update main index file'
);
$this->updateIndexMainFile(
$repo,
'README.md',
$this->mainReadme->get($settings),
'Update main readme file'
);
}
/**
* Validate repository and settings
*
* @param mixed $repo
* @param mixed $settings
*
* @return bool
* @since 3.2.2
*/
protected function isInvalidIndexRepo($repo, $settings): bool
{
return empty($repo) || empty($settings);
}
/**
* Merge current settings with new settings
*
* @param string $repoGuid
* @param array $settings
*
* @return array
* @since 3.2.2
*/
protected function mergeIndexSettings(string $repoGuid, array $settings):
array
{
$current_settings = $this->grep->getRemoteIndex($repoGuid);
if ($current_settings === null || (array) $current_settings === [])
{
return $settings;
}
$mergedSettings = [];
foreach ($current_settings as $guid => $setting)
{
$mergedSettings[$guid] = (array) $setting;
}
foreach ($settings as $guid => $setting)
{
$mergedSettings[$guid] = (array) $setting;
}
return $mergedSettings;
}
/**
* Update a file in the repository
*
* @param object $repo
* @param string $path
* @param string $content
* @param string $message
*
* @return void
* @since 3.2.2
*/
protected function updateIndexMainFile(object $repo, string $path,
string $content, string $message): void
{
$meta = $this->git->metadata(
$repo->organisation,
$repo->repository,
$path,
$repo->write_branch
);
if ($meta !== null && isset($meta->sha))
{
$this->git->update(
$repo->organisation,
$repo->repository,
$path,
$content,
$message,
$meta->sha,
$repo->write_branch
);
}
}
/**
* Get items
*
* @param array $guids The global unique id of the item
*
* @return array|null
* @since 3.2.2
*/
protected function getLocalItems(array $guids): ?array
{
return $this->items->table($this->getTable())->get($guids);
}
/**
* Map a single item to its properties
*
* @param object $item The item to be mapped
*
* @return object
* @since 3.2.2
*/
protected function mapItem(object $item): object
{
$power = [];
foreach ($this->map as $key => $map)
{
$methodName = "mapItemValue_{$key}";
if (method_exists($this, $methodName))
{
$this->{$methodName}($item, $power);
}
else
{
$power[$key] = $item->{$map} ?? null;
}
}
return (object) $power;
}
/**
* Save an item remotely
*
* @param object $item The item to save
*
* @return void
* @since 3.2.2
*/
protected function save(object $item): void
{
if (empty($item->guid))
{
return;
}
$index_item = null;
foreach ($this->repos as $key => $repo)
{
if (empty($repo->write_branch) || $repo->write_branch ===
'default' || !$this->targetRepo($item, $repo))
{
continue;
}
$item = $this->mapItem($item);
$this->setRepoPlaceholders($repo);
$this->git->load_($repo->base ?? null, $repo->token ??
null);
if (($existing = $this->grep->get($item->guid,
['remote'], $repo)) !== null)
{
if ($this->updateItem($item, $existing, $repo))
{
$this->updateItemReadme($item, $existing, $repo);
}
}
else
{
$this->createItem($item, $repo);
$this->createItemReadme($item, $repo);
$index_item ??= $this->getIndexItem($item);
if (!isset($this->settings[$key]))
{
$this->settings[$key] = ['repo' => $repo,
'items' => [$item->guid => $index_item]];
}
else
{
$this->settings[$key]['items'][$item->guid] =
$index_item;
}
}
$this->git->reset_();
}
}
/**
* Set the Repo Placeholders
*
* @param object $repo The repo
*
* @return void
* @since 5.0.3
*/
protected function setRepoPlaceholders(object $repo): void
{
$this->repoPlaceholders = $this->placeholders;
if (!empty($repo->placeholders) &&
is_array($repo->placeholders))
{
foreach ($repo->placeholders as $key => $value)
{
$this->repoPlaceholders[$key] = $value;
}
}
}
/**
* Update Placeholders in String
*
* @param string $string The value to update
*
* @return string
* @since 5.0.3
*/
protected function updatePlaceholders(string $string): string
{
return str_replace(
array_keys($this->repoPlaceholders),
array_values($this->repoPlaceholders),
$string
);
}
/**
* Get index values
*
* @param object $item The item
*
* @return array|null
* @since 3.2.2
*/
protected function getIndexItem(object $item): ?array
{
if (empty($this->index_map))
{
return null;
}
$index_item = [];
foreach ($this->index_map as $key => $function_name)
{
if (method_exists($this, $function_name))
{
$index_item[$key] = $this->{$function_name}($item);
}
}
return $index_item ?? null;
}
/**
* check that we have an active repo towards which we can write data
*
* @return bool
* @since 3.2.2
*/
protected function canWrite(): bool
{
foreach ($this->repos as $repo)
{
if (!empty($repo->write_branch) && $repo->write_branch !==
'default')
{
return true;
}
}
return false;
}
/**
* check that we have a target repo of this item
*
* @param object $item The item
* @param object $repo The current repo
*
* @return bool
* @since 5.0.3
*/
protected function targetRepo(object $item, object $repo): bool
{
return true; // for more control in children classes
}
/**
* Checks if two objects are equal by comparing their properties and
values.
*
* This method converts both input objects to associative arrays, sorts
the arrays by keys,
* and compares these sorted arrays.
*
* If the arrays are identical, the objects are considered equal.
*
* @param object|null $obj1 The first object to compare.
* @param object|null $obj2 The second object to compare.
*
* @return bool True if the objects are equal, false otherwise.
* @since 5.0.2
*/
protected function areObjectsEqual(?object $obj1, ?object $obj2): bool
{
return ObjectHelper::equal($obj1, $obj2); // basic comparison
}
/**
* Get the settings path
*
* @return string
* @since 3.2.2
*/
protected function getSettingsPath(): string
{
return $this->settings_path;
}
/**
* Get the index settings path
*
* @return string
* @since 3.2.2
*/
protected function getIndexSettingsPath(): string
{
return $this->index_settings_path;
}
//// index_map_ (area) /////////////////////////////////////////////
/**
* Get the item name for the index values
*
* @param object $item
*
* @return string|null
* @since 3.2.2
*/
protected function index_map_IndexName(object $item): ?string
{
return $item->system_name ?? null;
}
/**
* Get the item settings path for the index values
*
* @param object $item
*
* @return string
* @since 3.2.2
*/
protected function index_map_IndexSettingsPath(object $item): string
{
return "src/{$item->guid}/" . $this->getSettingsPath();
}
/**
* Get the item path for the index values
*
* @param object $item
*
* @return string
* @since 3.2.2
*/
protected function index_map_IndexPath(object $item): string
{
return "src/{$item->guid}";
}
/**
* Get the item JPK for the index values
*
* @param object $item
*
* @return string
* @since 3.2.2
*/
protected function index_map_IndexKey(object $item): string
{
return $this->prefix_key . str_replace('-', '_',
$item->guid) . $this->suffix_key;
}
/**
* Get the item GUID for the index values
*
* @param object $item
*
* @return string
* @since 3.2.2
*/
protected function index_map_IndexGUID(object $item): string
{
return $item->guid;
}
}
src/Abstraction/Schema.php000064400000055234151162054050011525
0ustar00<?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\Abstraction;
use Joomla\CMS\Factory;
use Joomla\CMS\Version;
use VDM\Joomla\Interfaces\Tableinterface as Table;
use VDM\Joomla\Interfaces\SchemaInterface;
/**
* Schema Checking
*
* @since 3.2.1
*/
abstract class Schema implements SchemaInterface
{
/**
* The Table Class.
*
* @var Table
* @since 3.2.1
*/
protected Table $table;
/**
* The Database Class
*
* @since 3.2.1
*/
protected $db;
/**
* The local tables
*
* @var array
* @since 3.2.1
*/
private array $tables;
/**
* The component table prefix
*
* @var string
* @since 3.2.1
*/
private string $prefix;
/**
* The field unique keys
*
* @var array
* @since 3.2.1
*/
private array $uniqueKeys;
/**
* The field keys
*
* @var array
* @since 3.2.1
*/
private array $keys;
/**
* The current table columns
*
* @var array
* @since 3.2.1
*/
private array $columns;
/**
* The success messages of the action
*
* @var array
* @since 3.2.1
*/
private array $success;
/**
* Current Joomla Version We are IN
*
* @var int
* @since 3.2.1
**/
protected $currentVersion;
/**
* Constructor.
*
* @param Table $table The Table Class.
*
* @since 3.2.1
* @throws \Exception If the database fails
*/
public function __construct(Table $table)
{
$this->table = $table;
try {
// set the database object
$this->db = Factory::getDbo();
// get current component tables
$this->tables = $this->db->getTableList();
// set the component table
$this->prefix = $this->db->getPrefix() . $this->getCode();
// set the current version
$this->currentVersion = Version::MAJOR_VERSION;
} catch (\Exception $e) {
throw new \Exception("Error: failed to initialize schema class due
to a database error.");
}
}
/**
* Check and update database schema for missing fields or tables.
*
* @return array The array of successful updates/actions, if empty no
update/action was taken.
* @since 3.2.1
* @throws \Exception If there is an error during the update process.
*/
public function update(): array
{
try {
$this->success = [
"Success: scan of the component tables started."
];
foreach ($this->table->tables() as $table)
{
$this->uniqueKeys = [];
$this->keys = [];
if ($this->tableExists($table))
{
$this->updateSchema($table);
}
else
{
$this->createTable($table);
}
}
} catch (\Exception $e) {
throw new \Exception("Error: updating database schema. " .
$e->getMessage());
}
if (count($this->success) == 1)
{
$this->success[] = "Success: scan of the component tables
completed with no update needed.";
}
else
{
$this->success[] = "Success: scan of the component tables
completed.";
}
return $this->success;
}
/**
* Get the targeted component code
*
* @return string
* @since 3.2.1
*/
abstract protected function getCode(): string;
/**
* Check if a table exists in the database.
*
* @param string $table The name of the table to check.
*
* @return bool True if table exists, False otherwise.
* @since 3.2.1
*/
protected function tableExists(string $table): bool
{
return in_array($this->getTable($table), $this->tables);
}
/**
* Update the schema of an existing table.
*
* @param string $table The table to update.
*
* @return void
* @since 3.2.1
* @throws \Exception If there is an error while updating the schema.
*/
public function updateSchema(string $table): void
{
try {
$existingColumns = $this->getExistingColumns($table);
$expectedColumns = $this->table->fields($table, true);
$missingColumns = array_diff($expectedColumns, $existingColumns);
if (!empty($missingColumns))
{
$this->addMissingColumns($table, $missingColumns);
}
$this->checkColumnsDataType($table, $expectedColumns);
} catch (\Exception $e) {
throw new \Exception("Error: updating schema for $table table.
" . $e->getMessage());
}
if (!empty($missingColumns))
{
$column_s = (count($missingColumns) == 1) ? 'column' :
'columns';
$missingColumns = implode(', ', $missingColumns);
$this->success[] = "Success: added missing ($missingColumns)
$column_s to $table table.";
}
}
/**
* Create a table with all necessary fields.
*
* @param string $table The name of the table to create.
*
* @return void
* @since 3.2.1
* @throws \Exception If there is an error creating the table.
*/
public function createTable(string $table): void
{
try {
$columns = [];
$fields = $this->table->fields($table, true);
$createTable = 'CREATE TABLE IF NOT EXISTS ' .
$this->db->quoteName($this->getTable($table));
foreach ($fields as $field)
{
if (($def = $this->getColumnDefinition($table, $field)) !== null)
{
$columns[] = $def;
}
}
$columnDefinitions = implode(', ', $columns);
$keys = $this->getTableKeys();
$createTableSql = "$createTable ($columnDefinitions, $keys)";
$this->db->setQuery($createTableSql);
$this->db->execute();
} catch (\Exception $e) {
throw new \Exception("Error: failed to create missing $table table.
" . $e->getMessage());
}
$this->success[] = "Success: created missing $table
table.";
}
/**
* Fetch existing columns from a database table.
*
* @param string $table The name of the table.
*
* @return array An array of column names.
* @since 3.2.1
*/
protected function getExistingColumns(string $table): array
{
$this->columns =
$this->db->getTableColumns($this->getTable($table), false);
return array_keys($this->columns);
}
/**
* Add missing columns to a table.
*
* @param string $table The table to update.
* @param array $columns List of missing columns/fields.
*
* @return void
* @since 3.2.1
* @throws \Exception If there is an error adding columns.
*/
protected function addMissingColumns(string $table, array $columns): void
{
try {
$query = $this->db->getQuery(true);
$alterTable = 'ALTER TABLE ' .
$this->db->quoteName($this->getTable($table)) . ' ';
// Start an ALTER TABLE query
$alterQueries = [];
foreach ($columns as $column)
{
if (($def = $this->getColumnDefinition($table, $column)) !== null)
{
$alterQueries[] = " ADD " . $def;
}
}
$this->db->setQuery($alterTable . implode(', ',
$alterQueries));
$this->db->execute();
} catch (\Exception $e) {
$column_s = (count($columns) == 1) ? 'column' :
'columns';
$columns = implode(', ', $columns);
throw new \Exception("Error: failed to add ($columns) $column_s to
$table table. " . $e->getMessage());
}
}
/**
* Validate and update the data type of existing fields/columns
*
* @param string $table The table to update.
* @param array $columns List of columns/fields to check.
*
* @return void
* @since 3.2.1
*/
protected function checkColumnsDataType(string $table, array $columns):
void
{
$requireUpdate = [];
foreach ($columns as $column)
{
$current = $this->columns[$column] ?? null;
if ($current === null || ($expected = $this->table->get($table,
$column, 'db')) === null)
{
continue;
}
// check if the data type and size match
if ($this->isDataTypeChangeSignificant($current->Type,
$expected['type']))
{
$requireUpdate[$column] = [
'column' => $column,
'current' => $current->Type,
'expected' => $expected['type']
];
}
// check if update of default values is needed
if ($this->checkDefault($table, $column))
{
$requireUpdate[$column] = [
'column' => $column,
'current' => $current->Type,
'expected' => $expected['type']
];
}
// check if update of null is needed
if ($this->checkNull($table, $column))
{
$requireUpdate[$column] = [
'column' => $column,
'current' => $current->Type,
'expected' => $expected['type']
];
}
}
if (!empty($requireUpdate))
{
$this->updateColumnsDataType($table, $requireUpdate);
}
}
/**
* Generates a SQL snippet for defining a table column, incorporating
column type,
* default value, nullability, and auto-increment properties.
*
* @param string $table The table name to be used.
* @param string $field The field name in the table to generate SQL for.
*
* @return string|null The SQL snippet for the column definition.
* @since 3.2.1
* @throws \Exception If the schema details cannot be retrieved or the SQL
statement cannot be constructed properly.
*/
protected function getColumnDefinition(string $table, string $field):
?string
{
try {
// Retrieve the database schema details for the specified table and
field
if (($db = $this->table->get($table, $field, 'db')) ===
null)
{
return null;
}
// Prepare the column name
$column_name = $this->db->quoteName($field);
$db['name'] = $field;
// Prepare the type and default value SQL statement
$type = $db['type'] ?? 'TEXT';
$db_default = isset($db['default']) ? $db['default']
: null;
$default = $this->getDefaultValue($type, $db_default);
// Prepare the null switch, and auto increment statement
$null_switch = !empty($db['null_switch']) ? ' ' .
$db['null_switch'] : '';
// Prepare the auto increment statement
$auto_increment = !empty($db['auto_increment']) ? "
AUTO_INCREMENT" : '';
// If there's a default value, the column should not be nullable
if ($default !== '')
{
$null_switch = '';
}
$this->setKeys($db);
// Assemble the SQL snippet for the column definition
return "{$column_name}
{$type}{$null_switch}{$auto_increment}{$default}";
} catch (\Exception $e) {
throw new \Exception("Error: failed to generate column definition
for ($table.$field). " . $e->getMessage());
}
}
/**
* Check and Update the default values if needed, including existing data
adjustments
*
* @param string $table The table to update.
* @param string $column The column/field to check.
*
* @return bool
* @since 3.2.1
*/
protected function checkDefault(string $table, string $column): bool
{
// Retrieve the expected column configuration
$expected = $this->table->get($table, $column, 'db');
// Skip updates if the column is auto_increment
if (isset($expected['auto_increment']) &&
$expected['auto_increment'] === true)
{
return false;
}
// Retrieve the current column configuration
$current = $this->columns[$column];
// Determine the new default value based on the expected settings
$type = $expected['type'] ?? 'TEXT';
$db_default = isset($expected['default']) ?
$expected['default'] : null;
$newDefault = $this->getDefaultValue($type, $db_default, true);
// First, adjust existing rows to conform to the new default if
necessary
if (is_numeric($newDefault) &&
$this->adjustExistingDefaults($table, $column, $current->Default,
$newDefault))
{
$this->success[] = "Success: updated the ($column) defaults in
$table table.";
return true;
}
if (isset($expected['default']) &&
is_string($expected['default']) &&
strtoupper($expected['default']) === 'EMPTY'
&&
isset($current->Default) && is_string($current->Default)
&& strpos($current->Default, 'EMPTY') !== false)
{
return true; // little fix
}
return false;
}
/**
* Check and Update the null value if needed, including existing data
adjustments
*
* @param string $table The table to update.
* @param string $column The column/field to check.
*
* @return bool
* @since 3.2.2
*/
protected function checkNull(string $table, string $column): bool
{
// Retrieve the expected column configuration
$expected = $this->table->get($table, $column, 'db');
// Skip updates if the null_switch is not set
if (!isset($expected['null_switch']))
{
return false;
}
// Retrieve the current column configuration
$current = $this->columns[$column];
// Skip updates if the Null is not set
if (!isset($current->Null))
{
return false;
}
// set the expected NULL
$expected_null = 'NO';
if ($expected['null_switch'] === "NULL")
{
$expected_null = 'YES';
}
// set the current NULL
$current_null = $current->Null;
// Prepare the type and default value SQL statement
$type = $expected['type'] ?? 'TEXT';
$db_default = isset($expected['default']) ?
$expected['default'] : null;
$default = $this->getDefaultValue($type, $db_default, true);
// check the null values if they match
if ($current_null !== $expected_null && $current_null ===
'NO' && empty($default))
{
$this->success[] = "Success: updated the ($column) null state in
$table table.";
return true;
}
return false;
}
/**
* Update the data type of the given fields.
*
* @param string $table The table to update.
* @param array $columns List of columns/fields that must be updated.
*
* @return void
* @since 3.2.1
*/
protected function updateColumnsDataType(string $table, array $columns):
void
{
$alterTable = 'ALTER TABLE ' .
$this->db->quoteName($this->getTable($table));
foreach ($columns as $column => $types)
{
if (($def = $this->getColumnDefinition($table, $column)) === null)
{
continue;
}
$dbField = $this->db->quoteName($column);
$alterQuery = "$alterTable CHANGE $dbField ". $def;
if ($this->updateColumnDataType($alterQuery, $table, $column))
{
$current = $types['current'] ?? 'error';
$expected = $types['expected'] ?? 'error';
$this->success[] = "Success: updated ($column) column datatype
$current to $expected in $table table.";
}
}
}
/**
* Add the component name to get the full table name.
*
* @param string $table The table name.
*
* @return void
* @since 3.2.1
*/
protected function getTable(string $table): string
{
return $this->prefix . '_' . $table;
}
/**
* Determines if the change in data type between two definitions is
significant.
*
* This function checks if there's a significant difference between
the current
* data type and the expected data type that would require updating the
database schema.
* It ignores display width for numeric types where MySQL considers these
attributes
* irrelevant for storage but considers size and other modifiers for types
like VARCHAR.
*
* @param string $currentType The current data type from the database
schema.
* @param string $expectedType The expected data type to validate
against.
*
* @return bool Returns true if the data type change is significant,
otherwise false.
* @since 3.2.1
*/
protected function isDataTypeChangeSignificant(string $currentType, string
$expectedType): bool
{
// Normalize both input types to lowercase for case-insensitive
comparison
$currentType = strtolower($currentType);
$expectedType = strtolower($expectedType);
// Regex to extract the base data type and numeric parameters with named
groups
$typePattern =
'/^(?<datatype>\w+)(\((?<params>\d+(,\d+)?)\))?/';
// Match types and parameters
preg_match($typePattern, $currentType, $currentMatches);
preg_match($typePattern, $expectedType, $expectedMatches);
// Compare base types
if ($currentMatches['datatype'] !==
$expectedMatches['datatype'])
{
return true; // Base types differ
}
// Define types where size and other modifiers are irrelevant
$sizeIrrelevantTypes = [
'int', 'tinyint', 'smallint',
'mediumint', 'bigint',
'float', 'double', 'decimal',
'numeric' // Numeric types where display width is irrelevant
];
// If the type is not in the size irrelevant list, compare full
definitions
if (!in_array($currentMatches['datatype'],
$sizeIrrelevantTypes))
{
return $currentType !== $expectedType; // Use full definition for types
where size matters
}
// For size irrelevant types, only compare base type, ignoring size and
unsigned
$currentBaseType = preg_replace('/\(\d+(,\d+)?\)|unsigned/',
'', $currentType);
$expectedBaseType = preg_replace('/\(\d+(,\d+)?\)|unsigned/',
'', $expectedType);
// Perform a final comparison for numeric types ignoring size
return $currentBaseType !== $expectedBaseType;
}
/**
* Updates existing rows in a column to a new default value
*
* @param string $table The table to update.
* @param string $column The column to update.
* @param mixed $currentDefault Current default value.
* @param mixed $newDefault The new default value to be set.
*
* @return void
* @since 3.2.1
* @throws \Exception If there is an error updating column defaults.
*/
protected function adjustExistingDefaults(string $table, string $column,
$currentDefault, $newDefault): bool
{
// Determine if adjustment is needed based on new and current defaults
if ($newDefault !== $currentDefault)
{
try {
// Format the new default for SQL use
$sqlDefault = $this->db->quote($newDefault);
$updateTable = 'UPDATE ' .
$this->db->quoteName($this->getTable($table));
$dbField = $this->db->quoteName($column);
// Update SQL to set new default on existing rows where the default is
currently the old default
$sql = $updateTable . " SET $dbField = $sqlDefault WHERE $dbField
IS NULL OR $dbField = ''";
// Execute the update
$this->db->setQuery($sql);
return $this->db->execute();
} catch (\Exception $e) {
throw new \Exception("Error: failed to update ($column) column
defaults in $table table. " . $e->getMessage());
}
}
return false;
}
/**
* Update the data type of the given field.
*
* @param string $updateString The SQL command to update the column data
type
* @param string $table The table to update.
* @param string $field Column/field that must be updated.
*
* @return bool true on succes
* @since 3.2.1
* @throws \Exception If there is an error adding columns.
*/
protected function updateColumnDataType(string $updateString, string
$table, string $field): bool
{
try {
$this->db->setQuery($updateString);
return $this->db->execute();
} catch (\Exception $e) {
throw new \Exception("Error: failed to update the datatype of
($field) column in $table table. " . $e->getMessage());
}
}
/**
* Key all needed keys for this table
*
* @return string of keys
* @since 3.2.1
*/
protected function getTableKeys(): string
{
$keys = [];
$keys[] = 'PRIMARY KEY (`id`)'; // TODO (we may want this to
be dynamicly set)
if (!empty($this->uniqueKeys))
{
$keys[] = implode(', ', $this->uniqueKeys);
}
if (!empty($this->keys))
{
$keys[] = implode(', ', $this->keys);
}
return implode(', ', $keys);
}
/**
* Function to set the view keys
*
* @param string $column The field column database array values
*
* @return void
* @since 3.2.1
*/
protected function setKeys(array $column): void
{
$this->setUniqueKey($column);
$this->setKey($column);
}
/**
* Function to set the unique key
*
* @param string $column The field column database array values
*
* @return void
* @since 3.2.1
*/
protected function setUniqueKey(array $column): void
{
if (isset($column['unique_key']) &&
$column['unique_key'])
{
$key = $column['unique_key_name'] ??
$column['name'];
$this->uniqueKeys[] = "UNIQUE KEY `idx_" . $key . "`
(`" . $column['name'] . "`)";
}
}
/**
* Function to set the key
*
* @param string $column The field column database array values
*
* @return void
* @since 3.2.1
*/
protected function setKey(array $column): void
{
if (isset($column['key']) && $column['key'])
{
$key = $column['key_name'] ?? $column['name'];
$this->keys[] = "KEY `idx_" . $key . "` (`" .
$column['name'] . "`)";
}
}
/**
* Adjusts the default value SQL fragment for a database field based on
its type and specific rules.
*
* If the field is of type DATETIME and the Joomla version is not 3, it
sets the default to CURRENT_TIMESTAMP
* if not explicitly specified otherwise. For all other types it handles
defaults by either leaving them unset or applying
* the provided default, properly quoted for SQL safety. When a
'EMPTY' default is specified, it returns no default at all. (:)
*
* @param string $type The type of the database field (e.g.,
'DATETIME').
* @param string|null $defaultValue Optional default value for the
field, null if not provided.
* @param bool $pure Optional to add the
'DEFAULT' string or not.
*
* @return string The SQL fragment to set the default value for a
field.
* @since 3.2.1
*/
protected function getDefaultValue(string $type, ?string $defaultValue,
bool $pure = false): string
{
if ($defaultValue === null || strtoupper($defaultValue) ===
'EMPTY')
{
return '';
}
// Set default for DATETIME fields in Joomla versions above 3
if (strtoupper($type) === 'DATETIME' &&
$this->currentVersion != 3)
{
return $pure ? "CURRENT_TIMESTAMP" : " DEFAULT
CURRENT_TIMESTAMP";
}
// Apply and quote the default value
$sql_default = $this->quote($defaultValue);
return $pure ? $defaultValue : " DEFAULT $sql_default";
}
/**
* Set a value based on data type
*
* @param mixed $value The value to set
*
* @return mixed
* @since 3.2.0
**/
protected function quote($value)
{
if ($value === null) // hmm the null does pose an issue (will keep an eye
on this)
{
return 'NULL';
}
if (is_numeric($value))
{
if (filter_var($value, FILTER_VALIDATE_INT))
{
return (int) $value;
}
elseif (filter_var($value, FILTER_VALIDATE_FLOAT))
{
return (float) $value;
}
}
elseif (is_bool($value)) // not sure if this will work well (but its
correct)
{
return $value ? 'TRUE' : 'FALSE';
}
// For date and datetime values
elseif ($value instanceof \DateTime)
{
return $this->db->quote($value->format('Y-m-d
H:i:s'));
}
// For other data types, just escape it
return $this->db->quote($value);
}
}
src/Abstraction/SchemaChecker.php000064400000010067151162054050013005
0ustar00<?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\Abstraction;
use Joomla\CMS\Factory;
use VDM\Joomla\Interfaces\SchemaInterface as Schema;
use VDM\Joomla\Interfaces\Tableinterface as Table;
use VDM\Joomla\Utilities\ClassHelper;
use VDM\Joomla\Interfaces\SchemaCheckerInterface;
/**
* Schema Checker
*
* @since 3.2.2
*/
abstract class SchemaChecker implements SchemaCheckerInterface
{
/**
* The Table Class.
*
* @var Table|null
* @since 3.2.2
*/
protected ?Table $table;
/**
* The Schema Class.
*
* @var Schema|null
* @since 3.2.2
*/
protected ?Schema $schema;
/**
* Application object.
*
* @since 3.2.2
**/
protected $app;
/**
* Constructor.
*
* @param Schema|null $schema The Schema Class.
* @param Table|null $table The Table Class.
* @param $app The app object.
*
* @throws \Exception
* @since 3.2.2
*/
public function __construct(?Schema $schema = null, ?Table $table = null,
$app = null)
{
$this->schema = $schema;
$this->table = $table;
$this->app = $app ?: Factory::getApplication();
// Validate classes are set
// Since this class is often called from outside a container
$this->initializeInstances();
// I don't care! I have more important thing to do, maybe later...
(last updated in 1983 ;)
}
/**
* Make sure that the database schema is up-to-date.
*
* @return void
* @since 3.2.2
*/
public function run(): void
{
if ($this->schema === null)
{
$this->app->enqueueMessage('We failed to find/load the Schema
class', 'warning');
return;
}
// try to load the update the tables with the schema class
try
{
$messages = $this->schema->update();
}
catch (\Exception $e)
{
$this->app->enqueueMessage($e->getMessage(),
'warning');
return;
}
foreach ($messages as $message)
{
$this->app->enqueueMessage($message, 'message');
}
}
/**
* Initialize the needed class instances if needed
*
* @return void
* @since 3.2.2
*/
protected function initializeInstances(): void
{
if ($this->schema !== null)
{
return;
}
if ($this->table === null)
{
$this->setTableInstance();
}
$this->setSchemaInstance();
}
/**
* set the schema class instance
*
* @return void
* @since 3.2.2
*/
protected function setSchemaInstance(): void
{
// make sure the class is loaded
if (ClassHelper::exists(
$this->getSchemaClass(), $this->getCode(),
$this->getPowerPath()
))
{
// instantiate the schema class
$this->schema = new ($this->getSchemaClass())($this->table);
}
}
/**
* set the table class instance
*
* @return void
* @since 3.2.2
*/
protected function setTableInstance(): void
{
// make sure the class is loaded
if (ClassHelper::exists(
$this->getTableClass(), $this->getCode(),
$this->getPowerPath()
))
{
// instantiate the table class
$this->table = new ($this->getTableClass())();
}
}
/**
* Get the targeted component code
*
* @return string
* @since 3.2.2
*/
abstract protected function getCode(): string;
/**
* Get the targeted component power path
*
* @return string
* @since 3.2.2
*/
abstract protected function getPowerPath(): string;
/**
* Get the fully qualified name of the schema class.
*
* @return string
* @since 3.2.2
*/
abstract protected function getSchemaClass(): string;
/**
* Get the fully qualified name of the table class.
*
* @return string
* @since 3.2.2
*/
abstract protected function getTableClass(): string;
}
src/Data/Action/Delete.php000064400000004214151162054050011334
0ustar00<?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\Data\Action;
use VDM\Joomla\Interfaces\DeleteInterface as Database;
use VDM\Joomla\Interfaces\Data\DeleteInterface;
/**
* Data Delete
*
* @since 3.2.2
*/
class Delete implements DeleteInterface
{
/**
* The Delete Class.
*
* @var Database
* @since 3.2.2
*/
protected Database $database;
/**
* Table Name
*
* @var string
* @since 3.2.2
*/
protected string $table;
/**
* Constructor.
*
* @param Database $database The Delete Class.
* @param string|null $table The table name.
*
* @since 3.2.2
*/
public function __construct(Database $database, ?string $table = null)
{
$this->database = $database;
if ($table !== null)
{
$this->table = $table;
}
}
/**
* Set the current active table
*
* @param string|null $table The table that should be active
*
* @return self
* @since 3.2.2
*/
public function table(?string $table): self
{
if ($table !== null)
{
$this->table = $table;
}
return $this;
}
/**
* Delete all items in the database that match these conditions
*
* @param array $conditions Conditions by which to delete the data
in database [array of arrays (key => value)]
*
* @return bool
* @since 3.2.2
**/
public function items(array $conditions): bool
{
return $this->database->items($conditions, $this->getTable());
}
/**
* Truncate a table
*
* @return void
* @since 3.2.2
**/
public function truncate(): void
{
$this->database->truncate($this->getTable());
}
/**
* Get the current active table
*
* @return string
* @since 3.2.2
*/
public function getTable(): string
{
return $this->table;
}
}
src/Data/Action/index.html000064400000000054151162054050011414
0ustar00<html><body
bgcolor="#FFFFFF"></body></html>src/Data/Action/Insert.php000064400000010776151162054050011410
0ustar00<?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\Data\Action;
use VDM\Joomla\Interfaces\ModelInterface as Model;
use VDM\Joomla\Interfaces\InsertInterface as Database;
use VDM\Joomla\Interfaces\Data\InsertInterface;
/**
* Data Insert (GUID)
*
* @since 3.2.2
*/
class Insert implements InsertInterface
{
/**
* Model
*
* @var Model
* @since 3.2.0
*/
protected Model $model;
/**
* Database
*
* @var Database
* @since 3.2.0
*/
protected Database $database;
/**
* Table Name
*
* @var string
* @since 3.2.1
*/
protected string $table;
/**
* Constructor
*
* @param Model $model The set model object.
* @param Database $database The insert database object.
* @param string|null $table The table name.
*
* @since 3.2.2
*/
public function __construct(Model $model, Database $database, ?string
$table = null)
{
$this->model = $model;
$this->database = $database;
if ($table !== null)
{
$this->table = $table;
}
}
/**
* Set the current active table
*
* @param string|null $table The table that should be active
*
* @return self
* @since 3.2.2
*/
public function table(?string $table): self
{
if ($table !== null)
{
$this->table = $table;
}
return $this;
}
/**
* Insert a value to a given table
* Example: $this->value(Value, 'value_key',
'GUID');
*
* @param mixed $value The field value
* @param string $field The field key
* @param string $keyValue The key value
* @param string $key The key name
*
* @return bool
* @since 3.2.0
*/
public function value($value, string $field, string $keyValue, string $key
= 'guid'): bool
{
// build the array
$item = [];
$item[$key] = $keyValue;
$item[$field] = $value;
// Insert the column of this table
return $this->row($item);
}
/**
* Insert single row with multiple values to a given table
* Example: $this->item(Array);
*
* @param array $item The item to save
*
* @return bool
* @since 3.2.0
*/
public function row(array $item): bool
{
// check if object could be modelled
if (($item = $this->model->row($item, $this->getTable())) !==
null)
{
// Insert the column of this table
return $this->database->row($item, $this->getTable());
}
return false;
}
/**
* Insert multiple rows to a given table
* Example: $this->items(Array);
*
* @param array|null $items The items updated in database (array of
arrays)
*
* @return bool
* @since 3.2.0
*/
public function rows(?array $items): bool
{
// check if object could be modelled
if (($items = $this->model->rows($items, $this->getTable())) !==
null)
{
// Insert the column of this table
return $this->database->rows($items, $this->getTable());
}
return false;
}
/**
* Insert single item with multiple values to a given table
* Example: $this->item(Object);
*
* @param object $item The item to save
*
* @return bool
* @since 3.2.0
*/
public function item(object $item): bool
{
// check if object could be modelled
if (($item = $this->model->item($item, $this->getTable())) !==
null)
{
// Insert the column of this table
return $this->database->item($item, $this->getTable());
}
return false;
}
/**
* Insert multiple items to a given table
* Example: $this->items(Array);
*
* @param array|null $items The items updated in database (array of
objects)
*
* @return bool
* @since 3.2.0
*/
public function items(?array $items): bool
{
// check if object could be modelled
if (($items = $this->model->items($items, $this->getTable()))
!== null)
{
// Update the column of this table using guid as the primary key.
return $this->database->items($items, $this->getTable());
}
return false;
}
/**
* Get the current active table
*
* @return string
* @since 3.2.2
*/
public function getTable(): string
{
return $this->table;
}
}
src/Data/Action/Load.php000064400000011471151162054050011014
0ustar00<?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\Data\Action;
use VDM\Joomla\Interfaces\ModelInterface as Model;
use VDM\Joomla\Interfaces\LoadInterface as Database;
use VDM\Joomla\Interfaces\Data\LoadInterface;
/**
* Data Load (GUID)
*
* @since 3.2.2
*/
class Load implements LoadInterface
{
/**
* Model Load
*
* @var Model
* @since 2.0.1
*/
protected Model $model;
/**
* Database Load
*
* @var Database
* @since 2.0.1
*/
protected Database $load;
/**
* Table Name
*
* @var string
* @since 3.2.1
*/
protected string $table;
/**
* Constructor
*
* @param Model $model The model object.
* @param Database $load The database object.
* @param string|null $table The table name.
*
* @since 2.0.1
*/
public function __construct(Model $model, Database $load, ?string $table =
null)
{
$this->model = $model;
$this->load = $load;
if ($table !== null)
{
$this->table = $table;
}
}
/**
* Set the current active table
*
* @param string|null $table The table that should be active
*
* @return self
* @since 3.2.2
*/
public function table(?string $table): self
{
if ($table !== null)
{
$this->table = $table;
}
return $this;
}
/**
* Get a value from a given table
* Example: $this->value(
* [
* 'guid' =>
'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'
* ], 'value_key'
* );
*
* @param array $keys The item keys
* @param string $field The field key
*
* @return mixed
* @since 2.0.1
*/
public function value(array $keys, string $field)
{
return $this->model->value(
$this->load->value(
["a.{$field}" => $field],
['a' => $this->getTable()],
$this->prefix($keys)
),
$field,
$this->getTable()
);
}
/**
* Get a value from multiple rows from a given table
* Example: $this->values(
* [
* 'guid' =>
'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'
* ], 'value_key'
* );
*
* @param array $keys The item keys
* @param string $field The field key
*
* @return array|null
* @since 3.2.2
*/
public function values(array $keys, string $field): ?array
{
return $this->model->values(
$this->load->values(
["a.{$field}" => $field],
['a' => $this->getTable()],
$this->prefix($keys)
),
$field,
$this->getTable()
);
}
/**
* Get values from a given table
* Example: $this->item(
* [
* 'guid' =>
'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'
* ]
* );
*
* @param array $keys The item keys
*
* @return object|null
* @since 2.0.1
*/
public function item(array $keys): ?object
{
return $this->model->item(
$this->load->item(
['all' => 'a.*'],
['a' => $this->getTable()],
$this->prefix($keys)
),
$this->getTable()
);
}
/**
* Get values from a given table
* Example: $this->items(
* [
* 'guid' => [
* 'operator' =>
'IN',
* 'value' =>
[''xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'',
''xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'']
* ]
* ]
* );
* Example: $this->items($ids);
*
* @param array $keys The item keys
*
* @return array|null
* @since 2.0.1
*/
public function items(array $keys): ?array
{
return $this->model->items(
$this->load->items(
['all' => 'a.*'], ['a' =>
$this->getTable()], $this->prefix($keys)
),
$this->getTable()
);
}
/**
* Get the current active table
*
* @return string
* @since 3.2.2
*/
public function getTable(): string
{
return $this->table;
}
/**
* Add prefix to the keys
*
* @param array $keys The query keys
*
* @return array
* @since 2.0.1
*/
private function prefix(array &$keys): array
{
// update the key values
$bucket = [];
foreach ($keys as $k => $v)
{
$bucket['a.' . $k] = $v;
}
return $bucket;
}
}
src/Data/Action/Update.php000064400000011642151162054050011357
0ustar00<?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\Data\Action;
use VDM\Joomla\Interfaces\ModelInterface as Model;
use VDM\Joomla\Interfaces\UpdateInterface as Database;
use VDM\Joomla\Interfaces\Data\UpdateInterface;
/**
* Data Update
*
* @since 3.2.2
*/
class Update implements UpdateInterface
{
/**
* Model
*
* @var Model
* @since 3.2.0
*/
protected Model $model;
/**
* Database
*
* @var Database
* @since 3.2.0
*/
protected Database $database;
/**
* Table Name
*
* @var string
* @since 3.2.1
*/
protected string $table;
/**
* Constructor
*
* @param Model $model The set model object.
* @param Database $database The update database object.
* @param string|null $table The table name.
*
* @since 3.2.0
*/
public function __construct(Model $model, Database $database, ?string
$table = null)
{
$this->model = $model;
$this->database = $database;
if ($table !== null)
{
$this->table = $table;
}
}
/**
* Set the current active table
*
* @param string|null $table The table that should be active
*
* @return self
* @since 3.2.2
*/
public function table(?string $table): self
{
if ($table !== null)
{
$this->table = $table;
}
return $this;
}
/**
* Update a value to a given table
* Example: $this->value(Value, 'value_key',
'GUID');
*
* @param mixed $value The field value
* @param string $field The field key
* @param string $keyValue The key value
* @param string $key The key name
*
* @return bool
* @since 3.2.0
*/
public function value($value, string $field, string $keyValue, string $key
= 'guid'): bool
{
// build the array
$item = [];
$item[$key] = $keyValue;
$item[$field] = $value;
// Update the column of this table using $key as the primary key.
return $this->row($item, $key);
}
/**
* Update single row with multiple values to a given table
* Example: $this->item(Array);
*
* @param array $item The item to save
* @param string $key The key name
*
* @return bool
* @since 3.2.0
*/
public function row(array $item, string $key = 'guid'): bool
{
// check if object could be modelled
if (($item = $this->model->row($item, $this->getTable())) !==
null)
{
// Update the column of this table using $key as the primary key.
return $this->database->row($item, $key, $this->getTable());
}
return false;
}
/**
* Update multiple rows to a given table
* Example: $this->items(Array);
*
* @param array|null $items The items updated in database (array of
arrays)
* @param string $key The key name
*
* @return bool
* @since 3.2.0
*/
public function rows(?array $items, string $key = 'guid'): bool
{
// check if object could be modelled
if (($items = $this->model->rows($items, $this->getTable())) !==
null)
{
// Update the column of this table using $key as the primary key.
return $this->database->rows($items, $key, $this->getTable());
}
return false;
}
/**
* Update single item with multiple values to a given table
* Example: $this->item(Object);
*
* @param object $item The item to save
* @param string $key The key name
*
* @return bool
* @since 3.2.0
*/
public function item(object $item, string $key = 'guid'): bool
{
// check if object could be modelled
if (($item = $this->model->item($item, $this->getTable())) !==
null)
{
// Update the column of this table using $key as the primary key.
return $this->database->item($item, $key, $this->getTable());
}
return false;
}
/**
* Update multiple items to a given table
* Example: $this->items(Array);
*
* @param array|null $items The items updated in database (array of
objects)
* @param string $key The key name
*
* @return bool
* @since 3.2.0
*/
public function items(?array $items, string $key = 'guid'):
bool
{
// check if object could be modelled
if (($items = $this->model->items($items, $this->getTable()))
!== null)
{
// Update the column of this table using $key as the primary key.
return $this->database->items($items, $key,
$this->getTable());
}
return false;
}
/**
* Get the current active table
*
* @return string
* @since 3.2.2
*/
public function getTable(): string
{
return $this->table;
}
}
src/Data/Factory.php000064400000002221151162054050010320 0ustar00<?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\Data;
use Joomla\DI\Container;
use VDM\Joomla\Service\Table;
use VDM\Joomla\Service\Database;
use VDM\Joomla\Service\Model;
use VDM\Joomla\Service\Data;
use VDM\Joomla\Interfaces\FactoryInterface;
use VDM\Joomla\Abstraction\Factory as ExtendingFactory;
/**
* Data Factory
*
* @since 3.2.2
*/
abstract class Factory extends ExtendingFactory implements FactoryInterface
{
/**
* Create a container object
*
* @return Container
* @since 3.2.2
*/
protected static function createContainer(): Container
{
return (new Container())
->registerServiceProvider(new Table())
->registerServiceProvider(new Database())
->registerServiceProvider(new Model())
->registerServiceProvider(new Data());
}
}
src/Data/Guid.php000064400000005470151162054050007612 0ustar00<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September, 2020
* @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\Data;
/**
* Globally Unique Identifier
*
* @since 5.0.2
*/
trait Guid
{
/**
* Returns a GUIDv4 string.
*
* This function uses the best cryptographically secure method
* available on the platform with a fallback to an older, less secure
version.
*
* @param string $key The key to check and modify values.
*
* @return string A GUIDv4 string.
*
* @since 5.0.2
*/
public function getGuid(string $key): string
{
// Windows: Use com_create_guid if available
if (function_exists('com_create_guid'))
{
$guid = trim(\com_create_guid(), '{}');
return $this->checkGuid($guid, $key);
}
// Unix-based systems: Use openssl_random_pseudo_bytes if available
if (function_exists('random_bytes'))
{
try {
$data = random_bytes(16);
} catch (Exception $e) {
// Handle the error appropriately (logging, throwing, etc.)
return $this->fallbackGuid($key);
}
// Set the version to 0100 and the bits 6-7 to 10 as per RFC 4122
$data[6] = chr(ord($data[6]) & 0x0f | 0x40);
$data[8] = chr(ord($data[8]) & 0x3f | 0x80);
$guid = vsprintf('%s%s-%s-%s-%s-%s%s%s',
str_split(bin2hex($data), 4));
return $this->checkGuid($guid, $key);
}
// Fallback to older methods if secure methods are not available
return $this->fallbackGuid($key);
}
/**
* Generates a fallback GUIDv4 using less secure methods.
*
* @param string $key The key to check and modify values.
*
* @return string A GUIDv4 string.
*
* @since 5.0.2
*/
private function fallbackGuid(string $key): string
{
$charid = strtolower(md5(uniqid(random_int(0, PHP_INT_MAX), true)));
$guidv4 = sprintf(
'%s-%s-%s-%s-%s',
substr($charid, 0, 8),
substr($charid, 8, 4),
substr($charid, 12, 4),
substr($charid, 16, 4),
substr($charid, 20, 12)
);
return $this->checkGuid($guidv4, $key);
}
/**
* Checks if the GUID value is unique and does not already exist.
*
* @param string $guid The GUID value to check.
* @param string $key The key to check and modify values.
*
* @return string The unique GUID value.
*
* @since 5.0.2
*/
private function checkGuid(string $guid, string $key): string
{
// Check that the GUID does not already exist
if ($this->items->table($this->getTable())->values([$guid],
$key))
{
return $this->getGuid($key);
}
return $guid;
}
}
src/Data/index.html000064400000000054151162054060010200
0ustar00<html><body
bgcolor="#FFFFFF"></body></html>src/Data/Item.php000064400000012204151162054060007612
0ustar00<?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\Data;
use VDM\Joomla\Interfaces\Data\LoadInterface as Load;
use VDM\Joomla\Interfaces\Data\InsertInterface as Insert;
use VDM\Joomla\Interfaces\Data\UpdateInterface as Update;
use VDM\Joomla\Interfaces\Data\DeleteInterface as Delete;
use VDM\Joomla\Interfaces\LoadInterface as Database;
use VDM\Joomla\Interfaces\Data\ItemInterface;
/**
* Data Item
*
* @since 3.2.2
*/
final class Item implements ItemInterface
{
/**
* The Load Class.
*
* @var Load
* @since 3.2.2
*/
protected Load $load;
/**
* The Insert Class.
*
* @var Insert
* @since 3.2.2
*/
protected Insert $insert;
/**
* The Update Class.
*
* @var Update
* @since 3.2.2
*/
protected Update $update;
/**
* The Delete Class.
*
* @var Delete
* @since 3.2.2
*/
protected Delete $delete;
/**
* The Load Class.
*
* @var Database
* @since 3.2.2
*/
protected Database $database;
/**
* Table Name
*
* @var string
* @since 3.2.1
*/
protected string $table;
/**
* Constructor.
*
* @param Load $load The LoadInterface Class.
* @param Insert $insert The InsertInterface Class.
* @param Update $update The UpdateInterface Class.
* @param Delete $delete The UpdateInterface Class.
* @param Database $database The Database Load Class.
* @param string|null $table The table name.
*
* @since 3.2.2
*/
public function __construct(Load $load, Insert $insert, Update $update,
Delete $delete, Database $database, ?string $table = null)
{
$this->load = $load;
$this->insert = $insert;
$this->update = $update;
$this->delete = $delete;
$this->database = $database;
if ($table !== null)
{
$this->table = $table;
}
}
/**
* Set the current active table
*
* @param string $table The table that should be active
*
* @return self
* @since 3.2.2
*/
public function table(string $table): self
{
$this->table = $table;
return $this;
}
/**
* Get an item
*
* @param string $value The item key value
* @param string $key The item key
*
* @return object|null The item object or null
* @since 3.2.2
*/
public function get(string $value, string $key = 'guid'):
?object
{
return $this->load->table($this->getTable())->item([$key
=> $value]);
}
/**
* Get the value
*
* @param string $value The item key value
* @param string $key The item key
* @param string $get The key of the values we want back
*
* @return mixed
* @since 3.2.2
*/
public function value(string $value, string $key = 'guid',
string $get = 'id')
{
return $this->load->table($this->getTable())->value([$key
=> $value], $get);
}
/**
* Set an item
*
* @param object $item The item
* @param string $key The item key
* @param string|null $action The action to load power
*
* @return bool
* @since 3.2.2
*/
public function set(object $item, string $key = 'guid', ?string
$action = null): bool
{
if ($action !== null || (isset($item->{$key}) && ($action =
$this->action($item->{$key}, $key)) !== null))
{
return method_exists($this, $action) ? $this->{$action}($item, $key)
: false;
}
return false;
}
/**
* Delete an item
*
* @param string $value The item key value
* @param string $key The item key
*
* @return bool
* @since 3.2.2
*/
public function delete(string $value, string $key = 'guid'):
bool
{
return $this->delete->table($this->getTable())->items([$key
=> $value]);
}
/**
* Get the current active table
*
* @return string
* @since 3.2.2
*/
public function getTable(): string
{
return $this->table;
}
/**
* Insert a item
*
* @param object $item The item
*
* @return bool
* @since 3.2.2
*/
private function insert(object $item): bool
{
return $this->insert->table($this->getTable())->item($item);
}
/**
* Update a item
*
* @param object $item The item
* @param string $key The item key
*
* @return bool
* @since 3.2.2
*/
private function update(object $item, string $key): bool
{
return $this->update->table($this->getTable())->item($item,
$key);
}
/**
* Get loading action
*
* @param string $value The key value the item
* @param string $key The item key
*
* @return string
* @since 3.2.2
*/
private function action(string $value, string $key): string
{
$id = $this->database->value(
["a.id" => 'id'],
["a" => $this->getTable()],
["a.$key" => $value]
);
if ($id !== null && $id > 0)
{
return 'update';
}
return 'insert';
}
}
src/Data/Items.php000064400000017210151162054060007777 0ustar00<?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\Data;
use VDM\Joomla\Interfaces\Data\LoadInterface as Load;
use VDM\Joomla\Interfaces\Data\InsertInterface as Insert;
use VDM\Joomla\Interfaces\Data\UpdateInterface as Update;
use VDM\Joomla\Interfaces\Data\DeleteInterface as Delete;
use VDM\Joomla\Interfaces\LoadInterface as Database;
use VDM\Joomla\Interfaces\Data\ItemsInterface;
/**
* Data Items
*
* @since 3.2.2
*/
final class Items implements ItemsInterface
{
/**
* The LoadInterface Class.
*
* @var Load
* @since 3.2.2
*/
protected Load $load;
/**
* The InsertInterface Class.
*
* @var Insert
* @since 3.2.2
*/
protected Insert $insert;
/**
* The UpdateInterface Class.
*
* @var Update
* @since 3.2.2
*/
protected Update $update;
/**
* The DeleteInterface Class.
*
* @var Delete
* @since 3.2.2
*/
protected Delete $delete;
/**
* The Load Class.
*
* @var Database
* @since 3.2.2
*/
protected Database $database;
/**
* Table Name
*
* @var string
* @since 3.2.1
*/
protected string $table;
/**
* Constructor.
*
* @param Load $load The LoadInterface Class.
* @param Insert $insert The InsertInterface Class.
* @param Update $update The UpdateInterface Class.
* @param Delete $delete The DeleteInterface Class.
* @param Database $database The Database Load Class.
* @param string|null $table The table name.
*
* @since 3.2.2
*/
public function __construct(Load $load, Insert $insert, Update $update,
Delete $delete,
Database $database, ?string $table = null)
{
$this->load = $load;
$this->insert = $insert;
$this->update = $update;
$this->delete = $delete;
$this->database = $database;
if ($table !== null)
{
$this->table = $table;
}
}
/**
* Set the current active table
*
* @param string $table The table that should be active
*
* @return self
* @since 3.2.2
*/
public function table(string $table): self
{
$this->table = $table;
return $this;
}
/**
* Get list of items
*
* @param array $values The ids of the items
* @param string $key The key of the values
*
* @return array|null The item object or null
* @since 3.2.2
*/
public function get(array $values, string $key = 'guid'):
?array
{
return $this->load->table($this->getTable())->items([
$key => [
'operator' => 'IN',
'value' => array_values($values)
]
]);
}
/**
* Get the values
*
* @param array $values The list of values (to search by).
* @param string $key The key on which the values being searched.
* @param string $get The key of the values we want back
*
* @return array|null The array of found values.
* @since 3.2.2
*/
public function values(array $values, string $key = 'guid',
string $get = 'id'): ?array
{
// Perform the database query
return $this->load->table($this->getTable())->values([
$key => [
'operator' => 'IN',
'value' => array_values($values)
]
], $get);
}
/**
* Set items
*
* @param array $items The list of items
* @param string $key The key on which the items should be set
*
* @return bool
* @since 3.2.2
*/
public function set(array $items, string $key = 'guid'): bool
{
if (($sets = $this->sort($items, $key)) !== null)
{
foreach ($sets as $action => $items)
{
$this->{$action}($items, $key);
}
return true;
}
return false;
}
/**
* Delete items
*
* @param array $values The item key value
* @param string $key The item key
*
* @return bool
* @since 3.2.2
*/
public function delete(array $values, string $key = 'guid'):
bool
{
return $this->delete->table($this->getTable())->items([$key
=> ['operator' => 'IN', 'value' =>
$values]]);
}
/**
* Get the current active table
*
* @return string
* @since 3.2.2
*/
public function getTable(): string
{
return $this->table;
}
/**
* Insert a item
*
* @param array $items The item
*
* @return bool
* @since 3.2.2
*/
private function insert(array $items): bool
{
return
$this->insert->table($this->getTable())->rows($items);
}
/**
* Update a item
*
* @param object $item The item
* @param string $key The item key
*
* @return bool
* @since 3.2.2
*/
private function update(array $items, string $key): bool
{
return $this->update->table($this->getTable())->rows($items,
$key);
}
/**
* Sort items between insert and update.
*
* @param array $items The list of items.
* @param string $key The key on which the items should be sorted.
*
* @return array|null The sorted sets.
* @since 3.2.2
*/
private function sort(array $items, string $key): ?array
{
// Extract relevant items based on the key.
$values = $this->extractValues($items, $key);
if ($values === null)
{
return null;
}
$sets = [
'insert' => [],
'update' => []
];
// Check for existing items.
$existingItems = $this->database->values(
["a.$key" => $key],
["a" => $this->getTable()],
["a.$key" => ['operator' => 'IN',
'value' => $values]]
);
if ($existingItems !== null)
{
$sets['update'] = $this->extractSet($items, $existingItems,
$key) ?? [];
$sets['insert'] = $this->extractSet($items, $existingItems,
$key, true) ?? [];
}
else
{
$sets['insert'] = $items;
}
// If either set is empty, remove it from the result.
$sets = array_filter($sets);
return !empty($sets) ? $sets : null;
}
/**
* Extracts values for a given key from an array of items.
* Items can be either arrays or objects.
*
* @param array $items Array of items (arrays or objects)
* @param string $key The key to extract values for
*
* @return array|null Extracted values
* @since 3.2.2
*/
private function extractValues(array $items, string $key): ?array
{
$result = [];
foreach ($items as $item)
{
if (is_array($item) && !empty($item[$key]))
{
$result[] = $item[$key];
}
elseif (is_object($item) && !empty($item->{$key}))
{
$result[] = $item->{$key};
}
}
return ($result === []) ? null : $result;
}
/**
* Extracts items from an array of items based on a set.
* Items can be either arrays or objects.
*
* @param array $items Array of items (arrays or objects)
* @param array $set The set to match values against
* @param string $key The key of the set values
* @param bool $inverse Whether to extract items not in the set
*
* @return array|null Extracted values
* @since 3.2.2
*/
private function extractSet(array $items, array $set, string $key, bool
$inverse = false): ?array
{
$result = [];
foreach ($items as $item)
{
$value = is_array($item) ? ($item[$key] ?? null) : ($item->{$key} ??
null);
if ($value !== null)
{
$inSet = in_array($value, $set);
if (($inSet && !$inverse) || (!$inSet && $inverse))
{
$result[] = is_array($item) ? $item : (array) $item; // convert all to
arrays
}
}
}
return empty($result) ? null : $result;
}
}
src/Data/MultiSubform.php000064400000033636151162054060011360
0ustar00<?php
/**
* @package Joomla.Component.Builder
*
* @created 3rd September, 2020
* @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\Data;
use VDM\Joomla\Interfaces\Data\SubformInterface as Subform;
use VDM\Joomla\Interfaces\Data\MultiSubformInterface;
/**
* CRUD the data of multi subform to another views (tables)
*
* @since 3.2.2
*/
final class MultiSubform implements MultiSubformInterface
{
/**
* The Subform Class.
*
* @var Subform
* @since 3.2.2
*/
protected Subform $subform;
/**
* Constructor.
*
* @param Subform $subform The Subform Class.
*
* @since 3.2.2
*/
public function __construct(Subform $subform)
{
$this->subform = $subform;
}
/**
* Get a subform items
*
* @param array $getMap The map to get the subfrom data
*
* Example:
* $getMap = [
* '_core' => [
* 'table' =>'data',
* 'linkValue' => $item->guid ?? '',
* 'linkKey' => 'look',
* 'field' => 'data',
* 'get' =>
['guid','email','image','mobile_phone','website','dateofbirth']
* ],
* 'countries' => [
* 'table' =>'data_country',
* 'linkValue' => 'data:guid', //
coretable:fieldname
* 'linkKey' => 'data',
* 'get' =>
['guid','country','currency']
* ]
* ];
*
* @return array|null The subform
* @since 3.2.2
*/
public function get(array $getMap): ?array
{
// Validate the core map presence and structure
if (!isset($getMap['_core']) ||
!is_array($getMap['_core']) ||
!$this->validGetMap($getMap['_core']))
{
return null;
}
// Initialize the core data
$coreData = $this->getSubformData($getMap['_core']);
// Return null if fetching core data fails
if (null === $coreData)
{
return null;
}
$table = $getMap['_core']['table'];
unset($getMap['_core']);
// Recursively get data for all nested subforms
return $this->getNestedSubforms($getMap, $coreData, $table);
}
/**
* Set a subform items
*
* @param mixed $items The list of items from the subform to set
* @param array $setMap The map to set the subfrom data
*
* Example:
* $items,
* $setMap = [
* '_core' => [
* 'table' =>'data',
* 'indexKey' => 'guid',
* 'linkKey' => 'look',
* 'linkValue' => $data['guid'] ??
''
* ],
* 'countries' => [
* 'table' =>'data_country',
* 'indexKey' => 'guid',
* 'linkKey' => 'data',
* 'linkValue' => 'data:guid' //
coretable:fieldname
* ]
* ];
*
* @return bool
* @since 3.2.2
*/
public function set(mixed $items, array $setMap): bool
{
// Validate the core map presence and structure
if (!isset($setMap['_core']) ||
!is_array($setMap['_core']) ||
!$this->validSetMap($setMap['_core']))
{
return false;
}
// catch an empty set
if (!is_array($items))
{
$items = []; // will delete all existing linked items :( not ideal, but
real
}
// Save the core data
if (!$this->setSubformData($items, $setMap['_core']))
{
return false;
}
$table = $setMap['_core']['table'];
unset($setMap['_core']);
// Recursively set data for all nested subforms
return $this->setNestedSubforms($setMap, $items, $table);
}
/**
* Fetch data based on provided map configuration.
*
* @param array $map Map configuration
* @param array|null $coreData The core data to be appended with subform
data
*
* @return array|null Fetched data or null on failure
* @since 3.2.2
*/
private function getSubformData(array $map, ?array $coreData = null):
?array
{
$map['linkValue'] =
$this->setLinkValue($map['linkValue'], $coreData);
if (empty($map['linkValue']) ||
strpos($map['linkValue'], ':') !== false)
{
return null;
}
return $this->subform->table($map['table'])->get(
$map['linkValue'],
$map['linkKey'],
$map['field'],
$map['get']
);
}
/**
* Set data based on provided map configuration.
*
* @param array $items The list of items from the subform to
set
* @param array $map The map to set the subfrom data
* @param array|null $coreData The core data to be appended with subform
data
*
* @return bool
* @since 3.2.2
*/
private function setSubformData(array $items, array $map, ?array $coreData
= null): bool
{
$map['linkValue'] =
$this->setLinkValue($map['linkValue'], $coreData);
if (empty($map['linkValue']) ||
strpos($map['linkValue'], ':') !== false)
{
return false;
}
return $this->subform->table($map['table'])->set(
$items,
$map['indexKey'],
$map['linkKey'],
$map['linkValue']
);
}
/**
* Set the linked value if needed, and posible.
*
* @param string $linkValue The current linkValue
* @param array|null $data The already found data as table =>
dataSet[field] => value
*
* @return string|null The actual linkValue
* @since 3.2.2
*/
private function setLinkValue(string $linkValue, ?array $data = null):
?string
{
if ($data !== null && strpos($linkValue, ':') !==
false)
{
[$table, $field] = explode(':', $linkValue);
$linkValue = $data[$table][$field] ?? null;
}
return $linkValue;
}
/**
* Recursively process additional subform data.
*
* @param array $getMap The nested map of data to process
* @param array $subformData The core subform data
* @param string $table The core table
*
* @return array The core data with nested subforms included
* @since 3.2.2
*/
private function getNestedSubforms(array $getMap, array $subformData,
string $table): array
{
foreach ($subformData as &$subform)
{
$subform = $this->processGetSubform($getMap, $subform, $table);
}
return $subformData;
}
/**
* Recursively process additional subform data.
*
* @param array $setMap The nested map of data to process
* @param array $subformData The core subform data
* @param string $table The core table
*
* @return bool
* @since 3.2.2
*/
private function setNestedSubforms(array $setMap, array $subformData,
string $table): bool
{
$status = true;
foreach ($subformData as $subform)
{
if (!$this->processSetSubform($setMap, $subform, $table))
{
$status = false;
}
}
return $status;
}
/**
* Process each subform entry based on the map.
*
* @param array $getMap Mapping data for processing subforms
* @param array $subform A single subform entry
* @param string $table The table name used for linking values
*
* @return array Updated subform
* @since 3.2.2
*/
private function processGetSubform(array $getMap, array $subform, string
$table): array
{
foreach ($getMap as $key => $map)
{
if (!is_array($map) || isset($subform[$key]))
{
continue;
}
$this->processGetMap($subform, $map, $key, $table);
}
return $subform;
}
/**
* Process each subform entry based on the map.
*
* @param array $setMap Mapping data for processing subforms
* @param array $subform A single subform entry
* @param string $table The table name used for linking values
*
* @return bool
* @since 3.2.2
*/
private function processSetSubform(array $setMap, array $subform, string
$table): bool
{
$status = true;
foreach ($setMap as $key => $map)
{
if (!is_array($map) || !isset($subform[$key]))
{
continue;
}
if (!$this->processSetMap($subform, $map, $key, $table))
{
$status = false;
}
}
return $status;
}
/**
* Process a given map by either fetching nested subforms or handling them
directly.
*
* @param array &$subform Reference to subform data
* @param array $map Map configuration for subform processing
* @param string $key Key associated with the map
* @param string $table Core table name for linking values
*
* @return void
* @since 3.2.2
*/
private function processGetMap(array &$subform, array $map, string
$key, string $table): void
{
if (isset($map['_core']))
{
$this->handleCoreGetMap($subform, $map, $key, $table);
}
else
{
$this->handleRegularGetMap($subform, $map, $key, $table);
}
}
/**
* Process a given map by either setting nested subforms or handling them
directly.
*
* @param array $subform Subform data
* @param array $map Map configuration for subform processing
* @param string $key Key associated with the map
* @param string $table Core table name for linking values
*
* @return bool
* @since 3.2.2
*/
private function processSetMap(array $subform, array $map, string $key,
string $table): bool
{
if (isset($map['_core']))
{
return $this->handleCoreSetMap($subform, $map, $key, $table);
}
return $this->handleRegularSetMap($subform, $map, $key, $table);
}
/**
* Handle the processing of '_core' maps in a subform.
*
* @param array &$subform Reference to subform data
* @param array $map Map configuration for core subform processing
* @param string $key Key associated with the map
* @param string $table Core table name for linking values
*
* @return void
* @since 3.2.2
*/
private function handleCoreGetMap(array &$subform, array $map, string
$key, string $table): void
{
if (is_array($map['_core']) &&
$this->validGetMap($map['_core']))
{
$map['_core']['linkValue'] =
$this->setLinkValue($map['_core']['linkValue'],
[$table => $subform]);
$subCoreData = $this->get($map);
if ($subCoreData !== null)
{
$subform[$key] = $subCoreData;
}
}
}
/**
* Handle the processing of '_core' maps in a subform.
*
* @param array $subform Subform data
* @param array $map Map configuration for core subform processing
* @param string $key Key associated with the map
* @param string $table Core table name for linking values
*
* @return bool
* @since 3.2.2
*/
private function handleCoreSetMap(array $subform, array $map, string $key,
string $table): bool
{
if (is_array($map['_core']) &&
$this->validGetMap($map['_core']))
{
$map['_core']['linkValue'] =
$this->setLinkValue($map['_core']['linkValue'],
[$table => $subform]);
return $this->set($subform[$key], $map);
}
return false;
}
/**
* Handle the processing of regular maps in a subform.
*
* @param array &$subform Reference to subform data
* @param array $map Map configuration for regular subform
processing
* @param string $key Key associated with the map
* @param string $table Core table name for linking values
*
* @return void
* @since 3.2.2
*/
private function handleRegularGetMap(array &$subform, array $map,
string $key, string $table): void
{
$map['field'] = $key;
if ($this->validGetMap($map))
{
$subformData = $this->getSubformData($map, [$table => $subform]);
if ($subformData !== null)
{
$subform[$key] = $subformData;
}
}
}
/**
* Handle the processing of regular maps in a subform.
*
* @param array $subform Subform data
* @param array $map Map configuration for regular subform
processing
* @param string $key Key associated with the map
* @param string $table Core table name for linking values
*
* @return bool
* @since 3.2.2
*/
private function handleRegularSetMap(array $subform, array $map, string
$key, string $table): bool
{
if ($this->validSetMap($map))
{
// will delete all existing linked items [IF EMPTY] :( not ideal, but
real
$data = (empty($subform[$key]) || !is_array($subform[$key])) ? [] :
$subform[$key];
return $this->setSubformData($data, $map, [$table => $subform]);
}
return false;
}
/**
* Validate the get map configuration for fetching subform data.
* Ensures all required keys are present and have valid values.
*
* @param array $map The map configuration to validate.
*
* @return bool Returns true if the map is valid, false otherwise.
* @since 3.2.2
*/
private function validGetMap(array $map): bool
{
// List of required keys with their expected types or validation
functions
$requiredKeys = [
'table' => 'is_string',
'linkValue' => 'is_string',
'linkKey' => 'is_string',
'field' => 'is_string',
'get' => 'is_array'
];
// Iterate through each required key and validate
foreach ($requiredKeys as $key => $validator)
{
if (empty($map[$key]) || !$validator($map[$key]))
{
return false; // Key missing or validation failed
}
}
return true; // All checks passed
}
/**
* Validate the set map configuration for fetching subform data.
* Ensures all required keys are present and have valid values.
*
* @param array $map The map configuration to validate.
*
* @return bool Returns true if the map is valid, false otherwise.
* @since 3.2.2
*/
private function validSetMap(array $map): bool
{
// List of required keys with their expected types or validation
functions
$requiredKeys = [
'table' => 'is_string',
'indexKey' => 'is_string',
'linkKey' => 'is_string',
'linkValue' => 'is_string'
];
// Iterate through each required key and validate
foreach ($requiredKeys as $key => $validator)
{
if (empty($map[$key]) || !$validator($map[$key]))
{
return false; // Key missing or validation failed
}
}
return true; // All checks passed
}
}
src/Data/Subform.php000064400000020236151162054060010335 0ustar00<?php
/**
* @package Joomla.Component.Builder
*
* @created 3rd September, 2020
* @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\Data;
use VDM\Joomla\Interfaces\Data\ItemsInterface as Items;
use VDM\Joomla\Data\Guid;
use VDM\Joomla\Interfaces\Data\GuidInterface;
use VDM\Joomla\Interfaces\Data\SubformInterface;
/**
* CRUD the data of any sub-form to another view (table)
*
* @since 3.2.2
*/
final class Subform implements GuidInterface, SubformInterface
{
/**
* The Globally Unique Identifier.
*
* @since 5.0.2
*/
use Guid;
/**
* The Items Class.
*
* @var Items
* @since 3.2.2
*/
protected Items $items;
/**
* Table Name
*
* @var string
* @since 3.2.1
*/
protected string $table;
/**
* Constructor.
*
* @param Items $items The Items Class.
* @param string|null $table The table name.
*
* @since 3.2.2
*/
public function __construct(Items $items, ?string $table = null)
{
$this->items = $items;
if ($table !== null)
{
$this->table = $table;
}
}
/**
* Set the current active table
*
* @param string $table The table that should be active
*
* @return self
* @since 3.2.2
*/
public function table(string $table): self
{
$this->table = $table;
return $this;
}
/**
* Get a subform items
*
* @param string $linkValue The value of the link key in child table.
* @param string $linkKey The link key on which the items where
linked in the child table.
* @param string $field The parent field name of the subform in the
parent view.
* @param array $get The array SET of the keys of each row in
the subform.
* @param bool $multi The switch to return a multiple set.
*
* @return array|null The subform
* @since 3.2.2
*/
public function get(string $linkValue, string $linkKey, string $field,
array $get, bool $multi = true): ?array
{
if (($items =
$this->items->table($this->getTable())->get([$linkValue],
$linkKey)) !== null)
{
return $this->converter($items, $get, $field, $multi);
}
return null;
}
/**
* Set a subform items
*
* @param mixed $items The list of items from the subform to set
* @param string $indexKey The index key on which the items should be
observed as it relates to insert/update/delete.
* @param string $linkKey The link key on which the items where
linked in the child table.
* @param string $linkValue The value of the link key in child table.
*
* @return bool
* @since 3.2.2
*/
public function set(mixed $items, string $indexKey, string $linkKey,
string $linkValue): bool
{
$items = $this->process($items, $indexKey, $linkKey, $linkValue);
$this->purge($items, $indexKey, $linkKey, $linkValue);
if (empty($items))
{
return true; // nothing to set (already purged)
}
return $this->items->table($this->getTable())->set(
$items, $indexKey
);
}
/**
* Get the current active table
*
* @return string
* @since 3.2.2
*/
public function getTable(): string
{
return $this->table;
}
/**
* Purge all items no longer in subform
*
* @param array $items The list of items to set.
* @param string $indexKey The index key on which the items should be
observed as it relates to insert/update/delete
* @param string $linkKey The link key on which the items where
linked in the child table.
* @param string $linkValue The value of the link key in child table.
*
* @return void
* @since 3.2.2
*/
private function purge(array $items, string $indexKey, string $linkKey,
string $linkValue): void
{
// Get the current index values from the database
$currentIndexValues =
$this->items->table($this->getTable())->values([$linkValue],
$linkKey, $indexKey);
if ($currentIndexValues !== null)
{
// Check if the items array is empty
if (empty($items))
{
// Set activeIndexValues to an empty array if items is empty
$activeIndexValues = [];
}
else
{
// Extract the index values from the items array
$activeIndexValues = array_values(array_map(function($item) use
($indexKey) {
return $item[$indexKey] ?? null;
}, $items));
}
// Find the index values that are no longer in the items array
$inactiveIndexValues = array_diff($currentIndexValues,
$activeIndexValues);
// Delete the inactive index values
if (!empty($inactiveIndexValues))
{
$this->items->table($this->getTable())->delete($inactiveIndexValues,
$indexKey);
}
}
}
/**
* Filters the specified keys from an array of objects or arrays, converts
them to arrays,
* and sets them by association with a specified key and an incrementing
integer.
*
* @param array $items Array of objects or arrays to be filtered.
* @param array $keySet Array of keys to retain in each item.
* @param string $field The field prefix for the resulting associative
array.
* @param bool $multi The switch to return a multiple set.
*
* @return array Array of filtered arrays set by association.
* @since 3.2.2
*/
private function converter(array $items, array $keySet, string $field,
bool $multi): array
{
/**
* Filters keys for a single item and converts it to an array.
*
* @param object|array $item The item to filter.
* @param array $keySet The keys to retain.
*
* @return array The filtered array.
* @since 3.2.2
*/
$filterKeys = function ($item, array $keySet) {
$filteredArray = [];
foreach ($keySet as $key) {
if (is_object($item) && property_exists($item, $key)) {
$filteredArray[$key] = $item->{$key};
} elseif (is_array($item) && array_key_exists($key, $item)) {
$filteredArray[$key] = $item[$key];
}
}
return $filteredArray;
};
$result = [];
foreach ($items as $index => $item)
{
if (!$multi)
{
return $filterKeys($item, $keySet);
}
$filteredArray = $filterKeys($item, $keySet);
$result[$field . $index] = $filteredArray;
}
return $result;
}
/**
* Processes an array of arrays based on the specified key.
*
* @param mixed $items Array of arrays to be processed.
* @param string $indexKey The index key on which the items should be
observed as it relates to insert/update/delete
* @param string $linkKey The link key on which the items where
linked in the child table.
* @param string $linkValue The value of the link key in child table.
*
* @return array The processed array of arrays.
* @since 3.2.2
*/
private function process($items, string $indexKey, string $linkKey, string
$linkValue): array
{
$items = is_array($items) ? $items : [];
if ($items !== [] && !$this->isMultipleSets($items))
{
$items = [$items];
}
foreach ($items as &$item)
{
$value = $item[$indexKey] ?? '';
switch ($indexKey) {
case 'guid':
if (empty($value))
{
// set INDEX
$item[$indexKey] = $this->getGuid($indexKey);
}
break;
case 'id':
if (empty($value))
{
$item[$indexKey] = 0;
}
break;
default:
// No action for other keys if empty
break;
}
// set LINK
$item[$linkKey] = $linkValue;
}
return array_values($items);
}
/**
* Function to determine if the array consists of multiple data sets
(arrays of arrays).
*
* @param array $array The input array to be checked.
*
* @return bool True if the array contains only arrays (multiple data
sets), false otherwise.
* @since 5.0.2
*/
private function isMultipleSets(array $array): bool
{
foreach ($array as $element)
{
// As soon as we find a non-array element, return false
if (!is_array($element))
{
return false;
}
}
// If all elements are arrays, return true
return true;
}
}
src/Data/UsersSubform.php000064400000037475151162054060011374
0ustar00<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September, 2020
* @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\Data;
use Joomla\CMS\Factory;
use Joomla\CMS\User\User;
use VDM\Joomla\Interfaces\Data\ItemsInterface as Items;
use VDM\Joomla\Data\Guid;
use VDM\Joomla\Componentbuilder\Utilities\UserHelper;
use VDM\Joomla\Componentbuilder\Utilities\Exception\NoUserIdFoundException;
use VDM\Joomla\Utilities\Component\Helper as Component;
use VDM\Joomla\Interfaces\Data\GuidInterface;
use VDM\Joomla\Interfaces\Data\SubformInterface;
/**
* CRUD the user data of any sub-form to another view (table)
*
* @since 5.0.2
*/
final class UsersSubform implements GuidInterface, SubformInterface
{
/**
* The Globally Unique Identifier.
*
* @since 5.0.2
*/
use Guid;
/**
* The Items Class.
*
* @var Items
* @since 3.2.2
*/
protected Items $items;
/**
* Table Name
*
* @var string
* @since 3.2.1
*/
protected string $table;
/**
* The user properties
*
* @var array
* @since 5.0.2
*/
protected array $user;
/**
* The current active user
*
* @var User
* @since 5.0.2
*/
protected User $identity;
/**
* The active users
*
* @var array
* @since 5.0.2
*/
protected array $activeUsers = [];
/**
* Constructor.
*
* @param Items $items The items Class.
* @param string|null $table The table name.
*
* @since 3.2.2
*/
public function __construct(Items $items, ?string $table = null)
{
$this->items = $items;
if ($table !== null)
{
$this->table = $table;
}
$this->identity = Factory::getApplication()->getIdentity();
// Retrieve the user properties
$this->initializeUserProperties();
}
/**
* Set the current active table
*
* @param string $table The table that should be active
*
* @return self
* @since 3.2.2
*/
public function table(string $table): self
{
$this->table = $table;
return $this;
}
/**
* Get a subform items
*
* @param string $linkValue The value of the link key in child table.
* @param string $linkKey The link key on which the items where
linked in the child table.
* @param string $field The parent field name of the subform in the
parent view.
* @param array $get The array get:set of the keys of each row
in the subform.
* @param bool $multi The switch to return a multiple set.
*
* @return array|null The subform
* @since 3.2.2
*/
public function get(string $linkValue, string $linkKey, string $field,
array $get, bool $multi = true): ?array
{
if (($items =
$this->items->table($this->getTable())->get([$linkValue],
$linkKey)) !== null)
{
return $this->converter(
$this->getUsersDetails($items),
$get,
$field,
$multi
);
}
return null;
}
/**
* Set a subform items
*
* @param mixed $items The list of items from the subform to set
* @param string $indexKey The index key on which the items should be
observed as it relates to insert/update/delete.
* @param string $linkKey The link key on which the items where
linked in the child table.
* @param string $linkValue The value of the link key in child table.
*
* @return bool
* @since 3.2.2
*/
public function set(mixed $items, string $indexKey, string $linkKey,
string $linkValue): bool
{
$items = $this->process($items, $indexKey, $linkKey, $linkValue);
$this->purge($items, $indexKey, $linkKey, $linkValue);
if (empty($items))
{
return true; // nothing to set (already purged)
}
return $this->items->table($this->getTable())->set(
$items, $indexKey
);
}
/**
* Get the current active table
*
* @return string
* @since 3.2.2
*/
public function getTable(): string
{
return $this->table;
}
/**
* Initializes the user properties.
*
* @return void
* @since 5.0.2
*/
private function initializeUserProperties(): void
{
$user = UserHelper::getUserById(0);
// Populate user properties array excluding the 'id'
foreach (get_object_vars($user) as $property => $value)
{
if ($property !== 'id')
{
$this->user[$property] = $property;
}
}
$this->user['password2'] = 'password2';
}
/**
* Purge all items no longer in subform
*
* @param array $items The list of items to set.
* @param string $indexKey The index key on which the items should be
observed as it relates to insert/update/delete
* @param string $linkKey The link key on which the items where
linked in the child table.
* @param string $linkValue The value of the link key in child table.
*
* @return void
* @since 3.2.2
*/
private function purge(array $items, string $indexKey, string $linkKey,
string $linkValue): void
{
// Get the current index values from the database
$currentIndexValues =
$this->items->table($this->getTable())->values([$linkValue],
$linkKey, $indexKey);
if ($currentIndexValues !== null)
{
// Check if the items array is empty
if (empty($items))
{
// Set activeIndexValues to an empty array if items is empty
$activeIndexValues = [];
}
else
{
// Extract the index values from the items array
$activeIndexValues = array_values(array_map(function($item) use
($indexKey) {
return $item[$indexKey] ?? null;
}, $items));
}
// Find the index values that are no longer in the items array
$inactiveIndexValues = array_diff($currentIndexValues,
$activeIndexValues);
// Delete the inactive index values
if (!empty($inactiveIndexValues))
{
$this->items->table($this->getTable())->delete($inactiveIndexValues,
$indexKey);
// $this->deleteUsers($inactiveIndexValues); (soon)
}
}
}
/**
* Get the users details found in the user table.
*
* @param array $items Array of objects or arrays to be filtered.
*
* @return array
* @since 5.0.2
*/
private function getUsersDetails(array $items): array
{
foreach ($items as $index => &$item)
{
$item = (array) $item;
$this->getUserDetails($item);
}
return $items;
}
/**
* Get the user details found in the user table.
*
* @param array $item The user map array
*
* @return void
* @since 5.0.2
*/
private function getUserDetails(array &$item): void
{
// Validate the user_id and ensure it is numeric and greater than 0
if (empty($item['user_id']) ||
!is_numeric($item['user_id']) || $item['user_id'] <=
0)
{
return;
}
// Retrieve the user by ID
$user = UserHelper::getUserById((int)$item['user_id']);
// Verify if the user exists and the ID matches
if ($user && $user->id === (int) $item['user_id'])
{
// Iterate over public properties of the user object
foreach (get_object_vars($user) as $property => $value)
{
// Avoid overwriting the id in the item
if ($property !== 'id')
{
$item[$property] = $value;
}
}
}
}
/**
* Filters the specified keys from an array of objects or arrays, converts
them to arrays,
* and sets them by association with a specified key and an incrementing
integer.
*
* @param array $items Array of objects or arrays to be filtered.
* @param array $keySet Array of keys to retain in each item.
* @param string $field The field prefix for the resulting associative
array.
* @param bool $multi The switch to return a multiple set.
*
* @return array Array of filtered arrays set by association.
* @since 3.2.2
*/
private function converter(array $items, array $keySet, string $field,
bool $multi): array
{
/**
* Filters keys for a single item and converts it to an array.
*
* @param object|array $item The item to filter.
* @param array $keySet The keys to retain.
*
* @return array The filtered array.
* @since 3.2.2
*/
$filterKeys = function ($item, array $keySet) {
$filteredArray = [];
foreach ($keySet as $key) {
if (is_object($item) && property_exists($item, $key)) {
$filteredArray[$key] = $item->{$key};
} elseif (is_array($item) && array_key_exists($key, $item)) {
$filteredArray[$key] = $item[$key];
}
}
return $filteredArray;
};
$result = [];
foreach ($items as $index => $item)
{
if (!$multi)
{
return $filterKeys($item, $keySet);
}
$filteredArray = $filterKeys($item, $keySet);
$result[$field . $index] = $filteredArray;
}
return $result;
}
/**
* Processes an array of arrays based on the specified key.
*
* @param mixed $items Array of arrays to be processed.
* @param string $indexKey The index key on which the items should be
observed as it relates to insert/update/delete
* @param string $linkKey The link key on which the items where
linked in the child table.
* @param string $linkValue The value of the link key in child table.
*
* @return array The processed array of arrays.
* @since 3.2.2
*/
private function process($items, string $indexKey, string $linkKey, string
$linkValue): array
{
$items = is_array($items) ? $items : [];
if ($items !== [] && !$this->isMultipleSets($items))
{
$items = [$items];
}
foreach ($items as $n => &$item)
{
$value = $item[$indexKey] ?? '';
switch ($indexKey) {
case 'guid':
if (empty($value))
{
// set INDEX
$item[$indexKey] = $this->getGuid($indexKey);
}
break;
case 'id':
if (empty($value))
{
$item[$indexKey] = 0;
}
break;
default:
// No action for other keys if empty
break;
}
// set LINK
$item[$linkKey] = $linkValue;
// create/update user
$item['user_id'] = $this->setUserDetails(
$item,
$this->getActiveUsers(
$linkKey,
$linkValue
)
);
// remove empty row (means no user linked)
if ($item['user_id'] == 0)
{
unset($items[$n]);
}
}
return array_values($items);
}
/**
* Get current active Users Linked to this entity
*
* @param string $linkKey The link key on which the items where
linked in the child table.
* @param string $linkValue The value of the link key in child table.
*
* @return array The IDs of all active users.
* @since 5.0.2
*/
private function getActiveUsers(string $linkKey, string $linkValue):
array
{
if (isset($this->activeUsers[$linkKey . $linkValue]))
{
return $this->activeUsers[$linkKey . $linkValue];
}
if (($users =
$this->items->table($this->getTable())->values([$linkValue],
$linkKey, 'user_id')) !== null)
{
$this->activeUsers[$linkKey . $linkValue] = $users;
return $users;
}
return [];
}
/**
* Handles setting user details and saving them.
*
* This function retrieves the user by ID, sets the user details,
* and adds appropriate user groups before saving the user.
*
* @param array $item The user details passed by reference.
* @param array $activeUsers The current active user linked to this
entity.
*
* @return int The ID of the saved user, or 0 on failure.
* @since 5.0.2
*/
private function setUserDetails(array &$item, array $activeUsers):
int
{
$user = $this->loadUser($item, $activeUsers);
$details = $this->extractUserDetails($item, $user);
if ($this->identity->id != $user->id)
{
$this->assignUserGroups($details, $user, $item);
}
return $this->saveUserDetails($details, $details['id'] ??
0);
}
/**
* Load the user based on the user ID from the item array.
*
* @param array $item The array containing user details.
* @param array $activeUsers The current active user linked to this
entity.
*
* @return User|null The user object if found, null otherwise.
* @since 5.0.2
*/
private function loadUser(array $item, array $activeUsers): ?User
{
if (!isset($item['user_id']) ||
!is_numeric($item['user_id']) || $item['user_id'] <=
0)
{
return null;
}
// only allow update to linked users
if (!in_array($item['user_id'], $activeUsers))
{
return null;
}
$user = UserHelper::getUserById((int) $item['user_id']);
if ($user && $user->id == $item['user_id'])
{
return $user;
}
return null;
}
/**
* Extract user details from the item array and prepare them for saving.
*
* @param array $item The array containing user details.
* @param User|null $user The user object if found, null otherwise.
*
* @return array The prepared user details array.
* @since 5.0.2
*/
private function extractUserDetails(array &$item, ?User $user): array
{
$details = [];
if ($user !== null)
{
$details['id'] = (int) $item['user_id'];
}
foreach ($this->user as $property)
{
if (isset($item[$property]))
{
$details[$property] = $item[$property];
unset($item[$property]);
}
}
return $details;
}
/**
* Assigns user groups based on existing groups and entity type.
*
* @param array &$details The array to store user details
including groups.
* @param User|null $user The user object if found, null otherwise.
* @param array $item The array containing additional user
details.
*
* @return void
* @since 5.0.2
*/
private function assignUserGroups(array &$details, ?User $user, array
$item): void
{
$groups = $user !== null ? (array) $user->groups : [];
if (!empty($item['entity_type']))
{
$global_entity_groups =
Component::getParams()->get($item['entity_type'] .
'_groups', []);
foreach ($global_entity_groups as $group)
{
if (!in_array($group, $groups))
{
$groups[] = $group;
}
}
}
// Ensure $details['groups'] is an array if it exists, else
default to an empty array
$detailsGroups = isset($details['groups']) ? (array)
$details['groups'] : [];
// Merge the arrays and remove duplicates
$mergedGroups = array_unique(array_merge($detailsGroups, $groups));
// Only set $details['groups'] if the merged array is not
empty
if (!empty($mergedGroups))
{
$details['groups'] = $mergedGroups;
}
else
{
unset($details['groups']);
}
}
/**
* Save the user details using UserHelper and handle exceptions.
*
* @param array $details The prepared user details array.
* @param int $userId The ID of the user being processed.
*
* @return int The ID of the saved user, or 0 on failure.
* @since 5.0.2
*/
private function saveUserDetails(array $details, int $userId): int
{
try {
return UserHelper::save($details, 0, ['useractivation' =>
0, 'sendpassword' => 1, 'allowUserRegistration'
=> 1]);
} catch (NoUserIdFoundException $e) {
Factory::getApplication()->enqueueMessage($e->getMessage(),
'error');
} catch (\Exception $e) {
Factory::getApplication()->enqueueMessage($e->getMessage(),
'warning');
return $userId;
}
return 0;
}
/**
* Function to determine if the array consists of multiple data sets
(arrays of arrays).
*
* @param array $array The input array to be checked.
*
* @return bool True if the array contains only arrays (multiple data
sets), false otherwise.
* @since 5.0.2
*/
private function isMultipleSets(array $array): bool
{
foreach ($array as $element)
{
// As soon as we find a non-array element, return false
if (!is_array($element))
{
return false;
}
}
// If all elements are arrays, return true
return true;
}
}
src/Database/Delete.php000064400000006340151162054060010755
0ustar00<?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\Database;
use VDM\Joomla\Utilities\ArrayHelper;
use VDM\Joomla\Interfaces\DeleteInterface;
use VDM\Joomla\Abstraction\Database;
/**
* Database Delete Class
*
* @since 3.2.0
*/
final class Delete extends Database implements DeleteInterface
{
/**
* Delete all items in the database that match these conditions
*
* @param array $conditions Conditions by which to delete the data
in database [array of arrays (key => value)]
* @param string $table The table where the data is being
deleted
*
* @return bool
* @since 3.2.2
**/
public function items(array $conditions, string $table): bool
{
// set the update columns
if ($conditions === [])
{
return false;
}
// get a query object
$query = $this->db->getQuery(true);
// start the conditions bucket
$_conditions = [];
foreach ($conditions as $key => $value)
{
if (ArrayHelper::check($value))
{
if (isset($value['value']) &&
isset($value['operator']))
{
// check if value needs to be quoted
$quote = $value['quote'] ?? true;
if (!$quote)
{
if (ArrayHelper::check($value['value']))
{
// add the where by array
$_conditions[] = $this->db->quoteName($key)
. ' ' . $value['operator']
. ' ' . ' (' .
implode(',', $value['value'])
. ')';
}
else
{
// add the conditions
$_conditions[] = $this->db->quoteName($key)
. ' ' . $value['operator']
. ' ' . $value['value'];
}
}
else
{
if (ArrayHelper::check($value['value']))
{
// add the where by array
$_conditions[] = $this->db->quoteName($key)
. ' ' . $value['operator']
. ' ' . ' (' .
implode(',', array_map(fn($val) =>
$this->quote($val), $value['value']))
. ')';
}
else
{
// add the conditions
$_conditions[] = $this->db->quoteName($key)
. ' ' . $value['operator']
. ' ' . $this->quote($value['value']);
}
}
}
else
{
// we should through an exception
// for security we just return false for now
return false;
}
}
else
{
// add default condition
$_conditions[] = $this->db->quoteName($key) . ' = ' .
$this->quote($value);
}
}
// set the query targets
$query->delete($this->db->quoteName($this->getTable($table)));
$query->where($_conditions);
$this->db->setQuery($query);
return $this->db->execute();
}
/**
* Truncate a table
*
* @param string $table The table that should be truncated
*
* @return void
* @since 3.2.2
**/
public function truncate(string $table): void
{
$this->db->truncateTable($this->getTable($table));
}
}
src/Database/index.html000064400000000054151162054060011033
0ustar00<html><body
bgcolor="#FFFFFF"></body></html>src/Database/Insert.php000064400000015205151162054060011017
0ustar00<?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\Database;
use Joomla\CMS\Date\Date;
use VDM\Joomla\Utilities\ArrayHelper;
use VDM\Joomla\Interfaces\InsertInterface;
use VDM\Joomla\Abstraction\Database;
/**
* Database Insert Class
*
* @since 3.2.0
*/
final class Insert extends Database implements InsertInterface
{
/**
* Switch to set the defaults
*
* @var bool
* @since 1.2.0
**/
protected bool $defaults = true;
/**
* Switch to prevent/allow defaults from being added.
*
* @param bool $trigger toggle the defaults
*
* @return void
* @since 3.2.0
**/
public function defaults(bool $trigger = true)
{
$this->defaults = $trigger;
}
/**
* Insert rows to the database (with remapping and filtering columns
option)
*
* @param array $data Dataset to store in database [array of
arrays (key => value)]
* @param string $table The table where the data is being added
* @param array $columns Data columns for remapping and filtering
*
* @return bool
* @since 3.2.0
**/
public function rows(array $data, string $table, array $columns = []):
bool
{
if (!ArrayHelper::check($data))
{
return false;
}
if ($columns === [])
{
$columns = $this->getArrayColumns($data);
}
return ($columns === []) ? false : $this->insert($data, $table,
$columns, true);
}
/**
* Insert items to the database (with remapping and filtering columns
option)
*
* @param array $data Data to store in database (array of
objects)
* @param string $table The table where the data is being
added
* @param array $columns Data columns for remapping and
filtering
*
* @return bool
* @since 3.2.0
**/
public function items(array $data, string $table, array $columns = []):
bool
{
if (!ArrayHelper::check($data))
{
return false;
}
if ($columns === [])
{
$columns = $this->getObjectsColumns($data);
}
return ($columns === []) ? false : $this->insert($data, $table,
$columns, false);
}
/**
* Insert row to the database
*
* @param array $data Dataset to store in database (key =>
value)
* @param string $table The table where the data is being added
*
* @return bool
* @since 3.2.0
**/
public function row(array $data, string $table): bool
{
return $this->rows([$data], $table);
}
/**
* Insert item to the database
*
* @param object $data Dataset to store in database (key =>
value)
* @param string $table The table where the data is being added
*
* @return bool
* @since 3.2.0
**/
public function item(object $data, string $table): bool
{
return $this->items([$data], $table);
}
/**
* Get columns from data array
*
* @param array $data Data array
*
* @return array
* @since 3.2.0
**/
protected function getArrayColumns(array &$data): array
{
$row = array_values($data)[0];
if (!ArrayHelper::check($row))
{
return [];
}
$columns = array_keys($row);
return array_combine($columns, $columns);
}
/**
* Get columns from data objects
*
* @param array $data Data objects
*
* @return array
* @since 3.2.0
**/
protected function getObjectsColumns(array &$data): array
{
$row = array_values($data)[0];
if (!is_object($row))
{
return [];
}
$columns = get_object_vars($row);
return array_combine(array_keys($columns), array_keys($columns));
}
/**
* Insert data into the database
*
* @param array $data Data to store in database
* @param string $table The table where the data is being added
* @param array $columns Data columns for remapping and filtering
* @param bool $isArray Whether the data is an array of arrays or
an array of objects
*
* @return bool
* @since 3.2.0
**/
protected function insert(array &$data, string $table, array $columns,
bool $isArray): bool
{
// set joomla default columns
$add_created = false;
$add_version = false;
$add_published = false;
// check if we should load the defaults
if ($this->defaults)
{
// get the date
$date = (new Date())->toSql();
if (!isset($columns['created']))
{
$columns['created'] = ' (o_O) ';
$add_created = true;
}
if (!isset($columns['version']))
{
$columns['version'] = ' (o_O) ';
$add_version = true;
}
if (!isset($columns['published']))
{
$columns['published'] = ' (o_O) ';
$add_published = true;
}
// the (o_O) prevents an empty value from being loaded
}
// get a query object
$query = $this->db->getQuery(true);
// set the query targets
$query->insert($this->db->quoteName($this->getTable($table)))->columns($this->db->quoteName(array_keys($columns)));
// limiting factor on the amount of rows to insert before we reset the
query
$limit = 300;
// set the insert values
foreach ($data as $nr => $value)
{
// check the limit
if ($limit <= 1)
{
// execute and reset the query
$this->db->setQuery($query);
$this->db->execute();
// reset limit
$limit = 300;
// get a query object
$query = $this->db->getQuery(true);
// set the query targets
$query->insert($this->db->quoteName($this->getTable($table)))->columns($this->db->quoteName(array_keys($columns)));
}
$row = [];
foreach ($columns as $column => $key)
{
if (' (o_O) ' !== $key)
{
$row[] = ($isArray && isset($value[$key])) ?
$this->quote($value[$key])
: ((!$isArray && isset($value->{$key})) ?
$this->quote($value->{$key}) : '');
}
}
// set joomla default columns
if ($add_created)
{
$row[] = $this->db->quote($date);
}
if ($add_version)
{
$row[] = 1;
}
if ($add_published)
{
$row[] = 1;
}
// add to query
$query->values(implode(',', $row));
// decrement the limiter
$limit--;
// clear the data from memory
unset($data[$nr]);
}
// execute the final query
$this->db->setQuery($query);
$this->db->execute();
// always reset the default switch
$this->defaults();
return true;
}
}
src/Database/Load.php000064400000031552151162054060010435 0ustar00<?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\Database;
use VDM\Joomla\Utilities\ArrayHelper;
use VDM\Joomla\Interfaces\LoadInterface;
use VDM\Joomla\Abstraction\Database;
/**
* Database Load
*
* @since 3.2.0
*/
final class Load extends Database implements LoadInterface
{
/**
* Load data rows as an array of associated arrays
*
* @param array $select Array of selection keys
* @param array $tables Array of tables to search
* @param array|null $where Array of where key=>value match
exist
* @param array|null $order Array of how to order the data
* @param int|null $limit Limit the number of values returned
*
* @return array|null
* @since 3.2.0
**/
public function rows(array $select, array $tables, ?array $where = null,
?array $order = null, ?int $limit = null): ?array
{
// set key if found
$key = $this->getKey($select);
// check if we can get many rows
if ($this->many($select, $tables, $where, $order, $limit))
{
// return associated arrays from the table records
return $this->db->loadAssocList($key);
}
// data does not exist
return null;
}
/**
* Load data rows as an array of objects
*
* @param array $select Array of selection keys
* @param array $tables Array of tables to search
* @param array|null $where Array of where key=>value match
exist
* @param array|null $order Array of how to order the data
* @param int|null $limit Limit the number of values returned
*
* @return array|null
* @since 3.2.0
**/
public function items(array $select, array $tables, ?array $where = null,
?array $order = null, ?int $limit = null): ?array
{
// set key if found
$key = $this->getKey($select);
// check if we can get many rows
if ($this->many($select, $tables, $where, $order, $limit))
{
// return associated arrays from the table records
return $this->db->loadObjectList($key);
}
// data does not exist
return null;
}
/**
* Load data row as an associated array
*
* @param array $select Array of selection keys
* @param array $tables Array of tables to search
* @param array|null $where Array of where key=>value match exist
* @param array|null $order Array of how to order the data
*
* @return array|null
* @since 3.2.0
**/
public function row(array $select, array $tables, ?array $where = null,
?array $order = null): ?array
{
// check if we can get one row
if ($this->one($select, $tables, $where, $order))
{
return $this->db->loadAssoc();
}
// data does not exist
return null;
}
/**
* Load data row as an object
*
* @param array $select Array of selection keys
* @param array $tables Array of tables to search
* @param array|null $where Array of where key=>value match exist
* @param array|null $order Array of how to order the data
*
* @return object|null
* @since 3.2.0
**/
public function item(array $select, array $tables, ?array $where = null,
?array $order = null): ?object
{
// check if we can get one row
if ($this->one($select, $tables, $where, $order))
{
return $this->db->loadObject();
}
// data does not exist
return null;
}
/**
* Get the max value based on a filtered result from a given table
*
* @param string $field The field key
* @param string $tables The tables
* @param array $filter The filter keys
*
* @return int|null
* @since 3.2.0
**/
public function max($field, array $tables, array $filter): ?int
{
// only do check if we have the table set
if (isset($tables['a']))
{
// get the query
$query = $this->query(["all" =>
"MAX(`$field`)"], $tables, $filter);
// Load the max number
$this->db->setQuery($query);
$this->db->execute();
// check if we have values
if ($this->db->getNumRows())
{
return (int) $this->db->loadResult();
}
}
// data does not exist
return null;
}
/**
* Count the number of items based on filter result from a given table
*
* @param string $tables The table
* @param array $filter The filter keys
*
* @return int|null
* @since 3.2.0
**/
public function count(array $tables, array $filter): ?int
{
// only do check if we have the table set
if (isset($tables['a']))
{
// get the query
$query = $this->query(["all" => 'COUNT(*)'],
$tables, $filter);
// Load the max number
$this->db->setQuery($query);
$this->db->execute();
// check if we have values
if ($this->db->getNumRows())
{
return (int) $this->db->loadResult();
}
}
// data does not exist
return null;
}
/**
* Load one value from a row
*
* @param array $select Array of selection keys
* @param array $tables Array of tables to search
* @param array|null $where Array of where key=>value match exist
* @param array|null $order Array of how to order the data
*
* @return mixed
* @since 3.2.0
**/
public function value(array $select, array $tables, ?array $where = null,
?array $order = null)
{
// check if we can get one value
if ($this->one($select, $tables, $where, $order))
{
return $this->db->loadResult();
}
// data does not exist
return null;
}
/**
* Load values from multiple rows
*
* @param array $select Array of selection keys
* @param array $tables Array of tables to search
* @param array|null $where Array of where key=>value match
exist
* @param array|null $order Array of how to order the data
* @param int|null $limit Limit the number of values returned
*
* @return array|null
* @since 3.2.2
**/
public function values(array $select, array $tables, ?array $where =
null,
?array $order = null, ?int $limit = null): ?array
{
// check if we can get many rows
if ($this->many($select, $tables, $where, $order, $limit))
{
return $this->db->loadColumn();
}
// data does not exist
return null;
}
/**
* Load many
*
* @param array $select Array of selection keys
* @param array $tables Array of tables to search
* @param array|null $where Array of where key=>value match
exist
* @param array|null $order Array of how to order the data
* @param int|null $limit Limit the number of values returned
*
* @return bool
* @since 3.2.0
**/
protected function many(array $select, array $tables, ?array $where =
null,
?array $order = null, ?int $limit = null): bool
{
// only do check if we have the table set
if (isset($tables['a']))
{
// get the query
$query = $this->query($select, $tables, $where, $order, $limit);
// Load the items
$this->db->setQuery($query);
$this->db->execute();
// check if we have values
if ($this->db->getNumRows())
{
return true;
}
}
// data does not exist
return false;
}
/**
* Load one
*
* @param array $select Array of selection keys
* @param array $tables Array of tables to search
* @param array|null $where Array of where key=>value match exist
* @param array|null $order Array of how to order the data
*
* @return bool
* @since 3.2.0
**/
protected function one(array $select, array $tables, ?array $where = null,
?array $order = null): bool
{
// only do check if we have the table set
if (isset($tables['a']))
{
// get the query
$query = $this->query($select, $tables, $where, $order);
// Load the item
$this->db->setQuery($query, 0, 1);
$this->db->execute();
// check if we have values
if ($this->db->getNumRows())
{
return true;
}
}
// data does not exist
return false;
}
/**
* Get the query object
*
* @param array $select Array of selection keys
* @param array $tables Array of tables to search
* @param array|null $where Array of where key=>value match
exist
* @param array|null $order Array of how to order the data
* @param int|null $limit Limit the number of values returned
*
* @return object|null The query object (DatabaseQuery)
* @since 3.2.0
**/
protected function query(array $select, array $tables, ?array $where =
null,
?array $order = null, ?int $limit = null): ?object
{
$query = $this->db->getQuery(true);
// check if we have an all selection set
if (isset($select['all']))
{
// all selection example array: ['all' => ['a.*',
'b.*']]
if (ArrayHelper::check($select['all']))
{
foreach ($select['all'] as $select_all)
{
// set target selection
$query->select(
$select_all
);
}
}
// all selection example string: ['all' =>'a.*']
elseif (is_string($select['all']))
{
// set target selection
$query->select(
$select['all']
);
}
unset($select['all']);
}
// load the table where join
if (ArrayHelper::check($select))
{
// set target selection
$query->select(
$this->db->quoteName(
array_keys($select),
array_values($select)
)
);
}
// set main table
$query->from($this->db->quoteName($this->getTable($tables['a']),
'a'));
// remove main table
unset($tables['a']);
// load the table where join
if (ArrayHelper::check($tables))
{
foreach ($tables as $as => $table)
{
$query->join(
'LEFT', $this->db->quoteName(
$this->getTable($table['name']), $as
) . ' ON (' .
$this->db->quoteName($table['join_on'])
. ' = ' .
$this->db->quoteName($table['as_on']) . ')'
);
}
}
// load the table where getters
if (ArrayHelper::check($where))
{
foreach ($where as $key => $value)
{
if (ArrayHelper::check($value))
{
if (isset($value['value']) &&
isset($value['operator']))
{
// check if value needs to be quoted
$quote = $value['quote'] ?? true;
if (!$quote)
{
if (ArrayHelper::check($value['value']))
{
// add the where by array
$query->where($this->db->quoteName($key) . ' '
.
$value['operator'] . ' (' .
implode(',', $value['value'])
. ')'
);
}
else
{
// add the where
$query->where($this->db->quoteName($key) . ' '
.
$value['operator'] . ' ' .
$value['value']);
}
}
else
{
if (ArrayHelper::check($value['value']))
{
// add the where by array
$query->where($this->db->quoteName($key) . ' '
.
$value['operator'] . ' (' .
implode(',',
array_map(
fn($val) => $this->quote($val),
$value['value']
)
)
. ')'
);
}
else
{
// add the where
$query->where($this->db->quoteName($key) . ' '
.
$value['operator'] . ' ' .
$this->quote($value['value']));
}
}
}
else
{
// we should through an exception
// for security we just return nothing for now
return null;
}
}
else
{
// add the where
$query->where($this->db->quoteName($key) .
' = ' . $this->quote($value));
}
}
}
// load the row ordering
if (ArrayHelper::check($order))
{
foreach ($order as $key => $direction)
{
// add the ordering
$query->order($this->db->quoteName($key) .
' ' . $direction);
}
}
// only return a limited number
if (is_numeric($limit))
{
$query->setLimit($limit);
}
return $query;
}
/**
* Get the key from the selection array.
*
* This function retrieves a key from the provided selection array.
* The key is removed from the array after being retrieved.
*
* @param array $select Array of selection keys.
*
* @return string|null The key, or null if no key is found.
* @since 3.2.2
**/
protected function getKey(array &$select): ?string
{
$key = null;
// Check for 'key' first and ensure it's a string.
if (isset($select['key']) &&
is_string($select['key']))
{
$key = $select['key'];
unset($select['key']); // Remove 'key' from the
array.
}
return $key;
}
}
src/Database/Update.php000064400000011165151162054060010776
0ustar00<?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\Database;
use VDM\Joomla\Interfaces\UpdateInterface;
use VDM\Joomla\Abstraction\Database;
/**
* Database Update Class
*
* @since 3.2.0
*/
final class Update extends Database implements UpdateInterface
{
/**
* Update rows in the database (with remapping and filtering columns
option)
*
* @param array $data Dataset to update in database [array of
arrays (key => value)]
* @param string $key Dataset key column to use in updating the
values in the Database
* @param string $table The table where the data is being updated
* @param array $columns Data columns for remapping and filtering
*
* @return bool
* @since 3.2.0
**/
public function rows(array $data, string $key, string $table, array
$columns = []): bool
{
// set the update columns
if ($data === [] || strlen($key) == 0)
{
return false;
}
// set the update values
foreach ($data as $values)
{
if ($columns !== [])
{
// load only what is part of the columns set
$row = [];
foreach ($columns as $column => $key_)
{
if (isset($values[$key_]))
{
$row[$column] = $values[$key_];
}
}
// update the row
$this->row($row, $key, $table);
}
else
{
// update the row
$this->row((array) $values, $key, $table);
}
}
return true;
}
/**
* Update items in the database (with remapping and filtering columns
option)
*
* @param array $data Data to updated in database (array of
objects)
* @param string $key Dataset key column to use in updating the
values in the Database
* @param string $table The table where the data is being update
* @param array $columns Data columns for remapping and filtering
*
* @return bool
* @since 3.2.0
**/
public function items(array $data, string $key, string $table, array
$columns = []): bool
{
// set the update columns
if ($data === [] || strlen($key) == 0)
{
return false;
}
// set the update values
foreach ($data as $nr => $values)
{
if ($columns !== [])
{
// load only what is part of the columns set
$row = [];
foreach ($columns as $column => $key_)
{
if (isset($values->{$key_}))
{
$row[$column] = $values->{$key_};
}
}
// update the row
$this->row($row, $key, $table);
}
else
{
// update the row
$this->row((array) $values, $key, $table);
}
}
return true;
}
/**
* Update row in the database
*
* @param array $data Dataset to update in database (key =>
value)
* @param string $key Dataset key column to use in updating the
values in the Database
* @param string $table The table where the data is being updated
*
* @return bool
* @since 3.2.0
**/
public function row(array $data, string $key, string $table): bool
{
// set the update columns
if ($data === [] || strlen($key) == 0)
{
return false;
}
// get a query object
$query = $this->db->getQuery(true);
// set the query targets
$query->update($this->db->quoteName($this->getTable($table)));
// set the update values
$key_ = null;
foreach ($data as $column => $value)
{
if ($column === $key)
{
$key_ = $value;
}
else
{
$query->set($this->db->quoteName($column) . ' = ' .
$this->quote($value));
}
}
// add the key condition
if ($key_ !== null)
{
$query->where($this->db->quoteName($key) . ' = ' .
$this->quote($key_));
// execute the final query
$this->db->setQuery($query);
return $this->db->execute();
}
return false;
}
/**
* Update item in the database
*
* @param object $data Dataset to update in database (key =>
value)
* @param string $key Dataset key column to use in updating the
values in the Database
* @param string $table The table where the data is being updated
*
* @return bool
* @since 3.2.0
**/
public function item(object $data, string $key, string $table): bool
{
// convert to an array
return $this->row((array) get_object_vars($data), $key, $table);
}
}
src/Interfaces/Activeregistryinterface.php000064400000006274151162054060015025
0ustar00<?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\Interfaces;
/**
* The Active Registry Interface
*
* @since 3.2.0
*/
interface Activeregistryinterface
{
/**
* Check if the registry has any content.
*
* @return bool Returns true if the active array is not empty, false
otherwise.
* @since 3.2.0
*/
public function isActive(): bool;
/**
* Retrieves all value from the registry.
*
* @return array The values.
* @since 3.2.0
*/
public function allActive(): array;
/**
* Sets a value into the registry using multiple keys.
*
* @param mixed $value The value to set.
* @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 setActive($value, string ...$keys): void;
/**
* 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|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;
/**
* Retrieves a value (or sub-array) from the registry using multiple
keys.
*
* @param mixed $default The default value if not set.
* @param string ...$keys The keys to determine the location.
*
* @throws \InvalidArgumentException If any of the keys are not a number
or string.
* @return mixed The value or sub-array from the storage. Null if the
location doesn't exist.
* @since 3.2.0
*/
public function getActive($default, string ...$keys);
/**
* Removes a value (or sub-array) from the registry using multiple keys.
*
* @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 removeActive(string ...$keys): void;
/**
* Checks the existence of a particular location in the registry using
multiple keys.
*
* @param string ...$keys The keys to determine the location.
*
* @throws \InvalidArgumentException If any of the keys are not a number
or string.
* @return bool True if the location exists, false otherwise.
* @since 3.2.0
*/
public function existsActive(string ...$keys): bool;
}
src/Interfaces/Data/DeleteInterface.php000064400000002507151162054060014027
0ustar00<?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\Interfaces\Data;
/**
* Data Delete
*
* @since 3.2.2
*/
interface DeleteInterface
{
/**
* Set the current active table
*
* @param string|null $table The table that should be active
*
* @return self
* @since 3.2.2
*/
public function table(?string $table): self;
/**
* Delete all items in the database that match these conditions
*
* @param array $conditions Conditions by which to delete the data
in database [array of arrays (key => value)]
*
* @return bool
* @since 3.2.2
**/
public function items(array $conditions): bool;
/**
* Truncate a table
*
* @param string|null $table The table that should be truncated
*
* @return void
* @since 3.2.2
**/
public function truncate(): void;
/**
* Get the current active table
*
* @return string
* @since 3.2.2
*/
public function getTable(): string;
}
src/Interfaces/Data/GuidInterface.php000064400000001625151162054060013515
0ustar00<?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\Interfaces\Data;
/**
* Globally Unique Identifier Interface
*
* @since 5.0.2
*/
interface GuidInterface
{
/**
* Returns a GUIDv4 string.
*
* This function uses the best cryptographically secure method
* available on the platform with a fallback to an older, less secure
version.
*
* @param string $key The key to check and modify values.
*
* @return string A GUIDv4 string.
*
* @since 5.0.2
*/
public function getGuid(string $key): string;
}
src/Interfaces/Data/index.html000064400000000054151162054060012263
0ustar00<html><body
bgcolor="#FFFFFF"></body></html>src/Interfaces/Data/InsertInterface.php000064400000004516151162054060014073
0ustar00<?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\Interfaces\Data;
/**
* Data Insert
*
* @since 3.2.2
*/
interface InsertInterface
{
/**
* Set the current active table
*
* @param string|null $table The table that should be active
*
* @return self
* @since 3.2.2
*/
public function table(?string $table): self;
/**
* Insert a value to a given table
* Example: $this->value(Value, 'value_key',
'GUID');
*
* @param mixed $value The field value
* @param string $field The field key
* @param string $keyValue The key value
* @param string $key The key name
*
* @return bool
* @since 3.2.0
*/
public function value($value, string $field, string $keyValue, string $key
= 'guid'): bool;
/**
* Insert single row with multiple values to a given table
* Example: $this->item(Array);
*
* @param array $item The item to save
*
* @return bool
* @since 3.2.0
*/
public function row(array $item): bool;
/**
* Insert multiple rows to a given table
* Example: $this->items(Array);
*
* @param array|null $items The items updated in database (array of
arrays)
*
* @return bool
* @since 3.2.0
*/
public function rows(?array $items): bool;
/**
* Insert single item with multiple values to a given table
* Example: $this->item(Object);
*
* @param object $item The item to save
*
* @return bool
* @since 3.2.0
*/
public function item(object $item): bool;
/**
* Insert multiple items to a given table
* Example: $this->items(Array);
*
* @param array|null $items The items updated in database (array of
objects)
*
* @return bool
* @since 3.2.0
*/
public function items(?array $items): bool;
/**
* Get the current active table
*
* @return string
* @since 3.2.2
*/
public function getTable(): string;
}
src/Interfaces/Data/ItemInterface.php000064400000003731151162054060013523
0ustar00<?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\Interfaces\Data;
/**
* Data Item Interface
*
* @since 3.2.2
*/
interface ItemInterface
{
/**
* Set the current active table
*
* @param string $table The table that should be active
*
* @return self
* @since 3.2.2
*/
public function table(string $table): self;
/**
* Get an item
*
* @param string $value The item key value
* @param string $key The item key
*
* @return object|null The item object or null
* @since 3.2.2
*/
public function get(string $value, string $key = 'guid'):
?object;
/**
* Get the value
*
* @param string $value The item key value
* @param string $key The item key
* @param string $get The key of the values we want back
*
* @return mixed
* @since 3.2.2
*/
public function value(string $value, string $key = 'guid',
string $get = 'id');
/**
* Set an item
*
* @param object $item The item
* @param string $key The item key
* @param string|null $action The action to load power
*
* @return bool
* @since 3.2.2
*/
public function set(object $item, string $key = 'guid', ?string
$action = null): bool;
/**
* Delete an item
*
* @param string $value The item key value
* @param string $key The item key
*
* @return bool
* @since 3.2.2
*/
public function delete(string $value, string $key = 'guid'):
bool;
/**
* Get the current active table
*
* @return string
* @since 3.2.2
*/
public function getTable(): string;
}
src/Interfaces/Data/ItemsInterface.php000064400000004007151162054060013703
0ustar00<?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\Interfaces\Data;
/**
* Data Items Interface
*
* @since 3.2.2
*/
interface ItemsInterface
{
/**
* Set the current active table
*
* @param string $table The table that should be active
*
* @return self
* @since 3.2.2
*/
public function table(string $table): self;
/**
* Get list of items
*
* @param array $values The ids of the items
* @param string $key The key of the values
*
* @return array|null The item object or null
* @since 3.2.2
*/
public function get(array $values, string $key = 'guid'):
?array;
/**
* Get the values
*
* @param array $values The list of values (to search by).
* @param string $key The key on which the values being searched.
* @param string $get The key of the values we want back
*
* @return array|null The array of found values.
* @since 3.2.2
*/
public function values(array $values, string $key = 'guid',
string $get = 'id'): ?array;
/**
* Set items
*
* @param array $items The list of items
* @param string $key The key on which the items should be set
*
* @return bool
* @since 3.2.2
*/
public function set(array $items, string $key = 'guid'): bool;
/**
* Delete items
*
* @param array $values The item key value
* @param string $key The item key
*
* @return bool
* @since 3.2.2
*/
public function delete(array $values, string $key = 'guid'):
bool;
/**
* Get the current active table
*
* @return string
* @since 3.2.2
*/
public function getTable(): string;
}
src/Interfaces/Data/LoadInterface.php000064400000005445151162054060013510
0ustar00<?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\Interfaces\Data;
/**
* Data Load Interface
*
* @since 3.2.2
*/
interface LoadInterface
{
/**
* Set the current active table
*
* @param string|null $table The table that should be active
*
* @return self
* @since 3.2.2
*/
public function table(?string $table): self;
/**
* Get a value from a given table
* Example: $this->value(
* [
* 'guid' =>
'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'
* ], 'value_key'
* );
*
* @param array $keys The item keys
* @param string $field The field key
*
* @return mixed
* @since 2.0.1
*/
public function value(array $keys, string $field);
/**
* Get a value from multiple rows from a given table
* Example: $this->values(
* [
* 'guid' =>
'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'
* ], 'value_key'
* );
*
* @param array $keys The item keys
* @param string $field The field key
*
* @return array|null
* @since 3.2.2
*/
public function values(array $keys, string $field): ?array;
/**
* Get values from a given table
* Example: $this->item(
* [
* 'guid' =>
'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'
* ]
* );
*
* @param array $keys The item keys
*
* @return object|null
* @since 2.0.1
*/
public function item(array $keys): ?object;
/**
* Get values from a given table
* Example: $this->items(
* [
* 'guid' => [
* 'operator' =>
'IN',
* 'value' =>
[''xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'',
''xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'']
* ]
* ]
* );
* Example: $this->items($keys);
*
* @param array $keys The item keys
*
* @return array|null
* @since 2.0.1
*/
public function items(array $keys): ?array;
/**
* Get the current active table
*
* @return string
* @since 3.2.2
*/
public function getTable(): string;
}
src/Interfaces/Data/MultiSubformInterface.php000064400000004101151162054060015245
0ustar00<?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\Interfaces\Data;
/**
* Data Multi Subform Interface
*
* @since 3.2.2
*/
interface MultiSubformInterface
{
/**
* Get a subform items
*
* @param array $getMap The the map to get the subfrom data
*
* Example:
* $getMap = [
* '_core' => [
* 'table' =>'data',
* 'linkValue' => $item->guid ?? '',
* 'linkKey' => 'look',
* 'field' => 'data',
* 'get' =>
['guid','email','image','mobile_phone','website','dateofbirth']
* ],
* 'countries' => [
* 'table' =>'data_country',
* 'linkValue' => 'data:guid', //
coretable:fieldname
* 'linkKey' => 'data',
* 'get' =>
['guid','country','currency']
* ]
* ];
*
* @return array|null The subform
* @since 3.2.2
*/
public function get(array $getMap): ?array;
/**
* Set a subform items
*
* @param mixed $items The list of items from the subform to set
* @param array $setMap The the map to set the subfrom data
*
* Example:
* $items,
* $setMap = [
* '_core' => [
* 'table' =>'data',
* 'indexKey' => 'guid',
* 'linkKey' => 'look',
* 'linkValue' => $data['guid'] ??
''
* ],
* 'countries' => [
* 'table' =>'data_country',
* 'indexKey' => 'guid',
* 'linkKey' => 'data',
* 'linkValue' => 'data:guid' //
coretable:fieldname
* ]
* ];
*
* @return bool
* @since 3.2.2
*/
public function set(mixed $items, array $setMap): bool;
}
src/Interfaces/Data/SubformInterface.php000064400000004005151162054060014235
0ustar00<?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\Interfaces\Data;
/**
* Data Subform Interface
*
* @since 3.2.2
*/
interface SubformInterface
{
/**
* Set the current active table
*
* @param string $table The table that should be active
*
* @return self
* @since 3.2.2
*/
public function table(string $table): self;
/**
* Get a subform items
*
* @param string $linkValue The value of the link key in child table.
* @param string $linkKey The link key on which the items where
linked in the child table.
* @param string $field The parent field name of the subform in the
parent view.
* @param array $get The array SET of the keys of each row in
the subform.
* @param bool $multi The switch to return a multiple set.
*
* @return array|null The subform
* @since 3.2.2
*/
public function get(string $linkValue, string $linkKey, string $field,
array $get, bool $multi = true): ?array;
/**
* Set a subform items
*
* @param mixed $items The list of items from the subform to set
* @param string $indexKey The index key on which the items should be
observed as it relates to insert/update/delete.
* @param string $linkKey The link key on which the items where
linked in the child table.
* @param string $linkValue The value of the link key in child table.
*
* @return bool
* @since 3.2.2
*/
public function set(mixed $items, string $indexKey, string $linkKey,
string $linkValue): bool;
/**
* Get the current active table
*
* @return string
* @since 3.2.2
*/
public function getTable(): string;
}
src/Interfaces/Data/UpdateInterface.php000064400000005137151162054060014051
0ustar00<?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\Interfaces\Data;
/**
* Data Update
*
* @since 3.2.2
*/
interface UpdateInterface
{
/**
* Set the current active table
*
* @param string|null $table The table that should be active
*
* @return self
* @since 3.2.2
*/
public function table(?string $table): self;
/**
* Update a value to a given table
* Example: $this->value(Value, 'value_key',
'GUID');
*
* @param mixed $value The field value
* @param string $field The field key
* @param string $keyValue The key value
* @param string $key The key name
*
* @return bool
* @since 3.2.0
*/
public function value($value, string $field, string $keyValue, string $key
= 'guid'): bool;
/**
* Update single row with multiple values to a given table
* Example: $this->item(Array);
*
* @param array $item The item to save
* @param string $key The key name
*
* @return bool
* @since 3.2.0
*/
public function row(array $item, string $key = 'guid'): bool;
/**
* Update multiple rows to a given table
* Example: $this->items(Array);
*
* @param array|null $items The items updated in database (array of
arrays)
* @param string $key The key name
*
* @return bool
* @since 3.2.0
*/
public function rows(?array $items, string $key = 'guid'):
bool;
/**
* Update single item with multiple values to a given table
* Example: $this->item(Object);
*
* @param object $item The item to save
* @param string $key The key name
*
* @return bool
* @since 3.2.0
*/
public function item(object $item, string $key = 'guid'): bool;
/**
* Update multiple items to a given table
* Example: $this->items(Array);
*
* @param array|null $items The items updated in database (array of
objects)
* @param string $key The key name
*
* @return bool
* @since 3.2.0
*/
public function items(?array $items, string $key = 'guid'):
bool;
/**
* Get the current active table
*
* @return string
* @since 3.2.2
*/
public function getTable(): string;
}
src/Interfaces/DeleteInterface.php000064400000002150151162054060013150
0ustar00<?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\Interfaces;
/**
* Database Delete Interface
*
* @since 3.2.0
*/
interface DeleteInterface
{
/**
* Delete all rows in the database that match these conditions
*
* @param array $conditions Conditions by which to delete the data
in database [array of arrays (key => value)]
* @param string $table The table where the data is being
deleted
*
* @return bool
* @since 3.2.0
**/
public function items(array $conditions, string $table): bool;
/**
* Truncate a table
*
* @param string $table The table that should be truncated
*
* @return void
* @since 3.2.2
**/
public function truncate(string $table): void;
}
src/Interfaces/FactoryInterface.php000064400000001603151162054060013357
0ustar00<?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\Interfaces;
use Joomla\DI\Container;
/**
* The Container Factory Interface
*
* @since 0.0.0
*/
interface FactoryInterface
{
/**
* Get any class from the container
*
* @param string $key The container class key
*
* @return Mixed
* @since 0.0.0
*/
public static function _(string $key);
/**
* Get the global container
*
* @return Container
* @since 0.0.0
*/
public static function getContainer(): Container;
}
src/Interfaces/Git/ApiInterface.php000064400000002142151162054060013203
0ustar00<?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\Interfaces\Git;
/**
* The Git Api Interface
*
* @since 3.2.0
*/
interface ApiInterface
{
/**
* Load/Reload API.
*
* @param string|null $url The url.
* @param token|null $token The token.
* @param bool $backup The backup swapping switch.
*
* @return void
* @since 3.2.0
**/
public function load_(?string $url = null, ?string $token = null, bool
$backup = true): void;
/**
* Reset to previous toke, url it set
*
* @return void
* @since 3.2.0
**/
public function reset_(): void;
/**
* Get the API url
*
* @return string
* @since 3.2.0
**/
public function api();
}
src/Interfaces/Git/index.html000064400000000054151162054060012135
0ustar00<html><body
bgcolor="#FFFFFF"></body></html>src/Interfaces/Git/Repository/ContentsInterface.php000064400000017331151162054060016454
0ustar00<?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\Interfaces\Git\Repository;
use VDM\Joomla\Interfaces\Git\ApiInterface;
/**
* The Git Repository Contents Interface
*
* @since 3.2.2
*/
interface ContentsInterface extends ApiInterface
{
/**
* Get a file from a repository.
*
* @param string $owner The owner name.
* @param string $repo The repository name.
* @param string $filepath The file path.
* @param string|null $ref Optional. The name of the
commit/branch/tag.
* Default the repository's default
branch (usually master).
*
* @return mixed
* @since 3.2.0
**/
public function get(string $owner, string $repo, string $filepath, ?string
$ref = null);
/**
* Get the metadata and contents (if a file) of an entry in a repository,
* or a list of entries if a directory.
*
* @param string $owner The owner name.
* @param string $repo The repository name.
* @param string $filepath The file or directory path.
* @param string|null $ref Optional. The name of the
commit/branch/tag.
* Default the repository's default
branch (usually master).
*
* @return null|array|object
* @since 3.2.0
**/
public function metadata(string $owner, string $repo, string $filepath,
?string $ref = null): null|array|object;
/**
* Create a file in a repository.
*
* @param string $owner The owner name.
* @param string $repo The repository name.
* @param string $filepath The file path.
* @param string $content The file content.
* @param string $message The commit message.
* @param string $branch The branch name. Defaults to the
repository's default branch.
* @param string|null $authorName The author's name.
* @param string|null $authorEmail The author's email.
* @param string|null $committerName The committer's name.
* @param string|null $committerEmail The committer's email.
* @param string|null $newBranch Whether to create a new branch.
Defaults to null.
* @param string|null $authorDate The author's date.
* @param string|null $committerDate The committer's date.
* @param bool|null $signoff Add a Signed-off-by trailer.
Defaults to null.
*
* @return object|null
* @since 3.2.0
**/
public function create(
string $owner,
string $repo,
string $filepath,
string $content,
string $message,
string $branch = 'master',
?string $authorName = null,
?string $authorEmail = null,
?string $committerName = null,
?string $committerEmail = null,
?string $newBranch = null,
?string $authorDate = null,
?string $committerDate = null,
?bool $signoff = null
): ?object;
/**
* Get the metadata of all the entries of the root directory.
*
* @param string $owner The owner name.
* @param string $repo The repository name.
* @param string|null $ref The name of the commit/branch/tag. Default
the repository's default branch (usually master).
*
* @return array|null
* @since 3.2.0
**/
public function root(string $owner, string $repo, ?string $ref = null):
?array;
/**
* Update a file in a repository.
*
* @param string $owner The owner name.
* @param string $repo The repository name.
* @param string $filepath The file path.
* @param string $content The file content.
* @param string $message The commit message.
* @param string $sha The blob SHA of the file.
* @param string $branch The branch name. Defaults to the
repository's default branch.
* @param string|null $authorName The author name. Defaults to the
authenticated user.
* @param string|null $authorEmail The author email. Defaults to the
authenticated user.
* @param string|null $committerName The committer name. Defaults to
the authenticated user.
* @param string|null $committerEmail The committer email. Defaults to
the authenticated user.
* @param string|null $authorDate The author date.
* @param string|null $committerDate The committer date.
* @param string|null $fromPath The original file path to
move/rename.
* @param string|null $newBranch The new branch to create from the
specified branch.
* @param bool|null $signoff Add a Signed-off-by trailer.
*
* @return object|null
* @since 3.2.0
**/
public function update(
string $owner,
string $repo,
string $filepath,
string $content,
string $message,
string $sha,
string $branch = 'master',
?string $authorName = null,
?string $authorEmail = null,
?string $committerName = null,
?string $committerEmail = null,
?string $authorDate = null,
?string $committerDate = null,
?string $fromPath = null,
?string $newBranch = null,
?bool $signoff = null
): ?object;
/**
* Delete a file in a repository.
*
* @param string $owner The owner name.
* @param string $repo The repository name.
* @param string $filepath The file path.
* @param string $message The commit message.
* @param string $sha The blob SHA of the file.
* @param string|null $branch The branch name (optional).
* @param string|null $authorName The author name (optional).
* @param string|null $authorEmail The author email (optional).
* @param string|null $committerName The committer name (optional).
* @param string|null $committerEmail The committer email (optional).
* @param string|null $authorDate The author date (optional).
* @param string|null $committerDate The committer date (optional).
* @param string|null $newBranch The new branch name (optional).
* @param bool|null $signoff Add a Signed-off-by trailer
(optional).
*
* @return object|null
* @since 3.2.0
**/
public function delete(
string $owner,
string $repo,
string $filepath,
string $message,
string $sha,
?string $branch = null,
?string $authorName = null,
?string $authorEmail = null,
?string $committerName = null,
?string $committerEmail = null,
?string $authorDate = null,
?string $committerDate = null,
?string $newBranch = null,
?bool $signoff = null
): ?object;
/**
* Get the EditorConfig definitions of a file in a repository.
*
* @param string $owner The owner name.
* @param string $repo The repository name.
* @param string $filepath The file path.
* @param string|null $ref The name of the commit/branch/tag.
*
* @return string|null
* @since 3.2.0
**/
public function editor(string $owner, string $repo, string $filepath,
string $ref = null): ?string;
/**
* Get the blob of a repository.
*
* @param string $owner The owner name.
* @param string $repo The repository name.
* @param string $sha The SHA hash of the blob.
*
* @return object|null
* @since 3.2.0
**/
public function blob(string $owner, string $repo, string $sha): ?object;
}
src/Interfaces/Git/Repository/index.html000064400000000054151162054060014314
0ustar00<html><body
bgcolor="#FFFFFF"></body></html>src/Interfaces/GrepInterface.php000064400000003712151162054060012650
0ustar00<?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\Interfaces;
/**
* Global Resource Empowerment Platform
*
* @since 3.2.1
*/
interface GrepInterface
{
/**
* Get an item
*
* @param string $guid The global unique id of the item
* @param array|null $order The search order
* @param object|null $repo The repository object to search. If null,
all repos will be searched.
*
* @return object|null
* @since 3.2.2
*/
public function get(string $guid, ?array $order = null, ?object $repo =
null): ?object;
/**
* Get all remote GUID's
*
* @return array|null
* @since 3.2.0
*/
public function getRemoteGuid(): ?array;
/**
* Set the branch field
*
* @param string $field The field to use to get the branch name from
the data set
*
* @return void
* @since 3.2.2
*/
public function setBranchField(string $field): void;
/**
* Set the DEFAULT branch name (only used if branch field is not found)
*
* @param string|null $name The default branch to use if no name
could be found
*
* @return void
* @since 3.2.2
*/
public function setBranchDefaultName(?string $name): void;
/**
* Set the index path
*
* @param string $indexPath The repository index path
*
* @return void
* @since 3.2.2
*/
public function setIndexPath(string $indexPath): void;
/**
* Get the index of a repo
*
* @param string $guid The unique identifier for the repo.
*
* @return object|null
* @since 3.2.2
*/
public function getRemoteIndex(string $guid): ?object;
}
src/Interfaces/index.html000064400000000054151162054060011412
0ustar00<html><body
bgcolor="#FFFFFF"></body></html>src/Interfaces/InsertInterface.php000064400000004370151162054060013220
0ustar00<?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\Interfaces;
/**
* Database Insert Interface
*
* @since 3.2.0
*/
interface InsertInterface
{
/**
* Switch to prevent/allow defaults from being added.
*
* @param bool $trigger toggle the defaults
*
* @return void
* @since 3.2.0
**/
public function defaults(bool $trigger = true);
/**
* Insert rows to the database (with remapping and filtering columns
option)
*
* @param array $data Dataset to store in database [array of
arrays (key => value)]
* @param string $table The table where the data is being added
* @param array $columns Data columns for remapping and filtering
*
* @return bool
* @since 3.2.0
**/
public function rows(array $data, string $table, array $columns = []):
bool;
/**
* Insert items to the database (with remapping and filtering columns
option)
*
* @param array $data Data to store in database (array of
objects)
* @param string $table The table where the data is being
added
* @param array $columns Data columns for remapping and
filtering
*
* @return bool
* @since 3.2.0
**/
public function items(array $data, string $table, array $columns = []):
bool;
/**
* Insert row to the database
*
* @param array $data Dataset to store in database (key =>
value)
* @param string $table The table where the data is being added
*
* @return bool
* @since 3.2.0
**/
public function row(array $data, string $table): bool;
/**
* Insert item to the database
*
* @param object $data Dataset to store in database (key =>
value)
* @param string $table The table where the data is being added
*
* @return bool
* @since 3.2.0
**/
public function item(object $data, string $table): bool;
}
src/Interfaces/LoadInterface.php000064400000010361151162054060012630
0ustar00<?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\Interfaces;
/**
* Database Load Interface
*
* @since 3.2.0
*/
interface LoadInterface
{
/**
* Load data rows as an array of associated arrays
*
* @param array $select Array of selection keys
* @param array $tables Array of tables to search
* @param array|null $where Array of where key=>value match
exist
* @param array|null $order Array of how to order the data
* @param int|null $limit Limit the number of values returned
*
* @return array|null
* @since 3.2.0
**/
public function rows(array $select, array $tables, ?array $where = null,
?array $order = null, ?int $limit = null): ?array;
/**
* Load data rows as an array of objects
*
* @param array $select Array of selection keys
* @param array $tables Array of tables to search
* @param array|null $where Array of where key=>value match
exist
* @param array|null $order Array of how to order the data
* @param int|null $limit Limit the number of values returned
*
* @return array|null
* @since 3.2.0
**/
public function items(array $select, array $tables, ?array $where = null,
?array $order = null, ?int $limit = null): ?array;
/**
* Load data row as an associated array
*
* @param array $select Array of selection keys
* @param array $tables Array of tables to search
* @param array|null $where Array of where key=>value match exist
* @param array|null $order Array of how to order the data
*
* @return array|null
* @since 3.2.0
**/
public function row(array $select, array $tables, ?array $where = null,
?array $order = null): ?array;
/**
* Load data row as an object
*
* @param array $select Array of selection keys
* @param array $tables Array of tables to search
* @param array|null $where Array of where key=>value match exist
* @param array|null $order Array of how to order the data
*
* @return object|null
* @since 3.2.0
**/
public function item(array $select, array $tables, ?array $where = null,
?array $order = null): ?object;
/**
* Get the max value based on a filtered result from a given table
*
* @param string $field The field key
* @param string $tables The table
* @param array $filter The filter keys
*
* @return int|null
* @since 3.2.0
**/
public function max($field, array $tables, array $filter): ?int;
/**
* Count the number of items based on filter result from a given table
*
* @param string $tables The table
* @param array $filter The filter keys
*
* @return int|null
* @since 3.2.0
**/
public function count(array $tables, array $filter): ?int;
/**
* Load one value from a row
*
* @param array $select Array of selection keys
* @param array $tables Array of tables to search
* @param array|null $where Array of where key=>value match exist
* @param array|null $order Array of how to order the data
*
* @return mixed
* @since 3.2.0
**/
public function value(array $select, array $tables, ?array $where = null,
?array $order = null);
/**
* Load values from multiple rows
*
* @param array $select Array of selection keys
* @param array $tables Array of tables to search
* @param array|null $where Array of where key=>value match
exist
* @param array|null $order Array of how to order the data
* @param int|null $limit Limit the number of values returned
*
* @return array|null
* @since 3.2.2
**/
public function values(array $select, array $tables, ?array $where =
null,
?array $order = null, ?int $limit = null): ?array;
}
src/Interfaces/ModelInterface.php000064400000006747151162054060013026
0ustar00<?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\Interfaces;
/**
* Model Interface
*
* @since 3.2.0
*/
interface ModelInterface
{
/**
* Set the current active table
*
* @param string $table The table that should be active
*
* @return self
* @since 3.2.2
*/
public function table(string $table): self;
/**
* Model the value
* Example: $this->value(value, 'value_key',
'table_name');
*
* @param mixed $value The value to model
* @param string $field The field key
* @param string|null $table The table
*
* @return mixed
* @since 3.2.0
*/
public function value($value, string $field, ?string $table = null);
/**
* Model a value of multiple items
* Example: $this->items(Array, 'value_key',
'table_name');
*
* @param array|null $items The array of values
* @param string $field The field key
* @param string|null $table The table
*
* @return array|null
* @since 3.2.0
*/
public function values(?array $items, string $field, ?string $table =
null): ?array;
/**
* Model the values of an item
* Example: $this->item(Object, 'table_name');
*
* @param object|null $item The item object
* @param string|null $table The table
*
* @return object|null
* @since 3.2.0
*/
public function item(?object $item, ?string $table = null): ?object;
/**
* Model the values of multiple items
* Example: $this->items(Array, 'table_name');
*
* @param array|null $items The array of item objects
* @param string|null $table The table
*
* @return array|null
* @since 3.2.0
*/
public function items(?array $items = null, ?string $table = null):
?array;
/**
* Model the values of an row
* Example: $this->item(Array, 'table_name');
*
* @param array|null $item The item array
* @param string|null $table The table
*
* @return array|null
* @since 3.2.0
*/
public function row(?array $item, ?string $table = null): ?array;
/**
* Model the values of multiple rows
* Example: $this->items(Array, 'table_name');
*
* @param array|null $items The array of item array
* @param string|null $table The table
*
* @return array|null
* @since 3.2.0
*/
public function rows(?array $items = null, ?string $table = null):
?array;
/**
* Get last modeled ID
* Example: $this->last('table_name');
*
* @param string|null $table The table
*
* @return int|null
* @since 3.2.0
*/
public function last(?string $table = null): ?int;
/**
* Set the current active table
*
* @param string $tableName The table name
*
* @return void
* @since 3.2.2
*/
public function setTable(string $tableName): void;
/**
* Set the switch to control the behaviour of empty values
*
* @param bool $allowEmpty The switch
*
* @return void
* @since 3.2.2
*/
public function setAllowEmpty(bool $allowEmpty): void;
}
src/Interfaces/PHPConfigurationCheckerInterface.php000064400000001266151162054060016421
0ustar00<?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\Interfaces;
/**
* PHP Configuration Checker
*
* @since 5.0.2
*/
interface PHPConfigurationCheckerInterface
{
/**
* Check that the required configurations are set for PHP
*
* @return void
* @since 5.0.2
**/
public function run(): void;
}
src/Interfaces/Readme/index.html000064400000000054151162054060012607
0ustar00<html><body
bgcolor="#FFFFFF"></body></html>src/Interfaces/Readme/ItemInterface.php000064400000001301151162054060014036
0ustar00<?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\Interfaces\Readme;
/**
* Item Readme Interface
*
* @since 3.2.2
*/
interface ItemInterface
{
/**
* Get an item readme
*
* @param object $item An item details.
*
* @return string
* @since 3.2.2
*/
public function get(object $item): string;
}
src/Interfaces/Readme/MainInterface.php000064400000001315151162054060014031
0ustar00<?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\Interfaces\Readme;
/**
* Main Readme Interface
*
* @since 3.2.2
*/
interface MainInterface
{
/**
* Get Main Readme
*
* @param array $items All items of this repository.
*
* @return string
* @since 3.2.0
*/
public function get(array $items): string;
}
src/Interfaces/Registryinterface.php000064400000006241151162054060013623
0ustar00<?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\Interfaces;
use VDM\Joomla\Interfaces\Activeregistryinterface;
/**
* The Registry Interface
*
* @since 3.2.0
*/
interface Registryinterface extends Activeregistryinterface
{
/**
* Sets a value into the registry using multiple keys.
*
* @param string $path Registry path (e.g. vdm.content.builder)
* @param mixed $value Value of entry
*
* @throws \InvalidArgumentException If any of the path values are not a
number or string.
* @return self
* @since 3.2.0
*/
public function set(string $path, $value): self;
/**
* 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|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 self
* @since 3.2.0
*/
public function add(string $path, $value, ?bool $asArray = null): self;
/**
* Retrieves a value (or sub-array) from the registry using multiple
keys.
*
* @param string $path Registry path (e.g. vdm.content.builder)
* @param mixed $default Optional default value, returned if the
internal doesn't exist.
*
* @throws \InvalidArgumentException If any of the path values are not a
number or string.
* @return mixed The value or sub-array from the storage. Null if the
location doesn't exist.
* @since 3.2.0
*/
public function get(string $path, $default = null);
/**
* Removes a value (or sub-array) from the registry using multiple keys.
*
* @param string $path Registry path (e.g. vdm.content.builder)
*
* @throws \InvalidArgumentException If any of the path values are not a
number or string.
* @return self
* @since 3.2.0
*/
public function remove(string $path): self;
/**
* Checks the existence of a particular location in the registry using
multiple keys.
*
* @param string $path Registry path (e.g. vdm.content.builder)
*
* @throws \InvalidArgumentException If any of the path values are not a
number or string.
* @return bool True if the location exists, false otherwise.
* @since 3.2.0
*/
public function exists(string $path): bool;
/**
* Sets a separator value
*
* @param string|null $value The value to set.
*
* @return self
* @since 3.2.0
*/
public function setSeparator(?string $value): self;
}
src/Interfaces/Remote/GetInterface.php000064400000002707151162054060013730
0ustar00<?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\Interfaces\Remote;
/**
* Load data based on global unique ids from remote system
*
* @since 3.2.2
*/
interface GetInterface
{
/**
* Set the current active table
*
* @param string $table The table that should be active
*
* @return self
* @since 3.2.2
*/
public function table(string $table): self;
/**
* Init all items not found in database
*
* @return bool
* @since 3.2.0
*/
public function init(): bool;
/**
* Reset the items
*
* @param array $items The global unique ids of the items
*
* @return bool
* @since 3.2.0
*/
public function reset(array $items): bool;
/**
* Load an item
*
* @param string $guid The global unique id of the item
* @param array $order The search order
*
* @return bool
* @since 3.2.2
*/
public function item(string $guid, array $order = ['remote',
'local']): bool;
/**
* Get the current active table
*
* @return string
* @since 3.2.2
*/
public function getTable(): string;
}
src/Interfaces/Remote/index.html000064400000000054151162054060012645
0ustar00<html><body
bgcolor="#FFFFFF"></body></html>src/Interfaces/Remote/SetInterface.php000064400000003137151162054060013742
0ustar00<?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\Interfaces\Remote;
/**
* Set data based on global unique ids to remote system
*
* @since 3.2.2
*/
interface SetInterface
{
/**
* Set the current active table
*
* @param string $table The table that should be active
*
* @return self
* @since 3.2.2
*/
public function table(string $table): self;
/**
* Set the current active area
*
* @param string $area The area that should be active
*
* @return self
* @since 3.2.2
*/
public function area(string $area): self;
/**
* Set the settings path
*
* @param string $settingsPath The repository settings path
*
* @return self
* @since 3.2.2
*/
public function setSettingsPath(string $settingsPath): self;
/**
* Set the index settings path
*
* @param string $settingsIndexPath The repository index settings
path
*
* @return self
* @since 3.2.2
*/
public function setIndexSettingsPath(string $settingsIndexPath): self;
/**
* Save items remotely
*
* @param array $guids The global unique id of the item
*
* @return bool
* @throws \Exception
* @since 3.2.2
*/
public function items(array $guids): bool;
}
src/Interfaces/SchemaCheckerInterface.php000064400000001244151162054060014436
0ustar00<?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\Interfaces;
/**
* Schema Checker Interface
*
* @since 3.2.2
*/
interface SchemaCheckerInterface
{
/**
* Make sure that the database schema is up-to-date.
*
* @return void
* @since 3.2.2
*/
public function run(): void;
}
src/Interfaces/SchemaInterface.php000064400000002574151162054060013160
0ustar00<?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\Interfaces;
/**
* Schema Checking Interface
*
* @since 3.2.1
*/
interface SchemaInterface
{
/**
* Check and update database schema for missing fields or tables.
*
* @return array The array of successful updates/actions, if empty no
update/action was taken.
* @since 3.2.1
* @throws \Exception If there is an error during the update process.
*/
public function update(): array;
/**
* Create a table with all necessary fields.
*
* @param string $table The name of the table to create.
*
* @return void
* @since 3.2.1
* @throws \Exception If there is an error creating the table.
*/
public function createTable(string $table): void;
/**
* Update the schema of an existing table.
*
* @param string $table The table to update.
*
* @return void
* @since 3.2.1
* @throws \Exception If there is an error while updating the schema.
*/
public function updateSchema(string $table): void;
}
src/Interfaces/Tableinterface.php000064400000004631151162054060013043
0ustar00<?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\Interfaces;
/**
* The VDM Core Table Interface
*/
interface Tableinterface
{
/**
* Get any value from a item/field/column of an area/view/table
* Example: $this->get('table_name',
'field_name', 'value_key');
* Get an item/field/column of an area/view/table
* Example: $this->get('table_name',
'field_name');
* Get all items/fields/columns of an area/view/table
* Example: $this->get('table_name');
* Get all areas/views/tables with all their item/field/column details
* Example: $this->get('All');
* Example: $this->get();
*
* @param string|null $table The table
* @param string|null $field The field
* @param string|null $key The value key
*
* @return mixed
* @since 3.2.0
*/
public function get(?string $table = null, ?string $field = null, ?string
$key = null);
/**
* Get title field from an area/view/table
*
* @param string $table The area
*
* @return ?array
* @since 3.2.0
*/
public function title(string $table): ?array;
/**
* Get title field name
*
* @param string $table The area
*
* @return string
* @since 3.2.0
*/
public function titleName(string $table): string;
/**
* Get all tables
*
* @return array
* @since 3.2.0
*/
public function tables(): array;
/**
* Check if a table (and field) exist
*
* @param string $table The area
* @param string|null $field The area
*
* @return bool
* @since 3.2.0
*/
public function exist(string $table, ?string $field = null): bool;
/**
* Get all fields of an area/view/table
*
* @param string $table The area
* @param bool $default Add the default fields
* @param bool $details Add/Leave fields the details
*
* @return array|null On success an array of fields
* @since 3.2.0
*/
public function fields(string $table, bool $default = false, bool $details
= false): ?array;
}
src/Interfaces/UpdateInterface.php000064400000004731151162054060013177
0ustar00<?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\Interfaces;
/**
* Database Update Interface
*
* @since 3.2.0
*/
interface UpdateInterface
{
/**
* Update rows in the database (with remapping and filtering columns
option)
*
* @param array $data Dataset to update in database [array of
arrays (key => value)]
* @param string $key Dataset key column to use in updating the
values in the Database
* @param string $table The table where the data is being updated
* @param array $columns Data columns for remapping and filtering
*
* @return bool
* @since 3.2.0
**/
public function rows(array $data, string $key, string $table, array
$columns = []): bool;
/**
* Update items in the database (with remapping and filtering columns
option)
*
* @param array $data Data to updated in database (array of
objects)
* @param string $key Dataset key column to use in updating the
values in the Database
* @param string $table The table where the data is being update
* @param array $columns Data columns for remapping and filtering
*
* @return bool
* @since 3.2.0
**/
public function items(array $data, string $key, string $table, array
$columns = []): bool;
/**
* Update row in the database
*
* @param array $data Dataset to update in database (key =>
value)
* @param string $key Dataset key column to use in updating the
values in the Database
* @param string $table The table where the data is being updated
*
* @return bool
* @since 3.2.0
**/
public function row(array $data, string $key, string $table): bool;
/**
* Update item in the database
*
* @param object $data Dataset to update in database (key =>
value)
* @param string $key Dataset key column to use in updating the
values in the Database
* @param string $table The table where the data is being updated
*
* @return bool
* @since 3.2.0
**/
public function item(object $data, string $key, string $table): bool;
}
src/Model/index.html000064400000000054151162054060010367
0ustar00<html><body
bgcolor="#FFFFFF"></body></html>src/Model/Load.php000064400000005626151162054060007774
0ustar00<?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\Model;
use VDM\Joomla\Utilities\StringHelper;
use VDM\Joomla\Utilities\ArrayHelper;
use VDM\Joomla\Utilities\ObjectHelper;
use VDM\Joomla\Interfaces\ModelInterface;
use VDM\Joomla\Abstraction\Model;
/**
* Power Model Load
*
* @since 3.2.2
*/
final class Load extends Model implements ModelInterface
{
/**
* Model the value
* Example: $this->value(value, 'field_key',
'table_name');
*
* @param mixed $value The value to model
* @param string $field The field key
* @param string|null $table The table
*
* @return mixed
* @since 3.2.0
*/
public function value($value, string $field, ?string $table = null)
{
// set the table name
if (empty($table))
{
$table = $this->getTable();
}
// check if this is a valid table (don't touch null)
if ($value !== null && ($store = $this->table->get($table,
$field, 'store')) !== null)
{
// open the value based on the store method
switch($store)
{
case 'base64':
$value = base64_decode((string) $value);
break;
case 'json':
$value = json_decode($value);
break;
}
}
return $value;
}
/**
* Validate before the value is modelled
*
* @param mixed $value The field value
* @param string|null $field The field key
* @param string|null $table The table
*
* @return bool
* @since 3.2.0
*/
protected function validateBefore(&$value, ?string $field = null,
?string $table = null): bool
{
// only strings or numbers allowed
if (StringHelper::check($value) || is_numeric($value))
{
return true;
}
// check if we allow empty
elseif ($this->getAllowEmpty() && empty($value))
{
return true;
}
// remove empty values
return false;
}
/**
* Validate after the value is modelled
*
* @param mixed $value The field value
* @param string|null $field The field key
* @param string|null $table The table
*
* @return bool
* @since 3.2.0
*/
protected function validateAfter(&$value, ?string $field = null,
?string $table = null): bool
{
// only strings or numbers allowed
if (StringHelper::check($value) || ArrayHelper::check($value, true) ||
ObjectHelper::check($value) || is_numeric($value))
{
return true;
}
// check if we allow empty
elseif ($this->getAllowEmpty() && empty($value))
{
return true;
}
// remove empty values
return false;
}
}
src/Model/Upsert.php000064400000005577151162054060010404 0ustar00<?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\Model;
use VDM\Joomla\Utilities\StringHelper;
use VDM\Joomla\Utilities\ArrayHelper;
use VDM\Joomla\Utilities\ObjectHelper;
use VDM\Joomla\Interfaces\ModelInterface;
use VDM\Joomla\Abstraction\Model;
/**
* Power Model Update or Insert
*
* @since 3.2.0
*/
final class Upsert extends Model implements ModelInterface
{
/**
* Model the value
* Example: $this->value(value, 'field_key',
'table_name');
*
* @param mixed $value The value to model
* @param string $field The field key
* @param string|null $table The table
*
* @return mixed
* @since 3.2.0
*/
public function value($value, string $field, ?string $table = null)
{
// set the table name
if (empty($table))
{
$table = $this->getTable();
}
// check if this is a valid table
if (($store = $this->table->get($table, $field, 'store'))
!== null)
{
// open the value based on the store method
switch($store)
{
case 'base64':
$value = base64_encode((string) $value);
break;
case 'json':
$value = json_encode($value, JSON_FORCE_OBJECT);
break;
}
}
return $value;
}
/**
* Validate before the value is modelled
*
* @param mixed $value The field value
* @param string|null $field The field key
* @param string|null $table The table
*
* @return bool
* @since 3.2.0
*/
protected function validateBefore(&$value, ?string $field = null,
?string $table = null): bool
{
// check values
if (StringHelper::check($value) || ArrayHelper::check($value, true) ||
ObjectHelper::check($value) || is_numeric($value))
{
return true;
}
// check if we allow empty
elseif ($this->getAllowEmpty() && empty($value))
{
return true;
}
// remove empty values
return false;
}
/**
* Validate after the value is modelled
*
* @param mixed $value The field value
* @param string|null $field The field key
* @param string|null $table The table
*
* @return bool
* @since 3.2.0
*/
protected function validateAfter(&$value, ?string $field = null,
?string $table = null): bool
{
// only strings or numbers allowed
if (StringHelper::check($value) || is_numeric($value))
{
return true;
}
// check if we allow empty
elseif ($this->getAllowEmpty() && empty($value))
{
return true;
}
// remove empty values
return false;
}
}
src/Service/Data.php000064400000011614151162054060010320 0ustar00<?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\Service;
use Joomla\DI\Container;
use Joomla\DI\ServiceProviderInterface;
use VDM\Joomla\Data\Action\Load;
use VDM\Joomla\Data\Action\Insert;
use VDM\Joomla\Data\Action\Update;
use VDM\Joomla\Data\Action\Delete;
use VDM\Joomla\Data\Item;
use VDM\Joomla\Data\Items;
use VDM\Joomla\Data\Subform;
use VDM\Joomla\Data\UsersSubform;
use VDM\Joomla\Data\MultiSubform;
/**
* Data Service Provider
*
* @since 3.2.0
*/
class Data implements ServiceProviderInterface
{
/**
* Registers the service provider with a DI container.
*
* @param Container $container The DI container.
*
* @return void
* @since 3.2.0
*/
public function register(Container $container)
{
$container->alias(Load::class, 'Data.Load')
->share('Data.Load', [$this, 'getLoad'], true);
$container->alias(Insert::class, 'Data.Insert')
->share('Data.Insert', [$this, 'getInsert'],
true);
$container->alias(Update::class, 'Data.Update')
->share('Data.Update', [$this, 'getUpdate'],
true);
$container->alias(Delete::class, 'Data.Delete')
->share('Data.Delete', [$this, 'getDelete'],
true);
$container->alias(Item::class, 'Data.Item')
->share('Data.Item', [$this, 'getItem'], true);
$container->alias(Items::class, 'Data.Items')
->share('Data.Items', [$this, 'getItems'],
true);
$container->alias(Subform::class, 'Data.Subform')
->share('Data.Subform', [$this, 'getSubform'],
true);
$container->alias(UsersSubform::class, 'Data.UsersSubform')
->share('Data.UsersSubform', [$this,
'getUsersSubform'], true);
$container->alias(MultiSubform::class, 'Data.MultiSubform')
->share('Data.MultiSubform', [$this,
'getMultiSubform'], true);
}
/**
* Get The Load Class.
*
* @param Container $container The DI container.
*
* @return Load
* @since 3.2.0
*/
public function getLoad(Container $container): Load
{
return new Load(
$container->get('Model.Load'),
$container->get('Load')
);
}
/**
* Get The Insert Class.
*
* @param Container $container The DI container.
*
* @return Insert
* @since 3.2.0
*/
public function getInsert(Container $container): Insert
{
return new Insert(
$container->get('Model.Upsert'),
$container->get('Insert')
);
}
/**
* Get The Update Class.
*
* @param Container $container The DI container.
*
* @return Update
* @since 3.2.0
*/
public function getUpdate(Container $container): Update
{
return new Update(
$container->get('Model.Upsert'),
$container->get('Update')
);
}
/**
* Get The Delete Class.
*
* @param Container $container The DI container.
*
* @return Delete
* @since 3.2.0
*/
public function getDelete(Container $container): Delete
{
return new Delete(
$container->get('Delete')
);
}
/**
* Get The Item Class.
*
* @param Container $container The DI container.
*
* @return Item
* @since 3.2.0
*/
public function getItem(Container $container): Item
{
return new Item(
$container->get('Data.Load'),
$container->get('Data.Insert'),
$container->get('Data.Update'),
$container->get('Data.Delete'),
$container->get('Load')
);
}
/**
* Get The Items Class.
*
* @param Container $container The DI container.
*
* @return Items
* @since 3.2.0
*/
public function getItems(Container $container): Items
{
return new Items(
$container->get('Data.Load'),
$container->get('Data.Insert'),
$container->get('Data.Update'),
$container->get('Data.Delete'),
$container->get('Load')
);
}
/**
* Get The Subform Class.
*
* @param Container $container The DI container.
*
* @return Subform
* @since 3.2.0
*/
public function getSubform(Container $container): Subform
{
return new Subform(
$container->get('Data.Items')
);
}
/**
* Get The Users Subform Class.
*
* @param Container $container The DI container.
*
* @return UsersSubform
* @since 5.0.2
*/
public function getUsersSubform(Container $container): UsersSubform
{
return new UsersSubform(
$container->get('Data.Items')
);
}
/**
* Get The MultiSubform Class.
*
* @param Container $container The DI container.
*
* @return MultiSubform
* @since 3.2.0
*/
public function getMultiSubform(Container $container): MultiSubform
{
return new MultiSubform(
$container->get('Data.Subform')
);
}
}
src/Service/Database.php000064400000004417151162054060011156
0ustar00<?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\Service;
use Joomla\DI\Container;
use Joomla\DI\ServiceProviderInterface;
use VDM\Joomla\Database\Load;
use VDM\Joomla\Database\Insert;
use VDM\Joomla\Database\Update;
use VDM\Joomla\Database\Delete;
/**
* Database Service Provider
*
* @since 3.2.0
*/
class Database implements ServiceProviderInterface
{
/**
* Registers the service provider with a DI container.
*
* @param Container $container The DI container.
*
* @return void
* @since 3.2.0
*/
public function register(Container $container)
{
$container->alias(Load::class, 'Load')
->share('Load', [$this, 'getLoad'], true);
$container->alias(Insert::class, 'Insert')
->share('Insert', [$this, 'getInsert'], true);
$container->alias(Update::class, 'Update')
->share('Update', [$this, 'getUpdate'], true);
$container->alias(Delete::class, 'Delete')
->share('Delete', [$this, 'getDelete'], true);
}
/**
* Get the Core Load Database
*
* @param Container $container The DI container.
*
* @return Load
* @since 3.2.0
*/
public function getLoad(Container $container): Load
{
return new Load();
}
/**
* Get the Core Insert Database
*
* @param Container $container The DI container.
*
* @return Insert
* @since 3.2.0
*/
public function getInsert(Container $container): Insert
{
return new Insert();
}
/**
* Get the Core Update Database
*
* @param Container $container The DI container.
*
* @return Update
* @since 3.2.0
*/
public function getUpdate(Container $container): Update
{
return new Update();
}
/**
* Get the Core Delete Database
*
* @param Container $container The DI container.
*
* @return Delete
* @since 3.2.2
*/
public function getDelete(Container $container): Delete
{
return new Delete();
}
}
src/Service/index.html000064400000000054151162054060010727
0ustar00<html><body
bgcolor="#FFFFFF"></body></html>src/Service/Model.php000064400000003145151162054060010507
0ustar00<?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\Service;
use Joomla\DI\Container;
use Joomla\DI\ServiceProviderInterface;
use VDM\Joomla\Model\Load;
use VDM\Joomla\Model\Upsert;
/**
* Model Service Provider
*
* @since 3.2.0
*/
class Model implements ServiceProviderInterface
{
/**
* Registers the service provider with a DI container.
*
* @param Container $container The DI container.
*
* @return void
* @since 3.2.0
*/
public function register(Container $container)
{
$container->alias(Load::class, 'Model.Load')
->share('Model.Load', [$this, 'getLoad'], true);
$container->alias(Upsert::class, 'Model.Upsert')
->share('Model.Upsert', [$this, 'getUpsert'],
true);
}
/**
* Get The Load Class.
*
* @param Container $container The DI container.
*
* @return Load
* @since 3.2.0
*/
public function getLoad(Container $container): Load
{
return new Load(
$container->get('Table')
);
}
/**
* Get The Upsert Class.
*
* @param Container $container The DI container.
*
* @return Upsert
* @since 3.2.0
*/
public function getUpsert(Container $container): Upsert
{
return new Upsert(
$container->get('Table')
);
}
}
src/Service/Table.php000064400000003221151162054060010471 0ustar00<?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\Service;
use Joomla\DI\Container;
use Joomla\DI\ServiceProviderInterface;
use VDM\Joomla\Componentbuilder\Table as DataTable;
use VDM\Joomla\Componentbuilder\Table\Schema;
/**
* Table Service Provider
*
* @since 3.2.2
*/
class Table implements ServiceProviderInterface
{
/**
* Registers the service provider with a DI container.
*
* @param Container $container The DI container.
*
* @return void
* @since 3.2.2
*/
public function register(Container $container)
{
$container->alias(DataTable::class, 'Table')
->share('Table', [$this, 'getTable'], true);
$container->alias(Schema::class, 'Table.Schema')
->share('Table.Schema', [$this, 'getSchema'],
true);
}
/**
* Get The Componentbuilder Data Table Class.
*
* @param Container $container The DI container.
*
* @return DataTable
* @since 3.2.2
*/
public function getTable(Container $container): DataTable
{
return new DataTable();
}
/**
* Get The Schema Class.
*
* @param Container $container The DI container.
*
* @return Schema
* @since 3.2.2
*/
public function getSchema(Container $container): Schema
{
return new Schema(
$container->get('Table')
);
}
}
src/Utilities/ArrayHelper.php000064400000004024151162054060012235
0ustar00<?php
/**
* @package Joomla.Component.Builder
*
* @created 3rd September, 2020
* @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\Utilities;
/**
* Some array tricks helper
*
* @since 3.0.9
*/
abstract class ArrayHelper
{
/**
* Check if have an array with a length
*
* @input array The array to check
*
* @returns int|false number of items in array on success
*
* @since 3.2.0
*/
public static function check($array, $removeEmptyString = false)
{
if (is_array($array) && ($nr = count((array) $array)) > 0)
{
// also make sure the empty strings are removed
if ($removeEmptyString)
{
$array = array_filter($array);
if ($array === [])
{
return false;
}
return count($array);
}
return $nr;
}
return false;
}
/**
* Merge an array of array's
*
* @input array The arrays you would like to merge
*
* @returns array|null merged array on success
*
* @since 3.0.9
*/
public static function merge($arrays): ?array
{
if(self::check($arrays))
{
$merged = [];
foreach ($arrays as $array)
{
if (self::check($array))
{
$merged = array_merge($merged, $array);
}
}
return $merged;
}
return null;
}
/**
* Check if arrays intersect
*
* @input array The first array
* @input array The second array
*
* @returns bool true if intersect else false
*
* @since 3.1.1
*/
public static function intersect($a_array, $b_array): bool
{
// flip the second array
$b_array = array_flip($b_array);
// loop the first array
foreach ($a_array as $v)
{
if (isset($b_array[$v]))
{
return true;
}
}
return false;
}
}
src/Utilities/Base64Helper.php000064400000003046151162054060012206
0ustar00<?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\Utilities;
use VDM\Joomla\Utilities\StringHelper;
/**
* The Base64 Helper
*
* @since 3.2.0
*/
abstract class Base64Helper
{
/**
* open base64 string if stored as base64 (in JCB)
*
* @param string|null $data The base64 string
* @param string|null $key We store the string with that suffix
:)
* @param string|null $default The default switch
*
* @return string|null The opened string
* @since 3.2.0
*/
public static function open(?string $data, ?string $key =
'__.o0=base64=Oo.__', ?string $default = 'string'):
?string
{
// check that we have a string
if (StringHelper::check($data))
{
// check if we have a key
if (StringHelper::check($key))
{
if (strpos($data, $key) !== false)
{
return base64_decode(str_replace($key, '', $data));
}
}
// fallback to this, not perfect method
if (base64_encode(base64_decode($data, true)) === $data)
{
return base64_decode($data);
}
}
// check if we should just return the string
if ('string' === $default)
{
return $data;
}
return $default;
}
}
src/Utilities/ClassHelper.php000064400000003144151162054060012226
0ustar00<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September, 2020
* @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\Utilities;
/**
* Class Helper for JCB Powers
*
* @since 3.2.2
*/
abstract class ClassHelper
{
/**
* Ensures that a class in the namespace is available.
* If the class is not already loaded, it attempts to load it via the
specified autoloader.
*
* @param string $className The fully qualified name of the class
to check.
* @param string $component The component name where the autoloader
resides.
* @param string $autoloaderPath The path to the autoloader file within
the component.
*
* @return bool True if the class exists or was successfully loaded, false
otherwise.
* @since 3.2.2
*/
public static function exists(string $className, string $component, string
$autoloaderPath): bool
{
if (!class_exists($className, true))
{
// Construct the path to the autoloader file
$autoloaderFile = JPATH_ADMINISTRATOR . '/components/com_' .
$component . '/' . $autoloaderPath;
if (file_exists($autoloaderFile))
{
require_once $autoloaderFile;
}
// Check again if the class now exists after requiring the autoloader
if (!class_exists($className, true))
{
return false;
}
}
return true;
}
}
src/Utilities/Component/Helper.php000064400000027307151162054060013211
0ustar00<?php
/**
* @package Joomla.Component.Builder
*
* @created 3rd September, 2020
* @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\Utilities\Component;
use Joomla\CMS\Factory;
use Joomla\CMS\Component\ComponentHelper;
use Joomla\CMS\MVC\Model\BaseDatabaseModel;
use Joomla\Input\Input;
use Joomla\Registry\Registry;
use VDM\Joomla\Utilities\String\NamespaceHelper;
use VDM\Joomla\Utilities\StringHelper;
/**
* Some component helper
*
* @since 3.0.11
*/
abstract class Helper
{
/**
* The current option
*
* @var string|null
* @since 3.0.11
*/
public static ?string $option = null;
/**
* The component manifest list cache
*
* @var array
* @since 3.2.0
*/
public static array $manifest = [];
/**
* The component params list cache
*
* @var Registry[]
* @since 3.0.11
*/
protected static array $params = [];
/**
* Sets a parameter value for the given target in the specified
option's params.
* If no option is provided, it falls back to the default option.
*
* This method updates the parameters for a given extension in the
database,
* only if the new value differs from the existing one.
*
* @param string $target The parameter name to be updated.
* @param mixed $value The value to set for the parameter.
* @param string|null $option The optional extension element name.
Defaults to null, which will use the default option.
*
* @return mixed The previous value of the parameter before it was
updated.
* @since 5.0.3
*/
public static function setParams(string $target, $value, ?string $option =
null)
{
// Ensure that an option is specified, defaulting to the system's
option if not provided.
if (empty($option))
{
$option = static::getOption();
}
// Retrieve current parameters for the specified option.
$params = static::getParams($option);
// Get the current value of the target parameter.
$was = $params->get($target, null);
// Only proceed if the new value differs from the current value.
if ($was !== $value)
{
// Update the parameter value.
$params->set($target, $value);
// Obtain a database connection instance.
$db = Factory::getDBO();
$query = $db->getQuery(true);
// Build and execute the query to update the parameters in the
database.
$query->update('#__extensions AS a')
->set('a.params = ' . $db->quote((string) $params))
->where('a.element = ' . $db->quote((string)
$option));
$db->setQuery($query);
$db->execute();
}
// Return the previous value of the parameter.
return $was;
}
/**
* Gets the parameter object for the component
*
* @param string|null $option The option for the component.
*
* @return Registry A Registry object.
* @see Registry
* @since 3.0.11
*/
public static function getParams(?string $option = null): Registry
{
// check that we have an option
if (empty($option))
{
$option = static::getOption();
}
// get global value
if (!isset(static::$params[$option]) || !static::$params[$option]
instanceof Registry)
{
static::$params[$option] = ComponentHelper::getParams($option);
}
return static::$params[$option];
}
/**
* Set the component option
*
* @param string|null $option The option
*
* @return void
* @since 3.2.0
*/
public static function setOption(?string $option): void
{
static::$option = $option;
}
/**
* Get the component option
*
* @param string|null $default The default return value if none is
found
*
* @return string|null A component option
* @since 3.0.11
*/
public static function getOption(?string $default = 'empty'):
?string
{
if (empty(static::$option))
{
// get the option from the url input
static::$option = (new Input)->getString('option', null);
}
if (empty(static::$option))
{
$app = Factory::getApplication();
// Check if the getInput method exists in the application object
if (method_exists($app, 'getInput'))
{
// get the option from the application
static::$option = $app->getInput()->getCmd('option',
$default);
}
else
{
// Use the default value if getInput method does not exist
static::$option = $default;
}
}
return static::$option;
}
/**
* Gets the component code name
*
* @param string|null $option The option for the component.
* @param string|null $default The default return value if none is
found
*
* @return string|null A component code name
* @since 3.0.11
*/
public static function getCode(?string $option = null, ?string $default =
null): ?string
{
// check that we have an option
if (empty($option))
{
$option = static::getOption();
}
// option with com_
if (is_string($option) && strpos($option, 'com_') ===
0)
{
return strtolower(trim(substr($option, 4)));
}
return $default;
}
/**
* Gets the component abstract helper class
*
* @param string|null $option The option for the component.
* @param string|null $default The default return value if none is
found
*
* @return string|null A component helper name
*
* @since 3.0.11
*/
public static function get(?string $option = null, ?string $default =
null): ?string
{
// check that we have an option
// and get the code name from it
if (($code_name = static::getCode($option, null)) !== null)
{
// we build the helper class name
$helper_name = '\\' . \ucfirst($code_name) .
'Helper';
// check if class exist
if (class_exists($helper_name))
{
return $helper_name;
}
// try loading namespace
if (($namespace = static::getNamespace($option)) !== null)
{
$name = \ucfirst($code_name) . 'Helper';
$namespace_helper = '\\' . $namespace .
'\Administrator\Helper\\' . NamespaceHelper::safeSegment($name);
// TODO target site or admin locations not just admin...
if (class_exists($namespace_helper))
{
return $namespace_helper;
}
}
}
return $default;
}
/**
* Gets the component namespace if set
*
* @param string|null $option The option for the component.
* @param string|null $default The default return value if none is
found
*
* @return string|null A component namespace
*
* @since 3.0.11
*/
public static function getNamespace(?string $option = null): ?string
{
$manifest = static::getManifest($option);
return $manifest->namespace ?? null;
}
/**
* Gets the component abstract helper class
*
* @param string|null $option The option for the component.
* @param string|null $default The default return value if none is
found
*
* @return object|null A component helper name
*
* @since 3.0.11
*/
public static function getManifest(?string $option = null): ?object
{
if ($option === null
&& ($option = static::getOption($option)) === null)
{
return null;
}
// get global manifest_cache values
if (!isset(static::$manifest[$option]))
{
$db = Factory::getDbo();
$query = $db->getQuery(true);
$query->select($db->quoteName('manifest_cache'))
->from($db->quoteName('#__extensions'))
->where($db->quoteName('type') . ' = ' .
$db->quote('component'))
->where($db->quoteName('element') . ' LIKE
' . $db->quote($option));
$db->setQuery($query);
try {
$manifest = $db->loadResult();
static::$manifest[$option] = json_decode($manifest);
} catch (\Exception $e) {
// Handle the database error appropriately.
static::$manifest[$option] = null;
}
}
return static::$manifest[$option];
}
/**
* Check if the helper class of this component has a method
*
* @param string $method The method name to search for
* @param string|null $option The option for the component.
*
* @return bool true if method exist
*
* @since 3.0.11
*/
public static function methodExists(string $method, ?string $option =
null): bool
{
// get the helper class
return ($helper = static::get($option, null)) !== null &&
method_exists($helper, $method);
}
/**
* Check if the helper class of this component has a method, and call it
with the arguments
*
* @param string $method The method name to search for
* @param array $arguments The arguments for function.
* @param string|null $option The option for the component.
*
* @return mixed return whatever the method returns or null
* @since 3.2.0
*/
public static function _(string $method, array $arguments = [], ?string
$option = null)
{
// get the helper class
if (($helper = static::get($option, null)) !== null &&
method_exists($helper, $method))
{
// we know this is not ideal...
// so we need to move these
// functions to their own classes
return call_user_func_array([$helper, $method], $arguments);
}
return null;
}
/**
* Returns a Model object based on the specified type, prefix, and
configuration.
*
* @param string $type The model type to instantiate. Must not
be empty.
* @param string $prefix Prefix for the model class name.
Optional, defaults to 'Administrator'.
* @param string|null $option The component option. Optional,
defaults to the component's option.
* @param array $config Configuration array for the model.
Optional, defaults to an empty array.
*
* @return BaseDatabaseModel The instantiated model object.
*
* @throws \InvalidArgumentException If the $type parameter is empty.
* @throws \Exception For other errors that may occur
during model creation.
*
* @since 5.0.3
*/
public static function getModel(string $type, string $prefix =
'Administrator',
?string $option = null, array $config = []): BaseDatabaseModel
{
// Ensure the $type parameter is not empty
if (empty($type))
{
throw new \InvalidArgumentException('The $type parameter cannot be
empty when calling Component Helper getModel method.');
}
// Ensure the $option parameter is set, defaulting to the
component's option if not provided
if (empty($option))
{
$option = static::getOption();
}
// Normalize the model type name if the first character is not uppercase
if (!ctype_upper($type[0]))
{
$type = StringHelper::safe($type, 'F');
}
// Normalize the prefix if it's not 'Site' or
'Administrator'
if ($prefix !== 'Site' && $prefix !==
'Administrator')
{
$prefix = static::getPrefixFromModelPath($prefix);
}
// Instantiate and return the model using the MVCFactory
return Factory::getApplication()
->bootComponent($option)
->getMVCFactory()
->createModel($type, $prefix, $config);
}
/**
* Get the prefix from the model path
*
* @param string $path The model path
*
* @return string The prefix value
* @since 5.0.3
*/
private static function getPrefixFromModelPath(string $path): string
{
// Check if $path starts with JPATH_ADMINISTRATOR path
if (str_starts_with($path, JPATH_ADMINISTRATOR .
'/components/'))
{
return 'Administrator';
}
// Check if $path starts with JPATH_SITE path
elseif (str_starts_with($path, JPATH_SITE . '/components/'))
{
return 'Site';
}
return 'Administrator';
}
}
src/Utilities/Component/index.html000064400000000054151162054060013244
0ustar00<html><body
bgcolor="#FFFFFF"></body></html>src/Utilities/FileHelper.php000064400000023121151162054060012035
0ustar00<?php
/**
* @package Joomla.Component.Builder
*
* @created 3rd September, 2020
* @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\Utilities;
use Joomla\CMS\Uri\Uri;
use Joomla\CMS\Factory;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Filesystem\Path;
use Joomla\CMS\Filesystem\File;
use Joomla\CMS\Filesystem\Folder;
use Joomla\Archive\Archive;
use VDM\Joomla\Utilities\Component\Helper;
/**
* File helper
*
* @since 3.0.9
*/
abstract class FileHelper
{
/**
* Trigger error notice only once
*
* @var bool
*
* @since 3.0.9
*/
protected static $curlError = false;
/**
* The zipper method
*
* @param string $workingDirectory The directory where the items
must be zipped
* @param string $filepath The path to where the zip file must
be placed
*
* @return bool true On success
*
* @since 3.0.9
*/
public static function zip($workingDirectory, &$filepath): bool
{
// check the work directory is set
if (!is_dir($workingDirectory))
{
return false;
}
// store the current joomla working directory
$joomla = getcwd();
// we are changing the working directory to the component temp folder
chdir($workingDirectory);
// the full file path of the zip file
$filepath = Path::clean($filepath);
// delete an existing zip file (or use an exclusion parameter in
Folder::files()
File::delete($filepath);
// get a list of files in the current directory tree (also the hidden
files)
$files = Folder::files('.', '', true, true,
array('.svn', 'CVS', '.DS_Store',
'__MACOSX'), array('.*~'));
$zipArray = [];
// setup the zip array
foreach ($files as $file)
{
$tmp = [];
$tmp['name'] = str_replace('./', '',
(string) $file);
$tmp['data'] = self::getContent($file);
$tmp['time'] = filemtime($file);
$zipArray[] = $tmp;
}
// change back to joomla working directory
chdir($joomla);
// get the zip adapter
$zip = (new Archive())->getAdapter('zip');
//create the zip file
return (bool) $zip->create($filepath, $zipArray);
}
/**
* get the content of a file
*
* @param string $path The path to the file
* @param mixed $none The return value if no content was found
*
* @return string On success
*
* @since 3.0.9
*/
public static function getContent($path, $none = '')
{
if (StringHelper::check($path))
{
// use basic file get content for now
if (($content = @file_get_contents($path)) !== FALSE)
{
return $content;
}
// use curl if available
elseif (function_exists('curl_version'))
{
// start curl
$ch = curl_init();
// set the options
$options = [];
$options[CURLOPT_URL] = $path;
$options[CURLOPT_USERAGENT] = 'Mozilla/5.0 (Windows; U; Windows NT
6.1; en-US; rv:1.9.2.12) Gecko/20101026 Firefox/3.6.12';
$options[CURLOPT_RETURNTRANSFER] = TRUE;
$options[CURLOPT_SSL_VERIFYPEER] = FALSE;
// load the options
curl_setopt_array($ch, $options);
// get the content
$content = curl_exec($ch);
// close the connection
curl_close($ch);
// return if found
if (StringHelper::check($content))
{
return $content;
}
}
elseif (!self::$curlError)
{
// set the notice
Factory::getApplication()->enqueueMessage('<h2>Curl Not
Found!</h2><p>Please setup curl on your system, or the
<b>Joomla Component</b> will not function
correctly!</p>', 'Error');
// load this notice only once
self::$curlError = true;
}
}
return $none;
}
/**
* Write a file to the server
*
* @param string $path The path and file name where to safe the
data
* @param string $data The data to safe
*
* @return bool true On success
*
* @since 3.0.9
*/
public static function write($path, $data): bool
{
$klaar = false;
if (StringHelper::check($data))
{
// open the file
$fh = fopen($path, "w");
if (!is_resource($fh))
{
return $klaar;
}
// write to the file
if (fwrite($fh, $data))
{
// has been done
$klaar = true;
}
// close file.
fclose($fh);
}
return $klaar;
}
/**
* get all the file paths in folder and sub folders
*
* @param string $folder The local path to parse
* @param array $fileTypes The type of files to get
*
* @return array|null
*
* @since 3.0.9
*/
public static function getPaths($folder, $fileTypes =
array('\.php', '\.js', '\.css',
'\.less'), $recurse = true, $full = true): ?array
{
if (Folder::exists($folder))
{
// we must first store the current woking directory
$joomla = getcwd();
// we are changing the working directory to the component path
chdir($folder);
// make sure we have file type filter
if (ArrayHelper::check($fileTypes))
{
// get the files
foreach ($fileTypes as $type)
{
// get a list of files in the current directory tree
$files[] = Folder::files('.', $type, $recurse, $full);
}
}
elseif (StringHelper::check($fileTypes))
{
// get a list of files in the current directory tree
$files[] = Folder::files('.', $fileTypes, $recurse, $full);
}
else
{
// get a list of files in the current directory tree
$files[] = Folder::files('.', '.', $recurse,
$full);
}
// change back to Joomla working directory
chdir($joomla);
// return array of files
return array_map( fn($file) => str_replace('./',
'/', (string) $file), (array) ArrayHelper::merge($files));
}
return null;
}
/**
* Get the file path or url
*
* @param string $type The (url/path) type to return
* @param string $target The Params Target name (if set)
* @param string $fileType The kind of filename to generate
(if not set no file name is generated)
* @param string $key The key to adjust the filename (if
not set ignored)
* @param string $default The default path if not set in
Params (fallback path)
* @param bool $createIfNotSet The switch to create the folder if
not found
*
* @return string On success the path or url is returned based on the
type requested
*
* @since 3.0.9
*/
public static function getPath($type = 'path', $target =
'filepath', $fileType = null, $key = '', $default =
'', $createIfNotSet = true): string
{
// make sure to always have a string/path
if(!StringHelper::check($default))
{
$default = JPATH_SITE . '/images/';
}
// get the global settings
$filePath = Helper::getParams()->get($target, $default);
// check the file path (revert to default only of not a hidden file
path)
if ('hiddenfilepath' !== $target && strpos((string)
$filePath, (string) JPATH_SITE) === false)
{
$filePath = $default;
}
// create the folder if it does not exist
if ($createIfNotSet && !Folder::exists($filePath))
{
Folder::create($filePath);
}
// setup the file name
$fileName = '';
// Get basic key
$basickey = 'Th!s_iS_n0t_sAfe_buT_b3tter_then_n0thiug';
// get the component helper
$helper = Helper::get();
// check if method exist in helper class
if ($helper && Helper::methodExists('getCryptKey'))
{
$basickey = $helper::getCryptKey('basic', $basickey);
}
// check the key
if (!StringHelper::check($key))
{
$key = 'vDm';
}
// set the file name
if (StringHelper::check($fileType))
{
// set the name
$fileName = trim( md5($type . $target . $basickey . $key) .
'.' . trim($fileType, '.'));
}
else
{
$fileName = trim( md5($type . $target . $basickey . $key)) .
'.txt';
}
// return the url
if ('url' === $type)
{
if (\strpos((string) $filePath, (string) JPATH_SITE) !== false)
{
$filePath = trim( str_replace( JPATH_SITE, '', (string)
$filePath), '/');
return Uri::root() . $filePath . '/' . $fileName;
}
// since the path is behind the root folder of the site, return only the
root url (may be used to build the link)
return Uri::root();
}
// sanitize the path
return '/' . trim((string) $filePath, '/' ) .
'/' . $fileName;
}
/**
* Check if file exist
*
* @param string $path The url/path to check
*
* @return bool If exist true
*
* @since 3.0.9
*/
public static function exists($path): bool
{
$exists = false;
// if this is a local path
if (strpos($path, 'http:') === false && strpos($path,
'https:') === false)
{
if (file_exists($path))
{
$exists = true;
}
}
// check if we can use curl
elseif (function_exists('curl_version'))
{
// initiate curl
$ch = curl_init($path);
// CURLOPT_NOBODY (do not return body)
curl_setopt($ch, CURLOPT_NOBODY, true);
// make call
$result = curl_exec($ch);
// check return value
if ($result !== false)
{
// get the http CODE
$statusCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
if ($statusCode !== 404)
{
$exists = true;
}
}
// close the connection
curl_close($ch);
}
elseif ($headers = @get_headers($path))
{
if(isset($headers[0]) && is_string($headers[0]) &&
strpos($headers[0],'404') === false)
{
$exists = true;
}
}
return $exists;
}
}
src/Utilities/FormHelper.php000064400000011620151162054060012062
0ustar00<?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\Utilities;
use Joomla\CMS\Form\FormHelper as JoomlaFormHelper;
use Joomla\CMS\Form\FormField;
/**
* Form Helper
*
* @since 3.2.0
*/
abstract class FormHelper
{
/**
* get the field xml
*
* @param array $attributes The array of attributes
* @param array $options The options to apply to the XML
element
*
* @return \SimpleXMLElement|null
* @since 3.2.0
*/
public static function xml(array $attributes, ?array $options = null):
?\SimpleXMLElement
{
// make sure we have attributes and a type value
if (ArrayHelper::check($attributes))
{
// start field xml
$XML = new \SimpleXMLElement('<field/>');
// load the attributes
self::attributes($XML, $attributes);
// check if we have options
if (ArrayHelper::check($options))
{
// load the options
self::options($XML, $options);
}
// return the field xml
return $XML;
}
return null;
}
/**
* xmlAppend
*
* @param \SimpleXMLElement $xml The XML element reference in
which to inject a comment
* @param mixed $node A SimpleXMLElement node to append
to the XML element reference,
* or a stdClass object containing
a comment attribute to be injected
* before the XML node and a
fieldXML attribute containing a SimpleXMLElement
*
* @return void
* @since 3.2.0
*/
public static function append(\SimpleXMLElement &$xml, $node)
{
if (!$node)
{
// element was not returned
return;
}
if ($node instanceof \stdClass)
{
if (property_exists($node, 'comment'))
{
self::comment($xml, $node->comment);
}
if (property_exists($node, 'fieldXML'))
{
self::append($xml, $node->fieldXML);
}
}
elseif ($node instanceof \SimpleXMLElement)
{
$domXML = \dom_import_simplexml($xml);
$domNode = \dom_import_simplexml($node);
$domXML->appendChild($domXML->ownerDocument->importNode($domNode,
true));
$xml = \simplexml_import_dom($domXML);
}
}
/**
* xmlComment
*
* @param \SimpleXMLElement $xml The XML element reference in
which to inject a comment
* @param string $comment The comment to inject
*
* @return void
* @since 3.2.0
*/
public static function comment(\SimpleXMLElement &$xml, string
$comment)
{
$domXML = \dom_import_simplexml($xml);
$domComment = new \DOMComment($comment);
$nodeTarget = $domXML->ownerDocument->importNode($domComment,
true);
$domXML->appendChild($nodeTarget);
$xml = \simplexml_import_dom($domXML);
}
/**
* xmlAddAttributes
*
* @param \SimpleXMLElement $xml The XML element reference in
which to inject a comment
* @param array $attributes The attributes to apply to
the XML element
*
* @return void
* @since 3.2.0
*/
public static function attributes(\SimpleXMLElement &$xml, array
$attributes = [])
{
foreach ($attributes as $key => $value)
{
$xml->addAttribute($key, $value ?? '');
}
}
/**
* xmlAddOptions
*
* @param \SimpleXMLElement $xml The XML element reference in
which to inject a comment
* @param array $options The options to apply to the
XML element
*
* @return void
* @since 3.2.0
*/
public static function options(\SimpleXMLElement &$xml, array $options
= [])
{
foreach ($options as $key => $value)
{
$addOption = $xml->addChild('option');
$addOption->addAttribute('value', $key ?? '');
$addOption[] = $value;
}
}
/**
* get the field object
*
* @param array $attributes The array of attributes
* @param string $default The default of the field
* @param array $options The options to apply to the XML
element
*
* @return FormField|null
* @since 3.2.0
*/
public static function field(array $attributes, string $default =
'', ?array $options = null): ?FormField
{
// make sure we have attributes and a type value
if (ArrayHelper::check($attributes) &&
isset($attributes['type']))
{
// get field type
if (($field =
JoomlaFormHelper::loadFieldType($attributes['type'], true)) ===
false)
{
return null;
}
// get field xml
$XML = self::xml($attributes, $options);
// setup the field
$field->setup($XML, $default);
// return the field object
return $field;
}
return null;
}
}
src/Utilities/GetHelper.php000064400000014442151162054060011703
0ustar00<?php
/**
* @package Joomla.Component.Builder
*
* @created 3rd September, 2020
* @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\Utilities;
use Joomla\CMS\Factory;
use VDM\Joomla\Utilities\Component\Helper;
use VDM\Joomla\Data\Factory as Data;
/**
* Some easy get...
*
* @since 3.0.9
*/
abstract class GetHelper
{
/**
* Get a Variable
*
* @param string|null $table The table from which to get the
variable
* @param mixed $where The value where
* @param string $whereString The target/field string where/name
* @param string $what The return field
* @param string $operator The operator between
$whereString/field and $where/value
* @param string $main The component in which the table is
found
*
* @return mixed string/int/float
* @since 3.0.9
*
* @deprecated 5.1 Use
Data::_('Load')->table($table)->value(...)
*/
public static function var(?string $table = null, $where = null,
string $whereString = 'user', string $what = 'id',
string $operator = '=', ?string $main = null)
{
if(empty($where))
{
$where = Factory::getUser()->id;
}
if(empty($main))
{
$main = Helper::getCode();
}
// Get a db connection.
$db = Factory::getDbo();
// Create a new query object.
$query = $db->getQuery(true);
$query->select($db->quoteName(array($what)));
if (empty($table))
{
$query->from($db->quoteName('#__' . $main));
}
else
{
$query->from($db->quoteName('#__' . $main .
'_' . $table));
}
if (is_numeric($where))
{
$query->where($db->quoteName($whereString) . ' ' .
$operator . ' ' . (int) $where);
}
elseif (is_string($where))
{
$query->where($db->quoteName($whereString) . ' ' .
$operator . ' ' . $db->quote((string)$where));
}
else
{
return false;
}
$db->setQuery($query);
$db->execute();
if ($db->getNumRows())
{
return $db->loadResult();
}
return false;
}
/**
* Get array of variables
*
* @param string|null $table The table from which to get the
variables
* @param mixed $where The value where
* @param string $whereString The target/field string where/name
* @param string $what The return field
* @param string $operator The operator between
$whereString/field and $where/value
* @param string $main The component in which the table is
found
* @param bool $unique The switch to return a unique
array
*
* @return array|null
* @since 3.0.9
*
* @deprecated 5.1 Use
Data::_('Load')->table($table)->values(...)
*/
public static function vars(?string $table = null, $where = null,
string $whereString = 'user', string $what = 'id',
string $operator = 'IN',
?string $main = null, bool $unique = true): ?array
{
if(empty($where))
{
$where = Factory::getUser()->id;
}
if($main === null)
{
$main = Helper::getCode();
}
if (!ArrayHelper::check($where) && $where > 0)
{
$where = [$where];
}
if (ArrayHelper::check($where))
{
// prep main <-- why? well if $main='' is empty then $table
can be categories or users
if (StringHelper::check($main))
{
$main = '_' . ltrim($main, '_');
}
// Get a db connection.
$db = Factory::getDbo();
// Create a new query object.
$query = $db->getQuery(true);
$query->select($db->quoteName(array($what)));
if (empty($table))
{
$query->from($db->quoteName('#__' . $main));
}
else
{
$query->from($db->quoteName('#_' . $main .
'_' . $table));
}
// add strings to array search
if ('IN_STRINGS' === $operator || 'NOT IN_STRINGS'
=== $operator)
{
$query->where($db->quoteName($whereString) . ' ' .
str_replace('_STRINGS', '', $operator) . '
("' . implode('","', $where) .
'")');
}
else
{
$query->where($db->quoteName($whereString) . ' ' .
$operator . ' (' . implode(',', $where) .
')');
}
$db->setQuery($query);
$db->execute();
if ($db->getNumRows())
{
if ($unique)
{
return array_unique($db->loadColumn());
}
return $db->loadColumn();
}
}
return null;
}
/**
* get all strings between two other strings
*
* @param string $content The content to search
* @param string $start The starting value
* @param string $end The ending value
*
* @return array|null On success
* @since 3.0.9
*/
public static function allBetween(string $content, string $start, string
$end): ?array
{
// reset bucket
$bucket = [];
for ($i = 0; ; $i++)
{
// search for string
$found = self::between($content, $start, $end);
if (StringHelper::check($found))
{
// add to bucket
$bucket[] = $found;
// build removal string
$remove = $start . $found . $end;
// remove from content
$content = str_replace($remove, '', $content);
}
else
{
break;
}
// safety catch
if ($i == 500)
{
break;
}
}
// only return unique array of values
if (ArrayHelper::check($bucket))
{
return array_unique($bucket);
}
return null;
}
/**
* get a string between two other strings
*
* @param string $content The content to search
* @param string $start The starting value
* @param string $end The ending value
* @param string $default The default value if none found
*
* @return string On success / empty string on failure
* @since 3.0.9
*/
public static function between(string $content, string $start, string
$end, string $default = ''): string
{
$array = explode($start, $content);
if (isset($array[1]) && strpos($array[1], $end) !== false)
{
$array = explode($end, $array[1]);
// return string found between
return $array[0];
}
return $default;
}
}
src/Utilities/GetHelperExtrusion.php000064400000004504151162054060013622
0ustar00<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September, 2020
* @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\Utilities;
use VDM\Joomla\Utilities\GetHelper;
/**
* Some easy get...
*
* @since 3.2.0
*/
abstract class GetHelperExtrusion extends GetHelper
{
/**
* get all strings between two other strings
*
* @param string $content The content to search
* @param string $start The starting value
* @param string $end The ending value
*
* @return array|null On success
* @since 3.0.9
*/
public static function allBetween(string $content, string $start, string
$end): ?array
{
// reset bucket
$bucket = [];
for ($i = 0; ; $i++)
{
// search for string
$found = self::between($content, $start, $end);
if (StringHelper::check($found))
{
// add to bucket
$bucket[] = $found;
// build removal string
$remove = $start . $found . $end;
// remove from content
$content = str_replace($remove, '', $content);
}
else
{
break;
}
// safety catch
if ($i == 500)
{
break;
}
}
// only return unique array of values
if (ArrayHelper::check($bucket))
{
return array_unique($bucket);
}
return null;
}
/**
* get a string between two other strings
*
* @param string $content The content to search
* @param string $start The starting value
* @param string $end The ending value
* @param string $default The default value if none found
*
* @return string On success / empty string on failure
* @since 3.0.9
*/
public static function between(string $content, string $start, string
$end, string $default = ''): string
{
$array = explode($start, $content);
if (isset($array[1]) && strpos($array[1], $end) !== false)
{
$array = explode($end, $array[1]);
// return string found between
return $array[0];
}
return $default;
}
}
src/Utilities/GuidHelper.php000064400000012220151162054060012044
0ustar00<?php
/**
* @package Joomla.Component.Builder
*
* @created 3rd September, 2020
* @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\Utilities;
use Joomla\CMS\Factory;
use VDM\Joomla\Utilities\Component\Helper;
/**
* Global Unique ID Helper
*
* @since 3.0.9
*/
abstract class GuidHelper
{
/**
* Returns a GUIDv4 string
*
* Thanks to Dave Pearson (and other)
* https://www.php.net/manual/en/function.com-create-guid.php#119168
*
* Uses the best cryptographically secure method
* for all supported platforms with fallback to an older,
* less secure version.
*
* @param bool $trim
*
* @return string
*
* @since 3.0.9
*/
public static function get(bool $trim = true): string
{
// Windows
if (function_exists('com_create_guid'))
{
if ($trim)
{
return trim(com_create_guid(), '{}');
}
return com_create_guid();
}
// set the braces if needed
$lbrace = $trim ? "" : chr(123); // "{"
$rbrace = $trim ? "" : chr(125); // "}"
// OSX/Linux
if (function_exists('openssl_random_pseudo_bytes'))
{
$data = openssl_random_pseudo_bytes(16);
$data[6] = chr( ord($data[6]) & 0x0f | 0x40); // set version to
0100
$data[8] = chr( ord($data[8]) & 0x3f | 0x80); // set bits 6-7 to
10
return $lbrace . vsprintf('%s%s-%s-%s-%s-%s%s%s',
str_split(bin2hex($data), 4)) . $lbrace;
}
// Fallback (PHP 4.2+)
mt_srand((double) microtime() * 10000);
$charid = strtolower( md5( uniqid( rand(), true)));
$hyphen = chr(45); // "-"
$guidv4 = $lbrace.
substr($charid, 0, 8). $hyphen.
substr($charid, 8, 4). $hyphen.
substr($charid, 12, 4). $hyphen.
substr($charid, 16, 4). $hyphen.
substr($charid, 20, 12).
$rbrace;
return $guidv4;
}
/**
* Validate the Globally Unique Identifier ( and check if table already
has this identifier)
*
* @param string $guid
* @param string|null $table
* @param int $id
* @param string|null $component
*
* @return bool
*
* @since 3.0.9
*/
public static function valid($guid, ?string $table = null, int $id = 0,
?string $component = null): bool
{
// check if we have a string
if (self::validate($guid))
{
// check if table already has this identifier
if (StringHelper::check($table))
{
// check that we have the component code name
if (!is_string($component))
{
$component = (string) Helper::getCode();
}
// Get the database object and a new query object.
$db = Factory::getDbo();
$query = $db->getQuery(true);
$query->select('COUNT(*)')
->from('#__' . (string) $component . '_' .
(string) $table)
->where($db->quoteName('guid') . ' = ' .
$db->quote($guid));
// remove this item from the list
if ($id > 0)
{
$query->where($db->quoteName('id') . ' <>
' . (int) $id);
}
// Set and query the database.
$db->setQuery($query);
$duplicate = (bool) $db->loadResult();
if ($duplicate)
{
return false;
}
}
return true;
}
return false;
}
/**
* get the item by guid in a table
*
* @param string $guid
* @param string $table
* @param string|array $what
* @param string|null $component
*
* @return mixed
*
* @since 3.0.9
*/
public static function item($guid, $table, $what = 'a.id',
?string $component = null)
{
// check if we have a string
// check if table already has this identifier
if (self::validate($guid) && StringHelper::check($table))
{
// check that we have the component code name
if (!is_string($component))
{
$component = (string) Helper::getCode();
}
// Get the database object and a new query object.
$db = Factory::getDbo();
$query = $db->getQuery(true);
if (ArrayHelper::check($what))
{
$query->select($db->quoteName($what));
}
else
{
$query->select($what);
}
$query->from($db->quoteName('#__' . (string) $component
. '_' . (string) $table, 'a'))
->where($db->quoteName('a.guid') . ' = ' .
$db->quote($guid));
// Set and query the database.
$db->setQuery($query);
$db->execute();
if ($db->getNumRows())
{
if (ArrayHelper::check($what) || $what === 'a.*')
{
return $db->loadObject();
}
else
{
return $db->loadResult();
}
}
}
return null;
}
/**
* Validate the Globally Unique Identifier
*
* Thanks to Lewie
* https://stackoverflow.com/a/1515456/1429677
*
* @param string $guid
*
* @return bool
*
* @since 3.0.9
*/
protected static function validate($guid)
{
// check if we have a string
if (StringHelper::check($guid))
{
return
preg_match("/^(\{)?[a-f\d]{8}(-[a-f\d]{4}){4}[a-f\d]{8}(?(1)\})$/i",
$guid);
}
return false;
}
}
src/Utilities/index.html000064400000000054151162054060011302
0ustar00<html><body
bgcolor="#FFFFFF"></body></html>src/Utilities/JsonHelper.php000064400000004303151162054060012070
0ustar00<?php
/**
* @package Joomla.Component.Builder
*
* @created 3rd September, 2020
* @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\Utilities;
/**
* The json checker
*
* @since 3.0.9
*/
abstract class JsonHelper
{
/**
* Check if you have a json string
*
* @input string $string The json string to check
*
* @returns bool true on success
*
* @since 3.0.9
*/
public static function check($string): bool
{
if (StringHelper::check($string))
{
json_decode((string) $string);
return (json_last_error() === JSON_ERROR_NONE);
}
return false;
}
/**
* Convert a json object to a string
*
* @input string $value The json string to convert
*
* @returns a string
*
* @since 3.0.9
*/
public static function string($value, $separator = ", ", $table
= null, $id = 'id', $name = 'name')
{
// do some table foot work
$external = false;
if (is_string($table) && strpos((string) $table, '#__')
!== false)
{
$external = true;
$table = str_replace('#__', '', (string) $table);
}
// check if string is JSON
$result = json_decode((string) $value, true);
if (json_last_error() === JSON_ERROR_NONE)
{
// is JSON
if (ArrayHelper::check($result))
{
if (StringHelper::check($table))
{
$names = [];
foreach ($result as $val)
{
if ($external)
{
if ($_name = GetHelper::var(null, $val, $id, $name, '=',
$table))
{
$names[] = $_name;
}
}
else
{
if ($_name = GetHelper::var($table, $val, $id, $name))
{
$names[] = $_name;
}
}
}
if (ArrayHelper::check($names))
{
return (string) implode($separator, $names);
}
}
return (string) implode($separator, $result);
}
return (string) json_decode((string) $value);
}
return $value;
}
}
src/Utilities/MathHelper.php000064400000004623151162054060012055
0ustar00<?php
/**
* @package Joomla.Component.Builder
*
* @created 3rd September, 2020
* @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\Utilities;
/**
* Basic Math Helper
*
* @since 3.0.9
*/
abstract class MathHelper
{
/**
* bc math wrapper (very basic not for accounting)
*
* @param string $type The type bc math
* @param int $val1 The first value
* @param int $val2 The second value
* @param int $scale The scale value
*
* @return string|int|null|bool
*
* @since 3.0.9
*/
public static function bc($type, $val1, $val2, $scale = 0)
{
// Validate input
if (!is_numeric($val1) || !is_numeric($val2))
{
return null;
}
// Build function name
$function = 'bc' . $type;
// Use the bcmath function if available
if (is_callable($function))
{
return $function($val1, $val2, $scale);
}
// if function does not exist we use +-*/ operators (fallback - not
ideal)
switch ($type)
{
case 'mul':
return (string) round($val1 * $val2, $scale);
case 'div':
if ($val2 == 0) return null; // Avoid division by zero
return (string) round($val1 / $val2, $scale);
case 'add':
return (string) round($val1 + $val2, $scale);
case 'sub':
return (string) round($val1 - $val2, $scale);
case 'pow':
return (string) round(pow($val1, $val2), $scale);
case 'comp':
$diff = round($val1 - $val2, $scale);
return ($diff > 0) ? 1 : (($diff < 0) ? -1 : 0);
}
return null;
}
/**
* Basic sum of an array with more precision
*
* @param array $array The values to sum
* @param int $scale The scale value
*
* @return float
*
* @since 3.0.9
*/
public static function sum($array, $scale = 4)
{
// use the bcadd function if available
if (function_exists('bcadd'))
{
// set the start value
$value = 0.0;
// loop the values and run bcadd
foreach($array as $val)
{
$value = bcadd($value, (string) $val, $scale);
}
return $value;
}
// fall back on array sum
return array_sum($array);
}
}
src/Utilities/ObjectHelper.php000064400000004763151162054060012377
0ustar00<?php
/**
* @package Joomla.Component.Builder
*
* @created 3rd September, 2020
* @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\Utilities;
/**
* Some object tricks
*
* @since 3.0.9
*/
abstract class ObjectHelper
{
/**
* Check if have an object with a length
*
* @input object The object to check
*
* @returns bool true on success
*
* @since 3.0.9
*/
public static function check($object)
{
if (is_object($object))
{
return count((array) $object) > 0;
}
return false;
}
/**
* Checks if two objects are equal by comparing their properties and
values.
*
* This method converts both input objects to
* associative arrays, sorts the arrays by keys,
* and compares these sorted arrays.
*
* If the arrays are identical, the objects are considered equal.
*
* @param object|null $obj1 The first object to compare.
* @param object|null $obj2 The second object to compare.
*
* @return bool True if the objects are equal, false otherwise.
* @since 5.0.2
*/
public static function equal(?object $obj1, ?object $obj2): bool
{
// if any is null we return false as that means there is a none object
// we are not comparing null but objects
// but we allow null as some objects while
// not instantiate are still null
if (is_null($obj1) || is_null($obj2))
{
return false;
}
// Convert both objects to associative arrays
$array1 = json_decode(json_encode($obj1), true);
$array2 = json_decode(json_encode($obj2), true);
// Sort the arrays by keys
self::recursiveKsort($array1);
self::recursiveKsort($array2);
// Compare the sorted arrays
return $array1 === $array2;
}
/**
* Recursively sorts an associative array by keys.
*
* This method will sort an associative array by its keys at all levels.
*
* @param array &$array The array to sort.
*
* @return void
* @since 5.0.2
*/
protected static function recursiveKsort(array &$array): void
{
// Sort the array by its keys
ksort($array);
// Recursively sort nested arrays
foreach ($array as &$value)
{
if (is_array($value))
{
self::recursiveKsort($value);
}
}
}
}
src/Utilities/String/ClassfunctionHelper.php000064400000002135151162054060015241
0ustar00<?php
/**
* @package Joomla.Component.Builder
*
* @created 3rd September, 2020
* @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\Utilities\String;
use VDM\Joomla\Utilities\StringHelper;
/**
* Control the naming of a class and function
*
* @since 3.0.9
*/
abstract class ClassfunctionHelper
{
/**
* Making class or function name safe
*
* @input string The name you would like to make safe
*
* @returns string on success
*
* @since 3.0.9
*/
public static function safe($name): string
{
// remove numbers if the first character is a number
if (is_numeric(substr((string) $name, 0, 1)))
{
$name = StringHelper::numbers($name);
}
// remove all spaces and strange characters
return trim(preg_replace("/[^A-Za-z0-9_-]/", '',
(string) $name));
}
}
src/Utilities/String/ComponentCodeNameHelper.php000064400000002703151162054060015765
0ustar00<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September, 2020
* @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\Utilities\String;
/**
* Control the naming of a component code name
*
* @since 3.2.1
*/
abstract class ComponentCodeNameHelper
{
/**
* Making component code name safe for namespacing.
*
* This function processes a given string to format it according to PHP
namespace naming conventions.
* ensures no spaces or underscores are present.
*
* @param string $string The component code name string to make
safe
*
* @return string A namespace-safe string on success
* @since 3.2.1
*/
public static function safe(string $string): string
{
// Trim whitespace from both ends of the string
$string = trim($string);
// Replace any sequence of non-alphanumeric characters or underscores
with a single underscore
$string = preg_replace('/[^\p{L}\p{N}]+/u', '',
$string);
// Ensure the first character is uppercase (useful if the input string
started with an invalid character)
$string = ucfirst($string);
// Return the namespace-safe component code name
return $string;
}
}
src/Utilities/String/FieldHelper.php000064400000004707151162054060013460
0ustar00<?php
/**
* @package Joomla.Component.Builder
*
* @created 3rd September, 2020
* @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\Utilities\String;
use VDM\Joomla\Utilities\StringHelper;
use VDM\Joomla\Utilities\Component\Helper;
/**
* Control the naming of a field
*
* @since 3.0.9
*/
abstract class FieldHelper
{
/**
* The field builder switch
*
* @since 3.0.9
*/
protected static $builder = false;
/**
* Making field names safe
*
* @input string The string you would like to make safe
* @input boolean The switch to return an ALL UPPER CASE string
* @input string The string to use in white space
*
* @returns string on success
*
* @since 3.0.9
*/
public static function safe($string, $allcap = false, $spacer =
'_')
{
// get global value
if (self::$builder === false)
{
self::$builder =
Helper::getParams()->get('field_name_builder', 1);
}
// use the new convention
if (2 == self::$builder)
{
// 0nly continue if we have a string
if (StringHelper::check($string))
{
// check that the first character is not a number
if (is_numeric(substr((string)$string, 0, 1)))
{
$string = StringHelper::numbers($string);
}
// remove all other strange characters
$string = trim((string) $string);
$string = preg_replace('/'.$spacer.'+/', '
', $string);
$string = preg_replace('/\s+/', ' ', $string);
// Transliterate string
$string = StringHelper::transliterate($string);
// remove all and keep only characters and numbers
$string = preg_replace("/[^A-Za-z0-9 ]/", '',
(string) $string);
// replace white space with underscore (SAFEST OPTION)
$string = preg_replace('/\s+/', (string) $spacer, $string);
// return all caps
if ($allcap)
{
return strtoupper($string);
}
// default is to return lower
return strtolower($string);
}
// not a string
return '';
}
// return all caps
if ($allcap)
{
return StringHelper::safe($string, 'U');
}
// use the default (original behavior/convention)
return StringHelper::safe($string);
}
}
src/Utilities/String/index.html000064400000000054151162054070012551
0ustar00<html><body
bgcolor="#FFFFFF"></body></html>src/Utilities/String/NamespaceHelper.php000064400000003771151162054070014332
0ustar00<?php
/**
* @package Joomla.Component.Builder
*
* @created 3rd September, 2020
* @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\Utilities\String;
use VDM\Joomla\Utilities\StringHelper;
/**
* Control the naming of a namespace helper
*
* @since 3.0.9
*/
abstract class NamespaceHelper
{
/**
* Making namespace safe
*
* @param string $string The namespace string you would like to make
safe
*
* @return string on success
* @since 3.0.9
*/
public static function safe(string $string): string
{
// Remove leading and trailing backslashes
$string = trim($string, '\\');
// Split the string into namespace segments
$segments = explode('\\', $string);
// make each segment safe
$segments = array_map([self::class, 'safeSegment'],
$segments);
// Join the namespace segments back together
return implode('\\', $segments);
}
/**
* Making one namespace segment safe
*
* @param string $string The namespace segment string you would like
to make safe
*
* @return string on success
* @since 3.0.9
*/
public static function safeSegment(string $string): string
{
// Check if segment starts with a number
if (preg_match("/^\d/", $string))
{
// Extract the starting number(s)
preg_match("/^\d+/", $string, $matches);
if (isset($matches[0]))
{
$numberWord = StringHelper::numbers($matches[0]);
$string = str_replace($matches[0], $numberWord, $string);
}
}
// Transliterate string TODO: look again as this makes it lowercase
// $segment = StringHelper::transliterate($segment);
// Make sure segment only contains valid characters
return preg_replace("/[^A-Za-z0-9]/", '', $string);
}
}
src/Utilities/String/PluginHelper.php000064400000005143151162054070013667
0ustar00<?php
/**
* @package Joomla.Component.Builder
*
* @created 3rd September, 2020
* @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\Utilities\String;
/**
* Control the naming of a plugin
*
* @since 3.0.9
*/
abstract class PluginHelper
{
/**
* Making plugin folder name safe
*
* @input string $codeName The name
* @input string $group The group name
*
* @returns string on success
*
* @since 3.0.9
*/
public static function safeFolderName(string $codeName, string $group):
string
{
// editors-xtd group plugins must have a class with
plgButton<PluginName> structure
if ($group === 'editors-xtd')
{
$group = 'Button';
}
return 'plg_' . strtolower($group) . '_' .
strtolower(
$codeName
);
}
/**
* Making plugin class name safe
*
* @input string $codeName The name
* @input string $group The group name
*
* @returns string on success
*
* @since 3.0.9
*/
public static function safeClassName(string $codeName, string $group):
string
{
// editors-xtd group plugins must have a class with
plgButton<PluginName> structure
if ($group === 'editors-xtd')
{
$group = 'Button';
}
return 'Plg' . ucfirst($group) . ucfirst(
$codeName
);
}
/**
* Making plugin install class name safe
*
* @input string $codeName The name
* @input string $group The group name
*
* @returns string on success
*
* @since 3.0.9
*/
public static function safeInstallClassName(string $codeName, string
$group): string
{
// editors-xtd group plugins must have a class with
plgButton<PluginName> structure
if ($group === 'editors-xtd')
{
$group = 'Button';
}
return 'plg' . ucfirst($group) . ucfirst(
$codeName
) . 'InstallerScript';
}
/**
* Making language prefix safe
*
* @input string $codeName The name
* @input string $group The group name
*
* @returns string on success
*
* @since 3.0.9
*/
public static function safeLangPrefix(string $codeName, string $group):
string
{
// editors-xtd group plugins must have a class with
plgButton<PluginName> structure
if ($group === 'editors-xtd')
{
$group = 'Button';
}
return 'PLG_' . strtoupper($group) . '_' .
strtoupper(
$codeName
);
}
}
src/Utilities/String/TypeHelper.php000064400000003775151162054070013363
0ustar00<?php
/**
* @package Joomla.Component.Builder
*
* @created 3rd September, 2020
* @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\Utilities\String;
use Joomla\CMS\Component\ComponentHelper;
use VDM\Joomla\Utilities\StringHelper;
use VDM\Joomla\Utilities\Component\Helper;
/**
* Control the naming of a field type
*
* @since 3.0.9
*/
abstract class TypeHelper
{
/**
* The field builder switch
*
* @since 3.0.9
*/
protected static $builder = false;
/**
* Making field type name safe
*
* @param String $string The you would like to make safe
* @param String $option The option for the component.
*
* @returns string on success
*
* @since 3.0.9
*/
public static function safe($string, $option = null)
{
// get global value
if (self::$builder === false)
{
self::$builder =
Helper::getParams($option)->get('type_name_builder', 1);
}
// use the new convention
if (2 == self::$builder)
{
// 0nly continue if we have a string
if (StringHelper::check($string))
{
// check that the first character is not a number
if (is_numeric(substr($string, 0, 1)))
{
$string = StringHelper::numbers($string);
}
// Transliterate string
$string = StringHelper::transliterate($string);
// remove all and keep only characters and numbers and point (TODO just
one point)
$string = trim(preg_replace("/[^A-Za-z0-9_\.]/",
'', (string) $string));
// best is to return lower (for all string equality in compiler)
return strtolower($string);
}
// not a string
return '';
}
// use the default (original behaviour/convention)
return StringHelper::safe($string);
}
}
src/Utilities/StringHelper.php000064400000023677151162054070012445
0ustar00<?php
/**
* @package Joomla.Component.Builder
*
* @created 3rd September, 2020
* @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\Utilities;
use Joomla\Filter\InputFilter;
use Joomla\CMS\Language\Language;
use VDM\Joomla\Utilities\Component\Helper;
/**
* Some string tricks
*
* @since 3.0.9
*/
abstract class StringHelper
{
/**
* The Main Active Language
*
* @var string
*
* @since 3.0.9
*/
public static $langTag;
/**
* Check if we have a string with a length
*
* @input string $string The string to check
*
* @returns bool true on success
*
* @since 3.0.9
*/
public static function check($string): bool
{
return is_string($string) && strlen($string) > 0;
}
/**
* Shorten a string
*
* @input string The sting that you would like to shorten
*
* @returns string on success
*
* @since 3.2.0
*/
public static function shorten($string, $length = 40, $addTip = true)
{
if (self::check($string))
{
$initial = strlen((string) $string);
$words = preg_split('/([\s\n\r]+)/', (string) $string, -1,
PREG_SPLIT_DELIM_CAPTURE);
$words_count = count((array)$words);
$word_length = 0;
$last_word = 0;
for (; $last_word < $words_count; ++$last_word)
{
$word_length += strlen($words[$last_word]);
if ($word_length > $length)
{
break;
}
}
$newString = implode(array_slice($words, 0, $last_word));
$final = strlen($newString);
if ($initial !== $final && $addTip)
{
$title = self::shorten($string, 400 , false);
return '<span class="hasTip" title="' .
$title . '" style="cursor:help">' .
trim($newString) . '...</span>';
}
elseif ($initial !== $final && !$addTip)
{
return trim($newString) . '...';
}
}
return $string;
}
/**
* Making strings safe (various ways)
*
* @input string The you would like to make safe
*
* @returns string on success
*
* @since 3.0.9
*/
public static function safe($string, $type = 'L', $spacer =
'_', $replaceNumbers = true, $keepOnlyCharacters = true)
{
if ($replaceNumbers === true)
{
// remove all numbers and replace with English text version (works well
only up to millions)
$string = self::numbers($string);
}
// 0nly continue if we have a string
if (self::check($string))
{
// create file name without the extension that is safe
if ($type === 'filename')
{
// make sure VDM is not in the string
$string = str_replace('VDM', 'vDm', (string)
$string);
// Remove anything which isn't a word, whitespace, number
// or any of the following caracters -_()
// If you don't need to handle multi-byte characters
// you can use preg_replace rather than mb_ereg_replace
// Thanks @Łukasz Rysiak!
// $string = mb_ereg_replace("([^\w\s\d\-_\(\)])",
'', $string);
$string = preg_replace("([^\w\s\d\-_\(\)])", '',
$string);
// http://stackoverflow.com/a/2021729/1429677
return preg_replace('/\s+/', ' ', (string)
$string);
}
// remove all other characters
$string = trim((string) $string);
$string = preg_replace('/'.$spacer.'+/', '
', $string);
$string = preg_replace('/\s+/', ' ', $string);
// Transliterate string
$string = self::transliterate($string);
// remove all and keep only characters
if ($keepOnlyCharacters)
{
$string = preg_replace("/[^A-Za-z ]/", '', (string)
$string);
}
// keep both numbers and characters
else
{
$string = preg_replace("/[^A-Za-z0-9 ]/", '',
(string) $string);
}
// select final adaptations
if ($type === 'L' || $type === 'strtolower')
{
// replace white space with underscore
$string = preg_replace('/\s+/', (string) $spacer, (string)
$string);
// default is to return lower
return strtolower($string);
}
elseif ($type === 'W')
{
// return a string with all first letter of each word uppercase(no
underscore)
return ucwords(strtolower($string));
}
elseif ($type === 'w' || $type === 'word')
{
// return a string with all lowercase(no underscore)
return strtolower($string);
}
elseif ($type === 'Ww' || $type === 'Word')
{
// return a string with first letter of the first word uppercase and
all the rest lowercase(no underscore)
return ucfirst(strtolower($string));
}
elseif ($type === 'WW' || $type === 'WORD')
{
// return a string with all the uppercase(no underscore)
return strtoupper($string);
}
elseif ($type === 'U' || $type === 'strtoupper')
{
// replace white space with underscore
$string = preg_replace('/\s+/', (string) $spacer, $string);
// return all upper
return strtoupper($string);
}
elseif ($type === 'F' || $type === 'ucfirst')
{
// replace white space with underscore
$string = preg_replace('/\s+/', (string) $spacer, $string);
// return with first character to upper
return ucfirst(strtolower($string));
}
elseif ($type === 'cA' || $type === 'cAmel' || $type
=== 'camelcase')
{
// convert all words to first letter uppercase
$string = ucwords(strtolower($string));
// remove white space
$string = preg_replace('/\s+/', '', $string);
// now return first letter lowercase
return lcfirst($string);
}
// return string
return $string;
}
// not a string
return '';
}
/**
* Convert none English strings to code usable string
*
* @input an string
*
* @returns a string
*
* @since 3.0.9
*/
public static function transliterate($string)
{
// set tag only once
if (!self::check(self::$langTag))
{
// get global value
self::$langTag = Helper::getParams()->get('language',
'en-GB');
}
// Transliterate on the language requested
$lang = Language::getInstance(self::$langTag);
return $lang->transliterate($string);
}
/**
* make sure a string is HTML save
*
* @input an html string
*
* @returns a string
*
* @since 3.0.9
*/
public static function html($var, $charset = 'UTF-8', $shorten =
false, $length = 40, $addTip = true)
{
if (self::check($var))
{
$filter = new InputFilter();
$string = $filter->clean(
html_entity_decode(
htmlentities(
(string) $var,
ENT_COMPAT,
$charset
)
),
'HTML'
);
if ($shorten)
{
return self::shorten($string, $length, $addTip);
}
return $string;
}
else
{
return '';
}
}
/**
* Convert all int in a string to an English word string
*
* @input an string with numbers
*
* @returns a string
*
* @since 3.0.9
*/
public static function numbers($string)
{
// set numbers array
$numbers = [];
$search_replace= [];
// first get all numbers
preg_match_all('!\d+!', (string) $string, $numbers);
// check if we have any numbers
if (isset($numbers[0]) && ArrayHelper::check($numbers[0]))
{
foreach ($numbers[0] as $number)
{
$search_replace[$number] = self::number((int)$number);
}
// now replace numbers in string
$string = str_replace(array_keys($search_replace),
array_values($search_replace), (string) $string);
// check if we missed any, strange if we did.
return self::numbers($string);
}
// return the string with no numbers remaining.
return $string;
}
/**
* Convert an integer into an English word string
* Thanks to Tom Nicholson
<http://php.net/manual/en/function.strval.php#41988>
*
* @input an int
* @returns a string
*
* @since 3.0.9
*/
public static function number($x)
{
$nwords = array( "zero", "one", "two",
"three", "four", "five", "six",
"seven",
"eight", "nine", "ten",
"eleven", "twelve", "thirteen",
"fourteen", "fifteen", "sixteen",
"seventeen", "eighteen",
"nineteen", "twenty", 30 => "thirty",
40 => "forty",
50 => "fifty", 60 => "sixty", 70 =>
"seventy", 80 => "eighty",
90 => "ninety" );
if(!is_numeric($x))
{
$w = $x;
}
elseif(fmod($x, 1) != 0)
{
$w = $x;
}
else
{
if($x < 0)
{
$w = 'minus ';
$x = -$x;
}
else
{
$w = '';
// ... now $x is a non-negative integer.
}
if($x < 21) // 0 to 20
{
$w .= $nwords[$x];
}
elseif($x < 100) // 21 to 99
{
$w .= $nwords[10 * floor($x/10)];
$r = fmod($x, 10);
if($r > 0)
{
$w .= ' ' . $nwords[$r];
}
}
elseif($x < 1000) // 100 to 999
{
$w .= $nwords[floor($x/100)] .' hundred';
$r = fmod($x, 100);
if($r > 0)
{
$w .= ' and '. self::number($r);
}
}
elseif($x < 1000000) // 1000 to 999999
{
$w .= self::number(floor($x/1000)) .' thousand';
$r = fmod($x, 1000);
if($r > 0)
{
$w .= ' ';
if($r < 100)
{
$w .= 'and ';
}
$w .= self::number($r);
}
}
else // millions
{
$w .= self::number(floor($x/1000000)) .' million';
$r = fmod($x, 1000000);
if($r > 0)
{
$w .= ' ';
if($r < 100)
{
$w .= 'and ';
}
$w .= self::number($r);
}
}
}
return $w;
}
/**
* Random Key
*
* @input int $size The size of the random string
*
* @returns a string
* @since 3.0.9
*/
public static function random(int $size): string
{
$bag =
"abcefghijknopqrstuwxyzABCDDEFGHIJKLLMMNOPQRSTUVVWXYZabcddefghijkllmmnopqrstuvvwxyzABCEFGHIJKNOPQRSTUWXYZ";
$key = [];
$bagsize = strlen($bag) - 1;
for ($i = 0; $i < $size; $i++)
{
$get = rand(0, $bagsize);
$key[] = $bag[$get];
}
return implode($key);
}
}
src/Componentbuilder/Abstraction/BaseConfig.php000064400000003014151162054070015625
0ustar00<?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\Abstraction;
use Joomla\Registry\Registry as JoomlaRegistry;
use Joomla\CMS\Factory;
use Joomla\Input\Input;
use VDM\Joomla\Utilities\Component\Helper;
use VDM\Joomla\Utilities\String\ClassfunctionHelper;
use VDM\Joomla\Abstraction\BaseConfig as ExtendingBaseConfig;
/**
* Config
*
* @since 3.2.0
*/
abstract class BaseConfig extends ExtendingBaseConfig
{
/**
* Hold a JInput object for easier access to the input variables.
*
* @var Input
* @since 3.2.0
*/
protected Input $input;
/**
* The Params
*
* @var JoomlaRegistry
* @since 3.2.0
*/
protected JoomlaRegistry $params;
/**
* Constructor
*
* @param Input|null $input Input
* @param Registry|null $params The component parameters
*
* @throws \Exception
* @since 3.2.0
*/
public function __construct(?Input $input = null, ?JoomlaRegistry $params
= null)
{
$this->input = $input ?: Factory::getApplication()->input;
$this->params = $params ?:
Helper::getParams('com_componentbuilder');
// run parent constructor
parent::__construct();
}
}
src/Componentbuilder/Abstraction/BaseRegistry.php000064400000006107151162054070016236
0ustar00<?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\Abstraction;
use Joomla\Registry\Registry as JoomlaRegistry;
/**
* Registry
*
* So we have full control over this class
*
* @since 3.2.0
*/
abstract class BaseRegistry extends JoomlaRegistry implements
\JsonSerializable, \ArrayAccess, \IteratorAggregate, \Countable
{
/**
* Method to iterate over any part of the registry
*
* @param string $path Registry path (e.g. joomla.content.showauthor)
*
* @return \ArrayIterator|null This object represented as an
ArrayIterator.
*
* @since 3.4.0
*/
public function _(string $path): ?\ArrayIterator
{
$data = $this->extract($path);
if ($data === null)
{
return null;
}
return $data->getIterator();
}
/**
* Append value to a path in registry of an array
*
* @param string $path Parent registry Path (e.g.
joomla.content.showauthor)
* @param mixed $value Value of entry
*
* @return mixed The value of the that has been set.
*
* @since 3.2.0
*/
public function appendArray(string $path, $value)
{
// check if it does not exist
if (!$this->exists($path))
{
$this->set($path, []);
}
return $this->append($path, $value);
}
/**
* Check if a registry path exists and is an array
*
* @param string $path Registry path (e.g. joomla.content.showauthor)
*
* @return boolean
*
* @since 3.2.0
*/
public function isArray(string $path): bool
{
// Return default value if path is empty
if (empty($path)) {
return false;
}
// get the value
if (($node = $this->get($path)) !== null
&& is_array($node)
&& $node !== [])
{
return true;
}
return false;
}
/**
* Check if a registry path exists and is a string
*
* @param string $path Registry path (e.g. joomla.content.showauthor)
*
* @return boolean
*
* @since 3.2.0
*/
public function isString(string $path): bool
{
// Return default value if path is empty
if (empty($path)) {
return false;
}
// get the value
if (($node = $this->get($path)) !== null
&& is_string($node)
&& strlen((string) $node) > 0)
{
return true;
}
return false;
}
/**
* Check if a registry path exists and is numeric
*
* @param string $path Registry path (e.g. joomla.content.showauthor)
*
* @return boolean
*
* @since 3.2.0
*/
public function isNumeric(string $path): bool
{
// Return default value if path is empty
if (empty($path)) {
return false;
}
// get the value
if (($node = $this->get($path)) !== null
&& is_numeric($node))
{
return true;
}
return false;
}
}
src/Componentbuilder/Abstraction/index.html000064400000000054151162054070015112
0ustar00<html><body
bgcolor="#FFFFFF"></body></html>src/Componentbuilder/Compiler/Adminview/Data.php000064400000034057151162054070015735
0ustar00<?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\Adminview;
use Joomla\CMS\Factory;
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\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;
use VDM\Joomla\Componentbuilder\Compiler\Model\Permissions;
use VDM\Joomla\Componentbuilder\Compiler\Model\Conditions;
use VDM\Joomla\Componentbuilder\Compiler\Model\Relations;
use VDM\Joomla\Componentbuilder\Compiler\Model\Linkedviews;
use VDM\Joomla\Componentbuilder\Compiler\Model\Javascriptadminview as
Javascript;
use VDM\Joomla\Componentbuilder\Compiler\Model\Cssadminview as Css;
use VDM\Joomla\Componentbuilder\Compiler\Model\Phpadminview as Php;
use VDM\Joomla\Componentbuilder\Compiler\Model\Custombuttons;
use VDM\Joomla\Componentbuilder\Compiler\Model\Customimportscripts;
use VDM\Joomla\Componentbuilder\Compiler\Model\Ajaxadmin as Ajax;
use VDM\Joomla\Componentbuilder\Compiler\Model\Customalias;
use VDM\Joomla\Componentbuilder\Compiler\Model\Sql;
use VDM\Joomla\Componentbuilder\Compiler\Model\Mysqlsettings;
use VDM\Joomla\Componentbuilder\Compiler\Builder\SiteEditView;
use VDM\Joomla\Utilities\StringHelper;
use VDM\Joomla\Utilities\JsonHelper;
use VDM\Joomla\Utilities\ArrayHelper;
/**
* Admin View Data Class
*
* @since 3.2.0
*/
class Data
{
/**
* The Config Class.
*
* @var Config
* @since 3.2.0
*/
protected Config $config;
/**
* The EventInterface Class.
*
* @var Event
* @since 3.2.0
*/
protected Event $event;
/**
* The Placeholder Class.
*
* @var Placeholder
* @since 3.2.0
*/
protected Placeholder $placeholder;
/**
* The Dispenser Class.
*
* @var Dispenser
* @since 3.2.0
*/
protected Dispenser $dispenser;
/**
* The Customtabs Class.
*
* @var Customtabs
* @since 3.2.0
*/
protected Customtabs $customtabs;
/**
* The Tabs Class.
*
* @var Tabs
* @since 3.2.0
*/
protected Tabs $tabs;
/**
* The Fields Class.
*
* @var Fields
* @since 3.2.0
*/
protected Fields $fields;
/**
* The Historyadminview Class.
*
* @var History
* @since 3.2.0
*/
protected History $history;
/**
* The Permissions Class.
*
* @var Permissions
* @since 3.2.0
*/
protected Permissions $permissions;
/**
* The Conditions Class.
*
* @var Conditions
* @since 3.2.0
*/
protected Conditions $conditions;
/**
* The Relations Class.
*
* @var Relations
* @since 3.2.0
*/
protected Relations $relations;
/**
* The Linkedviews Class.
*
* @var Linkedviews
* @since 3.2.0
*/
protected Linkedviews $linkedviews;
/**
* The Javascriptadminview Class.
*
* @var Javascript
* @since 3.2.0
*/
protected Javascript $javascript;
/**
* The Cssadminview Class.
*
* @var Css
* @since 3.2.0
*/
protected Css $css;
/**
* The Phpadminview Class.
*
* @var Php
* @since 3.2.0
*/
protected Php $php;
/**
* The Custombuttons Class.
*
* @var Custombuttons
* @since 3.2.0
*/
protected Custombuttons $custombuttons;
/**
* The Customimportscripts Class.
*
* @var Customimportscripts
* @since 3.2.0
*/
protected Customimportscripts $customimportscripts;
/**
* The Ajaxadmin Class.
*
* @var Ajax
* @since 3.2.0
*/
protected Ajax $ajax;
/**
* The Customalias Class.
*
* @var Customalias
* @since 3.2.0
*/
protected Customalias $customalias;
/**
* The Sql Class.
*
* @var Sql
* @since 3.2.0
*/
protected Sql $sql;
/**
* The Mysqlsettings Class.
*
* @var Mysqlsettings
* @since 3.2.0
*/
protected Mysqlsettings $mysqlsettings;
/**
* The SiteEditView Class.
*
* @var SiteEditView
* @since 3.2.0
*/
protected SiteEditView $siteeditview;
/**
* Database object to query local DB
*
* @since 3.2.0
**/
protected $db;
/**
* Constructor.
*
* @param Config $config The Config Class.
* @param Event $event The EventInterface
Class.
* @param Placeholder $placeholder The Placeholder
Class.
* @param Dispenser $dispenser The Dispenser
Class.
* @param Customtabs $customtabs The Customtabs
Class.
* @param Tabs $tabs The Tabs Class.
* @param Fields $fields The Fields Class.
* @param History $history The
Historyadminview Class.
* @param Permissions $permissions The Permissions
Class.
* @param Conditions $conditions The Conditions
Class.
* @param Relations $relations The Relations
Class.
* @param Linkedviews $linkedviews The Linkedviews
Class.
* @param Javascript $javascript The
Javascriptadminview Class.
* @param Css $css The Cssadminview
Class.
* @param Php $php The Phpadminview
Class.
* @param Custombuttons $custombuttons The Custombuttons
Class.
* @param Customimportscripts $customimportscripts The
Customimportscripts Class.
* @param Ajax $ajax The Ajaxadmin
Class.
* @param Customalias $customalias The Customalias
Class.
* @param Sql $sql The Sql Class.
* @param Mysqlsettings $mysqlsettings The Mysqlsettings
Class.
* @param SiteEditView $siteeditview The SiteEditView
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)
{
$this->config = $config;
$this->event = $event;
$this->placeholder = $placeholder;
$this->dispenser = $dispenser;
$this->customtabs = $customtabs;
$this->tabs = $tabs;
$this->fields = $fields;
$this->history = $history;
$this->permissions = $permissions;
$this->conditions = $conditions;
$this->relations = $relations;
$this->linkedviews = $linkedviews;
$this->javascript = $javascript;
$this->css = $css;
$this->php = $php;
$this->custombuttons = $custombuttons;
$this->customimportscripts = $customimportscripts;
$this->ajax = $ajax;
$this->customalias = $customalias;
$this->sql = $sql;
$this->mysqlsettings = $mysqlsettings;
$this->siteeditview = $siteeditview;
$this->db = Factory::getDbo();
}
/**
* Get Admin View Data
*
* @param int $id The view ID
*
* @return object|null The view data
* @since 3.2.0
*/
public function get(int $id): ?object
{
if (!isset($this->data[$id]))
{
// Create a new query object.
$query = $this->db->getQuery(true);
$query->select('a.*');
$query->select(
$this->db->quoteName(
array(
'b.addfields',
'b.id',
'c.addconditions',
'c.id',
'r.addrelations',
't.tabs'
), array(
'addfields',
'addfields_id',
'addconditions',
'addconditions_id',
'addrelations',
'customtabs'
)
)
);
$query->from('#__componentbuilder_admin_view AS a');
$query->join(
'LEFT',
$this->db->quoteName('#__componentbuilder_admin_fields',
'b')
. ' ON (' . $this->db->quoteName('a.id') .
' = '
. $this->db->quoteName('b.admin_view') . ')'
);
$query->join(
'LEFT', $this->db->quoteName(
'#__componentbuilder_admin_fields_conditions',
'c'
) . ' ON (' . $this->db->quoteName('a.id') .
' = '
. $this->db->quoteName('c.admin_view') . ')'
);
$query->join(
'LEFT', $this->db->quoteName(
'#__componentbuilder_admin_fields_relations', 'r'
) . ' ON (' . $this->db->quoteName('a.id') .
' = '
. $this->db->quoteName('r.admin_view') . ')'
);
$query->join(
'LEFT', $this->db->quoteName(
'#__componentbuilder_admin_custom_tabs', 't'
) . ' ON (' . $this->db->quoteName('a.id') .
' = '
. $this->db->quoteName('t.admin_view') . ')'
);
$query->where($this->db->quoteName('a.id') . ' =
' . (int) $id);
// Trigger Event: jcb_ce_onBeforeQueryViewData
$this->event->trigger(
'jcb_ce_onBeforeQueryViewData', [&$id, &$query,
&$this->db]
);
// Reset the query using our newly populated query object.
$this->db->setQuery($query);
// Load the results as a list of stdClass objects (see later for more
options on retrieving data).
$view = $this->db->loadObject();
// setup single view code names to use in storing the data
$view->name_single_code = 'oops_hmm_' . $id;
if (isset($view->name_single) && $view->name_single !=
'null')
{
$view->name_single_code = StringHelper::safe(
$view->name_single
);
}
// setup list view code name to use in storing the data
$view->name_list_code = 'oops_hmmm_' . $id;
if (isset($view->name_list) && $view->name_list !=
'null')
{
$view->name_list_code = StringHelper::safe(
$view->name_list
);
}
// check the length of the view name (+5 for com_ and _)
$name_length = $this->config->component_code_name_length +
strlen(
(string) $view->name_single_code
) + 5;
// when the name is larger than 49 we need to add the assets' table
name fix
if ($name_length > 49)
{
$this->config->set('add_assets_table_name_fix', true);
}
// setup token check
if (!isset($this->dispenser->hub['token']))
{
$this->dispenser->hub['token'] = [];
}
$this->dispenser->hub['token'][$view->name_single_code]
= false;
$this->dispenser->hub['token'][$view->name_list_code]
= false;
// set some placeholders
$this->placeholder->set('view',
$view->name_single_code);
$this->placeholder->set('views',
$view->name_list_code);
$this->placeholder->set('View', StringHelper::safe(
$view->name_single, 'F'
));
$this->placeholder->set('Views', StringHelper::safe(
$view->name_list, 'F'
));
$this->placeholder->set('VIEW', StringHelper::safe(
$view->name_single, 'U'
));
$this->placeholder->set('VIEWS', StringHelper::safe(
$view->name_list, 'U'
));
// Trigger Event: jcb_ce_onBeforeModelViewData
$this->event->trigger(
'jcb_ce_onBeforeModelViewData', [&$view]
);
// add the tables
$view->addtables = (isset($view->addtables)
&& JsonHelper::check($view->addtables))
? json_decode((string) $view->addtables, true) : null;
if (ArrayHelper::check($view->addtables))
{
$view->tables = array_values($view->addtables);
}
unset($view->addtables);
// Make sure the icon is only an icon path
if (strpos($view->icon, '#') !== false)
{
$view->icon = strstr($view->icon, '#', true);
}
// Make sure the icon_add is only an icon_add path
if (strpos($view->icon_add, '#') !== false)
{
$view->icon_add = strstr($view->icon_add, '#', true);
}
// Make sure the icon_add is only an icon_add path
if (strpos($view->icon_category, '#') !== false)
{
$view->icon_category = strstr($view->icon_category,
'#', true);
}
// set custom tabs
$this->customtabs->set($view);
// set the local tabs
$this->tabs->set($view);
// set permissions
$this->permissions->set($view);
// set fields
$this->fields->set($view);
// build update SQL
$this->history->set($view);
// set the conditions
$this->conditions->set($view);
// set the relations
$this->relations->set($view);
// set linked views
$this->linkedviews->set($view);
// set the lang target
$this->config->lang_target = 'admin';
if ($this->siteeditview->exists($id))
{
$this->config->lang_target = 'both';
}
// set javascript
$this->javascript->set($view);
// set css
$this->css->set($view);
// set php
$this->php->set($view);
// set custom buttons
$this->custombuttons->set($view);
// set custom import scripts
$this->customimportscripts->set($view);
// set Ajax for this view
$this->ajax->set($view);
// activate alias builder
$this->customalias->set($view);
// set sql
$this->sql->set($view);
// set mySql Table Settings
$this->mysqlsettings->set($view);
// Trigger Event: jcb_ce_onAfterModelViewData
$this->event->trigger(
'jcb_ce_onAfterModelViewData', [&$view]
);
// clear placeholders
$this->placeholder->remove('view');
$this->placeholder->remove('views');
$this->placeholder->remove('View');
$this->placeholder->remove('Views');
$this->placeholder->remove('VIEW');
$this->placeholder->remove('VIEWS');
// store this view to class object
$this->data[$id] = $view;
}
// return the found view data
return $this->data[$id];
}
}
src/Componentbuilder/Compiler/Adminview/Permission.php000064400000005754151162054070017216
0ustar00<?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\Adminview;
use VDM\Joomla\Componentbuilder\Compiler\Builder\HasPermissions;
use VDM\Joomla\Utilities\ArrayHelper;
/**
* Admin View Permission Class
*
* @since 3.2.0
*/
final class Permission
{
/**
* The HasPermissions Class.
*
* @var HasPermissions
* @since 3.2.0
*/
protected HasPermissions $haspermissions;
/**
* Constructor.
*
* @param HasPermissions $haspermissions The HasPermissions Class.
*
* @since 3.2.0
*/
public function __construct(HasPermissions $haspermissions)
{
$this->haspermissions = $haspermissions;
}
/**
* Check to see if a view has permissions
*
* @param array $view View details
* @param string $nameSingleCode View Single Code Name
*
* @return bool true if it has permissions
* @since 3.2.0
*/
public function check(array &$view, string &$nameSingleCode):
bool
{
// first check if we have checked this already
if (!$this->haspermissions->exists($nameSingleCode))
{
// when a view has history, it has permissions
// since it tracks the version access
if (isset($view['history']) &&
$view['history'] == 1)
{
// set the permission for later
$this->haspermissions->set($nameSingleCode, true);
// break out here
return true;
}
// check if the view has permissions
if (isset($view['settings'])
&& ArrayHelper::check(
$view['settings']->permissions, true
))
{
foreach ($view['settings']->permissions as $per)
{
// check if the permission targets the view
// 1 = view
// 3 = both view & component
if (isset($per['implementation'])
&& (
$per['implementation'] == 1
|| $per['implementation'] == 3
))
{
// set the permission for later
$this->haspermissions->set($nameSingleCode, true);
// break out here
return true;
}
}
}
// check if the fields has permissions
if (isset($view['settings'])
&& ArrayHelper::check(
$view['settings']->fields, true
))
{
foreach ($view['settings']->fields as $field)
{
// if a field has any permissions
// the a view has permissions
if (isset($field['permission'])
&& ArrayHelper::check(
$field['permission'], true
))
{
// set the permission for later
$this->haspermissions->set($nameSingleCode, true);
// break out here
return true;
}
}
}
}
return $this->haspermissions->exists($nameSingleCode);
}
}
src/Componentbuilder/Compiler/Adminview/index.html000064400000000054151162054070016336
0ustar00<html><body
bgcolor="#FFFFFF"></body></html>src/Componentbuilder/Compiler/Alias/Data.php000064400000015352151162054070015040
0ustar00<?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\Alias;
use Joomla\CMS\Factory;
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\Customcode;
use VDM\Joomla\Componentbuilder\Compiler\Customcode\Gui;
use VDM\Joomla\Componentbuilder\Compiler\Model\Loader;
use VDM\Joomla\Componentbuilder\Compiler\Model\Libraries;
use VDM\Joomla\Utilities\ArrayHelper;
use VDM\Joomla\Utilities\StringHelper;
/**
* Alias Data Class
*
* @since 3.2.0
*/
class Data
{
/**
* Compiler Config
*
* @var Config
* @since 3.2.0
*/
protected Config $config;
/**
* The compiler registry
*
* @var Registry
* @since 3.2.0
*/
protected Registry $registry;
/**
* Compiler Customcode
*
* @var Customcode
* @since 3.2.0
*/
protected Customcode $customcode;
/**
* Compiler Customcode in Gui
*
* @var Gui
* @since 3.2.0
**/
protected Gui $gui;
/**
* Compiler Auto Loader
*
* @var Loader
* @since 3.2.0
*/
protected Loader $loader;
/**
* Compiler Libraries Model
*
* @var Libraries
* @since 3.2.0
*/
protected Libraries $libraries;
/**
* Database object to query local DB
*
* @since 3.2.0
**/
protected $db;
/**
* Constructor
*
* @param Config|null $config The compiler config
object.
* @param Registry|null $registry The compiler
registry object.
* @param Customcode|null $customcode The compiler
customcode object.
* @param Gui|null $gui The compiler
customcode gui.
* @param Loader|null $load The compiler loader
object.
* @param Libraries|null $libraries The compiler
libraries model object.
* @param \JDatabaseDriver|null $db The database
object.
*
* @since 3.2.0
*/
public function __construct(?Config $config = null, ?Registry $registry =
null,
?Customcode $customcode = null, ?Gui $gui = null,
?Loader $loader = null, ?Libraries $libraries = null)
{
$this->config = $config ?: Compiler::_('Config');
$this->registry = $registry ?: Compiler::_('Registry');
$this->customcode = $customcode ?:
Compiler::_('Customcode');
$this->gui = $gui ?: Compiler::_('Customcode.Gui');
$this->loader = $loader ?: Compiler::_('Model.Loader');
$this->libraries = $libraries ?:
Compiler::_('Model.Libraries');
$this->db = Factory::getDbo();
}
/**
* Get Data by Alias
*
* @param string $alias The alias name
* @param string $table The table where to find the alias
* @param string $view The view code name
*
* @return array|null The data found with the alias
* @since 3.2.0
*/
public function get(string $alias, string $table, string $view): ?array
{
// if not set, get all keys in table and set by ID
$this->set($table);
// now check if key is found
$name = preg_replace("/[^A-Za-z]/", '', $alias);
if (($id =
$this->registry->get('builder.data_with_alias_keys.' .
$table . '.' . $name, null)) === null &&
($id =
$this->registry->get('builder.data_with_alias_keys.' .
$table . '.' . $alias, null)) === null)
{
return null;
}
// Create a new query object.
$query = $this->db->getQuery(true);
$query->select('a.*');
$query->from('#__componentbuilder_' . $table . ' AS
a');
$query->where(
$this->db->quoteName('a.id') . ' = ' . (int)
$id
);
// get the row
$this->db->setQuery($query);
$item = $this->db->loadObject();
// get the other target if both
$targets = [$this->config->build_target];
if ($this->config->lang_target === 'both')
{
$targets = ['site', 'admin'];
}
// we load this layout
$php_view = '';
if ($item->add_php_view == 1
&& StringHelper::check($item->php_view))
{
$php_view = $this->gui->set(
$this->customcode->update(base64_decode((string)
$item->php_view)),
array(
'table' => $table,
'field' => 'php_view',
'id' => (int) $item->id,
'type' => 'php')
);
}
$content = $this->gui->set(
$this->customcode->update(base64_decode((string)
$item->{$table})),
array(
'table' => $table,
'field' => $table,
'id' => (int) $item->id,
'type' => 'html')
);
// load all targets
foreach ($targets as $target)
{
// set libraries
$this->libraries->set($view, $item, $target);
// auto loaders
$this->loader->set($view, $content, $target);
$this->loader->set($view, $php_view, $target);
}
// load uikit version 2 if required
$this->loader->uikit($view, $content);
$this->loader->uikit($view, $php_view);
return [
'id' => $item->id,
'html' => $this->gui->set(
$content,
[
'table' => $table,
'field' => $table,
'id' => $item->id,
'type' => 'html'
]
),
'php_view' => $this->gui->set(
$php_view,
[
'table' => $table,
'field' => 'php_view',
'id' => $item->id,
'type' => 'php'
]
)
];
}
/**
* Load all alias and ID's of a table
*
* @param string $table The table where to find the alias
*
* @return void
* @since 3.2.0
*/
protected function set(string $table)
{
// now check if key is found
if (!$this->registry->get('builder.data_with_alias_keys.'
. $table, null))
{
// Create a new query object.
$query = $this->db->getQuery(true);
$query->select(array('a.id', 'a.alias'));
$query->from('#__componentbuilder_' . $table . ' AS
a');
$this->db->setQuery($query);
$items = $this->db->loadObjectList();
// check if we have an array
if (ArrayHelper::check($items))
{
foreach ($items as $item)
{
// build the key
$k_ey = StringHelper::safe($item->alias);
$key = preg_replace("/[^A-Za-z]/", '', (string)
$k_ey);
// set the keys
$this->registry->
set('builder.data_with_alias_keys.' . $table .
'.' . $item->alias, $item->id);
$this->registry->
set('builder.data_with_alias_keys.' . $table .
'.' . $k_ey, $item->id);
$this->registry->
set('builder.data_with_alias_keys.' . $table .
'.' . $key, $item->id);
}
}
}
}
}
src/Componentbuilder/Compiler/Alias/index.html000064400000000054151162054070015444
0ustar00<html><body
bgcolor="#FFFFFF"></body></html>src/Componentbuilder/Compiler/Architecture/JoomlaFive/ComHelperClass/CreateUser.php000064400000014625151162054070024523
0ustar00<?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\ComHelperClass;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Indent;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Line;
use
VDM\Joomla\Componentbuilder\Compiler\Interfaces\Architecture\ComHelperClass\CreateUserInterface;
/**
* Helper Class Create User Class for Joomla 5
*
* @since 5.0.2
*/
final class CreateUser implements CreateUserInterface
{
/**
* Generates the method definition for creating or updating a user based
on the provided parameters.
*
* This method returns a string representation of a PHP function that
includes various
* steps for handling user creation and updates, depending on the mode
(site registration or admin registration).
*
* @param $add Determines whether to generate the user creation
method or not.
* If true, the method will be generated and returned
as a string.
*
* @return string The generated method code as a string if $add is true.
* Returns an empty string if $add is false.
*/
public function get($add): string
{
if ($add)
{
$method = [];
$method[] = PHP_EOL . PHP_EOL . Indent::_(1) . "/**";
$method[] = Indent::_(1) . " * Save user details by either creating
a new user or updating an existing user.";
$method[] = Indent::_(1) . " *";
$method[] = Indent::_(1)
. " * @param array \$credentials ['name' =>
string, 'username' => string, 'email' => string,
'password' => string, 'password2' =>
string]";
$method[] = Indent::_(1) . " * @param int \$autologin";
$method[] = Indent::_(1)
. " * @param array \$params ['useractivation' =>
int, 'sendpassword' => int, 'allowUserRegistration'
=> int]";
$method[] = Indent::_(1)
. " * @param array \$mode 1 = Site Registrations; 0 = Admin
Registration; 2 = Custom Helper Method Called registerUser";
$method[] = Indent::_(1) . " *";
$method[] = Indent::_(1) . " * @return int User ID on
success";
$method[] = Indent::_(1) . " *";
$method[] = Indent::_(1) . " * @throws \InvalidArgumentException
If required credentials are missing.";
$method[] = Indent::_(1) . " * @throws \RuntimeException
If the user update or creation fails.";
$method[] = Indent::_(1) . " * @throws
Super__"."_1c10a5f1_204d_4f17_ad9f_0e0684f2030d___Power If
the user is not found.";
$method[] = Indent::_(1) . " *";
$method[] = Indent::_(1) . " * @since 3.0.0";
$method[] = Indent::_(1) . " * @deprecated 4.3 Use
Super__"."_7832a726_87b6_4e95_887e_7b725d3fab8f___Power::create(\$credentials,
\$autologin, \$params, \$mode);";
$method[] = Indent::_(1) . " */";
$method[] = Indent::_(1)
. "public static function createUser(\$credentials, \$autologin =
0,";
$method[] = Indent::_(2) . "\$params = [";
$method[] = Indent::_(3)
. "'useractivation' => 0, 'sendpassword'
=> 1";
$method[] = Indent::_(2) . "], \$mode = 1";
$method[] = Indent::_(1) . ")";
$method[] = Indent::_(1) . "{";
$method[] = Indent::_(2) . "//" . Line::_(__Line__,
__Class__)
. " Create a user with the UserHelper class
(Super---7832a726_87b6_4e95_887e_7b725d3fab8f---Power)";
$method[] = Indent::_(2)
. "return
Super__"."_7832a726_87b6_4e95_887e_7b725d3fab8f___Power::create(\$credentials,
\$autologin, \$params, \$mode);";
$method[] = Indent::_(1) . "}";
$method[] = PHP_EOL . PHP_EOL . Indent::_(1) . "/**";
$method[] = Indent::_(1) . " * Update the given component
params.";
$method[] = Indent::_(1) . " *";
$method[] = Indent::_(1) . " * @param string|null \$option The
optional extension element name.";
$method[] = Indent::_(1) . " * @param string \$target The
parameter name to be updated.";
$method[] = Indent::_(1) . " * @param mixed \$value The
value to set for the parameter.";
$method[] = Indent::_(1) . " *";
$method[] = Indent::_(1) . " * @since 3.0.0";
$method[] = Indent::_(1) . " * @deprecated 4.3 Use
Super__"."_640b5352_fb09_425f_a26e_cd44eda03f15___Power::setParams(\$target,
\$value, \$option);";
$method[] = Indent::_(1) . " */";
$method[] = PHP_EOL . Indent::_(1)
. "public static function setParams(\$option, \$target,
\$value)";
$method[] = Indent::_(1) . "{";
$method[] = Indent::_(2) . "//" . Line::_(__Line__,
__Class__)
. " Sets a parameter value for the given target in the specified
option's params";
$method[] = Indent::_(2) . "//" . Line::_(__Line__,
__Class__)
. " (Super---640b5352_fb09_425f_a26e_cd44eda03f15---Power)";
$method[] = Indent::_(2)
. "return
Super__"."_640b5352_fb09_425f_a26e_cd44eda03f15___Power::setParams(\$target,
\$value, \$option);";
$method[] = Indent::_(1) . "}";
$method[] = PHP_EOL . Indent::_(1) . "/**";
$method[] = Indent::_(1) . " * Update user details";
$method[] = Indent::_(1) . " *";
$method[] = Indent::_(1) . " * @param array \$userDetails Array
containing user details to be updated";
$method[] = Indent::_(1) . " *";
$method[] = Indent::_(1) . " * @return int Updated user ID on
success.";
$method[] = Indent::_(1) . " *";
$method[] = Indent::_(1) . " * @throws \RuntimeException If user
update fails.";
$method[] = Indent::_(1) . " *";
$method[] = Indent::_(1) . " * @since 3.0.0";
$method[] = Indent::_(1) . " * @deprecated 4.3 Use
Super__"."_7832a726_87b6_4e95_887e_7b725d3fab8f___Power::update(\$userDetails);";
$method[] = Indent::_(1) . " */";
$method[] = Indent::_(1)
. "public static function updateUser(\$userDetails): int";
$method[] = Indent::_(1) . "{";
$method[] = Indent::_(2)
. "//" . Line::_(__Line__, __Class__)
. " Update user details with the UserHelper class
(Super---7832a726_87b6_4e95_887e_7b725d3fab8f---Power)";
$method[] = Indent::_(2) . "return
Super__"."_7832a726_87b6_4e95_887e_7b725d3fab8f___Power::update(\$userDetails);";
$method[] = Indent::_(1) . "}";
// return the help method
return implode(PHP_EOL, $method);
}
return '';
}
}
src/Componentbuilder/Compiler/Architecture/JoomlaFive/ComHelperClass/index.html000064400000000054151162054070023734
0ustar00<html><body
bgcolor="#FFFFFF"></body></html>src/Componentbuilder/Compiler/Architecture/JoomlaFive/Controller/AllowAdd.php000064400000007336151162054070023430
0ustar00<?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);
}
}
src/Componentbuilder/Compiler/Architecture/JoomlaFive/Controller/AllowEdit.php000064400000027164151162054070023626
0ustar00<?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
);
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);
}
}
src/Componentbuilder/Compiler/Architecture/JoomlaFive/Controller/AllowEditViews.php000064400000015677151162054070024652
0ustar00<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder
<https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights
reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
namespace
VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaFive\Controller;
use VDM\Joomla\Componentbuilder\Compiler\Creator\Permission;
use VDM\Joomla\Componentbuilder\Compiler\Customcode\Dispenser;
use VDM\Joomla\Componentbuilder\Compiler\Builder\Category;
use VDM\Joomla\Componentbuilder\Compiler\Builder\CategoryOtherName;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Indent;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Line;
use
VDM\Joomla\Componentbuilder\Compiler\Interfaces\Architecture\Controller\AllowEditViewsInterface;
/**
* Controller Allow Edit Views Class for Joomla 5
*
* @since 5.0.2
*/
final class AllowEditViews implements AllowEditViewsInterface
{
/**
* The Permission Class.
*
* @var Permission
* @since 5.0.2
*/
protected Permission $permission;
/**
* The Dispenser Class.
*
* @var Dispenser
* @since 5.0.2
*/
protected Dispenser $dispenser;
/**
* The Category Class.
*
* @var Category
* @since 5.0.2
*/
protected Category $category;
/**
* The CategoryOtherName Class.
*
* @var CategoryOtherName
* @since 5.0.2
*/
protected CategoryOtherName $categoryothername;
/**
* Constructor.
*
* @param Permission $permission The Permission Class.
* @param Dispenser $dispenser The Dispenser Class.
* @param Category $category The Category Class.
* @param CategoryOtherName $categoryothername The CategoryOtherName
Class.
*
* @since 5.0.2
*/
public function __construct(Permission $permission,
Dispenser $dispenser, Category $category,
CategoryOtherName $categoryothername)
{
$this->permission = $permission;
$this->dispenser = $dispenser;
$this->category = $category;
$this->categoryothername = $categoryothername;
}
/**
* Get Array Code
*
* @param array $views
*
* @since 5.0.2
* @return string The array of Code (string)
*/
public function getArray(array $views): string
{
$allow = [];
foreach ($views as $nameSingleCode => $nameListCode)
{
$allow[] = $this->getViewArray($nameSingleCode, $nameListCode);
}
if ($allow === [])
{
return '';
}
return PHP_EOL . Indent::_(2) . implode("," . PHP_EOL .
Indent::_(2), $allow);
}
/**
* Get Custom Function Code
*
* @param array $views
*
* @since 5.0.2
* @return string The functions of Code (string)
*/
public function getFunctions(array $views): string
{
$allow = [];
foreach ($views as $nameSingleCode => $nameListCode)
{
if (($function = $this->getViewFunction($nameSingleCode,
$nameListCode)) !== null)
{
$allow[] = $function;
}
}
if ($allow === [])
{
return '';
}
return PHP_EOL . PHP_EOL . implode(PHP_EOL . PHP_EOL, $allow);
}
/**
* Get View Permissions Array Code
*
* @param string $nameSingleCode The single code name of the view.
* @param string $nameListCode The list code name of the view.
*
* @since 3.2.0
* @return string The allow edit method code
*/
protected function getViewArray(string $nameSingleCode, string
$nameListCode): string
{
$allow = [];
// prepare custom permission script
$customAllow = $this->dispenser->get(
'php_allowedit', $nameSingleCode
);
if ($customAllow !== '')
{
$allow[] = Indent::_(3) . "'function' =>
'allowEdit_{$nameSingleCode}'";
}
if ($this->category->exists("{$nameListCode}"))
{
// check if category has another name
$otherView = $this->categoryothername->
get($nameListCode . '.view', $nameSingleCode);
// check if the item has permissions.
if ($this->permission->globalExist($otherView,
'core.access'))
{
$access = $this->permission->getGlobal($otherView,
'core.access');
$allow[] = Indent::_(3) . "'access' =>
'{$access}'";
}
$edit = $this->permission->getAction($otherView,
'core.edit');
$allow[] = Indent::_(3) . "'edit' =>
'{$edit}'";
$edit_own = $this->permission->getAction($otherView,
'core.edit.own');
$allow[] = Indent::_(3) . "'edit.own' =>
'{$edit_own}'";
}
else
{
// check if the item has permissions.
if ($this->permission->actionExist($nameSingleCode,
'core.access'))
{
$access = $this->permission->getAction($nameSingleCode,
'core.access');
$allow[] = Indent::_(3) . "'access' =>
'{$access}'";
}
$edit = $this->permission->getAction($nameSingleCode,
'core.edit');
$allow[] = Indent::_(3) . "'edit' =>
'{$edit}'";
$edit_own = $this->permission->getAction($nameSingleCode,
'core.edit.own');
$allow[] = Indent::_(3) . "'edit.own' =>
'{$edit_own}'";
}
return "'{$nameSingleCode}' => [" . PHP_EOL .
implode(',' . PHP_EOL, $allow) . PHP_EOL . Indent::_(2) .
']';
}
/**
* Get View Permissions Function Code
*
* @param string $nameSingleCode The single code name of the view.
* @param string $nameListCode The list code name of the view.
*
* @since 3.2.0
* @return string|null The allow edit method code
*/
protected function getViewFunction(string $nameSingleCode, string
$nameListCode): ?string
{
$allow = [];
// prepare custom permission script
$customAllow = $this->dispenser->get(
'php_allowedit', $nameSingleCode
);
if ($customAllow !== '')
{
// setup the function
$allow[] = Indent::_(1) . '/**';
$allow[] = Indent::_(1) . " * Method to check if you can edit an
existing {$nameSingleCode} record.";
$allow[] = Indent::_(1) . ' *';
$allow[] = Indent::_(1) . ' * @param array $data An array of
input data.';
$allow[] = Indent::_(1) . ' * @param string $key The name of
the key for the primary key.';
$allow[] = Indent::_(1) . ' *';
$allow[] = Indent::_(1) . ' * @return boolean';
$allow[] = Indent::_(1) . ' *';
$allow[] = Indent::_(1) . ' * @since 5.0.2';
$allow[] = Indent::_(1) . ' */';
$allow[] = Indent::_(1) . "protected function
allowEdit_{$nameSingleCode}(\$data = [], \$key = 'id')";
$allow[] = Indent::_(1) . '{';
$allow[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__)
. " get user object.";
$allow[] = Indent::_(2) . "\$user = \$this->identity;";
$allow[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__)
. " get record id.";
$allow[] = Indent::_(2)
. "\$recordId = (int) isset(\$data[\$key]) ? \$data[\$key] :
0;";
// load custom permission script
$allow[] = $customAllow;
$allow[] = Indent::_(1) . '}';
return implode(PHP_EOL, $allow);
}
return null;
}
}
src/Componentbuilder/Compiler/Architecture/JoomlaFive/Controller/index.html000064400000000054151162054070023213
0ustar00<html><body
bgcolor="#FFFFFF"></body></html>src/Componentbuilder/Compiler/Architecture/JoomlaFive/Model/CanDelete.php000064400000004671151162054070022501
0ustar00<?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);
}
}
src/Componentbuilder/Compiler/Architecture/JoomlaFive/Model/CanEditState.php000064400000006515151162054070023164
0ustar00<?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);
}
}
src/Componentbuilder/Compiler/Architecture/JoomlaFive/Model/index.html000064400000000054151162054070022130
0ustar00<html><body
bgcolor="#FFFFFF"></body></html>src/Componentbuilder/Compiler/Architecture/JoomlaFive/Plugin/Extension.php000064400000015353151162054070023026
0ustar00<?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\Plugin;
use VDM\Joomla\Componentbuilder\Compiler\Placeholder;
use VDM\Joomla\Componentbuilder\Compiler\Builder\ContentOne as Builder;
use VDM\Joomla\Componentbuilder\Power\Parser;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Indent;
use
VDM\Joomla\Componentbuilder\Compiler\Interfaces\Architecture\Plugin\ExtensionInterface;
/**
* Plugin Extension Class for Joomla 5
*
* @since 5.0.2
*/
final class Extension implements ExtensionInterface
{
/**
* The Placeholder Class.
*
* @var Placeholder
* @since 5.0.2
*/
protected Placeholder $placeholder;
/**
* The ContentOne Class.
*
* @var Builder
* @since 5.0.2
*/
protected Builder $builder;
/**
* The Parser Class.
*
* @var Parser
* @since 5.0.2
*/
protected Parser $parser;
/**
* Constructor.
*
* @param Placeholder $placeholder The Placeholder Class.
* @param Builder $builder The Content One Class.
* @param Parser $parser The Parser Class.
*
* @since 5.0.2
*/
public function __construct(Placeholder $placeholder, Builder $builder,
Parser $parser)
{
$this->placeholder = $placeholder;
$this->builder = $builder;
$this->parser = $parser;
}
/**
* Get the updated placeholder content for the given plugin.
*
* @param object $plugin The plugin object containing the necessary
data.
*
* @return string The updated placeholder content.
*
* @since 5.0.2
*/
public function get(object $plugin): string
{
$add_subscriber_interface =
$this->addNeededMethods($plugin->main_class_code);
$extension = [];
$extension[] = $plugin->comment . PHP_EOL . 'final class ';
$extension[] = $plugin->class_name . ' extends ' .
$plugin->extends;
if ($add_subscriber_interface)
{
$extension[] = ' implements Joomla__' .
'_c06c5116_6b9d_487c_9b09_5094ec4506a3___Power';
}
$extension[] = PHP_EOL . '{' . PHP_EOL;
$extension[] = $plugin->main_class_code;
$extension[] = PHP_EOL . '}' . PHP_EOL;
return $this->placeholder->update(
implode('', $extension),
$this->builder->allActive()
);
}
/**
* Ensures that the required methods are present in the plugin code.
*
* This method checks the plugin's code for the presence of required
methods,
* particularly the method that indicates implementation of the
SubscriberInterface.
* If the necessary method is missing, it adds it to the code.
*
* @param string $code The main code of the plugin, passed by
reference.
*
* @return bool Returns true if the SubscriberInterface implementation is
added or already present, false otherwise.
*
* @since 5.0.2
*/
protected function addNeededMethods(string &$code): bool
{
// Parse the code to extract its structure, particularly its methods.
$code_structure = $this->parser->code($code);
if (empty($code_structure['methods']))
{
return false;
}
// Check if methods are defined and if getSubscribedEvents is not
present.
if
(!$this->getSubscribedEvents($code_structure['methods']))
{
// Attempt to add the getSubscribedEvents method.
$method =
$this->addGetSubscribedEvents($code_structure['methods']);
if ($method !== null)
{
// Append the new method to the code and indicate that the interface
must be added.
$code .= $method;
return true;
}
// Return false if the event method could not be added.
return false;
}
// Return true if getSubscribedEvents is already present.
return true;
}
/**
* Add the getSubscribedEvents method
*
* @param array $methods The plugin methods.
*
* @return string|null The getSubscribedEvents code
*
* @since 5.0.2
*/
protected function addGetSubscribedEvents(array $methods): ?string
{
$events = [];
$counter = 0;
foreach ($methods as $method)
{
if ($this->validEventName($method))
{
$events[$method['name']] = Indent::_(3) .
"'{$method['name']}' =>
'{$method['name']}'";
// autoloaded when method start with 'on'
// so we can ignore adding the getSubscribedEvents
if (substr($method['name'], 0, 2) === 'on')
{
$counter++;
}
}
}
if ($events === [] || $counter == count($events))
{
return null;
}
$method = [];
$method[] = PHP_EOL . PHP_EOL . Indent::_(1) . '/**';
$method[] = Indent::_(1) . ' * Returns an array of events this
subscriber will listen to.';
$method[] = Indent::_(1) . ' *';
$method[] = Indent::_(1) . ' * @return array';
$method[] = Indent::_(1) . ' *';
$method[] = Indent::_(1) . ' * @since 5.0.0';
$method[] = Indent::_(1) . ' */';
$method[] = Indent::_(1) . 'public static function
getSubscribedEvents(): array';
$method[] = Indent::_(1) . '{';
$method[] = Indent::_(2) . 'return [';
$method[] = implode(',' . PHP_EOL, $events);
$method[] = Indent::_(2) . '];';
$method[] = Indent::_(1) . '}';
return implode(PHP_EOL, $method);
}
/**
* Validates if a method name is a valid event name for a Joomla plugin.
*
* The method must meet the following criteria:
* - It must be public, not static, and not abstract.
* - It must not be a magic method (i.e., should not start with
'__').
*
* @param array $method The method details, including 'name',
'access', 'static', and 'abstract'.
*
* @return bool Returns true if the method is a valid event name,
otherwise false.
*
* @since 5.0.2
*/
protected function validEventName(array $method): bool
{
// Check if the method is public, static, and not abstract
if ($method['access'] !== 'public' ||
$method['static'] || $method['abstract'])
{
return false;
}
// Check if the method is a magic method (starts with '__')
if (substr($method['name'], 0, 2) === '__')
{
return false;
}
// If all checks pass, the method is a valid event name
return true;
}
/**
* Check if the getSubscribedEvents is set
*
* @param array $methods The plugin methods.
*
* @return bool
*
* @since 5.0.2
*/
protected function getSubscribedEvents(array $methods): bool
{
foreach ($methods as $method)
{
if ($method['name'] === 'getSubscribedEvents'
&& $method['static'] &&
!$method['abstract'])
{
return true;
}
}
return false;
}
}
src/Componentbuilder/Compiler/Architecture/JoomlaFive/Plugin/MainXML.php000064400000037711151162054070022321
0ustar00<?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\Plugin;
use Joomla\CMS\Filesystem\Folder;
use VDM\Joomla\Componentbuilder\Compiler\Config;
use VDM\Joomla\Componentbuilder\Compiler\Language;
use VDM\Joomla\Componentbuilder\Compiler\Language\Set;
use VDM\Joomla\Componentbuilder\Compiler\Language\Purge;
use VDM\Joomla\Componentbuilder\Compiler\Language\Translation;
use VDM\Joomla\Componentbuilder\Compiler\Language\Multilingual;
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\EventInterface as
Event;
use VDM\Joomla\Componentbuilder\Compiler\Creator\FieldsetExtension;
use VDM\Joomla\Componentbuilder\Compiler\Builder\ContentOne;
use VDM\Joomla\Componentbuilder\Compiler\Builder\Languages;
use VDM\Joomla\Componentbuilder\Compiler\Builder\Multilingual as
BuilderMultilingual;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Counter;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\File;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Line;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Indent;
use VDM\Joomla\Utilities\ArrayHelper;
use VDM\Joomla\Utilities\StringHelper;
use
VDM\Joomla\Componentbuilder\Interfaces\Architecture\Plugin\MainXMLInterface;
/**
* Joomla 5 Plugin Main XML Class
*
* @since 5.0.2
*/
final class MainXML implements MainXMLInterface
{
/**
* The Config Class.
*
* @var Config
* @since 5.0.2
*/
protected Config $config;
/**
* The Language Class.
*
* @var Language
* @since 5.0.2
*/
protected Language $language;
/**
* The Set Class.
*
* @var Set
* @since 5.0.2
*/
protected Set $set;
/**
* The Purge Class.
*
* @var Purge
* @since 5.0.2
*/
protected Purge $purge;
/**
* The Translation Class.
*
* @var Translation
* @since 5.0.2
*/
protected Translation $translation;
/**
* The Multilingual Class.
*
* @var Multilingual
* @since 5.0.2
*/
protected Multilingual $multilingual;
/**
* The EventInterface Class.
*
* @var Event
* @since 5.0.2
*/
protected Event $event;
/**
* The FieldsetExtension Class.
*
* @var FieldsetExtension
* @since 5.0.2
*/
protected FieldsetExtension $fieldsetextension;
/**
* The ContentOne Class.
*
* @var ContentOne
* @since 5.0.2
*/
protected ContentOne $contentone;
/**
* The Languages Class.
*
* @var Languages
* @since 5.0.2
*/
protected Languages $languages;
/**
* The Multilingual Class.
*
* @var BuilderMultilingual
* @since 5.0.2
*/
protected BuilderMultilingual $buildermultilingual;
/**
* The Counter Class.
*
* @var Counter
* @since 5.0.2
*/
protected Counter $counter;
/**
* The File Class.
*
* @var File
* @since 5.0.2
*/
protected File $file;
/**
* Constructor.
*
* @param Config $config The Config Class.
* @param Language $language The Language
Class.
* @param Set $set The Set Class.
* @param Purge $purge The Purge Class.
* @param Translation $translation The Translation
Class.
* @param Multilingual $multilingual The Multilingual
Class.
* @param Event $event The EventInterface
Class.
* @param FieldsetExtension $fieldsetextension The
FieldsetExtension Class.
* @param ContentOne $contentone The ContentOne
Class.
* @param Languages $languages The Languages
Class.
* @param BuilderMultilingual $buildermultilingual The Multilingual
Class.
* @param Counter $counter The Counter Class.
* @param File $file The File Class.
*
* @since 5.0.2
*/
public function __construct(Config $config, Language $language, Set $set,
Purge $purge,
Translation $translation, Multilingual $multilingual,
Event $event, FieldsetExtension $fieldsetextension,
ContentOne $contentone, Languages $languages,
BuilderMultilingual $buildermultilingual,
Counter $counter, File $file)
{
$this->config = $config;
$this->language = $language;
$this->set = $set;
$this->purge = $purge;
$this->translation = $translation;
$this->multilingual = $multilingual;
$this->event = $event;
$this->fieldsetextension = $fieldsetextension;
$this->contentone = $contentone;
$this->languages = $languages;
$this->buildermultilingual = $buildermultilingual;
$this->counter = $counter;
$this->file = $file;
}
/**
* Generates the main XML for the plugin.
*
* @param object $plugin The plugin object.
*
* @return string The generated XML.
* @since 5.0.2
*/
public function get(object $plugin): string
{
$config_fields = $this->buildConfigFields($plugin);
$add_component_path = $this->shouldAddComponentPath($plugin);
$language_files = $this->generateLanguageFiles($plugin);
$xml = $this->generateScriptAndSqlXml($plugin);
$xml .= $this->generateLanguageXml($plugin, $language_files);
$xml .= $this->generateFileXml($plugin, $language_files);
$xml .= $this->generateConfigXml($plugin, $config_fields,
$add_component_path);
$xml .= $this->generateUpdateServerXml($plugin);
return $xml;
}
/**
* Build configuration fields XML.
*
* @param object $plugin The plugin object.
*
* @return array The configuration fields.
* @since 5.0.2
*/
protected function buildConfigFields(object $plugin): array
{
$configFields = [];
if (!isset($plugin->config_fields) ||
!ArrayHelper::check($plugin->config_fields))
{
return $configFields;
}
$dbKey = 'yy';
foreach ($plugin->config_fields as $fieldName => $fieldsets)
{
foreach ($fieldsets as $fieldset => $fields)
{
$xmlFields = $this->fieldsetextension->get($plugin, $fields,
$dbKey);
if (isset($xmlFields) && StringHelper::check($xmlFields))
{
$configFields["{$fieldName}{$fieldset}"] = $xmlFields;
}
$dbKey++;
}
}
return $configFields;
}
/**
* Determine if the component path should be added.
*
* @param object $plugin The plugin object.
*
* @return bool True if the component path should be added, false
otherwise.
* @since 5.0.2
*/
protected function shouldAddComponentPath(object $plugin): bool
{
if (!isset($plugin->config_fields) ||
!ArrayHelper::check($plugin->config_fields) ||
!isset($plugin->fieldsets_paths) ||
!ArrayHelper::check($plugin->fieldsets_paths))
{
return false;
}
foreach ($plugin->config_fields as $fieldName => $fieldsets)
{
foreach ($fieldsets as $fieldset => $fields)
{
if
(isset($plugin->fieldsets_paths["{$fieldName}{$fieldset}"])
&&
$plugin->fieldsets_paths["{$fieldName}{$fieldset}"] ==
1)
{
return true;
}
}
}
return false;
}
/**
* Generate XML for script and SQL files.
*
* @param object $plugin The plugin object.
*
* @return string The XML for script and SQL files.
* @since 5.0.2
*/
protected function generateScriptAndSqlXml(object $plugin): string
{
$xml = '';
if ($plugin->add_install_script)
{
$xml .= PHP_EOL . PHP_EOL . Indent::_(1) . '<!--' .
Line::_(
__LINE__,__CLASS__
) . ' Scripts to run on installation -->';
$xml .= PHP_EOL . Indent::_(1) .
'<scriptfile>script.php</scriptfile>';
}
if ($plugin->add_sql)
{
$xml .= PHP_EOL . PHP_EOL . Indent::_(1) . '<!--' .
Line::_(
__LINE__,__CLASS__
) . ' Runs on install -->';
$xml .= PHP_EOL . Indent::_(1) . '<install>';
$xml .= PHP_EOL . Indent::_(2) . '<sql>';
$xml .= PHP_EOL . Indent::_(3) . '<file driver="mysql"
charset="utf8">sql/mysql/install.sql</file>';
$xml .= PHP_EOL . Indent::_(2) . '</sql>';
$xml .= PHP_EOL . Indent::_(1) . '</install>';
}
if ($plugin->add_sql_uninstall)
{
$xml .= PHP_EOL . PHP_EOL . Indent::_(1) . '<!--' .
Line::_(
__LINE__,__CLASS__
) . ' Runs on uninstall -->';
$xml .= PHP_EOL . Indent::_(1) . '<uninstall>';
$xml .= PHP_EOL . Indent::_(2) . '<sql>';
$xml .= PHP_EOL . Indent::_(3) . '<file driver="mysql"
charset="utf8">sql/mysql/uninstall.sql</file>';
$xml .= PHP_EOL . Indent::_(2) . '</sql>';
$xml .= PHP_EOL . Indent::_(1) . '</uninstall>';
}
return $xml;
}
/**
* Generate XML for language files.
*
* @param object $plugin The plugin object.
* @param array $languageFiles The language files.
*
* @return string The XML for language files.
* @since 5.0.2
*/
protected function generateLanguageXml(object $plugin, array
$languageFiles): string
{
$xml = '';
if (ArrayHelper::check($languageFiles))
{
$xml .= PHP_EOL . PHP_EOL . Indent::_(1) . '<!--' .
Line::_(
__LINE__,__CLASS__
) . ' Language files -->';
$xml .= PHP_EOL . Indent::_(1) . '<languages
folder="language">';
foreach ($languageFiles as $addTag)
{
$xml .= PHP_EOL . Indent::_(2) . '<language tag="'
. $addTag . '">' . $addTag . '/plg_'
. strtolower((string) $plugin->group) . '_' .
(string) $plugin->file_name
. '.ini</language>';
$xml .= PHP_EOL . Indent::_(2) . '<language tag="'
. $addTag . '">' . $addTag . '/plg_'
. strtolower((string) $plugin->group) . '_' .
(string) $plugin->file_name
. '.sys.ini</language>';
}
$xml .= PHP_EOL . Indent::_(1) . '</languages>';
}
return $xml;
}
/**
* Generate the XML for the files.
*
* @param object $plugin The plugin object.
* @param array $languageFiles The language files.
*
* @return string The XML for the files.
* @since 5.0.2
*/
protected function generateFileXml(object $plugin, array $languageFiles):
string
{
$files = Folder::files($plugin->folder_path);
$folders = Folder::folders($plugin->folder_path);
$ignore = ['sql', 'language', 'script.php',
"{$plugin->file_name}.xml"];
$xml = PHP_EOL . PHP_EOL . Indent::_(1) . '<!--' . Line::_(
__LINE__,__CLASS__
) . ' Plugin files -->';
$xml .= PHP_EOL . Indent::_(1) . '<files>';
$xml .= PHP_EOL . Indent::_(2) . "<folder
plugin=\"{$plugin->context_name}\">services</folder>";
foreach ($files as $file)
{
if (!in_array($file, $ignore))
{
$xml .= PHP_EOL . Indent::_(2) .
"<filename>{$file}</filename>";
}
}
if (!empty($languageFiles))
{
// $xml .= PHP_EOL . Indent::_(2) .
'<folder>language</folder>';
}
if ($plugin->add_sql || $plugin->add_sql_uninstall)
{
$xml .= PHP_EOL . Indent::_(2) .
'<folder>sql</folder>';
}
foreach ($folders as $folder)
{
if (!in_array($folder, $ignore))
{
$xml .= PHP_EOL . Indent::_(2) .
"<folder>{$folder}</folder>";
}
}
$xml .= PHP_EOL . Indent::_(1) . '</files>';
return $xml;
}
/**
* Generate XML for configuration fields.
*
* @param object $plugin The plugin object.
* @param array $configFields The configuration fields.
* @param bool $addComponentPath Whether to add the component path.
*
* @return string The XML for configuration fields.
* @since 5.0.2
*/
protected function generateConfigXml(object $plugin, array $configFields,
bool $addComponentPath): string
{
if (!isset($plugin->config_fields) ||
!ArrayHelper::check($configFields))
{
return '';
}
$xml = PHP_EOL . PHP_EOL . Indent::_(1) . '<!--' . Line::_(
__LINE__,__CLASS__
) . ' Config parameters -->';
$xml .= $addComponentPath ? PHP_EOL . Indent::_(1) .
'<config' : PHP_EOL . Indent::_(1) .
'<config>';
if ($addComponentPath)
{
$xml .= PHP_EOL . Indent::_(3) . 'addruleprefix="' .
$this->config->namespace_prefix . '\Component\\' .
$this->contentone->get('ComponentNamespace') .
'\Administrator\Rule"';
$xml .= PHP_EOL . Indent::_(3) . 'addfieldprefix="' .
$this->config->namespace_prefix . '\Component\\' .
$this->contentone->get('ComponentNamespace') .
'\Administrator\Field">';
$xml .= PHP_EOL . Indent::_(1) . '>';
}
foreach ($plugin->config_fields as $fieldName => $fieldsets)
{
$xml .= PHP_EOL . Indent::_(1) . "<fields
name=\"{$fieldName}\">";
foreach ($fieldsets as $fieldset => $fields)
{
$label =
$plugin->fieldsets_label["{$fieldName}{$fieldset}"] ??
$fieldset;
$xml .= PHP_EOL . Indent::_(1) . "<fieldset
name=\"{$fieldset}\" label=\"{$label}\">";
if (isset($configFields["{$fieldName}{$fieldset}"]))
{
$xml .= $configFields["{$fieldName}{$fieldset}"];
}
$xml .= PHP_EOL . Indent::_(1) . '</fieldset>';
}
$xml .= PHP_EOL . Indent::_(1) . '</fields>';
}
$xml .= PHP_EOL . Indent::_(1) . '</config>';
return $xml;
}
/**
* Generate XML for update servers.
*
* @param object $plugin The plugin object.
*
* @return string The XML for update servers.
* @since 5.0.2
*/
protected function generateUpdateServerXml(object $plugin): string
{
$xml = '';
if ($plugin->add_update_server)
{
$xml = PHP_EOL . PHP_EOL . Indent::_(1) . '<!--' .
Line::_(
__LINE__,__CLASS__
) . ' Update servers -->';
$xml .= PHP_EOL . Indent::_(1) . '<updateservers>';
$xml .= PHP_EOL . Indent::_(2) . '<server
type="extension" priority="1" name="' .
$plugin->official_name . '">' .
$plugin->update_server_url . '</server>';
$xml .= PHP_EOL . Indent::_(1) . '</updateservers>';
}
return $xml;
}
/**
* Generate language files.
*
* @param object $plugin The plugin object.
*
* @return array The language files.
* @since 5.0.2
*/
protected function generateLanguageFiles(object $plugin): array
{
$languageFiles = [];
if (!$this->language->exist($plugin->key))
{
return $languageFiles;
}
$langContent = $this->language->getTarget($plugin->key);
$this->event->trigger('jcb_ce_onBeforeBuildPluginLang',
[&$plugin, &$langContent]);
$values = array_unique($langContent);
$this->buildermultilingual->set('plugins',
$this->multilingual->get($values));
$langTag = $this->config->get('lang_tag',
'en-GB');
$this->languages->set("plugins.{$langTag}.all",
$langContent);
$this->language->setTarget($plugin->key, null);
$this->set->execute($values, $plugin->id, 'plugins');
$this->purge->execute($values, $plugin->id,
'plugins');
$this->event->trigger('jcb_ce_onBeforeBuildPluginLangFiles',
[&$plugin]);
if ($this->languages->IsArray('plugins'))
{
foreach ($this->languages->get('plugins') as $tag =>
$areas)
{
$tag = trim($tag);
foreach ($areas as $area => $languageStrings)
{
$fileName = "plg_" . strtolower((string)$plugin->group) .
'_' . $plugin->file_name . '.ini';
$total = count($values);
if ($this->translation->check($tag, $languageStrings, $total,
$fileName))
{
$lang = array_map(
fn($langString, $placeholder) =>
"{$placeholder}=\"{$langString}\"",
array_values($languageStrings),
array_keys($languageStrings)
);
$path = "{$plugin->folder_path}/language/{$tag}/";
if (!Folder::exists($path))
{
Folder::create($path);
$this->counter->folder++;
}
$this->file->write($path . $fileName, implode(PHP_EOL,
$lang));
$this->file->write(
$path . 'plg_' . strtolower((string)$plugin->group) .
'_' . $plugin->file_name . '.sys.ini',
implode(PHP_EOL, $lang)
);
$this->counter->line += count($lang);
unset($lang);
$languageFiles[$tag] = $tag;
}
}
}
}
return $languageFiles;
}
}
src/Componentbuilder/Compiler/Architecture/JoomlaFive/Plugin/Provider.php000064400000006667151162054070022654
0ustar00<?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\Plugin;
use VDM\Joomla\Componentbuilder\Compiler\Placeholder;
use VDM\Joomla\Componentbuilder\Compiler\Builder\ContentOne as Builder;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Indent;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Line;
use
VDM\Joomla\Componentbuilder\Compiler\Interfaces\Architecture\Plugin\ProviderInterface;
/**
* Plugin Provider Class for Joomla 5
*
* @since 5.0.2
*/
final class Provider implements ProviderInterface
{
/**
* The Placeholder Class.
*
* @var Placeholder
* @since 5.0.2
*/
protected Placeholder $placeholder;
/**
* The ContentOne Class.
*
* @var Builder
* @since 5.0.2
*/
protected Builder $builder;
/**
* Constructor.
*
* @param Placeholder $placeholder The Placeholder Class.
* @param Builder $builder The Content One Class.
*
* @since 5.0.2
*/
public function __construct(Placeholder $placeholder, Builder $builder)
{
$this->placeholder = $placeholder;
$this->builder = $builder;
}
/**
* Get the updated provider for the given plugin.
*
* @param object $plugin The plugin object containing the necessary
data.
*
* @return string The provider content.
*
* @since 5.0.2
*/
public function get(object $plugin): string
{
$group = strtolower((string) $plugin->group);
$provider = [];
$provider[] = PHP_EOL . PHP_EOL . "return new class () implements
ServiceProviderInterface {";
$provider[] = Indent::_(1) . "/**";
$provider[] = Indent::_(1) . "*" . Line::_(__Line__,
__Class__)
. " Registers the service provider with a DI container.";
$provider[] = Indent::_(1) . "*";
$provider[] = Indent::_(1) . "* @param Container \$container The
DI container.";
$provider[] = Indent::_(1) . "*";
$provider[] = Indent::_(1) . "* @return void";
$provider[] = Indent::_(1) . "* @since 4.3.0";
$provider[] = Indent::_(1) . "*/";
$provider[] = Indent::_(1) . "public function register(Container
\$container)";
$provider[] = Indent::_(1) . "{";
$provider[] = Indent::_(2) . "\$container->set(";
$provider[] = Indent::_(3) . "PluginInterface::class,";
$provider[] = Indent::_(3) . "function (Container \$container)
{";
$provider[] = Indent::_(4) . "\$plugin = new
{$plugin->class_name}(";
$provider[] = Indent::_(5) .
"\$container->get(DispatcherInterface::class),";
$provider[] = Indent::_(5) . "(array)
PluginHelper::getPlugin('{$group}',
'{$plugin->context_name}')";
$provider[] = Indent::_(4) . ");";
$provider[] = Indent::_(4) .
"\$plugin->setApplication(Factory::getApplication());";
$provider[] = $plugin->service_provider ?? ''; // to add
extra plug-in suff
$provider[] = Indent::_(4) . "return \$plugin;";
$provider[] = Indent::_(3) . "}";
$provider[] = Indent::_(2) . ");";
$provider[] = Indent::_(1) . "}";
$provider[] = "};";
return $this->placeholder->update(
implode(PHP_EOL, $provider). PHP_EOL,
$this->builder->allActive()
);
}
}
src/Componentbuilder/Compiler/Architecture/JoomlaFive/Plugin/index.html000064400000000054151162054070022326
0ustar00<html><body
bgcolor="#FFFFFF"></body></html>src/Componentbuilder/Compiler/Architecture/JoomlaFour/ComHelperClass/CreateUser.php000064400000014242151162054070024540
0ustar00<?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\ComHelperClass;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Indent;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Line;
use
VDM\Joomla\Componentbuilder\Compiler\Interfaces\Architecture\ComHelperClass\CreateUserInterface;
/**
* Helper Class Create User Class for Joomla 4
*
* @since 5.0.2
*/
final class CreateUser implements CreateUserInterface
{
/**
* Generates the method definition for creating or updating a user based
on the provided parameters.
*
* This method returns a string representation of a PHP function that
includes various
* steps for handling user creation and updates, depending on the mode
(site registration or admin registration).
*
* @param $add Determines whether to generate the user creation
method or not.
* If true, the method will be generated and returned
as a string.
*
* @return string The generated method code as a string if $add is true.
* Returns an empty string if $add is false.
*/
public function get($add): string
{
if ($add)
{
$method = [];
$method[] = PHP_EOL . PHP_EOL . Indent::_(1) . "/**";
$method[] = Indent::_(1) . " * Save user details by either creating
a new user or updating an existing user.";
$method[] = Indent::_(1) . " *";
$method[] = Indent::_(1)
. " * @param array \$credentials ['name' =>
string, 'username' => string, 'email' => string,
'password' => string, 'password2' =>
string]";
$method[] = Indent::_(1) . " * @param int \$autologin";
$method[] = Indent::_(1)
. " * @param array \$params ['useractivation' =>
int, 'sendpassword' => int, 'allowUserRegistration'
=> int]";
$method[] = Indent::_(1)
. " * @param array \$mode 1 = Site Registrations; 0 = Admin
Registration; 2 = Custom Helper Method Called registerUser";
$method[] = Indent::_(1) . " *";
$method[] = Indent::_(1) . " * @return int User ID on
success";
$method[] = Indent::_(1) . " *";
$method[] = Indent::_(1) . " * @throws \InvalidArgumentException
If required credentials are missing.";
$method[] = Indent::_(1) . " * @throws \RuntimeException
If the user update or creation fails.";
$method[] = Indent::_(1) . " * @throws
Super__"."_1c10a5f1_204d_4f17_ad9f_0e0684f2030d___Power If
the user is not found.";
$method[] = Indent::_(1) . " *";
$method[] = Indent::_(1) . " * @since 3.0.0";
$method[] = Indent::_(1) . " * @deprecated 4.3 Use
Super__"."_7832a726_87b6_4e95_887e_7b725d3fab8f___Power::create(\$credentials,
\$autologin, \$params, \$mode);";
$method[] = Indent::_(1) . " */";
$method[] = Indent::_(1)
. "public static function createUser(\$credentials, \$autologin =
0,";
$method[] = Indent::_(2) . "\$params = [";
$method[] = Indent::_(3)
. "'useractivation' => 0, 'sendpassword'
=> 1";
$method[] = Indent::_(2) . "], \$mode = 1";
$method[] = Indent::_(1) . ")";
$method[] = Indent::_(1) . "{";
$method[] = Indent::_(2) . "//" . Line::_(__Line__,
__Class__)
. " Create a user with the UserHelper class";
$method[] = Indent::_(2)
. "return
Super__"."_7832a726_87b6_4e95_887e_7b725d3fab8f___Power::create(\$credentials,
\$autologin, \$params, \$mode);";
$method[] = Indent::_(1) . "}";
$method[] = PHP_EOL . PHP_EOL . Indent::_(1) . "/**";
$method[] = Indent::_(1) . " * Update the given component
params.";
$method[] = Indent::_(1) . " *";
$method[] = Indent::_(1) . " * @param string|null \$option The
optional extension element name.";
$method[] = Indent::_(1) . " * @param string \$target The
parameter name to be updated.";
$method[] = Indent::_(1) . " * @param mixed \$value The
value to set for the parameter.";
$method[] = Indent::_(1) . " *";
$method[] = Indent::_(1) . " * @since 3.0.0";
$method[] = Indent::_(1) . " * @deprecated 4.3 Use
Super__"."_640b5352_fb09_425f_a26e_cd44eda03f15___Power::setParams(\$target,
\$value, \$option);";
$method[] = Indent::_(1) . " */";
$method[] = PHP_EOL . Indent::_(1)
. "public static function setParams(\$option, \$target,
\$value)";
$method[] = Indent::_(1) . "{";
$method[] = Indent::_(2) . "//" . Line::_(__Line__,
__Class__)
. " Sets a parameter value for the given target in the specified
option's params";
$method[] = Indent::_(2)
. "return
Super__"."_640b5352_fb09_425f_a26e_cd44eda03f15___Power::setParams(\$target,
\$value, \$option);";
$method[] = Indent::_(1) . "}";
$method[] = PHP_EOL . Indent::_(1) . "/**";
$method[] = Indent::_(1) . " * Update user details";
$method[] = Indent::_(1) . " *";
$method[] = Indent::_(1) . " * @param array \$userDetails Array
containing user details to be updated";
$method[] = Indent::_(1) . " *";
$method[] = Indent::_(1) . " * @return int Updated user ID on
success.";
$method[] = Indent::_(1) . " *";
$method[] = Indent::_(1) . " * @throws \RuntimeException If user
update fails.";
$method[] = Indent::_(1) . " *";
$method[] = Indent::_(1) . " * @since 3.0.0";
$method[] = Indent::_(1) . " * @deprecated 4.3 Use
Super__"."_7832a726_87b6_4e95_887e_7b725d3fab8f___Power::update(\$userDetails);";
$method[] = Indent::_(1) . " */";
$method[] = Indent::_(1)
. "public static function updateUser(\$userDetails): int";
$method[] = Indent::_(1) . "{";
$method[] = Indent::_(2)
. "//" . Line::_(__Line__, __Class__)
. " Update user details with the UserHelper class";
$method[] = Indent::_(2) . "return
Super__"."_7832a726_87b6_4e95_887e_7b725d3fab8f___Power::update(\$userDetails);";
$method[] = Indent::_(1) . "}";
// return the help method
return implode(PHP_EOL, $method);
}
return '';
}
}
src/Componentbuilder/Compiler/Architecture/JoomlaFour/ComHelperClass/index.html000064400000000054151162054070023756
0ustar00<html><body
bgcolor="#FFFFFF"></body></html>src/Componentbuilder/Compiler/Architecture/JoomlaFour/Controller/AllowAdd.php000064400000007336151162054070023452
0ustar00<?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);
}
}
src/Componentbuilder/Compiler/Architecture/JoomlaFour/Controller/AllowEdit.php000064400000027164151162054070023650
0ustar00<?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
);
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);
}
}
src/Componentbuilder/Compiler/Architecture/JoomlaFour/Controller/AllowEditViews.php000064400000015677151162054070024674
0ustar00<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder
<https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights
reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
namespace
VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaFour\Controller;
use VDM\Joomla\Componentbuilder\Compiler\Creator\Permission;
use VDM\Joomla\Componentbuilder\Compiler\Customcode\Dispenser;
use VDM\Joomla\Componentbuilder\Compiler\Builder\Category;
use VDM\Joomla\Componentbuilder\Compiler\Builder\CategoryOtherName;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Indent;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Line;
use
VDM\Joomla\Componentbuilder\Compiler\Interfaces\Architecture\Controller\AllowEditViewsInterface;
/**
* Controller Allow Edit Views Class for Joomla 4
*
* @since 5.0.2
*/
final class AllowEditViews implements AllowEditViewsInterface
{
/**
* The Permission Class.
*
* @var Permission
* @since 5.0.2
*/
protected Permission $permission;
/**
* The Dispenser Class.
*
* @var Dispenser
* @since 5.0.2
*/
protected Dispenser $dispenser;
/**
* The Category Class.
*
* @var Category
* @since 5.0.2
*/
protected Category $category;
/**
* The CategoryOtherName Class.
*
* @var CategoryOtherName
* @since 5.0.2
*/
protected CategoryOtherName $categoryothername;
/**
* Constructor.
*
* @param Permission $permission The Permission Class.
* @param Dispenser $dispenser The Dispenser Class.
* @param Category $category The Category Class.
* @param CategoryOtherName $categoryothername The CategoryOtherName
Class.
*
* @since 5.0.2
*/
public function __construct(Permission $permission,
Dispenser $dispenser, Category $category,
CategoryOtherName $categoryothername)
{
$this->permission = $permission;
$this->dispenser = $dispenser;
$this->category = $category;
$this->categoryothername = $categoryothername;
}
/**
* Get Array Code
*
* @param array $views
*
* @since 5.0.2
* @return string The array of Code (string)
*/
public function getArray(array $views): string
{
$allow = [];
foreach ($views as $nameSingleCode => $nameListCode)
{
$allow[] = $this->getViewArray($nameSingleCode, $nameListCode);
}
if ($allow === [])
{
return '';
}
return PHP_EOL . Indent::_(2) . implode("," . PHP_EOL .
Indent::_(2), $allow);
}
/**
* Get Custom Function Code
*
* @param array $views
*
* @since 5.0.2
* @return string The functions of Code (string)
*/
public function getFunctions(array $views): string
{
$allow = [];
foreach ($views as $nameSingleCode => $nameListCode)
{
if (($function = $this->getViewFunction($nameSingleCode,
$nameListCode)) !== null)
{
$allow[] = $function;
}
}
if ($allow === [])
{
return '';
}
return PHP_EOL . PHP_EOL . implode(PHP_EOL . PHP_EOL, $allow);
}
/**
* Get View Permissions Array Code
*
* @param string $nameSingleCode The single code name of the view.
* @param string $nameListCode The list code name of the view.
*
* @since 3.2.0
* @return string The allow edit method code
*/
protected function getViewArray(string $nameSingleCode, string
$nameListCode): string
{
$allow = [];
// prepare custom permission script
$customAllow = $this->dispenser->get(
'php_allowedit', $nameSingleCode
);
if ($customAllow !== '')
{
$allow[] = Indent::_(3) . "'function' =>
'allowEdit_{$nameSingleCode}'";
}
if ($this->category->exists("{$nameListCode}"))
{
// check if category has another name
$otherView = $this->categoryothername->
get($nameListCode . '.view', $nameSingleCode);
// check if the item has permissions.
if ($this->permission->globalExist($otherView,
'core.access'))
{
$access = $this->permission->getGlobal($otherView,
'core.access');
$allow[] = Indent::_(3) . "'access' =>
'{$access}'";
}
$edit = $this->permission->getAction($otherView,
'core.edit');
$allow[] = Indent::_(3) . "'edit' =>
'{$edit}'";
$edit_own = $this->permission->getAction($otherView,
'core.edit.own');
$allow[] = Indent::_(3) . "'edit.own' =>
'{$edit_own}'";
}
else
{
// check if the item has permissions.
if ($this->permission->actionExist($nameSingleCode,
'core.access'))
{
$access = $this->permission->getAction($nameSingleCode,
'core.access');
$allow[] = Indent::_(3) . "'access' =>
'{$access}'";
}
$edit = $this->permission->getAction($nameSingleCode,
'core.edit');
$allow[] = Indent::_(3) . "'edit' =>
'{$edit}'";
$edit_own = $this->permission->getAction($nameSingleCode,
'core.edit.own');
$allow[] = Indent::_(3) . "'edit.own' =>
'{$edit_own}'";
}
return "'{$nameSingleCode}' => [" . PHP_EOL .
implode(',' . PHP_EOL, $allow) . PHP_EOL . Indent::_(2) .
']';
}
/**
* Get View Permissions Function Code
*
* @param string $nameSingleCode The single code name of the view.
* @param string $nameListCode The list code name of the view.
*
* @since 3.2.0
* @return string|null The allow edit method code
*/
protected function getViewFunction(string $nameSingleCode, string
$nameListCode): ?string
{
$allow = [];
// prepare custom permission script
$customAllow = $this->dispenser->get(
'php_allowedit', $nameSingleCode
);
if ($customAllow !== '')
{
// setup the function
$allow[] = Indent::_(1) . '/**';
$allow[] = Indent::_(1) . " * Method to check if you can edit an
existing {$nameSingleCode} record.";
$allow[] = Indent::_(1) . ' *';
$allow[] = Indent::_(1) . ' * @param array $data An array of
input data.';
$allow[] = Indent::_(1) . ' * @param string $key The name of
the key for the primary key.';
$allow[] = Indent::_(1) . ' *';
$allow[] = Indent::_(1) . ' * @return boolean';
$allow[] = Indent::_(1) . ' *';
$allow[] = Indent::_(1) . ' * @since 5.0.2';
$allow[] = Indent::_(1) . ' */';
$allow[] = Indent::_(1) . "protected function
allowEdit_{$nameSingleCode}(\$data = [], \$key = 'id')";
$allow[] = Indent::_(1) . '{';
$allow[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__)
. " get user object.";
$allow[] = Indent::_(2) . "\$user = \$this->identity;";
$allow[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__)
. " get record id.";
$allow[] = Indent::_(2)
. "\$recordId = (int) isset(\$data[\$key]) ? \$data[\$key] :
0;";
// load custom permission script
$allow[] = $customAllow;
$allow[] = Indent::_(1) . '}';
return implode(PHP_EOL, $allow);
}
return null;
}
}
src/Componentbuilder/Compiler/Architecture/JoomlaFour/Controller/index.html000064400000000054151162054070023235
0ustar00<html><body
bgcolor="#FFFFFF"></body></html>src/Componentbuilder/Compiler/Architecture/JoomlaFour/Model/CanDelete.php000064400000004671151162054070022523
0ustar00<?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);
}
}
src/Componentbuilder/Compiler/Architecture/JoomlaFour/Model/CanEditState.php000064400000006515151162054070023206
0ustar00<?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);
}
}
src/Componentbuilder/Compiler/Architecture/JoomlaFour/Model/index.html000064400000000054151162054070022152
0ustar00<html><body
bgcolor="#FFFFFF"></body></html>src/Componentbuilder/Compiler/Architecture/JoomlaFour/Plugin/Extension.php000064400000015353151162054070023050
0ustar00<?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\Plugin;
use VDM\Joomla\Componentbuilder\Compiler\Placeholder;
use VDM\Joomla\Componentbuilder\Compiler\Builder\ContentOne as Builder;
use VDM\Joomla\Componentbuilder\Power\Parser;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Indent;
use
VDM\Joomla\Componentbuilder\Compiler\Interfaces\Architecture\Plugin\ExtensionInterface;
/**
* Plugin Extension Class for Joomla 4
*
* @since 5.0.2
*/
final class Extension implements ExtensionInterface
{
/**
* The Placeholder Class.
*
* @var Placeholder
* @since 5.0.2
*/
protected Placeholder $placeholder;
/**
* The ContentOne Class.
*
* @var Builder
* @since 5.0.2
*/
protected Builder $builder;
/**
* The Parser Class.
*
* @var Parser
* @since 5.0.2
*/
protected Parser $parser;
/**
* Constructor.
*
* @param Placeholder $placeholder The Placeholder Class.
* @param Builder $builder The Content One Class.
* @param Parser $parser The Parser Class.
*
* @since 5.0.2
*/
public function __construct(Placeholder $placeholder, Builder $builder,
Parser $parser)
{
$this->placeholder = $placeholder;
$this->builder = $builder;
$this->parser = $parser;
}
/**
* Get the updated placeholder content for the given plugin.
*
* @param object $plugin The plugin object containing the necessary
data.
*
* @return string The updated placeholder content.
*
* @since 5.0.2
*/
public function get(object $plugin): string
{
$add_subscriber_interface =
$this->addNeededMethods($plugin->main_class_code);
$extension = [];
$extension[] = $plugin->comment . PHP_EOL . 'final class ';
$extension[] = $plugin->class_name . ' extends ' .
$plugin->extends;
if ($add_subscriber_interface)
{
$extension[] = ' implements Joomla__' .
'_c06c5116_6b9d_487c_9b09_5094ec4506a3___Power';
}
$extension[] = PHP_EOL . '{' . PHP_EOL;
$extension[] = $plugin->main_class_code;
$extension[] = PHP_EOL . '}' . PHP_EOL;
return $this->placeholder->update(
implode('', $extension),
$this->builder->allActive()
);
}
/**
* Ensures that the required methods are present in the plugin code.
*
* This method checks the plugin's code for the presence of required
methods,
* particularly the method that indicates implementation of the
SubscriberInterface.
* If the necessary method is missing, it adds it to the code.
*
* @param string $code The main code of the plugin, passed by
reference.
*
* @return bool Returns true if the SubscriberInterface implementation is
added or already present, false otherwise.
*
* @since 5.0.2
*/
protected function addNeededMethods(string &$code): bool
{
// Parse the code to extract its structure, particularly its methods.
$code_structure = $this->parser->code($code);
if (empty($code_structure['methods']))
{
return false;
}
// Check if methods are defined and if getSubscribedEvents is not
present.
if
(!$this->getSubscribedEvents($code_structure['methods']))
{
// Attempt to add the getSubscribedEvents method.
$method =
$this->addGetSubscribedEvents($code_structure['methods']);
if ($method !== null)
{
// Append the new method to the code and indicate that the interface
must be added.
$code .= $method;
return true;
}
// Return false if the event method could not be added.
return false;
}
// Return true if getSubscribedEvents is already present.
return true;
}
/**
* Add the getSubscribedEvents method
*
* @param array $methods The plugin methods.
*
* @return string|null The getSubscribedEvents code
*
* @since 5.0.2
*/
protected function addGetSubscribedEvents(array $methods): ?string
{
$events = [];
$counter = 0;
foreach ($methods as $method)
{
if ($this->validEventName($method))
{
$events[$method['name']] = Indent::_(3) .
"'{$method['name']}' =>
'{$method['name']}'";
// autoloaded when method start with 'on'
// so we can ignore adding the getSubscribedEvents
if (substr($method['name'], 0, 2) === 'on')
{
$counter++;
}
}
}
if ($events === [] || $counter == count($events))
{
return null;
}
$method = [];
$method[] = PHP_EOL . PHP_EOL . Indent::_(1) . '/**';
$method[] = Indent::_(1) . ' * Returns an array of events this
subscriber will listen to.';
$method[] = Indent::_(1) . ' *';
$method[] = Indent::_(1) . ' * @return array';
$method[] = Indent::_(1) . ' *';
$method[] = Indent::_(1) . ' * @since 5.0.0';
$method[] = Indent::_(1) . ' */';
$method[] = Indent::_(1) . 'public static function
getSubscribedEvents(): array';
$method[] = Indent::_(1) . '{';
$method[] = Indent::_(2) . 'return [';
$method[] = implode(',' . PHP_EOL, $events);
$method[] = Indent::_(2) . '];';
$method[] = Indent::_(1) . '}';
return implode(PHP_EOL, $method);
}
/**
* Validates if a method name is a valid event name for a Joomla plugin.
*
* The method must meet the following criteria:
* - It must be public, not static, and not abstract.
* - It must not be a magic method (i.e., should not start with
'__').
*
* @param array $method The method details, including 'name',
'access', 'static', and 'abstract'.
*
* @return bool Returns true if the method is a valid event name,
otherwise false.
*
* @since 5.0.2
*/
protected function validEventName(array $method): bool
{
// Check if the method is public, static, and not abstract
if ($method['access'] !== 'public' ||
$method['static'] || $method['abstract'])
{
return false;
}
// Check if the method is a magic method (starts with '__')
if (substr($method['name'], 0, 2) === '__')
{
return false;
}
// If all checks pass, the method is a valid event name
return true;
}
/**
* Check if the getSubscribedEvents is set
*
* @param array $methods The plugin methods.
*
* @return bool
*
* @since 5.0.2
*/
protected function getSubscribedEvents(array $methods): bool
{
foreach ($methods as $method)
{
if ($method['name'] === 'getSubscribedEvents'
&& $method['static'] &&
!$method['abstract'])
{
return true;
}
}
return false;
}
}
src/Componentbuilder/Compiler/Architecture/JoomlaFour/Plugin/MainXML.php000064400000037711151162054070022343
0ustar00<?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\Plugin;
use Joomla\CMS\Filesystem\Folder;
use VDM\Joomla\Componentbuilder\Compiler\Config;
use VDM\Joomla\Componentbuilder\Compiler\Language;
use VDM\Joomla\Componentbuilder\Compiler\Language\Set;
use VDM\Joomla\Componentbuilder\Compiler\Language\Purge;
use VDM\Joomla\Componentbuilder\Compiler\Language\Translation;
use VDM\Joomla\Componentbuilder\Compiler\Language\Multilingual;
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\EventInterface as
Event;
use VDM\Joomla\Componentbuilder\Compiler\Creator\FieldsetExtension;
use VDM\Joomla\Componentbuilder\Compiler\Builder\ContentOne;
use VDM\Joomla\Componentbuilder\Compiler\Builder\Languages;
use VDM\Joomla\Componentbuilder\Compiler\Builder\Multilingual as
BuilderMultilingual;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Counter;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\File;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Line;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Indent;
use VDM\Joomla\Utilities\ArrayHelper;
use VDM\Joomla\Utilities\StringHelper;
use
VDM\Joomla\Componentbuilder\Interfaces\Architecture\Plugin\MainXMLInterface;
/**
* Joomla 4 Plugin Main XML Class
*
* @since 5.0.2
*/
final class MainXML implements MainXMLInterface
{
/**
* The Config Class.
*
* @var Config
* @since 5.0.2
*/
protected Config $config;
/**
* The Language Class.
*
* @var Language
* @since 5.0.2
*/
protected Language $language;
/**
* The Set Class.
*
* @var Set
* @since 5.0.2
*/
protected Set $set;
/**
* The Purge Class.
*
* @var Purge
* @since 5.0.2
*/
protected Purge $purge;
/**
* The Translation Class.
*
* @var Translation
* @since 5.0.2
*/
protected Translation $translation;
/**
* The Multilingual Class.
*
* @var Multilingual
* @since 5.0.2
*/
protected Multilingual $multilingual;
/**
* The EventInterface Class.
*
* @var Event
* @since 5.0.2
*/
protected Event $event;
/**
* The FieldsetExtension Class.
*
* @var FieldsetExtension
* @since 5.0.2
*/
protected FieldsetExtension $fieldsetextension;
/**
* The ContentOne Class.
*
* @var ContentOne
* @since 5.0.2
*/
protected ContentOne $contentone;
/**
* The Languages Class.
*
* @var Languages
* @since 5.0.2
*/
protected Languages $languages;
/**
* The Multilingual Class.
*
* @var BuilderMultilingual
* @since 5.0.2
*/
protected BuilderMultilingual $buildermultilingual;
/**
* The Counter Class.
*
* @var Counter
* @since 5.0.2
*/
protected Counter $counter;
/**
* The File Class.
*
* @var File
* @since 5.0.2
*/
protected File $file;
/**
* Constructor.
*
* @param Config $config The Config Class.
* @param Language $language The Language
Class.
* @param Set $set The Set Class.
* @param Purge $purge The Purge Class.
* @param Translation $translation The Translation
Class.
* @param Multilingual $multilingual The Multilingual
Class.
* @param Event $event The EventInterface
Class.
* @param FieldsetExtension $fieldsetextension The
FieldsetExtension Class.
* @param ContentOne $contentone The ContentOne
Class.
* @param Languages $languages The Languages
Class.
* @param BuilderMultilingual $buildermultilingual The Multilingual
Class.
* @param Counter $counter The Counter Class.
* @param File $file The File Class.
*
* @since 5.0.2
*/
public function __construct(Config $config, Language $language, Set $set,
Purge $purge,
Translation $translation, Multilingual $multilingual,
Event $event, FieldsetExtension $fieldsetextension,
ContentOne $contentone, Languages $languages,
BuilderMultilingual $buildermultilingual,
Counter $counter, File $file)
{
$this->config = $config;
$this->language = $language;
$this->set = $set;
$this->purge = $purge;
$this->translation = $translation;
$this->multilingual = $multilingual;
$this->event = $event;
$this->fieldsetextension = $fieldsetextension;
$this->contentone = $contentone;
$this->languages = $languages;
$this->buildermultilingual = $buildermultilingual;
$this->counter = $counter;
$this->file = $file;
}
/**
* Generates the main XML for the plugin.
*
* @param object $plugin The plugin object.
*
* @return string The generated XML.
* @since 5.0.2
*/
public function get(object $plugin): string
{
$config_fields = $this->buildConfigFields($plugin);
$add_component_path = $this->shouldAddComponentPath($plugin);
$language_files = $this->generateLanguageFiles($plugin);
$xml = $this->generateScriptAndSqlXml($plugin);
$xml .= $this->generateLanguageXml($plugin, $language_files);
$xml .= $this->generateFileXml($plugin, $language_files);
$xml .= $this->generateConfigXml($plugin, $config_fields,
$add_component_path);
$xml .= $this->generateUpdateServerXml($plugin);
return $xml;
}
/**
* Build configuration fields XML.
*
* @param object $plugin The plugin object.
*
* @return array The configuration fields.
* @since 5.0.2
*/
protected function buildConfigFields(object $plugin): array
{
$configFields = [];
if (!isset($plugin->config_fields) ||
!ArrayHelper::check($plugin->config_fields))
{
return $configFields;
}
$dbKey = 'yy';
foreach ($plugin->config_fields as $fieldName => $fieldsets)
{
foreach ($fieldsets as $fieldset => $fields)
{
$xmlFields = $this->fieldsetextension->get($plugin, $fields,
$dbKey);
if (isset($xmlFields) && StringHelper::check($xmlFields))
{
$configFields["{$fieldName}{$fieldset}"] = $xmlFields;
}
$dbKey++;
}
}
return $configFields;
}
/**
* Determine if the component path should be added.
*
* @param object $plugin The plugin object.
*
* @return bool True if the component path should be added, false
otherwise.
* @since 5.0.2
*/
protected function shouldAddComponentPath(object $plugin): bool
{
if (!isset($plugin->config_fields) ||
!ArrayHelper::check($plugin->config_fields) ||
!isset($plugin->fieldsets_paths) ||
!ArrayHelper::check($plugin->fieldsets_paths))
{
return false;
}
foreach ($plugin->config_fields as $fieldName => $fieldsets)
{
foreach ($fieldsets as $fieldset => $fields)
{
if
(isset($plugin->fieldsets_paths["{$fieldName}{$fieldset}"])
&&
$plugin->fieldsets_paths["{$fieldName}{$fieldset}"] ==
1)
{
return true;
}
}
}
return false;
}
/**
* Generate XML for script and SQL files.
*
* @param object $plugin The plugin object.
*
* @return string The XML for script and SQL files.
* @since 5.0.2
*/
protected function generateScriptAndSqlXml(object $plugin): string
{
$xml = '';
if ($plugin->add_install_script)
{
$xml .= PHP_EOL . PHP_EOL . Indent::_(1) . '<!--' .
Line::_(
__LINE__,__CLASS__
) . ' Scripts to run on installation -->';
$xml .= PHP_EOL . Indent::_(1) .
'<scriptfile>script.php</scriptfile>';
}
if ($plugin->add_sql)
{
$xml .= PHP_EOL . PHP_EOL . Indent::_(1) . '<!--' .
Line::_(
__LINE__,__CLASS__
) . ' Runs on install -->';
$xml .= PHP_EOL . Indent::_(1) . '<install>';
$xml .= PHP_EOL . Indent::_(2) . '<sql>';
$xml .= PHP_EOL . Indent::_(3) . '<file driver="mysql"
charset="utf8">sql/mysql/install.sql</file>';
$xml .= PHP_EOL . Indent::_(2) . '</sql>';
$xml .= PHP_EOL . Indent::_(1) . '</install>';
}
if ($plugin->add_sql_uninstall)
{
$xml .= PHP_EOL . PHP_EOL . Indent::_(1) . '<!--' .
Line::_(
__LINE__,__CLASS__
) . ' Runs on uninstall -->';
$xml .= PHP_EOL . Indent::_(1) . '<uninstall>';
$xml .= PHP_EOL . Indent::_(2) . '<sql>';
$xml .= PHP_EOL . Indent::_(3) . '<file driver="mysql"
charset="utf8">sql/mysql/uninstall.sql</file>';
$xml .= PHP_EOL . Indent::_(2) . '</sql>';
$xml .= PHP_EOL . Indent::_(1) . '</uninstall>';
}
return $xml;
}
/**
* Generate XML for language files.
*
* @param object $plugin The plugin object.
* @param array $languageFiles The language files.
*
* @return string The XML for language files.
* @since 5.0.2
*/
protected function generateLanguageXml(object $plugin, array
$languageFiles): string
{
$xml = '';
if (ArrayHelper::check($languageFiles))
{
$xml .= PHP_EOL . PHP_EOL . Indent::_(1) . '<!--' .
Line::_(
__LINE__,__CLASS__
) . ' Language files -->';
$xml .= PHP_EOL . Indent::_(1) . '<languages
folder="language">';
foreach ($languageFiles as $addTag)
{
$xml .= PHP_EOL . Indent::_(2) . '<language tag="'
. $addTag . '">' . $addTag . '/plg_'
. strtolower((string) $plugin->group) . '_' .
(string) $plugin->file_name
. '.ini</language>';
$xml .= PHP_EOL . Indent::_(2) . '<language tag="'
. $addTag . '">' . $addTag . '/plg_'
. strtolower((string) $plugin->group) . '_' .
(string) $plugin->file_name
. '.sys.ini</language>';
}
$xml .= PHP_EOL . Indent::_(1) . '</languages>';
}
return $xml;
}
/**
* Generate the XML for the files.
*
* @param object $plugin The plugin object.
* @param array $languageFiles The language files.
*
* @return string The XML for the files.
* @since 5.0.2
*/
protected function generateFileXml(object $plugin, array $languageFiles):
string
{
$files = Folder::files($plugin->folder_path);
$folders = Folder::folders($plugin->folder_path);
$ignore = ['sql', 'language', 'script.php',
"{$plugin->file_name}.xml"];
$xml = PHP_EOL . PHP_EOL . Indent::_(1) . '<!--' . Line::_(
__LINE__,__CLASS__
) . ' Plugin files -->';
$xml .= PHP_EOL . Indent::_(1) . '<files>';
$xml .= PHP_EOL . Indent::_(2) . "<folder
plugin=\"{$plugin->context_name}\">services</folder>";
foreach ($files as $file)
{
if (!in_array($file, $ignore))
{
$xml .= PHP_EOL . Indent::_(2) .
"<filename>{$file}</filename>";
}
}
if (!empty($languageFiles))
{
// $xml .= PHP_EOL . Indent::_(2) .
'<folder>language</folder>';
}
if ($plugin->add_sql || $plugin->add_sql_uninstall)
{
$xml .= PHP_EOL . Indent::_(2) .
'<folder>sql</folder>';
}
foreach ($folders as $folder)
{
if (!in_array($folder, $ignore))
{
$xml .= PHP_EOL . Indent::_(2) .
"<folder>{$folder}</folder>";
}
}
$xml .= PHP_EOL . Indent::_(1) . '</files>';
return $xml;
}
/**
* Generate XML for configuration fields.
*
* @param object $plugin The plugin object.
* @param array $configFields The configuration fields.
* @param bool $addComponentPath Whether to add the component path.
*
* @return string The XML for configuration fields.
* @since 5.0.2
*/
protected function generateConfigXml(object $plugin, array $configFields,
bool $addComponentPath): string
{
if (!isset($plugin->config_fields) ||
!ArrayHelper::check($configFields))
{
return '';
}
$xml = PHP_EOL . PHP_EOL . Indent::_(1) . '<!--' . Line::_(
__LINE__,__CLASS__
) . ' Config parameters -->';
$xml .= $addComponentPath ? PHP_EOL . Indent::_(1) .
'<config' : PHP_EOL . Indent::_(1) .
'<config>';
if ($addComponentPath)
{
$xml .= PHP_EOL . Indent::_(3) . 'addruleprefix="' .
$this->config->namespace_prefix . '\Component\\' .
$this->contentone->get('ComponentNamespace') .
'\Administrator\Rule"';
$xml .= PHP_EOL . Indent::_(3) . 'addfieldprefix="' .
$this->config->namespace_prefix . '\Component\\' .
$this->contentone->get('ComponentNamespace') .
'\Administrator\Field">';
$xml .= PHP_EOL . Indent::_(1) . '>';
}
foreach ($plugin->config_fields as $fieldName => $fieldsets)
{
$xml .= PHP_EOL . Indent::_(1) . "<fields
name=\"{$fieldName}\">";
foreach ($fieldsets as $fieldset => $fields)
{
$label =
$plugin->fieldsets_label["{$fieldName}{$fieldset}"] ??
$fieldset;
$xml .= PHP_EOL . Indent::_(1) . "<fieldset
name=\"{$fieldset}\" label=\"{$label}\">";
if (isset($configFields["{$fieldName}{$fieldset}"]))
{
$xml .= $configFields["{$fieldName}{$fieldset}"];
}
$xml .= PHP_EOL . Indent::_(1) . '</fieldset>';
}
$xml .= PHP_EOL . Indent::_(1) . '</fields>';
}
$xml .= PHP_EOL . Indent::_(1) . '</config>';
return $xml;
}
/**
* Generate XML for update servers.
*
* @param object $plugin The plugin object.
*
* @return string The XML for update servers.
* @since 5.0.2
*/
protected function generateUpdateServerXml(object $plugin): string
{
$xml = '';
if ($plugin->add_update_server)
{
$xml = PHP_EOL . PHP_EOL . Indent::_(1) . '<!--' .
Line::_(
__LINE__,__CLASS__
) . ' Update servers -->';
$xml .= PHP_EOL . Indent::_(1) . '<updateservers>';
$xml .= PHP_EOL . Indent::_(2) . '<server
type="extension" priority="1" name="' .
$plugin->official_name . '">' .
$plugin->update_server_url . '</server>';
$xml .= PHP_EOL . Indent::_(1) . '</updateservers>';
}
return $xml;
}
/**
* Generate language files.
*
* @param object $plugin The plugin object.
*
* @return array The language files.
* @since 5.0.2
*/
protected function generateLanguageFiles(object $plugin): array
{
$languageFiles = [];
if (!$this->language->exist($plugin->key))
{
return $languageFiles;
}
$langContent = $this->language->getTarget($plugin->key);
$this->event->trigger('jcb_ce_onBeforeBuildPluginLang',
[&$plugin, &$langContent]);
$values = array_unique($langContent);
$this->buildermultilingual->set('plugins',
$this->multilingual->get($values));
$langTag = $this->config->get('lang_tag',
'en-GB');
$this->languages->set("plugins.{$langTag}.all",
$langContent);
$this->language->setTarget($plugin->key, null);
$this->set->execute($values, $plugin->id, 'plugins');
$this->purge->execute($values, $plugin->id,
'plugins');
$this->event->trigger('jcb_ce_onBeforeBuildPluginLangFiles',
[&$plugin]);
if ($this->languages->IsArray('plugins'))
{
foreach ($this->languages->get('plugins') as $tag =>
$areas)
{
$tag = trim($tag);
foreach ($areas as $area => $languageStrings)
{
$fileName = "plg_" . strtolower((string)$plugin->group) .
'_' . $plugin->file_name . '.ini';
$total = count($values);
if ($this->translation->check($tag, $languageStrings, $total,
$fileName))
{
$lang = array_map(
fn($langString, $placeholder) =>
"{$placeholder}=\"{$langString}\"",
array_values($languageStrings),
array_keys($languageStrings)
);
$path = "{$plugin->folder_path}/language/{$tag}/";
if (!Folder::exists($path))
{
Folder::create($path);
$this->counter->folder++;
}
$this->file->write($path . $fileName, implode(PHP_EOL,
$lang));
$this->file->write(
$path . 'plg_' . strtolower((string)$plugin->group) .
'_' . $plugin->file_name . '.sys.ini',
implode(PHP_EOL, $lang)
);
$this->counter->line += count($lang);
unset($lang);
$languageFiles[$tag] = $tag;
}
}
}
}
return $languageFiles;
}
}
src/Componentbuilder/Compiler/Architecture/JoomlaFour/Plugin/Provider.php000064400000006667151162054070022676
0ustar00<?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\Plugin;
use VDM\Joomla\Componentbuilder\Compiler\Placeholder;
use VDM\Joomla\Componentbuilder\Compiler\Builder\ContentOne as Builder;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Indent;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Line;
use
VDM\Joomla\Componentbuilder\Compiler\Interfaces\Architecture\Plugin\ProviderInterface;
/**
* Plugin Provider Class for Joomla 4
*
* @since 5.0.2
*/
final class Provider implements ProviderInterface
{
/**
* The Placeholder Class.
*
* @var Placeholder
* @since 5.0.2
*/
protected Placeholder $placeholder;
/**
* The ContentOne Class.
*
* @var Builder
* @since 5.0.2
*/
protected Builder $builder;
/**
* Constructor.
*
* @param Placeholder $placeholder The Placeholder Class.
* @param Builder $builder The Content One Class.
*
* @since 5.0.2
*/
public function __construct(Placeholder $placeholder, Builder $builder)
{
$this->placeholder = $placeholder;
$this->builder = $builder;
}
/**
* Get the updated provider for the given plugin.
*
* @param object $plugin The plugin object containing the necessary
data.
*
* @return string The provider content.
*
* @since 5.0.2
*/
public function get(object $plugin): string
{
$group = strtolower((string) $plugin->group);
$provider = [];
$provider[] = PHP_EOL . PHP_EOL . "return new class () implements
ServiceProviderInterface {";
$provider[] = Indent::_(1) . "/**";
$provider[] = Indent::_(1) . "*" . Line::_(__Line__,
__Class__)
. " Registers the service provider with a DI container.";
$provider[] = Indent::_(1) . "*";
$provider[] = Indent::_(1) . "* @param Container \$container The
DI container.";
$provider[] = Indent::_(1) . "*";
$provider[] = Indent::_(1) . "* @return void";
$provider[] = Indent::_(1) . "* @since 4.3.0";
$provider[] = Indent::_(1) . "*/";
$provider[] = Indent::_(1) . "public function register(Container
\$container)";
$provider[] = Indent::_(1) . "{";
$provider[] = Indent::_(2) . "\$container->set(";
$provider[] = Indent::_(3) . "PluginInterface::class,";
$provider[] = Indent::_(3) . "function (Container \$container)
{";
$provider[] = Indent::_(4) . "\$plugin = new
{$plugin->class_name}(";
$provider[] = Indent::_(5) .
"\$container->get(DispatcherInterface::class),";
$provider[] = Indent::_(5) . "(array)
PluginHelper::getPlugin('{$group}',
'{$plugin->context_name}')";
$provider[] = Indent::_(4) . ");";
$provider[] = Indent::_(4) .
"\$plugin->setApplication(Factory::getApplication());";
$provider[] = $plugin->service_provider ?? ''; // to add
extra plug-in suff
$provider[] = Indent::_(4) . "return \$plugin;";
$provider[] = Indent::_(3) . "}";
$provider[] = Indent::_(2) . ");";
$provider[] = Indent::_(1) . "}";
$provider[] = "};";
return $this->placeholder->update(
implode(PHP_EOL, $provider). PHP_EOL,
$this->builder->allActive()
);
}
}
src/Componentbuilder/Compiler/Architecture/JoomlaFour/Plugin/index.html000064400000000054151162054070022350
0ustar00<html><body
bgcolor="#FFFFFF"></body></html>src/Componentbuilder/Compiler/Architecture/JoomlaThree/ComHelperClass/CreateUser.php000064400000042467151162054070024706
0ustar00<?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\ComHelperClass;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Indent;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Line;
use
VDM\Joomla\Componentbuilder\Compiler\Interfaces\Architecture\ComHelperClass\CreateUserInterface;
/**
* Helper Class Create User Class for Joomla 3
*
* @since 5.0.2
*/
final class CreateUser implements CreateUserInterface
{
/**
* Generates the method definition for creating or updating a user based
on the provided parameters.
*
* This method returns a string representation of a PHP function that
includes various
* steps for handling user creation and updates, depending on the mode
(site registration or admin registration).
*
* @param $add Determines whether to generate the user creation
method or not.
* If true, the method will be generated and returned
as a string.
*
* @return string The generated method code as a string if $add is true.
* Returns an empty string if $add is false.
*/
public function get($add): string
{
if ($add)
{
$method = [];
$method[] = PHP_EOL . PHP_EOL . Indent::_(1) . "/**";
$method[] = Indent::_(1) . " * Greate user and update given
table";
$method[] = Indent::_(1) . " *";
$method[] = Indent::_(1)
. " * @param array \$credentials Array('name' =>
string, 'username' => string, 'email' => string,
'password' => string, 'password2' =>
string)";
$method[] = Indent::_(1) . " * @param int \$autologin";
$method[] = Indent::_(1)
. " * @param array \$params Array('useractivation'
=> int, 'sendpassword' => int,
'allowUserRegistration' => int)";
$method[] = Indent::_(1)
. " * @param array \$mode 1 = Site Registrations; 0 = Admin
Registration; 2 = Custom Helper Method Called registerUser";
$method[] = Indent::_(1) . " *";
$method[] = Indent::_(1)
. " * @return int|Error User ID on success, or an error.";
$method[] = Indent::_(1) . " */";
$method[] = Indent::_(1)
. "public static function createUser(\$credentials, \$autologin =
0,";
$method[] = Indent::_(2) . "\$params = array(";
$method[] = Indent::_(3)
. "'useractivation' => 0, 'sendpassword'
=> 1";
$method[] = Indent::_(2) . "), \$mode = 1";
$method[] = Indent::_(1) . ")";
$method[] = Indent::_(1) . "{";
$method[] = Indent::_(2) . "//" . Line::_(__Line__,
__Class__)
. " Override mode";
$method[] = Indent::_(2)
. "if (\$mode == 2 && method_exists(__CLASS__,
'registerUser'))";
$method[] = Indent::_(2) . "{";
$method[] = Indent::_(3) . "//" . Line::_(__Line__,
__Class__)
. " Update params";
$method[] = Indent::_(3) . "\$params['autologin'] =
\$autologin;";
$method[] = Indent::_(3) . "//" . Line::_(__Line__,
__Class__)
. " Now Register User";
$method[] = Indent::_(3)
. "return self::registerUser(\$credentials, \$params);";
$method[] = Indent::_(2) . "}";
$method[] = Indent::_(2) . "elseif (\$mode == 2)";
$method[] = Indent::_(2) . "{";
$method[] = Indent::_(3) . "//" . Line::_(__Line__,
__Class__)
. " Fallback to Site Registrations";
$method[] = Indent::_(3) . "\$mode = 1;";
$method[] = Indent::_(2) . "}";
$method[] = Indent::_(2) . "//" . Line::_(__Line__,
__Class__)
. " load the user component language files if there is an
error.";
$method[] = Indent::_(2) . "\$lang =
Factory::getLanguage();";
$method[] = Indent::_(2) . "\$extension =
'com_users';";
$method[] = Indent::_(2) . "\$base_dir = JPATH_SITE;";
$method[] = Indent::_(2) . "\$language_tag =
'en-GB';";
$method[] = Indent::_(2) . "\$reload = true;";
$method[] = Indent::_(2)
. "\$lang->load(\$extension, \$base_dir, \$language_tag,
\$reload);";
$method[] = Indent::_(2) . "//" . Line::_(__Line__,
__Class__)
. " Load the correct user model.";
$method[] = Indent::_(2) . "if (\$mode == 1) //" . Line::_(
__LINE__,__CLASS__
)
. " 1 = Site Registrations";
$method[] = Indent::_(2) . "{";
$method[] = Indent::_(3) . "//" . Line::_(__Line__,
__Class__)
. " Load the user site-registration model";
$method[] = Indent::_(3)
. "\$model = self::getModel('registration', \$base_dir .
'/components/' . \$extension, 'Users');";
$method[] = Indent::_(2) . "}";
$method[] = Indent::_(2) . "else //" . Line::_(__Line__,
__Class__)
. " 0 = Admin Registration";
$method[] = Indent::_(2) . "{";
$method[] = Indent::_(3) . "//" . Line::_(__Line__,
__Class__)
. " Load the backend-user model";
$method[] = Indent::_(3)
. "\$model = self::getModel('user', JPATH_ADMINISTRATOR
. '/components/' . \$extension, 'Users');";
$method[] = Indent::_(2) . "}";
$method[] = Indent::_(2) . "//" . Line::_(__Line__,
__Class__)
. " Check if we have params/config";
$method[] = Indent::_(2) . "if (Super_" .
"__0a59c65c_9daf_4bc9_baf4_e063ff9e6a8a___Power::check(\$params))";
$method[] = Indent::_(2) . "{";
$method[] = Indent::_(3) . "//" . Line::_(__Line__,
__Class__)
. " Make changes to user config";
$method[] = Indent::_(3)
. "foreach (\$params as \$param => \$set)";
$method[] = Indent::_(3) . "{";
$method[] = Indent::_(4) . "//" . Line::_(__Line__,
__Class__)
. " If you know of a better path, let me know";
$method[] = Indent::_(4)
. "\$params[\$param] = self::setParams(\$extension, \$param,
\$set);";
$method[] = Indent::_(3) . "}";
$method[] = Indent::_(2) . "}";
$method[] = Indent::_(2) . "//" . Line::_(__Line__,
__Class__)
. " Set username to email if not set";
$method[] = Indent::_(2)
. "if (!isset(\$credentials['username']) ||
!Super_" .
"__1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::check(\$credentials['username']))";
$method[] = Indent::_(2) . "{";
$method[] = Indent::_(3)
. "\$credentials['username'] =
\$credentials['email'];";
$method[] = Indent::_(2) . "}";
$method[] = Indent::_(2) . "//" . Line::_(__Line__,
__Class__)
. " Lineup new user data array";
$method[] = Indent::_(2) . "\$data = array(";
$method[] = Indent::_(3)
. "'username' =>
\$credentials['username'],";
$method[] = Indent::_(3) . "'name' =>
\$credentials['name'],";
$method[] = Indent::_(3) . "'block' => 0 );";
$method[] = Indent::_(2) . "//" . Line::_(__Line__,
__Class__)
. " Added details based on mode";
$method[] = Indent::_(2) . "if (\$mode == 1) //" . Line::_(
__LINE__,__CLASS__
)
. " 1 = Site-registration mode";
$method[] = Indent::_(2) . "{";
$method[] = Indent::_(3)
. "\$data['email1'] =
\$credentials['email'];";
$method[] = Indent::_(2) . "}";
$method[] = Indent::_(2) . "else //" . Line::_(__Line__,
__Class__)
. " 0 = Admin-registration mode";
$method[] = Indent::_(2) . "{";
$method[] = Indent::_(3)
. "\$data['email'] =
\$credentials['email'];";
$method[] = Indent::_(3)
. "\$data['registerDate'] =
Factory::getDate()->toSql();";
$method[] = Indent::_(2) . "}";
$method[] = Indent::_(2) . "//" . Line::_(__Line__,
__Class__)
. " Check if password was set";
$method[] = Indent::_(2)
. "if (\$mode == 1 &&
(!isset(\$credentials['password']) ||
!isset(\$credentials['password2']) || !Super_" .
"__1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::check(\$credentials['password'])
|| !Super_" .
"__1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::check(\$credentials['password2'])))";
$method[] = Indent::_(2) . "{";
$method[] = Indent::_(3) . "//" . Line::_(__Line__,
__Class__)
. " Set random password when empty password was submitted,";
$method[] = Indent::_(3) . "//" . Line::_(__Line__,
__Class__)
. " when using the 1 = site-registration mode";
$method[] = Indent::_(3)
. "\$credentials['password'] =
self::randomkey(8);";
$method[] = Indent::_(3)
. "\$credentials['password2'] =
\$credentials['password'];";
$method[] = Indent::_(2) . "}";
$method[] = Indent::_(2) . "//" . Line::_(__Line__,
__Class__)
. " Now Add password if set";
$method[] = Indent::_(2)
. "if (isset(\$credentials['password']) &&
isset(\$credentials['password2']) && Super_" .
"__1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::check(\$credentials['password'])
&& Super_" .
"__1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::check(\$credentials['password2']))";
$method[] = Indent::_(2) . "{";
$method[] = Indent::_(3) . "if (\$mode == 1) //" . Line::_(
__LINE__,__CLASS__
)
. " 1 = Site-registration mode";
$method[] = Indent::_(3) . "{";
$method[] = Indent::_(4)
. "\$data['password1'] =
\$credentials['password'];";
$method[] = Indent::_(3) . "}";
$method[] = Indent::_(3) . "else //" . Line::_(__Line__,
__Class__)
. " 0 = Admin-registration mode";
$method[] = Indent::_(3) . "{";
$method[] = Indent::_(4)
. "\$data['password'] =
\$credentials['password'];";
$method[] = Indent::_(3) . "}";
$method[] = Indent::_(3)
. "\$data['password2'] =
\$credentials['password2'];";
$method[] = Indent::_(2) . "}";
$method[] = Indent::_(2) . "//" . Line::_(__Line__,
__Class__)
. " Load the group/s value if set, only for Admin Registration
(\$mode == 0)";
$method[] = Indent::_(2)
. "if (\$mode == 0 &&
isset(\$credentials['groups']) && Super_" .
"__0a59c65c_9daf_4bc9_baf4_e063ff9e6a8a___Power::check(\$credentials['groups']))";
$method[] = Indent::_(2) . "{";
$method[] = Indent::_(3)
. "\$data['groups'] =
\$credentials['groups'];";
$method[] = Indent::_(2) . "}";
$method[] = Indent::_(2) . "//" . Line::_(__Line__,
__Class__)
. " Create the new user";
$method[] = Indent::_(2) . "if (\$mode == 1) //" . Line::_(
__LINE__,__CLASS__
)
. " 1 = Site-registration mode";
$method[] = Indent::_(2) . "{";
$method[] = Indent::_(3) . "\$userId =
\$model->register(\$data);";
$method[] = Indent::_(2) . "}";
$method[] = Indent::_(2) . "else //" . Line::_(__Line__,
__Class__)
. " 0 = Admin-registration mode";
$method[] = Indent::_(2) . "{";
$method[] = Indent::_(3) . "\$model->save(\$data);";
$method[] = Indent::_(3)
. "\$userId = \$model->getState('user.id',
0);";
$method[] = Indent::_(2) . "}";
$method[] = Indent::_(2) . "//" . Line::_(__Line__,
__Class__)
. " Check if we have params";
$method[] = Indent::_(2) . "if (Super_" .
"__0a59c65c_9daf_4bc9_baf4_e063ff9e6a8a___Power::check(\$params))";
$method[] = Indent::_(2) . "{";
$method[] = Indent::_(3) . "//" . Line::_(__Line__,
__Class__)
. " Change user params/config back";
$method[] = Indent::_(3)
. "foreach (\$params as \$param => \$set)";
$method[] = Indent::_(3) . "{";
$method[] = Indent::_(4) . "//" . Line::_(__Line__,
__Class__)
. " If you know of a better path, let me know";
$method[] = Indent::_(4)
. "self::setParams(\$extension, \$param, \$set);";
$method[] = Indent::_(3) . "}";
$method[] = Indent::_(2) . "}";
$method[] = Indent::_(2) . "//" . Line::_(__Line__,
__Class__)
. " if user is created";
$method[] = Indent::_(2) . "if (\$userId > 0)";
$method[] = Indent::_(2) . "{";
$method[] = Indent::_(3) . "//" . Line::_(__Line__,
__Class__)
. " Auto Login if Needed";
$method[] = Indent::_(3)
. "if (\$autologin &&
isset(\$credentials['password']))";
$method[] = Indent::_(3) . "{";
$method[] = Indent::_(4) . "//" . Line::_(__Line__,
__Class__)
. " Try to login";
$method[] = Indent::_(4) . "try{";
$method[] = Indent::_(5)
. "Factory::getApplication()->login(\$credentials);";
$method[] = Indent::_(4) . "} catch (\Exception
\$exception){";
$method[] = Indent::_(5) . "//" . Line::_(__Line__,
__Class__)
. " Do noting for now, may want to set redirect.";
$method[] = Indent::_(4) . "}";
$method[] = Indent::_(3) . "}";
$method[] = Indent::_(3) . "//" . Line::_(__Line__,
__Class__)
. " Return ID";
$method[] = Indent::_(3) . "return \$userId;";
$method[] = Indent::_(2) . "}";
$method[] = Indent::_(2) . "return \$model->getError();";
$method[] = Indent::_(1) . "}";
$method[] = PHP_EOL . Indent::_(1)
. "public static function
setParams(\$component,\$target,\$value)";
$method[] = Indent::_(1) . "{";
$method[] = Indent::_(2) . "//" . Line::_(__Line__,
__Class__)
. " Get the params and set the new values";
$method[] = Indent::_(2)
. "\$params = ComponentHelper::getParams(\$component);";
$method[] = Indent::_(2) . "\$was = \$params->get(\$target,
null);";
$method[] = Indent::_(2) . "if (\$was != \$value)";
$method[] = Indent::_(2) . "{";
$method[] = Indent::_(3) . "\$params->set(\$target,
\$value);";
$method[] = Indent::_(3) . "//" . Line::_(__Line__,
__Class__)
. " Get a new database query instance";
$method[] = Indent::_(3) . "\$db = Factory::getDBO();";
$method[] = Indent::_(3) . "\$query =
\$db->getQuery(true);";
$method[] = Indent::_(3) . "//" . Line::_(__Line__,
__Class__)
. " Build the query";
$method[] = Indent::_(3) . "\$query->update('#__extensions
AS a');";
$method[] = Indent::_(3)
. "\$query->set('a.params = ' .
\$db->quote((string)\$params));";
$method[] = Indent::_(3)
. "\$query->where('a.element = ' .
\$db->quote((string)\$component));";
$method[] = Indent::_(3);
$method[] = Indent::_(3) . "//" . Line::_(__Line__,
__Class__)
. " Execute the query";
$method[] = Indent::_(3) . "\$db->setQuery(\$query);";
$method[] = Indent::_(3) . "\$db->execute();";
$method[] = Indent::_(2) . "}";
$method[] = Indent::_(2) . "return \$was;";
$method[] = Indent::_(1) . "}";
$method[] = PHP_EOL . Indent::_(1) . "/**";
$method[] = Indent::_(1) . " * Update user values";
$method[] = Indent::_(1) . " */";
$method[] = Indent::_(1)
. "public static function updateUser(\$new)";
$method[] = Indent::_(1) . "{";
$method[] = Indent::_(2)
. "// load the user component language files if there is an
error.";
$method[] = Indent::_(2) . "\$lang =
Factory::getLanguage();";
$method[] = Indent::_(2) . "\$extension =
'com_users';";
$method[] = Indent::_(2) . "\$base_dir =
JPATH_ADMINISTRATOR;";
$method[] = Indent::_(2) . "\$language_tag =
'en-GB';";
$method[] = Indent::_(2) . "\$reload = true;";
$method[] = Indent::_(2)
. "\$lang->load(\$extension, \$base_dir, \$language_tag,
\$reload);";
$method[] = Indent::_(2) . "// load the user model";
$method[] = Indent::_(2)
. "\$model = self::getModel('user', JPATH_ADMINISTRATOR
. '/components/com_users', 'Users');";
$method[] = Indent::_(2) . "// Check if password was set";
$method[] = Indent::_(2)
. "if (isset(\$new['password']) &&
isset(\$new['password2']) && Super_" .
"__1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::check(\$new['password'])
&& Super_" .
"__1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::check(\$new['password2']))";
$method[] = Indent::_(2) . "{";
$method[] = Indent::_(3) . "// Use the users passwords";
$method[] = Indent::_(3) . "\$password =
\$new['password'];";
$method[] = Indent::_(3) . "\$password2 =
\$new['password2'];";
$method[] = Indent::_(2) . "}";
$method[] = Indent::_(2) . "// set username";
$method[] = Indent::_(2)
. "if (!isset(\$new['username']) || !Super_" .
"__1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::check(\$new['username']))";
$method[] = Indent::_(2) . "{";
$method[] = Indent::_(3)
. "\$new['username'] = \$new['email'];";
$method[] = Indent::_(2) . "}";
$method[] = Indent::_(2) . "// lineup update user data";
$method[] = Indent::_(2) . "\$data = array(";
$method[] = Indent::_(3) . "'id' =>
\$new['id'],";
$method[] = Indent::_(3) . "'username' =>
\$new['username'],";
$method[] = Indent::_(3) . "'name' =>
\$new['name'],";
$method[] = Indent::_(3) . "'email' =>
\$new['email'],";
$method[] = Indent::_(3)
. "'password' => \$password, // First password
field";
$method[] = Indent::_(3)
. "'password2' => \$password2, // Confirm password
field";
$method[] = Indent::_(3) . "'block' => 0 );";
$method[] = Indent::_(2) . "// set groups if found";
$method[] = Indent::_(2)
. "if (isset(\$new['groups']) && Super_" .
"__0a59c65c_9daf_4bc9_baf4_e063ff9e6a8a___Power::check(\$new['groups']))";
$method[] = Indent::_(2) . "{";
$method[] = Indent::_(3) . "\$data['groups'] =
\$new['groups'];";
$method[] = Indent::_(2) . "}";
$method[] = Indent::_(2) . "// register the new user";
$method[] = Indent::_(2) . "\$done =
\$model->save(\$data);";
$method[] = Indent::_(2) . "// if user is updated";
$method[] = Indent::_(2) . "if (\$done)";
$method[] = Indent::_(2) . "{";
$method[] = Indent::_(3) . "return \$new['id'];";
$method[] = Indent::_(2) . "}";
$method[] = Indent::_(2) . "return \$model->getError();";
$method[] = Indent::_(1) . "}";
// return the help method
return implode(PHP_EOL, $method);
}
return '';
}
}
src/Componentbuilder/Compiler/Architecture/JoomlaThree/ComHelperClass/index.html000064400000000054151162054070024112
0ustar00<html><body
bgcolor="#FFFFFF"></body></html>src/Componentbuilder/Compiler/Architecture/JoomlaThree/Controller/AllowAdd.php000064400000007327151162054070023606
0ustar00<?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);
}
}
src/Componentbuilder/Compiler/Architecture/JoomlaThree/Controller/AllowEdit.php000064400000027145151162054070024003
0ustar00<?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
);
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);
}
}
src/Componentbuilder/Compiler/Architecture/JoomlaThree/Controller/AllowEditViews.php000064400000014674151162054070025024
0ustar00<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder
<https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights
reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
namespace
VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaThree\Controller;
use VDM\Joomla\Componentbuilder\Compiler\Creator\Permission;
use VDM\Joomla\Componentbuilder\Compiler\Customcode\Dispenser;
use VDM\Joomla\Componentbuilder\Compiler\Builder\Category;
use VDM\Joomla\Componentbuilder\Compiler\Builder\CategoryOtherName;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Indent;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Line;
use
VDM\Joomla\Componentbuilder\Compiler\Interfaces\Architecture\Controller\AllowEditViewsInterface;
/**
* Controller Allow Edit Views Class for Joomla 3
*
* @since 5.0.2
*/
final class AllowEditViews implements AllowEditViewsInterface
{
/**
* The Permission Class.
*
* @var Permission
* @since 5.0.2
*/
protected Permission $permission;
/**
* The Dispenser Class.
*
* @var Dispenser
* @since 5.0.2
*/
protected Dispenser $dispenser;
/**
* The Category Class.
*
* @var Category
* @since 5.0.2
*/
protected Category $category;
/**
* The CategoryOtherName Class.
*
* @var CategoryOtherName
* @since 5.0.2
*/
protected CategoryOtherName $categoryothername;
/**
* Constructor.
*
* @param Permission $permission The Permission Class.
* @param Dispenser $dispenser The Dispenser Class.
* @param Category $category The Category Class.
* @param CategoryOtherName $categoryothername The CategoryOtherName
Class.
*
* @since 5.0.2
*/
public function __construct(Permission $permission,
Dispenser $dispenser, Category $category,
CategoryOtherName $categoryothername)
{
$this->permission = $permission;
$this->dispenser = $dispenser;
$this->category = $category;
$this->categoryothername = $categoryothername;
}
/**
* Get Array Code
*
* @param array $views
*
* @since 5.0.2
* @return string The array of Code (string)
*/
public function getArray(array $views): string
{
return ''; // not used for now in Joomla 3
}
/**
* Get Custom Function Code
*
* @param array $views
*
* @since 5.0.2
* @return string The functions of Code (string)
*/
public function getFunctions(array $views): string
{
return ''; // not used for now in Joomla 3
}
/**
* Get View Permissions Array Code
*
* @param string $nameSingleCode The single code name of the view.
* @param string $nameListCode The list code name of the view.
*
* @since 3.2.0
* @return string The allow edit method code
*/
protected function getViewArray(string $nameSingleCode, string
$nameListCode): string
{
$allow = [];
// prepare custom permission script
$customAllow = $this->dispenser->get(
'php_allowedit', $nameSingleCode
);
if ($customAllow !== '')
{
$allow[] = Indent::_(3) . "'function' =>
'allowEdit_{$nameSingleCode}'";
}
if ($this->category->exists("{$nameListCode}"))
{
// check if category has another name
$otherView = $this->categoryothername->
get($nameListCode . '.view', $nameSingleCode);
// check if the item has permissions.
if ($this->permission->globalExist($otherView,
'core.access'))
{
$access = $this->permission->getGlobal($otherView,
'core.access');
$allow[] = Indent::_(3) . "'access' =>
'{$access}'";
}
$edit = $this->permission->getAction($otherView,
'core.edit');
$allow[] = Indent::_(3) . "'edit' =>
'{$edit}'";
$edit_own = $this->permission->getAction($otherView,
'core.edit.own');
$allow[] = Indent::_(3) . "'edit.own' =>
'{$edit_own}'";
}
else
{
// check if the item has permissions.
if ($this->permission->actionExist($nameSingleCode,
'core.access'))
{
$access = $this->permission->getAction($nameSingleCode,
'core.access');
$allow[] = Indent::_(3) . "'access' =>
'{$access}'";
}
$edit = $this->permission->getAction($nameSingleCode,
'core.edit');
$allow[] = Indent::_(3) . "'edit' =>
'{$edit}'";
$edit_own = $this->permission->getAction($nameSingleCode,
'core.edit.own');
$allow[] = Indent::_(3) . "'edit.own' =>
'{$edit_own}'";
}
return "'{$nameSingleCode}' => [" . PHP_EOL .
implode(',' . PHP_EOL, $allow) . PHP_EOL . Indent::_(2) .
']';
}
/**
* Get View Permissions Function Code
*
* @param string $nameSingleCode The single code name of the view.
* @param string $nameListCode The list code name of the view.
*
* @since 3.2.0
* @return string|null The allow edit method code
*/
protected function getViewFunction(string $nameSingleCode, string
$nameListCode): ?string
{
$allow = [];
// prepare custom permission script
$customAllow = $this->dispenser->get(
'php_allowedit', $nameSingleCode
);
if ($customAllow !== '')
{
// setup the function
$allow[] = Indent::_(1) . '/**';
$allow[] = Indent::_(1) . " * Method to check if you can edit an
existing {$nameSingleCode} record.";
$allow[] = Indent::_(1) . ' *';
$allow[] = Indent::_(1) . ' * @param array $data An array of
input data.';
$allow[] = Indent::_(1) . ' * @param string $key The name of
the key for the primary key.';
$allow[] = Indent::_(1) . ' *';
$allow[] = Indent::_(1) . ' * @return boolean';
$allow[] = Indent::_(1) . ' *';
$allow[] = Indent::_(1) . ' * @since 5.0.2';
$allow[] = Indent::_(1) . ' */';
$allow[] = Indent::_(1) . "protected function
allowEdit_{$nameSingleCode}(\$data = [], \$key = 'id')";
$allow[] = Indent::_(1) . '{';
$allow[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__)
. " get user object.";
$allow[] = Indent::_(2) . "\$user = \$this->identity;";
$allow[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__)
. " get record id.";
$allow[] = Indent::_(2)
. "\$recordId = (int) isset(\$data[\$key]) ? \$data[\$key] :
0;";
// load custom permission script
$allow[] = $customAllow;
$allow[] = Indent::_(1) . '}';
return implode(PHP_EOL, $allow);
}
return null;
}
}
src/Componentbuilder/Compiler/Architecture/JoomlaThree/Controller/index.html000064400000000054151162054070023371
0ustar00<html><body
bgcolor="#FFFFFF"></body></html>src/Componentbuilder/Compiler/Architecture/JoomlaThree/Model/CanDelete.php000064400000005170151162054070022652
0ustar00<?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);
}
}
src/Componentbuilder/Compiler/Architecture/JoomlaThree/Model/CanEditState.php000064400000006511151162054070023336
0ustar00<?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);
}
}
src/Componentbuilder/Compiler/Architecture/JoomlaThree/Model/index.html000064400000000054151162054070022306
0ustar00<html><body
bgcolor="#FFFFFF"></body></html>src/Componentbuilder/Compiler/Architecture/JoomlaThree/Plugin/Extension.php000064400000003672151162054070023205
0ustar00<?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\Plugin;
use VDM\Joomla\Componentbuilder\Compiler\Placeholder;
use VDM\Joomla\Componentbuilder\Compiler\Builder\ContentOne as Builder;
use
VDM\Joomla\Componentbuilder\Compiler\Interfaces\Architecture\Plugin\ExtensionInterface;
/**
* Plugin Extension Class for Joomla 3
*
* @since 5.0.2
*/
final class Extension implements ExtensionInterface
{
/**
* The Placeholder Class.
*
* @var Placeholder
* @since 5.0.2
*/
protected Placeholder $placeholder;
/**
* The ContentOne Class.
*
* @var Builder
* @since 5.0.2
*/
protected Builder $builder;
/**
* Constructor.
*
* @param Placeholder $placeholder The Placeholder Class.
* @param Builder $builder The Content One Class.
*
* @since 5.0.2
*/
public function __construct(Placeholder $placeholder, Builder $builder)
{
$this->placeholder = $placeholder;
$this->builder = $builder;
}
/**
* Get the updated placeholder content for the given plugin.
*
* @param object $plugin The plugin object containing the necessary
data.
*
* @return string The updated placeholder content.
*
* @since 5.0.2
*/
public function get(object $plugin): string
{
return $this->placeholder->update(
$plugin->comment . PHP_EOL . 'class ' .
$plugin->class_name . ' extends ' .
$plugin->extends . PHP_EOL . '{' . PHP_EOL .
$plugin->main_class_code . PHP_EOL .
"}" . PHP_EOL,
$this->builder->allActive()
);
}
}
src/Componentbuilder/Compiler/Architecture/JoomlaThree/Plugin/MainXML.php000064400000040032151162054070022465
0ustar00<?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\Plugin;
use Joomla\CMS\Filesystem\Folder;
use VDM\Joomla\Componentbuilder\Compiler\Config;
use VDM\Joomla\Componentbuilder\Compiler\Language;
use VDM\Joomla\Componentbuilder\Compiler\Language\Set;
use VDM\Joomla\Componentbuilder\Compiler\Language\Purge;
use VDM\Joomla\Componentbuilder\Compiler\Language\Translation;
use VDM\Joomla\Componentbuilder\Compiler\Language\Multilingual;
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\EventInterface as
Event;
use VDM\Joomla\Componentbuilder\Compiler\Creator\FieldsetExtension;
use VDM\Joomla\Componentbuilder\Compiler\Builder\ContentOne;
use VDM\Joomla\Componentbuilder\Compiler\Builder\Languages;
use VDM\Joomla\Componentbuilder\Compiler\Builder\Multilingual as
BuilderMultilingual;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Counter;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\File;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Line;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Indent;
use VDM\Joomla\Utilities\ArrayHelper;
use VDM\Joomla\Utilities\StringHelper;
use
VDM\Joomla\Componentbuilder\Interfaces\Architecture\Plugin\MainXMLInterface;
/**
* Joomla 3 Plugin Main XML Class
*
* @since 5.0.2
*/
final class MainXML implements MainXMLInterface
{
/**
* The Config Class.
*
* @var Config
* @since 5.0.2
*/
protected Config $config;
/**
* The Language Class.
*
* @var Language
* @since 5.0.2
*/
protected Language $language;
/**
* The Set Class.
*
* @var Set
* @since 5.0.2
*/
protected Set $set;
/**
* The Purge Class.
*
* @var Purge
* @since 5.0.2
*/
protected Purge $purge;
/**
* The Translation Class.
*
* @var Translation
* @since 5.0.2
*/
protected Translation $translation;
/**
* The Multilingual Class.
*
* @var Multilingual
* @since 5.0.2
*/
protected Multilingual $multilingual;
/**
* The EventInterface Class.
*
* @var Event
* @since 5.0.2
*/
protected Event $event;
/**
* The FieldsetExtension Class.
*
* @var FieldsetExtension
* @since 5.0.2
*/
protected FieldsetExtension $fieldsetextension;
/**
* The ContentOne Class.
*
* @var ContentOne
* @since 5.0.2
*/
protected ContentOne $contentone;
/**
* The Languages Class.
*
* @var Languages
* @since 5.0.2
*/
protected Languages $languages;
/**
* The Multilingual Class.
*
* @var BuilderMultilingual
* @since 5.0.2
*/
protected BuilderMultilingual $buildermultilingual;
/**
* The Counter Class.
*
* @var Counter
* @since 5.0.2
*/
protected Counter $counter;
/**
* The File Class.
*
* @var File
* @since 5.0.2
*/
protected File $file;
/**
* Constructor.
*
* @param Config $config The Config Class.
* @param Language $language The Language
Class.
* @param Set $set The Set Class.
* @param Purge $purge The Purge Class.
* @param Translation $translation The Translation
Class.
* @param Multilingual $multilingual The Multilingual
Class.
* @param Event $event The EventInterface
Class.
* @param FieldsetExtension $fieldsetextension The
FieldsetExtension Class.
* @param ContentOne $contentone The ContentOne
Class.
* @param Languages $languages The Languages
Class.
* @param BuilderMultilingual $buildermultilingual The Multilingual
Class.
* @param Counter $counter The Counter Class.
* @param File $file The File Class.
*
* @since 5.0.2
*/
public function __construct(Config $config, Language $language, Set $set,
Purge $purge,
Translation $translation, Multilingual $multilingual,
Event $event, FieldsetExtension $fieldsetextension,
ContentOne $contentone, Languages $languages,
BuilderMultilingual $buildermultilingual,
Counter $counter, File $file)
{
$this->config = $config;
$this->language = $language;
$this->set = $set;
$this->purge = $purge;
$this->translation = $translation;
$this->multilingual = $multilingual;
$this->event = $event;
$this->fieldsetextension = $fieldsetextension;
$this->contentone = $contentone;
$this->languages = $languages;
$this->buildermultilingual = $buildermultilingual;
$this->counter = $counter;
$this->file = $file;
}
/**
* Generates the main XML for the plugin.
*
* @param object $plugin The plugin object.
*
* @return string The generated XML.
* @since 5.0.2
*/
public function get(object $plugin): string
{
$config_fields = $this->buildConfigFields($plugin);
$add_component_path = $this->shouldAddComponentPath($plugin);
$language_files = $this->generateLanguageFiles($plugin);
$xml = $this->generateScriptAndSqlXml($plugin);
$xml .= $this->generateLanguageXml($plugin, $language_files);
$xml .= $this->generateFileXml($plugin, $language_files);
$xml .= $this->generateConfigXml($plugin, $config_fields,
$add_component_path);
$xml .= $this->generateUpdateServerXml($plugin);
return $xml;
}
/**
* Build configuration fields XML.
*
* @param object $plugin The plugin object.
*
* @return array The configuration fields.
* @since 5.0.2
*/
protected function buildConfigFields(object $plugin): array
{
$configFields = [];
if (!isset($plugin->config_fields) ||
!ArrayHelper::check($plugin->config_fields))
{
return $configFields;
}
$dbKey = 'yy';
foreach ($plugin->config_fields as $fieldName => $fieldsets)
{
foreach ($fieldsets as $fieldset => $fields)
{
$xmlFields = $this->fieldsetextension->get($plugin, $fields,
$dbKey);
if (isset($xmlFields) && StringHelper::check($xmlFields))
{
$configFields["{$fieldName}{$fieldset}"] = $xmlFields;
}
$dbKey++;
}
}
return $configFields;
}
/**
* Determine if the component path should be added.
*
* @param object $plugin The plugin object.
*
* @return bool True if the component path should be added, false
otherwise.
* @since 5.0.2
*/
protected function shouldAddComponentPath(object $plugin): bool
{
if (!isset($plugin->config_fields) ||
!ArrayHelper::check($plugin->config_fields) ||
!isset($plugin->fieldsets_paths) ||
!ArrayHelper::check($plugin->fieldsets_paths))
{
return false;
}
foreach ($plugin->config_fields as $fieldName => $fieldsets)
{
foreach ($fieldsets as $fieldset => $fields)
{
if
(isset($plugin->fieldsets_paths["{$fieldName}{$fieldset}"])
&&
$plugin->fieldsets_paths["{$fieldName}{$fieldset}"] ==
1)
{
return true;
}
}
}
return false;
}
/**
* Generate XML for script and SQL files.
*
* @param object $plugin The plugin object.
*
* @return string The XML for script and SQL files.
* @since 5.0.2
*/
protected function generateScriptAndSqlXml(object $plugin): string
{
$xml = '';
if ($plugin->add_install_script)
{
$xml .= PHP_EOL . PHP_EOL . Indent::_(1) . '<!--' .
Line::_(
__LINE__,__CLASS__
) . ' Scripts to run on installation -->';
$xml .= PHP_EOL . Indent::_(1) .
'<scriptfile>script.php</scriptfile>';
}
if ($plugin->add_sql)
{
$xml .= PHP_EOL . PHP_EOL . Indent::_(1) . '<!--' .
Line::_(
__LINE__,__CLASS__
) . ' Runs on install -->';
$xml .= PHP_EOL . Indent::_(1) . '<install>';
$xml .= PHP_EOL . Indent::_(2) . '<sql>';
$xml .= PHP_EOL . Indent::_(3) . '<file driver="mysql"
charset="utf8">sql/mysql/install.sql</file>';
$xml .= PHP_EOL . Indent::_(2) . '</sql>';
$xml .= PHP_EOL . Indent::_(1) . '</install>';
}
if ($plugin->add_sql_uninstall)
{
$xml .= PHP_EOL . PHP_EOL . Indent::_(1) . '<!--' .
Line::_(
__LINE__,__CLASS__
) . ' Runs on uninstall -->';
$xml .= PHP_EOL . Indent::_(1) . '<uninstall>';
$xml .= PHP_EOL . Indent::_(2) . '<sql>';
$xml .= PHP_EOL . Indent::_(3) . '<file driver="mysql"
charset="utf8">sql/mysql/uninstall.sql</file>';
$xml .= PHP_EOL . Indent::_(2) . '</sql>';
$xml .= PHP_EOL . Indent::_(1) . '</uninstall>';
}
return $xml;
}
/**
* Generate XML for language files.
*
* @param object $plugin The plugin object.
* @param array $languageFiles The language files.
*
* @return string The XML for language files.
* @since 5.0.2
*/
protected function generateLanguageXml(object $plugin, array
$languageFiles): string
{
$xml = '';
if (ArrayHelper::check($languageFiles))
{
$xml .= PHP_EOL . PHP_EOL . Indent::_(1) . '<!--' .
Line::_(
__LINE__,__CLASS__
) . ' Language files -->';
$xml .= PHP_EOL . Indent::_(1) . '<languages
folder="language">';
foreach ($languageFiles as $addTag)
{
$xml .= PHP_EOL . Indent::_(2) . '<language tag="'
. $addTag . '">' . $addTag . '/' . $addTag
. '.plg_'
. strtolower((string) $plugin->group) . '_' .
strtolower(
(string) $plugin->code_name
) . '.ini</language>';
$xml .= PHP_EOL . Indent::_(2) . '<language tag="'
. $addTag . '">' . $addTag . '/' . $addTag
. '.plg_'
. strtolower((string) $plugin->group) . '_' .
strtolower(
(string) $plugin->code_name
) . '.sys.ini</language>';
}
$xml .= PHP_EOL . Indent::_(1) . '</languages>';
}
return $xml;
}
/**
* Generate the XML for the files.
*
* @param object $plugin The plugin object.
* @param array $languageFiles The language files.
*
* @return string The XML for the files.
* @since 5.0.2
*/
protected function generateFileXml(object $plugin, array $languageFiles):
string
{
$files = Folder::files($plugin->folder_path);
$folders = Folder::folders($plugin->folder_path);
$ignore = ['sql', 'language', 'script.php',
"{$plugin->file_name}.xml",
"{$plugin->file_name}.php"];
$xml = PHP_EOL . PHP_EOL . Indent::_(1) . '<!--' . Line::_(
__LINE__,__CLASS__
) . ' Plugin files -->';
$xml .= PHP_EOL . Indent::_(1) . '<files>';
$xml .= PHP_EOL . Indent::_(2) . "<filename
plugin=\"{$plugin->file_name}\">{$plugin->file_name}.php</filename>";
foreach ($files as $file)
{
if (!in_array($file, $ignore))
{
$xml .= PHP_EOL . Indent::_(2) .
"<filename>{$file}</filename>";
}
}
if (!empty($languageFiles))
{
$xml .= PHP_EOL . Indent::_(2) .
'<folder>language</folder>';
}
if ($plugin->add_sql || $plugin->add_sql_uninstall)
{
$xml .= PHP_EOL . Indent::_(2) .
'<folder>sql</folder>';
}
foreach ($folders as $folder)
{
if (!in_array($folder, $ignore))
{
$xml .= PHP_EOL . Indent::_(2) .
"<folder>{$folder}</folder>";
}
}
$xml .= PHP_EOL . Indent::_(1) . '</files>';
return $xml;
}
/**
* Generate XML for configuration fields.
*
* @param object $plugin The plugin object.
* @param array $configFields The configuration fields.
* @param bool $addComponentPath Whether to add the component path.
*
* @return string The XML for configuration fields.
* @since 5.0.2
*/
protected function generateConfigXml(object $plugin, array $configFields,
bool $addComponentPath): string
{
if (!isset($plugin->config_fields) ||
!ArrayHelper::check($configFields))
{
return '';
}
$xml = PHP_EOL . PHP_EOL . Indent::_(1) . '<!--' . Line::_(
__LINE__,__CLASS__
) . ' Config parameters -->';
$xml .= $addComponentPath ? PHP_EOL . Indent::_(1) .
'<config' : PHP_EOL . Indent::_(1) .
'<config>';
if ($addComponentPath)
{
$xml .= PHP_EOL . Indent::_(2) .
'addrulepath="/administrator/components/com_' .
$this->config->component_code_name .
'/models/rules"';
$xml .= PHP_EOL . Indent::_(2) .
'addfieldpath="/administrator/components/com_' .
$this->config->component_code_name .
'/models/fields"';
$xml .= PHP_EOL . Indent::_(1) . '>';
}
foreach ($plugin->config_fields as $fieldName => $fieldsets)
{
$xml .= PHP_EOL . Indent::_(1) . "<fields
name=\"{$fieldName}\">";
foreach ($fieldsets as $fieldset => $fields)
{
$label =
$plugin->fieldsets_label["{$fieldName}{$fieldset}"] ??
$fieldset;
$xml .= PHP_EOL . Indent::_(1) . "<fieldset
name=\"{$fieldset}\" label=\"{$label}\">";
if (isset($configFields["{$fieldName}{$fieldset}"]))
{
$xml .= $configFields["{$fieldName}{$fieldset}"];
}
$xml .= PHP_EOL . Indent::_(1) . '</fieldset>';
}
$xml .= PHP_EOL . Indent::_(1) . '</fields>';
}
$xml .= PHP_EOL . Indent::_(1) . '</config>';
return $xml;
}
/**
* Generate XML for update servers.
*
* @param object $plugin The plugin object.
*
* @return string The XML for update servers.
* @since 5.0.2
*/
protected function generateUpdateServerXml(object $plugin): string
{
$xml = '';
if ($plugin->add_update_server)
{
$xml = PHP_EOL . PHP_EOL . Indent::_(1) . '<!--' .
Line::_(
__LINE__,__CLASS__
) . ' Update servers -->';
$xml .= PHP_EOL . Indent::_(1) . '<updateservers>';
$xml .= PHP_EOL . Indent::_(2) . '<server
type="extension" priority="1" name="' .
$plugin->official_name . '">' .
$plugin->update_server_url . '</server>';
$xml .= PHP_EOL . Indent::_(1) . '</updateservers>';
}
return $xml;
}
/**
* Generate language files.
*
* @param object $plugin The plugin object.
*
* @return array The language files.
* @since 5.0.2
*/
protected function generateLanguageFiles(object $plugin): array
{
$languageFiles = [];
if (!$this->language->exist($plugin->key))
{
return $languageFiles;
}
$langContent = $this->language->getTarget($plugin->key);
$this->event->trigger('jcb_ce_onBeforeBuildPluginLang',
[&$plugin, &$langContent]);
$values = array_unique($langContent);
$this->buildermultilingual->set('plugins',
$this->multilingual->get($values));
$langTag = $this->config->get('lang_tag',
'en-GB');
$this->languages->set("plugins.{$langTag}.all",
$langContent);
$this->language->setTarget($plugin->key, null);
$this->set->execute($values, $plugin->id, 'plugins');
$this->purge->execute($values, $plugin->id,
'plugins');
$this->event->trigger('jcb_ce_onBeforeBuildPluginLangFiles',
[&$plugin]);
if ($this->languages->IsArray('plugins'))
{
foreach ($this->languages->get('plugins') as $tag =>
$areas)
{
$tag = trim($tag);
foreach ($areas as $area => $languageStrings)
{
$fileName = "{$tag}.plg_" .
strtolower((string)$plugin->group) . '_' .
strtolower((string)$plugin->code_name) . '.ini';
$total = count($values);
if ($this->translation->check($tag, $languageStrings, $total,
$fileName))
{
$lang = array_map(
fn($langString, $placeholder) =>
"{$placeholder}=\"{$langString}\"",
array_values($languageStrings),
array_keys($languageStrings)
);
$path = "{$plugin->folder_path}/language/{$tag}/";
if (!Folder::exists($path))
{
Folder::create($path);
$this->counter->folder++;
}
$this->file->write($path . $fileName, implode(PHP_EOL,
$lang));
$this->file->write(
$path . $tag . '.plg_' .
strtolower((string)$plugin->group) . '_' .
strtolower((string)$plugin->code_name) . '.sys.ini',
implode(PHP_EOL, $lang)
);
$this->counter->line += count($lang);
unset($lang);
$languageFiles[$tag] = $tag;
}
}
}
}
return $languageFiles;
}
}
src/Componentbuilder/Compiler/Architecture/JoomlaThree/Plugin/Provider.php000064400000003274151162054070023021
0ustar00<?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\Plugin;
use VDM\Joomla\Componentbuilder\Compiler\Placeholder;
use VDM\Joomla\Componentbuilder\Compiler\Builder\ContentOne as Builder;
use
VDM\Joomla\Componentbuilder\Compiler\Interfaces\Architecture\Plugin\ProviderInterface;
/**
* Plugin Provider Class for Joomla 3
*
* @since 5.0.2
*/
final class Provider implements ProviderInterface
{
/**
* The Placeholder Class.
*
* @var Placeholder
* @since 5.0.2
*/
protected Placeholder $placeholder;
/**
* The ContentOne Class.
*
* @var Builder
* @since 5.0.2
*/
protected Builder $builder;
/**
* Constructor.
*
* @param Placeholder $placeholder The Placeholder Class.
* @param Builder $builder The Content One Class.
*
* @since 5.0.2
*/
public function __construct(Placeholder $placeholder, Builder $builder)
{
$this->placeholder = $placeholder;
$this->builder = $builder;
}
/**
* Get the updated provider for the given plugin.
*
* @param object $plugin The plugin object containing the necessary
data.
*
* @return string The provider content.
*
* @since 5.0.2
*/
public function get(object $plugin): string
{
return ''; // no provider in Joomla 3
}
}
src/Componentbuilder/Compiler/Architecture/JoomlaThree/Plugin/index.html000064400000000054151162054070022504
0ustar00<html><body
bgcolor="#FFFFFF"></body></html>src/Componentbuilder/Compiler/Builder/AccessSwitch.php000064400000001256151162054070017105
0ustar00<?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;
/**
* Access Switch Builder Class
*
* @since 3.2.0
*/
final class AccessSwitch extends Registry implements Registryinterface
{
}
src/Componentbuilder/Compiler/Builder/AccessSwitchList.php000064400000001267151162054070017743
0ustar00<?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;
/**
* Access Switch List Builder Class
*
* @since 3.2.0
*/
final class AccessSwitchList extends Registry implements Registryinterface
{
}
src/Componentbuilder/Compiler/Builder/AdminFilterType.php000064400000001265151162054070017562
0ustar00<?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;
/**
* Admin Filter Type Builder Class
*
* @since 3.2.0
*/
final class AdminFilterType extends Registry implements Registryinterface
{
}
src/Componentbuilder/Compiler/Builder/Alias.php000064400000001237151162054070015552
0ustar00<?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;
/**
* Alias Builder Class
*
* @since 3.2.0
*/
final class Alias extends Registry implements Registryinterface
{
}
src/Componentbuilder/Compiler/Builder/AssetsRules.php000064400000001664151162054070017002
0ustar00<?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;
}
src/Componentbuilder/Compiler/Builder/BaseSixFour.php000064400000001246151162054070016713
0ustar00<?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;
/**
* Base64 Builder Class
*
* @since 3.2.0
*/
final class BaseSixFour extends Registry implements Registryinterface
{
}
src/Componentbuilder/Compiler/Builder/Category.php000064400000001245151162054070016275
0ustar00<?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;
/**
* Category Builder Class
*
* @since 3.2.0
*/
final class Category extends Registry implements Registryinterface
{
}
src/Componentbuilder/Compiler/Builder/CategoryCode.php000064400000001456151162054070017074
0ustar00<?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\GetString;
use VDM\Joomla\Interfaces\Registryinterface;
use VDM\Joomla\Abstraction\Registry;
/**
* Category Code Builder Class
*
* @since 3.2.0
*/
final class CategoryCode extends Registry implements Registryinterface
{
/**
* Get String Values
*
* @since 3.2.0
*/
use GetString;
}
src/Componentbuilder/Compiler/Builder/CategoryOtherName.php000064400000001271151162054070020077
0ustar00<?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;
/**
* Category Other Name Builder Class
*
* @since 3.2.0
*/
final class CategoryOtherName extends Registry implements Registryinterface
{
}
src/Componentbuilder/Compiler/Builder/CheckBox.php000064400000001246151162054070016207
0ustar00<?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;
/**
* Check Box Builder Class
*
* @since 3.2.0
*/
final class CheckBox extends Registry implements Registryinterface
{
}
src/Componentbuilder/Compiler/Builder/ComponentFields.php000064400000001464151162054070017614
0ustar00<?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\VarExport;
use VDM\Joomla\Interfaces\Registryinterface;
use VDM\Joomla\Abstraction\Registry;
/**
* Component Fields Builder Class
*
* @since 3.2.0
*/
final class ComponentFields extends Registry implements Registryinterface
{
/**
* Var Export Values
*
* @since 3.2.0
*/
use VarExport;
}
src/Componentbuilder/Compiler/Builder/ConfigFieldsets.php000064400000001504151162054070017566
0ustar00<?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;
}
src/Componentbuilder/Compiler/Builder/ConfigFieldsetsCustomfield.php000064400000001503151162054070021764
0ustar00<?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;
}
src/Componentbuilder/Compiler/Builder/ContentMulti.php000064400000003471151162054070017150
0ustar00<?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\Componentbuilder\Compiler\Utilities\Placefix;
use VDM\Joomla\Abstraction\Registry\Traits\IsArray;
use VDM\Joomla\Interfaces\Registryinterface;
use VDM\Joomla\Abstraction\Registry;
/**
* Compiler Content Multi
*
* @since 3.2.0
*/
class ContentMulti extends Registry implements Registryinterface
{
/**
* Is an Array
*
* @since 3.2.0
*/
use IsArray;
/**
* Constructor.
*
* @since 3.2.0
*/
public function __construct()
{
$this->setSeparator('|');
}
/**
* Get that the active keys from a path
*
* @param string $path The path to determine the location mapper.
*
* @return array|null The valid array of keys
* @since 3.2.0
*/
protected function getActiveKeys(string $path): ?array
{
// Call the parent class's version of this method
$keys = parent::getActiveKeys($path);
if ($keys === null)
{
return null;
}
return $this->modelActiveKeys($keys);
}
/**
* Model that the active key
*
* @param array $keys The keys to the location mapper.
*
* @return array|null The valid array of key
* @since 3.2.0
*/
protected function modelActiveKeys(array $keys): ?array
{
if (isset($keys[1]))
{
return [$keys[0], Placefix::_h($keys[1])];
}
if (isset($keys[0]))
{
return [$keys[0]];
}
return null;
}
}
src/Componentbuilder/Compiler/Builder/ContentOne.php000064400000003275151162054070016601
0ustar00<?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\Componentbuilder\Compiler\Utilities\Placefix;
use VDM\Joomla\Abstraction\Registry\Traits\IsString;
use VDM\Joomla\Interfaces\Registryinterface;
use VDM\Joomla\Abstraction\Registry;
/**
* Compiler Content One
*
* @since 3.2.0
*/
class ContentOne extends Registry implements Registryinterface
{
/**
* Is String Values
*
* @since 3.2.0
*/
use IsString;
/**
* Constructor.
*
* @since 3.2.0
*/
public function __construct()
{
$this->setSeparator(null);
}
/**
* Get that the active keys from a path
*
* @param string $path The path to determine the location mapper.
*
* @return array|null The valid array of keys
* @since 3.2.0
*/
protected function getActiveKeys(string $path): ?array
{
// Call the parent class's version of this method
$keys = parent::getActiveKeys($path);
if ($keys === null)
{
return null;
}
return $this->modelActiveKeys($keys);
}
/**
* Model that the active key
*
* @param array $keys The keys to the location mapper.
*
* @return array The valid array of key
* @since 3.2.0
*/
protected function modelActiveKeys(array $keys): array
{
return [Placefix::_h($keys[0])];
}
}
src/Componentbuilder/Compiler/Builder/Contributors.php000064400000001255151162054070017216
0ustar00<?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
{
}
src/Componentbuilder/Compiler/Builder/CustomAlias.php000064400000001254151162054070016744
0ustar00<?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;
/**
* Custom Alias Builder Class
*
* @since 3.2.0
*/
final class CustomAlias extends Registry implements Registryinterface
{
}
src/Componentbuilder/Compiler/Builder/CustomField.php000064400000001254151162054070016736
0ustar00<?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;
/**
* Custom Field Builder Class
*
* @since 3.2.0
*/
final class CustomField extends Registry implements Registryinterface
{
}
src/Componentbuilder/Compiler/Builder/CustomFieldLinks.php000064400000001464151162054070017742
0ustar00<?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\ToString;
use VDM\Joomla\Interfaces\Registryinterface;
use VDM\Joomla\Abstraction\Registry;
/**
* Custom Field Links Builder Class
*
* @since 3.2.0
*/
final class CustomFieldLinks extends Registry implements Registryinterface
{
/**
* To String Values
*
* @since 3.2.0
*/
use ToString;
}
src/Componentbuilder/Compiler/Builder/CustomList.php000064400000001252151162054070016624
0ustar00<?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;
/**
* Custom List Builder Class
*
* @since 3.2.0
*/
final class CustomList extends Registry implements Registryinterface
{
}
src/Componentbuilder/Compiler/Builder/CustomTabs.php000064400000001252151162054070016602
0ustar00<?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;
/**
* Custom Tabs Builder Class
*
* @since 3.2.0
*/
final class CustomTabs extends Registry implements Registryinterface
{
}
src/Componentbuilder/Compiler/Builder/DatabaseKeys.php000064400000001713151162054070017060
0ustar00<?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 Keys Builder Class
*
* @since 3.2.0
*/
final class DatabaseKeys extends Registry implements Registryinterface
{
/**
* Base switch to add values as string or array
*
* @var boolean
* @since 3.2.0
**/
protected bool $addAsArray = true;
/**
* Base switch to keep array values unique
*
* @var boolean
* @since 3.2.2
**/
protected bool $uniqueArray = true;
}
src/Componentbuilder/Compiler/Builder/DatabaseTables.php000064400000001262151162054070017356
0ustar00<?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 Tables Builder Class
*
* @since 3.2.0
*/
final class DatabaseTables extends Registry implements Registryinterface
{
}
src/Componentbuilder/Compiler/Builder/DatabaseUninstall.php000064400000001700151162054070020112
0ustar00<?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;
}
src/Componentbuilder/Compiler/Builder/DatabaseUniqueGuid.php000064400000001273151162054070020225
0ustar00<?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 Unique Guid Builder Class
*
* @since 3.2.0
*/
final class DatabaseUniqueGuid extends Registry implements
Registryinterface
{
}
src/Componentbuilder/Compiler/Builder/DatabaseUniqueKeys.php000064400000001273151162054070020250
0ustar00<?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 Unique Keys Builder Class
*
* @since 3.2.0
*/
final class DatabaseUniqueKeys extends Registry implements
Registryinterface
{
}
src/Componentbuilder/Compiler/Builder/DoNotEscape.php000064400000001255151162054070016665
0ustar00<?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;
/**
* Do Not Escape Builder Class
*
* @since 3.2.0
*/
final class DoNotEscape extends Registry implements Registryinterface
{
}
src/Componentbuilder/Compiler/Builder/DynamicFields.php000064400000001455151162054070017236
0ustar00<?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\ToString;
use VDM\Joomla\Interfaces\Registryinterface;
use VDM\Joomla\Abstraction\Registry;
/**
* Dynamic Fields Builder Class
*
* @since 3.2.0
*/
final class DynamicFields extends Registry implements Registryinterface
{
/**
* To String Values
*
* @since 3.2.0
*/
use ToString;
}
src/Componentbuilder/Compiler/Builder/ExtensionCustomFields.php000064400000001301151162054070021007
0ustar00<?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;
/**
* Extension Custom Fields Builder Class
*
* @since 3.2.0
*/
final class ExtensionCustomFields extends Registry implements
Registryinterface
{
}
src/Componentbuilder/Compiler/Builder/ExtensionsParams.php000064400000001676151162054070020033
0ustar00<?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;
}
src/Componentbuilder/Compiler/Builder/FieldGroupControl.php000064400000001271151162054070020120
0ustar00<?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;
/**
* Field Group Control Builder Class
*
* @since 3.2.0
*/
final class FieldGroupControl extends Registry implements Registryinterface
{
}
src/Componentbuilder/Compiler/Builder/FieldNames.php000064400000001447151162054070016533
0ustar00<?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\IsString;
use VDM\Joomla\Interfaces\Registryinterface;
use VDM\Joomla\Abstraction\Registry;
/**
* Field Names Builder Class
*
* @since 3.2.0
*/
final class FieldNames extends Registry implements Registryinterface
{
/**
* Is String Values
*
* @since 3.2.0
*/
use IsString;
}
src/Componentbuilder/Compiler/Builder/FieldRelations.php000064400000001262151162054070017423
0ustar00<?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;
/**
* Field Relations Builder Class
*
* @since 3.2.0
*/
final class FieldRelations extends Registry implements Registryinterface
{
}
src/Componentbuilder/Compiler/Builder/Filter.php000064400000001241151162054070015741
0ustar00<?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;
/**
* Filter Builder Class
*
* @since 3.2.0
*/
final class Filter extends Registry implements Registryinterface
{
}
src/Componentbuilder/Compiler/Builder/FootableScripts.php000064400000001264151162054070017624
0ustar00<?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;
/**
* Footable Scripts Builder Class
*
* @since 3.2.0
*/
final class FootableScripts extends Registry implements Registryinterface
{
}
src/Componentbuilder/Compiler/Builder/FrontendParams.php000064400000001263151162054070017443
0ustar00<?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
{
}
src/Componentbuilder/Compiler/Builder/GetAsLookup.php000064400000001255151162054070016716
0ustar00<?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;
/**
* Get As Lookup Builder Class
*
* @since 3.2.0
*/
final class GetAsLookup extends Registry implements Registryinterface
{
}
src/Componentbuilder/Compiler/Builder/GetModule.php000064400000001250151162054070016401
0ustar00<?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;
/**
* Get Module Builder Class
*
* @since 3.2.0
*/
final class GetModule extends Registry implements Registryinterface
{
}
src/Componentbuilder/Compiler/Builder/GoogleChart.php000064400000001254151162054070016716
0ustar00<?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;
/**
* Google Chart Builder Class
*
* @since 3.2.0
*/
final class GoogleChart extends Registry implements Registryinterface
{
}
src/Componentbuilder/Compiler/Builder/HasMenuGlobal.php000064400000001261151162054070017177
0ustar00<?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
{
}
src/Componentbuilder/Compiler/Builder/HasPermissions.php000064400000001262151162054070017466
0ustar00<?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 Permissions Builder Class
*
* @since 3.2.0
*/
final class HasPermissions extends Registry implements Registryinterface
{
}
src/Componentbuilder/Compiler/Builder/HiddenFields.php000064400000001453151162054070017043
0ustar00<?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\ToString;
use VDM\Joomla\Interfaces\Registryinterface;
use VDM\Joomla\Abstraction\Registry;
/**
* Hidden Fields Builder Class
*
* @since 3.2.0
*/
final class HiddenFields extends Registry implements Registryinterface
{
/**
* To String Values
*
* @since 3.2.0
*/
use ToString;
}
src/Componentbuilder/Compiler/Builder/History.php000064400000001243151162054070016157
0ustar00<?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;
/**
* History Builder Class
*
* @since 3.2.0
*/
final class History extends Registry implements Registryinterface
{
}
src/Componentbuilder/Compiler/Builder/IntegerFields.php000064400000001455151162054070017247
0ustar00<?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\ToString;
use VDM\Joomla\Interfaces\Registryinterface;
use VDM\Joomla\Abstraction\Registry;
/**
* Integer Fields Builder Class
*
* @since 3.2.0
*/
final class IntegerFields extends Registry implements Registryinterface
{
/**
* To String Values
*
* @since 3.2.0
*/
use ToString;
}
src/Componentbuilder/Compiler/Builder/ItemsMethodEximportString.php000064400000001312151162054070021654
0ustar00<?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;
/**
* Items Method Eximport String Builder Class
*
* @since 3.2.0
*/
final class ItemsMethodEximportString extends Registry implements
Registryinterface
{
}
src/Componentbuilder/Compiler/Builder/ItemsMethodListString.php000064400000001302151162054070020757
0ustar00<?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;
/**
* Items Method List String Builder Class
*
* @since 3.2.0
*/
final class ItemsMethodListString extends Registry implements
Registryinterface
{
}
src/Componentbuilder/Compiler/Builder/JsonItem.php000064400000001246151162054070016251
0ustar00<?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;
/**
* Json Item Builder Class
*
* @since 3.2.0
*/
final class JsonItem extends Registry implements Registryinterface
{
}
src/Componentbuilder/Compiler/Builder/JsonItemArray.php000064400000001444151162054070017250
0ustar00<?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\InArray;
use VDM\Joomla\Interfaces\Registryinterface;
use VDM\Joomla\Abstraction\Registry;
/**
* Json Item Array Builder Class
*
* @since 3.2.0
*/
final class JsonItemArray extends Registry implements Registryinterface
{
/**
* In Array
*
* @since 3.2.0
*/
use InArray;
}
src/Componentbuilder/Compiler/Builder/JsonString.php000064400000001252151162054070016616
0ustar00<?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;
/**
* Json String Builder Class
*
* @since 3.2.0
*/
final class JsonString extends Registry implements Registryinterface
{
}
src/Componentbuilder/Compiler/Builder/LanguageMessages.php000064400000001454151162054070017735
0ustar00<?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;
}
src/Componentbuilder/Compiler/Builder/Languages.php000064400000001435151162054070016427
0ustar00<?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;
/**
* Languages Builder Class
*
* @since 3.2.2
*/
final class Languages extends Registry implements Registryinterface
{
/**
* Is an Array
*
* @since 3.2.2
*/
use IsArray;
}
src/Componentbuilder/Compiler/Builder/Layout.php000064400000001424151162054070015774
0ustar00<?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\Count;
use VDM\Joomla\Interfaces\Registryinterface;
use VDM\Joomla\Abstraction\Registry;
/**
* Layout Builder Class
*
* @since 3.2.0
*/
final class Layout extends Registry implements Registryinterface
{
/**
* Count Values
*
* @since 3.2.0
*/
use Count;
}
src/Componentbuilder/Compiler/Builder/LayoutData.php000064400000001252151162054070016565
0ustar00<?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;
/**
* Layout Data Builder Class
*
* @since 3.2.0
*/
final class LayoutData extends Registry implements Registryinterface
{
}
src/Componentbuilder/Compiler/Builder/LibraryManager.php000064400000001262151162054070017416
0ustar00<?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;
/**
* Library Manager Builder Class
*
* @since 3.2.0
*/
final class LibraryManager extends Registry implements Registryinterface
{
}
src/Componentbuilder/Compiler/Builder/ListFieldClass.php000064400000001263151162054070017365
0ustar00<?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;
/**
* List Field Class Builder Class
*
* @since 3.2.0
*/
final class ListFieldClass extends Registry implements Registryinterface
{
}
src/Componentbuilder/Compiler/Builder/ListHeadOverride.php000064400000001267151162054070017721
0ustar00<?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;
/**
* List Head Override Builder Class
*
* @since 3.2.0
*/
final class ListHeadOverride extends Registry implements Registryinterface
{
}
src/Componentbuilder/Compiler/Builder/ListJoin.php000064400000001246151162054070016254
0ustar00<?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;
/**
* List Join Builder Class
*
* @since 3.2.0
*/
final class ListJoin extends Registry implements Registryinterface
{
}
src/Componentbuilder/Compiler/Builder/Lists.php000064400000001237151162054070015617
0ustar00<?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;
/**
* Lists Builder Class
*
* @since 3.2.0
*/
final class Lists extends Registry implements Registryinterface
{
}
src/Componentbuilder/Compiler/Builder/MainTextField.php000064400000001261151162054070017213
0ustar00<?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;
/**
* Main Text Field Builder Class
*
* @since 3.2.0
*/
final class MainTextField extends Registry implements Registryinterface
{
}
src/Componentbuilder/Compiler/Builder/MetaData.php000064400000001443151162054070016200
0ustar00<?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\IsString;
use VDM\Joomla\Interfaces\Registryinterface;
use VDM\Joomla\Abstraction\Registry;
/**
* Meta Data Builder Class
*
* @since 3.2.0
*/
final class MetaData extends Registry implements Registryinterface
{
/**
* Is String Values
*
* @since 3.2.0
*/
use IsString;
}
src/Componentbuilder/Compiler/Builder/ModelBasicField.php000064400000001265151162054070017470
0ustar00<?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;
/**
* Basic Field Model Builder Class
*
* @since 3.2.0
*/
final class ModelBasicField extends Registry implements Registryinterface
{
}
src/Componentbuilder/Compiler/Builder/ModelExpertField.php000064400000001267151162054070017720
0ustar00<?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;
/**
* Expert Field Model Builder Class
*
* @since 3.2.0
*/
final class ModelExpertField extends Registry implements Registryinterface
{
}
src/Componentbuilder/Compiler/Builder/ModelExpertFieldInitiator.php000064400000001312151162054100021564
0ustar00<?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;
/**
* Expert Field Initiator Model Builder Class
*
* @since 3.2.0
*/
final class ModelExpertFieldInitiator extends Registry implements
Registryinterface
{
}
src/Componentbuilder/Compiler/Builder/ModelMediumField.php000064400000001267151162054100017663
0ustar00<?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;
/**
* Medium Field Model Builder Class
*
* @since 3.2.0
*/
final class ModelMediumField extends Registry implements Registryinterface
{
}
src/Componentbuilder/Compiler/Builder/ModelWhmcsField.php000064400000001265151162054100017522
0ustar00<?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;
/**
* Whmcs Field Model Builder Class
*
* @since 3.2.0
*/
final class ModelWhmcsField extends Registry implements Registryinterface
{
}
src/Componentbuilder/Compiler/Builder/MovedPublishingFields.php000064400000001301151162054100020731
0ustar00<?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;
/**
* Moved Publishing Fields Builder Class
*
* @since 3.2.0
*/
final class MovedPublishingFields extends Registry implements
Registryinterface
{
}
src/Componentbuilder/Compiler/Builder/Multilingual.php000064400000001443151162054100017160
0ustar00<?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;
/**
* Multilingual Builder Class
*
* @since 5.0.2
*/
final class Multilingual extends Registry implements Registryinterface
{
/**
* Is an Array
*
* @since 5.0.2
*/
use IsArray;
}
src/Componentbuilder/Compiler/Builder/MysqlTableSetting.php000064400000001271151162054100020124
0ustar00<?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;
/**
* Mysql Table Setting Builder Class
*
* @since 3.2.0
*/
final class MysqlTableSetting extends Registry implements Registryinterface
{
}
src/Componentbuilder/Compiler/Builder/NewPublishingFields.php000064400000001460151162054100020416
0ustar00<?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\Count;
use VDM\Joomla\Interfaces\Registryinterface;
use VDM\Joomla\Abstraction\Registry;
/**
* New Publishing Fields Builder Class
*
* @since 3.2.0
*/
final class NewPublishingFields extends Registry implements
Registryinterface
{
/**
* Count Values
*
* @since 3.2.0
*/
use Count;
}
src/Componentbuilder/Compiler/Builder/OrderZero.php000064400000001250151162054100016421
0ustar00<?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;
/**
* Order Zero Builder Class
*
* @since 3.2.0
*/
final class OrderZero extends Registry implements Registryinterface
{
}
src/Componentbuilder/Compiler/Builder/OtherFilter.php000064400000001254151162054100016741
0ustar00<?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;
/**
* Other Filter Builder Class
*
* @since 3.2.0
*/
final class OtherFilter extends Registry implements Registryinterface
{
}
src/Componentbuilder/Compiler/Builder/OtherGroup.php000064400000001252151162054100016606
0ustar00<?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;
/**
* Other Group Builder Class
*
* @since 3.2.0
*/
final class OtherGroup extends Registry implements Registryinterface
{
}
src/Componentbuilder/Compiler/Builder/OtherJoin.php000064400000001250151162054100016407
0ustar00<?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;
/**
* Other Join Builder Class
*
* @since 3.2.0
*/
final class OtherJoin extends Registry implements Registryinterface
{
}
src/Componentbuilder/Compiler/Builder/OtherOrder.php000064400000001252151162054100016565
0ustar00<?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;
/**
* Other Order Builder Class
*
* @since 3.2.0
*/
final class OtherOrder extends Registry implements Registryinterface
{
}
src/Componentbuilder/Compiler/Builder/OtherQuery.php000064400000001252151162054100016617
0ustar00<?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;
/**
* Other Query Builder Class
*
* @since 3.2.0
*/
final class OtherQuery extends Registry implements Registryinterface
{
}
src/Componentbuilder/Compiler/Builder/OtherWhere.php000064400000001252151162054100016564
0ustar00<?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;
/**
* Other Where Builder Class
*
* @since 3.2.0
*/
final class OtherWhere extends Registry implements Registryinterface
{
}
src/Componentbuilder/Compiler/Builder/PermissionAction.php000064400000001460151162054100017777
0ustar00<?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;
/**
* Permission Actions Builder Class
*
* @since 3.2.0
*/
final class PermissionAction extends Registry implements Registryinterface
{
/**
* Constructor.
*
* @since 3.2.0
*/
public function __construct()
{
$this->setSeparator('|');
}
}
src/Componentbuilder/Compiler/Builder/PermissionComponent.php000064400000003652151162054100020531
0ustar00<?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\Componentbuilder\Compiler\Utilities\Indent;
use VDM\Joomla\Interfaces\Registryinterface;
use VDM\Joomla\Abstraction\Registry;
/**
* Permission Component Builder Class
*
* @since 3.2.0
*/
final class PermissionComponent extends Registry implements
Registryinterface
{
/**
* Constructor.
*
* @since 3.2.0
*/
public function __construct()
{
$this->setSeparator('|');
}
/**
* Get the build component content
*
* @return string
* @since 3.2.0
*/
public function build(): string
{
if ($this->isActive())
{
$bucket = ['<section name="component">'];
// get the header
if ($this->exists('->HEAD<-'))
{
$headers = $this->get('->HEAD<-');
// remove from active values
$this->remove('->HEAD<-');
foreach ($headers as $action)
{
$bucket[] = Indent::_(2) . '<action name="'
. $action['name'] . '" title="'
. $action['title'] . '" description="'
. $action['description'] . '" />';
}
}
if ($this->isActive())
{
ksort($this->active, SORT_STRING);
foreach ($this->active as $active)
{
$bucket[] = Indent::_(2) . '<action name="'
. $active['name'] . '" title="'
. $active['title'] . '" description="'
. $active['description'] . '" />';
}
}
// reset memory
$this->active = [];
return implode(PHP_EOL, $bucket) . PHP_EOL . Indent::_(1) .
"</section>";
}
return '';
}
}
src/Componentbuilder/Compiler/Builder/PermissionCore.php000064400000001453151162054100017454
0ustar00<?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;
/**
* Permission Core Builder Class
*
* @since 3.2.0
*/
final class PermissionCore extends Registry implements Registryinterface
{
/**
* Constructor.
*
* @since 3.2.0
*/
public function __construct()
{
$this->setSeparator('|');
}
}
src/Componentbuilder/Compiler/Builder/PermissionDashboard.php000064400000002643151162054100020455
0ustar00<?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\VarExport;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Indent;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Line;
use VDM\Joomla\Interfaces\Registryinterface;
use VDM\Joomla\Abstraction\Registry;
/**
* Permission Dashboard Builder Class
*
* @since 3.2.0
*/
final class PermissionDashboard extends Registry implements
Registryinterface
{
/**
* Constructor.
*
* @since 3.2.0
*/
public function __construct()
{
$this->setSeparator('|');
}
/**
* Var Export Values
*
* @since 3.2.0
*/
use VarExport;
/**
* Get the build permission dashboard code
*
* @return string
* @since 3.2.0
*/
public function build(): string
{
if ($this->isActive())
{
return PHP_EOL . Indent::_(2) . "//" . Line::_(__Line__,
__Class__)
. " view access array" . PHP_EOL . Indent::_(2)
. "\$viewAccess = " . $this->varExport() . ';';
}
return '';
}
}
src/Componentbuilder/Compiler/Builder/PermissionFields.php000064400000001454151162054100017773
0ustar00<?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;
}
src/Componentbuilder/Compiler/Builder/PermissionGlobalAction.php000064400000001474151162054100021125
0ustar00<?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;
/**
* Permission Global Action Builder Class
*
* @since 3.2.0
*/
final class PermissionGlobalAction extends Registry implements
Registryinterface
{
/**
* Constructor.
*
* @since 3.2.0
*/
public function __construct()
{
$this->setSeparator('|');
}
}
src/Componentbuilder/Compiler/Builder/PermissionViews.php000064400000002761151162054100017664
0ustar00<?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\Componentbuilder\Compiler\Utilities\Indent;
use VDM\Joomla\Abstraction\Registry;
/**
* Permission Views Builder Class
*
* @since 3.2.0
*/
final class PermissionViews extends Registry
{
/**
* Constructor.
*
* @since 3.2.0
*/
public function __construct()
{
$this->setSeparator('|');
}
/**
* Get the build view content
*
* @return string
* @since 3.2.0
*/
public function build(): string
{
if ($this->isActive())
{
$bucket = [];
foreach ($this->active as $views_code_name => $actions)
{
$bucket[] = Indent::_(1) . '<section name="' .
$views_code_name . '">';
foreach ($actions as $action)
{
$bucket[] = Indent::_(2) . '<action name="'
. $action['name'] . '" title="'
. $action['title'] . '" description="'
. $action['description'] . '" />';
}
$bucket[] = Indent::_(1) . "</section>";
}
// reset memory
$this->active = [];
return PHP_EOL . implode(PHP_EOL, $bucket);
}
return '';
}
}
src/Componentbuilder/Compiler/Builder/Request.php000064400000001677151162054100016153
0ustar00<?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;
}
src/Componentbuilder/Compiler/Builder/Router.php000064400000001255151162054100015773
0ustar00<?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
{
}
src/Componentbuilder/Compiler/Builder/ScriptMediaSwitch.php000064400000001454151162054100020102
0ustar00<?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\InArray;
use VDM\Joomla\Interfaces\Registryinterface;
use VDM\Joomla\Abstraction\Registry;
/**
* Script Media Switch Builder Class
*
* @since 3.2.0
*/
final class ScriptMediaSwitch extends Registry implements Registryinterface
{
/**
* In Array
*
* @since 3.2.0
*/
use InArray;
}
src/Componentbuilder/Compiler/Builder/ScriptUserSwitch.php000064400000001452151162054100017777
0ustar00<?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\InArray;
use VDM\Joomla\Interfaces\Registryinterface;
use VDM\Joomla\Abstraction\Registry;
/**
* Script User Switch Builder Class
*
* @since 3.2.0
*/
final class ScriptUserSwitch extends Registry implements Registryinterface
{
/**
* In Array
*
* @since 3.2.0
*/
use InArray;
}
src/Componentbuilder/Compiler/Builder/Search.php000064400000001241151162054100015713
0ustar00<?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;
/**
* Search Builder Class
*
* @since 3.2.0
*/
final class Search extends Registry implements Registryinterface
{
}
src/Componentbuilder/Compiler/Builder/SelectionTranslation.php000064400000001276151162054100020662
0ustar00<?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;
/**
* Selection Translation Builder Class
*
* @since 3.2.0
*/
final class SelectionTranslation extends Registry implements
Registryinterface
{
}
src/Componentbuilder/Compiler/Builder/SiteDecrypt.php000064400000001254151162054100016751
0ustar00<?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;
/**
* Site Decrypt Builder Class
*
* @since 3.2.0
*/
final class SiteDecrypt extends Registry implements Registryinterface
{
}
src/Componentbuilder/Compiler/Builder/SiteDynamicGet.php000064400000001263151162054100017363
0ustar00<?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;
/**
* Site Dynamic Get Builder Class
*
* @since 3.2.0
*/
final class SiteDynamicGet extends Registry implements Registryinterface
{
}
src/Componentbuilder/Compiler/Builder/SiteEditView.php000064400000001257151162054100017062
0ustar00<?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;
/**
* Site Edit View Builder Class
*
* @since 3.2.0
*/
final class SiteEditView extends Registry implements Registryinterface
{
}
src/Componentbuilder/Compiler/Builder/SiteFieldData.php000064400000001444151162054100017155
0ustar00<?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\InArray;
use VDM\Joomla\Interfaces\Registryinterface;
use VDM\Joomla\Abstraction\Registry;
/**
* Site Field Data Builder Class
*
* @since 3.2.0
*/
final class SiteFieldData extends Registry implements Registryinterface
{
/**
* In Array
*
* @since 3.2.0
*/
use InArray;
}
src/Componentbuilder/Compiler/Builder/SiteFieldDecodeFilter.php000064400000001302151162054100020626
0ustar00<?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;
/**
* Site Field Decode Filter Builder Class
*
* @since 3.2.0
*/
final class SiteFieldDecodeFilter extends Registry implements
Registryinterface
{
}
src/Componentbuilder/Compiler/Builder/SiteFields.php000064400000001252151162054100016543
0ustar00<?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;
/**
* Site Fields Builder Class
*
* @since 3.2.0
*/
final class SiteFields extends Registry implements Registryinterface
{
}
src/Componentbuilder/Compiler/Builder/SiteMainGet.php000064400000001255151162054100016664
0ustar00<?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;
/**
* Site Main Get Builder Class
*
* @since 3.2.0
*/
final class SiteMainGet extends Registry implements Registryinterface
{
}
src/Componentbuilder/Compiler/Builder/Sort.php000064400000001235151162054100015440
0ustar00<?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;
/**
* Sort Builder Class
*
* @since 3.2.0
*/
final class Sort extends Registry implements Registryinterface
{
}
src/Componentbuilder/Compiler/Builder/TabCounter.php000064400000001252151162054100016556
0ustar00<?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;
/**
* Tab Counter Builder Class
*
* @since 3.2.0
*/
final class TabCounter extends Registry implements Registryinterface
{
}
src/Componentbuilder/Compiler/Builder/Tags.php000064400000001235151162054100015407
0ustar00<?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;
/**
* Tags Builder Class
*
* @since 3.2.0
*/
final class Tags extends Registry implements Registryinterface
{
}
src/Componentbuilder/Compiler/Builder/TemplateData.php000064400000001256151162054100017061
0ustar00<?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;
/**
* Template Data Builder Class
*
* @since 3.2.0
*/
final class TemplateData extends Registry implements Registryinterface
{
}
src/Componentbuilder/Compiler/Builder/Title.php000064400000001237151162054100015574
0ustar00<?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;
/**
* Title Builder Class
*
* @since 3.2.0
*/
final class Title extends Registry implements Registryinterface
{
}
src/Componentbuilder/Compiler/Builder/UikitComp.php000064400000001250151162054100016412
0ustar00<?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;
/**
* Uikit Comp Builder Class
*
* @since 3.2.0
*/
final class UikitComp extends Registry implements Registryinterface
{
}
src/Componentbuilder/Compiler/Builder/UpdateMysql.php000064400000001707151162054100016765
0ustar00<?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;
/**
* Compiler Builder Update Mysql
*
* @since 3.2.0
*/
class UpdateMysql extends Registry
{
/**
* Get that the active keys from a path
*
* @param string $path The path to determine the location.
*
* @return array|null The valid array of keys
* @since 3.2.0
*/
protected function getActiveKeys(string $path): ?array
{
if (!empty($path))
{
return [preg_replace('/\s+/', '', $path)];
}
return null;
}
}
src/Componentbuilder/Compiler/Builder/ViewsDefaultOrdering.php000064400000001277151162054100020613
0ustar00<?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
{
}
src/Componentbuilder/Compiler/Builder/index.html000064400000000054151162054100015773
0ustar00<html><body
bgcolor="#FFFFFF"></body></html>src/Componentbuilder/Compiler/Component.php000064400000002516151162054100015070
0ustar00<?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;
use VDM\Joomla\Componentbuilder\Compiler\Factory as Compiler;
use VDM\Joomla\Componentbuilder\Compiler\Component\Data;
use VDM\Joomla\Componentbuilder\Abstraction\BaseRegistry;
/**
* Compiler Component
*
* @since 3.2.0
*/
final class Component extends BaseRegistry
{
/**
* Constructor
*
* @param Data|null $component The component data class.
*
* @since 3.2.0
*/
public function __construct(?Data $component = null)
{
$component = $component ?: Compiler::_('Component.Data');
parent::__construct($component->get());
}
/**
* getting any valid value
*
* @param string $path The value's key/path name
*
* @since 3.2.0
*/
public function __get($path)
{
// check if it has been set
if (($value = $this->get($path, '__N0T_S3T_Y3T_')) !==
'__N0T_S3T_Y3T_')
{
return $value;
}
return null;
}
}
src/Componentbuilder/Compiler/Component/Dashboard.php000064400000013640151162054100016757
0ustar00<?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;
use Joomla\CMS\Factory;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Application\CMSApplication;
use VDM\Joomla\Componentbuilder\Compiler\Factory as Compiler;
use VDM\Joomla\Componentbuilder\Compiler\Registry;
use VDM\Joomla\Componentbuilder\Compiler\Component;
use VDM\Joomla\Utilities\StringHelper;
use VDM\Joomla\Utilities\ArrayHelper;
/**
* Compiler Component Dynamic Dashboard
*
* @since 3.2.0
*/
final class Dashboard
{
/**
* The compiler registry
*
* @var Registry
* @since 3.2.0
*/
protected Registry $registry;
/**
* Compiler Component
*
* @var Component
* @since 3.2.0
**/
protected Component $component;
/**
* Application object.
*
* @var CMSApplication
* @since 3.2.0
**/
protected CMSApplication $app;
/**
* Constructor
*
* @param Registry|null $registry The compiler registry
object.
* @param Component|null $component The component class.
* @param CMSApplication|null $app The app object.
*
* @since 3.2.0
*/
public function __construct(?Registry $registry = null, ?Component
$component = null,
?CMSApplication $app = null)
{
$this->registry = $registry ?: Compiler::_('Registry');
$this->component = $component ?: Compiler::_('Component');
$this->app = $app ?: Factory::getApplication();
}
/**
* Set the Dynamic Dashboard
*
* @return void
* @since 3.2.0
*/
public function set()
{
// only add the dynamic dashboard if all checks out
if ($this->component->get('dashboard_type', 0) == 2
&& ($dashboard_ =
$this->component->get('dashboard')) !== null
&& StringHelper::check($dashboard_)
&& strpos((string) $dashboard_, '_') !== false)
{
// set the default view
$getter = explode('_', (string) $dashboard_);
if (count((array) $getter) == 2 && is_numeric($getter[1]))
{
// the pointers
$t = StringHelper::safe($getter[0], 'U');
$id = (int) $getter[1];
// the dynamic stuff
$targets = array('A' => 'admin_views',
'C' => 'custom_admin_views');
$names = array('A' => 'admin view',
'C' => 'custom admin view');
$types = array('A' => 'adminview',
'C' => 'customadminview');
$keys = array('A' => 'name_list',
'C' => 'code');
// check the target values
if (isset($targets[$t]) && $id > 0)
{
// set the type name
$type_names = StringHelper::safe(
$targets[$t], 'w'
);
// set the dynamic dash
if (($target_ = $this->component->get($targets[$t])) !== null
&& ArrayHelper::check($target_))
{
// search the target views
$dashboard = (array) array_filter(
$target_,
function ($view) use ($id, $t, $types) {
if (isset($view[$types[$t]])
&& $id == $view[$types[$t]])
{
return true;
}
return false;
}
);
// set dashboard
if (ArrayHelper::check($dashboard))
{
$dashboard = array_values($dashboard)[0];
}
// check if view was found (this should be true)
if (isset($dashboard['settings'])
&& isset($dashboard['settings']->{$keys[$t]}))
{
$this->registry->set('build.dashboard',
StringHelper::safe(
$dashboard['settings']->{$keys[$t]}
)
);
$this->registry->set('build.dashboard.type',
$targets[$t]
);
}
else
{
// set massage that something is wrong
$this->app->enqueueMessage(
Text::_('COM_COMPONENTBUILDER_HR_HTHREEDASHBOARD_ERRORHTHREE'),
'Error'
);
$this->app->enqueueMessage(
Text::sprintf('COM_COMPONENTBUILDER_THE_BSB_BSB_IS_NOT_AVAILABLE_IN_YOUR_COMPONENT_PLEASE_INSURE_TO_ONLY_USED_S_FOR_A_DYNAMIC_DASHBOARD_THAT_ARE_STILL_LINKED_TO_YOUR_COMPONENT',
$names[$t], $dashboard_,
$type_names
), 'Error'
);
}
}
else
{
// set massage that something is wrong
$this->app->enqueueMessage(
Text::_('COM_COMPONENTBUILDER_HR_HTHREEDASHBOARD_ERRORHTHREE'),
'Error'
);
$this->app->enqueueMessage(
Text::sprintf('COM_COMPONENTBUILDER_THE_BSB_BSB_IS_NOT_AVAILABLE_IN_YOUR_COMPONENT_PLEASE_INSURE_TO_ONLY_USED_S_FOR_A_DYNAMIC_DASHBOARD_THAT_ARE_STILL_LINKED_TO_YOUR_COMPONENT',
$names[$t], $dashboard_,
$type_names
), 'Error'
);
}
}
else
{
// the target value is wrong
$this->app->enqueueMessage(
Text::_('COM_COMPONENTBUILDER_HR_HTHREEDASHBOARD_ERRORHTHREE'),
'Error'
);
$this->app->enqueueMessage(
Text::sprintf('COM_COMPONENTBUILDER_THE_BSB_VALUE_FOR_THE_DYNAMIC_DASHBOARD_IS_INVALID',
$dashboard_
), 'Error'
);
}
}
else
{
// the target value is wrong
$this->app->enqueueMessage(
Text::_('COM_COMPONENTBUILDER_HR_HTHREEDASHBOARD_ERRORHTHREE'),
'Error'
);
$this->app->enqueueMessage(
Text::sprintf('COM_COMPONENTBUILDER_THE_BSB_VALUE_FOR_THE_DYNAMIC_DASHBOARD_IS_INVALID',
$dashboard_
), 'Error'
);
}
// if default was changed to dynamic dashboard the remove default tab
and methods
if ($this->registry->get('build.dashboard'))
{
// dynamic dashboard is used
$this->component->remove('dashboard_tab');
$this->component->remove('php_dashboard_methods');
}
}
}
}
src/Componentbuilder/Compiler/Component/Data.php000064400000062770151162054100015751
0ustar00<?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;
use Joomla\CMS\Factory;
use VDM\Joomla\Componentbuilder\Compiler\Factory as Compiler;
use VDM\Joomla\Componentbuilder\Compiler\Config;
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\EventInterface;
use VDM\Joomla\Componentbuilder\Compiler\Placeholder;
use VDM\Joomla\Componentbuilder\Compiler\Component\Placeholder as
ComponentPlaceholder;
use VDM\Joomla\Componentbuilder\Compiler\Customcode\Dispenser;
use VDM\Joomla\Componentbuilder\Compiler\Customcode;
use VDM\Joomla\Componentbuilder\Compiler\Customcode\Gui;
use VDM\Joomla\Componentbuilder\Compiler\Field as Field;
use VDM\Joomla\Componentbuilder\Compiler\Field\Name as FieldName;
use VDM\Joomla\Componentbuilder\Compiler\Field\UniqueName;
use VDM\Joomla\Componentbuilder\Compiler\Model\Filesfolders;
use VDM\Joomla\Componentbuilder\Compiler\Model\Historycomponent;
use VDM\Joomla\Componentbuilder\Compiler\Model\Whmcs;
use VDM\Joomla\Componentbuilder\Compiler\Model\Sqltweaking;
use VDM\Joomla\Componentbuilder\Compiler\Model\Adminviews;
use VDM\Joomla\Componentbuilder\Compiler\Model\Siteviews;
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;
use VDM\Joomla\Utilities\GetHelper;
/**
* Compiler Component Data
*
* @since 3.2.0
*/
final class Data
{
/**
* Compiler Config
*
* @var Config
* @since 3.2.0
*/
protected Config $config;
/**
* Compiler Event
*
* @var EventInterface
* @since 3.2.0
*/
protected EventInterface $event;
/**
* Compiler Placeholder
*
* @var Placeholder
* @since 3.2.0
*/
protected Placeholder $placeholder;
/**
* Compiler Component Placeholder
*
* @var ComponentPlaceholder
* @since 3.2.0
**/
protected ComponentPlaceholder $componentPlaceholder;
/**
* Compiler Customcode Dispenser
*
* @var Dispenser
* @since 3.2.0
*/
protected Dispenser $dispenser;
/**
* Compiler Customcode
*
* @var Customcode
* @since 3.2.0
*/
protected Customcode $customcode;
/**
* Compiler Customcode in Gui
*
* @var Gui
* @since 3.2.0
**/
protected Gui $gui;
/**
* Compiler Field
*
* @var Field
* @since 3.2.0
*/
protected Field $field;
/**
* Compiler field name
*
* @var FieldName
* @since 3.2.0
*/
protected FieldName $fieldName;
/**
* Compiler Field Unique Name
*
* @var UniqueName
* @since 3.2.0
**/
protected UniqueName $uniqueName;
/**
* Compiler Files Folders
*
* @var Filesfolders
* @since 3.2.0
*/
protected Filesfolders $filesFolders;
/**
* The modelling component history
*
* @var Historycomponent
* @since 3.2.0
*/
protected Historycomponent $history;
/**
* The modelling whmcs
*
* @var Whmcs
* @since 3.2.0
*/
protected Whmcs $whmcs;
/**
* The modelling Sql Tweaking
*
* @var Sqltweaking
* @since 3.2.0
*/
protected Sqltweaking $sqltweaking;
/**
* The modelling Admin Views
*
* @var Adminviews
* @since 3.2.0
*/
protected Adminviews $adminviews;
/**
* The modelling Site Views
*
* @var Siteviews
* @since 3.2.0
*/
protected Siteviews $siteviews;
/**
* The modelling Custom Admin Views
*
* @var Customadminviews
* @since 3.2.0
*/
protected Customadminviews $customadminviews;
/**
* The modelling Update Server
*
* @var Updateserver
* @since 3.2.0
*/
protected Updateserver $updateserver;
/**
* The modelling Joomla Modules
*
* @var Joomlamodules
* @since 3.2.0
*/
protected Joomlamodules $modules;
/**
* The modelling Joomla Plugins
*
* @var Joomlaplugins
* @since 3.2.0
*/
protected Joomlaplugins $plugins;
/**
* The modelling Joomla Site Router
*
* @var Router
* @since 3.2.0
*/
protected Router $router;
/**
* Database object to query local DB
*
* @since 3.2.0
**/
protected $db;
/**
* Constructor
*
* @param Config|null $config The compiler
config object.
* @param EventInterface|null $event The compiler
event api object.
* @param Placeholder|null $placeholder The compiler
placeholder object.
* @param ComponentPlaceholder|null $componentPlaceholder The compiler
component placeholder object.
* @param Dispenser|null $dispenser The compiler
customcode dispenser object.
* @param Customcode|null $customcode The compiler
customcode object.
* @param Gui|null $gui The compiler
customcode gui.
* @param Field|null $field The compiler
field object.
* @param FieldName|null $fieldName The compiler
field name object.
* @param UniqueName|null $uniqueName The compiler
field unique name object.
* @param Filesfolders|null $filesFolders The compiler
files folders object.
* @param Historycomponent|null $history The modelling
component history object.
* @param Whmcs|null $whmcs The modelling
whmcs object.
* @param Sqltweaking|null $sqltweaking The modelling
sql tweaking object.
* @param Adminviews|null $adminviews The modelling
adminviews object.
* @param Siteviews|null $siteviews The modelling
siteviews object.
* @param Customadminviews|null $customadminviews The modelling
customadminviews object.
* @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 Router|null $router The modelling
router object.
*
* @since 3.2.0
*/
public function __construct(?Config $config = null, ?EventInterface $event
= null,
?Placeholder $placeholder = null, ?ComponentPlaceholder
$componentPlaceholder = null,
?Dispenser $dispenser = null, ?Customcode $customcode = null, ?Gui $gui =
null,
?Field $field = null, ?FieldName $fieldName = null, ?UniqueName
$uniqueName = null,
?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, ?Router
$router = null)
{
$this->config = $config ?: Compiler::_('Config');
$this->event = $event ?: Compiler::_('Event');
$this->placeholder = $placeholder ?:
Compiler::_('Placeholder');
$this->componentPlaceholder = $componentPlaceholder ?:
Compiler::_('Component.Placeholder');
$this->dispenser = $dispenser ?:
Compiler::_('Customcode.Dispenser');
$this->customcode = $customcode ?:
Compiler::_('Customcode');
$this->gui = $gui ?: Compiler::_('Customcode.Gui');
$this->field = $field ?: Compiler::_('Field');
$this->fieldName = $fieldName ?: Compiler::_('Field.Name');
$this->uniqueName = $uniqueName ?:
Compiler::_('Field.Unique.Name');
$this->filesFolders = $filesFolders ?:
Compiler::_('Model.Filesfolders');
$this->history = $history ?:
Compiler::_('Model.Historycomponent');
$this->whmcs = $whmcs ?: Compiler::_('Model.Whmcs');
$this->sqltweaking = $sqltweaking ?:
Compiler::_('Model.Sqltweaking');
$this->adminviews = $adminviews ?:
Compiler::_('Model.Adminviews');
$this->siteviews = $siteviews ?:
Compiler::_('Model.Siteviews');
$this->customadminviews = $customadminviews ?:
Compiler::_('Model.Customadminviews');
$this->updateserver = $updateserver ?:
Compiler::_('Model.Updateserver');
$this->modules = $modules ?:
Compiler::_('Model.Joomlamodules');
$this->plugins = $plugins ?:
Compiler::_('Model.Joomlaplugins');
$this->router = $router ?: Compiler::_('Model.Router');
$this->db = Factory::getDbo();
}
/**
* get current component data
*
* @return object|null The component data
* @since 3.2.0
*/
public function get(): ?object
{
// Create a new query object.
$query = $this->db->getQuery(true);
// selection
$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(
array_keys($selection), array_values($selection)
)
);
// from this table
$query->from('#__componentbuilder_joomla_component AS a');
// jointer-map
$joiners = [
'b' => 'component_admin_views',
'c' => 'component_site_views',
'd' => 'component_custom_admin_views',
'e' => 'component_updates',
'f' => 'component_mysql_tweaks',
'g' => 'component_custom_admin_menus',
'h' => 'component_config',
'i' => 'component_dashboard',
'j' => 'component_files_folders',
'k' => 'component_modules',
'l' => 'component_plugins',
'm' => 'component_router'
];
// load the joins
foreach ($joiners as $as => $join)
{
$query->join(
'LEFT',
$this->db->quoteName('#__componentbuilder_' . $join,
$as)
. ' ON (' . $this->db->quoteName('a.id') .
' = '
. $this->db->quoteName($as . '.joomla_component') .
')'
);
}
$query->where(
$this->db->quoteName('a.id') . ' = ' . (int)
$this->config->component_id
);
// Trigger Event: jcb_ce_onBeforeQueryComponentData
$this->event->trigger(
'jcb_ce_onBeforeQueryComponentData', [&$query,
&$this->db]
);
// Reset the query using our newly populated query object.
$this->db->setQuery($query);
// Load the results as a list of stdClass objects
$component = $this->db->loadObject();
// make sure we got a component loaded
if (!is_object($component) || !isset($component->system_name))
{
return null;
}
// Trigger Event: jcb_ce_onBeforeModelComponentData
$this->event->trigger(
'jcb_ce_onBeforeModelComponentData', [&$component]
);
// load the global placeholders
$this->placeholder->active =
$this->componentPlaceholder->get();
// set component sales name
$component->sales_name = StringHelper::safe(
$component->system_name
);
// set the component name_code
$component->name_code = StringHelper::safe(
$component->name_code
);
// ensure version naming is correct
$this->config->set('component_version', preg_replace(
'/^v/i', '', (string)
$component->component_version
)
);
// Make sure the image is only an image path
if (strpos($component->image, '#') !== false)
{
$component->image = strstr($component->image, '#',
true);
}
// set the website and autor for global use (default to VDM if not
found)
$this->config->set('project_website',
$component->website ?? 'https://dev.vdm.io');
$this->config->set('project_author',
$component->author ?? 'VDM');
// set the files and folders
$this->filesFolders->set($component);
// set the uikit switch
$this->config->set('uikit', $component->adduikit);
// set whmcs links if needed
$this->whmcs->set($component);
// set the footable switch
if ($component->addfootable > 0)
{
// force add footable
$this->config->set('footable', true);
// add the version
$this->config->set('footable_version', (3 ==
$component->addfootable) ? 3 : 2);
}
// set the addcustommenus data
$component->addcustommenus = (isset($component->addcustommenus)
&& JsonHelper::check($component->addcustommenus))
? json_decode((string) $component->addcustommenus, true) : null;
if (ArrayHelper::check($component->addcustommenus))
{
$component->custommenus =
array_values($component->addcustommenus);
}
unset($component->addcustommenus);
// set the sql tweak data
$this->sqltweaking->set($component);
// set the admin view data
$this->adminviews->set($component);
// set the site view data
$this->siteviews->set($component);
// set the custom_admin_views data
$this->customadminviews->set($component);
// set the config data
$component->addconfig = (isset($component->addconfig)
&& JsonHelper::check($component->addconfig))
? json_decode((string) $component->addconfig, true) : null;
if (ArrayHelper::check($component->addconfig))
{
$component->config = array_map(
function ($field) {
// make sure the alias and title is 0
$field['alias'] = 0;
$field['title'] = 0;
// set the field details
$this->field->set($field);
// set unique name counter
$this->uniqueName->set($field['base_name'],
'configs');
// return field
return $field;
}, array_values($component->addconfig)
);
// do some house cleaning (for fields)
foreach ($component->config as $field)
{
// so first we lock the field name in
$this->fieldName->get($field, 'configs');
}
// unset original value
unset($component->addconfig);
}
// set the add contributors
$component->addcontributors = (isset($component->addcontributors)
&& JsonHelper::check($component->addcontributors))
? json_decode((string) $component->addcontributors, true) : null;
if (ArrayHelper::check($component->addcontributors))
{
$this->config->set('add_contributors', true);
$component->contributors = array_values(
$component->addcontributors
);
}
unset($component->addcontributors);
// set the version updates
$this->updateserver->set($component);
// build the build date
if ($this->config->get('add_build_date', 1) == 3)
{
if (empty($this->component->modified) ||
$this->component->modified == '0000-00-00' ||
$this->component->modified == '0000-00-00 00:00:00')
{
$this->config->set('build_date',
$this->component->created);
}
else
{
$this->config->set('build_date',
$this->component->modified);
}
}
// build update SQL
$this->history->set($component);
// set GUI mapper
$guiMapper = [
'table' => 'joomla_component',
'id' => (int) $this->config->component_id,
'field' => 'javascript',
'type' => 'js'
];
// add_javascript
if ($component->add_javascript == 1)
{
$this->dispenser->set(
$component->javascript,
'component_js',
null,
null,
$guiMapper
);
}
else
{
$this->dispenser->hub['component_js'] = '';
}
unset($component->javascript);
// add global CSS
$addGlobalCss = ['admin', 'site'];
foreach ($addGlobalCss as $area)
{
// add_css if found
if (isset($component->{'add_css_' . $area})
&& $component->{'add_css_' . $area} == 1
&& isset($component->{'css_' . $area})
&& StringHelper::check(
$component->{'css_' . $area}
))
{
$this->dispenser->set(
$component->{'css_' . $area},
'component_css_' . $area
);
}
else
{
$this->dispenser->hub['component_css_' . $area] =
'';
}
unset($component->{'css_' . $area});
}
// set the lang target
$this->config->lang_target = 'admin';
// add PHP in ADMIN
$addScriptMethods = [
'php_preflight',
'php_postflight',
'php_method'
];
$addScriptTypes = [
'install',
'update',
'uninstall'
];
// update GUI mapper
$guiMapper['type'] = 'php';
foreach ($addScriptMethods as $scriptMethod)
{
foreach ($addScriptTypes as $scriptType)
{
if (isset($component->{'add_' . $scriptMethod .
'_' . $scriptType})
&& $component->{'add_' . $scriptMethod .
'_' . $scriptType} == 1
&& StringHelper::check(
$component->{$scriptMethod . '_' . $scriptType}
))
{
// set GUI mapper field
$guiMapper['field'] = $scriptMethod . '_' .
$scriptType;
$this->dispenser->set(
$component->{$scriptMethod . '_' . $scriptType},
$scriptMethod,
$scriptType,
null,
$guiMapper
);
}
else
{
$this->dispenser->hub[$scriptMethod][$scriptType] =
'';
}
unset($component->{$scriptMethod . '_' . $scriptType});
}
}
// add_php_helper
if ($component->add_php_helper_admin == 1
&& StringHelper::check(
$component->php_helper_admin
))
{
$this->config->lang_target = 'admin';
// update GUI mapper
$guiMapper['field'] = 'php_helper_admin';
$guiMapper['prefix'] = PHP_EOL . PHP_EOL;
$this->dispenser->set(
$component->php_helper_admin,
'component_php_helper_admin',
null,
null,
$guiMapper
);
unset($guiMapper['prefix']);
}
else
{
$this->dispenser->hub['component_php_helper_admin'] =
'';
}
unset($component->php_helper);
// add_admin_event
if ($component->add_admin_event == 1
&& StringHelper::check($component->php_admin_event))
{
$this->config->lang_target = 'admin';
// update GUI mapper field
$guiMapper['field'] = 'php_admin_event';
$this->dispenser->set(
$component->php_admin_event,
'component_php_admin_event',
null,
null,
$guiMapper
);
}
else
{
$this->dispenser->hub['component_php_admin_event'] =
'';
}
unset($component->php_admin_event);
// add_php_helper_both
if ($component->add_php_helper_both == 1
&& StringHelper::check($component->php_helper_both))
{
$this->config->lang_target = 'both';
// update GUI mapper field
$guiMapper['field'] = 'php_helper_both';
$guiMapper['prefix'] = PHP_EOL . PHP_EOL;
$this->dispenser->set(
$component->php_helper_both,
'component_php_helper_both',
null,
null,
$guiMapper
);
unset($guiMapper['prefix']);
}
else
{
$this->dispenser->hub['component_php_helper_both'] =
'';
}
// add_php_helper_site
if ($component->add_php_helper_site == 1
&& StringHelper::check($component->php_helper_site))
{
$this->config->lang_target = 'site';
// update GUI mapper field
$guiMapper['field'] = 'php_helper_site';
$guiMapper['prefix'] = PHP_EOL . PHP_EOL;
$this->dispenser->set(
$component->php_helper_site,
'component_php_helper_site',
null,
null,
$guiMapper
);
unset($guiMapper['prefix']);
}
else
{
$this->dispenser->hub['component_php_helper_site'] =
'';
}
unset($component->php_helper);
// add_site_event
if ($component->add_site_event == 1
&& StringHelper::check($component->php_site_event))
{
$this->config->lang_target = 'site';
// update GUI mapper field
$guiMapper['field'] = 'php_site_event';
$this->dispenser->set(
$component->php_site_event,
'component_php_site_event',
null,
null,
$guiMapper
);
}
else
{
$this->dispenser->hub['component_php_site_event'] =
'';
}
unset($component->php_site_event);
// add_sql
if ($component->add_sql == 1)
{
$this->dispenser->set(
$component->sql,
'sql',
'component_sql'
);
}
unset($component->sql);
// add_sql_uninstall
if ($component->add_sql_uninstall == 1)
{
$this->dispenser->set(
$component->sql_uninstall,
'sql_uninstall'
);
}
unset($component->sql_uninstall);
// bom
if (StringHelper::check($component->bom))
{
$this->config->set('bom_path',
$this->config->get('compiler_path',
JPATH_COMPONENT_ADMINISTRATOR . '/compiler') . '/' .
$component->bom
);
}
unset($component->bom);
// README
$component->readme =
$component->addreadme ?
$this->customcode->update(
base64_decode((string) $component->readme)
) : '';
// set lang now
$nowLang = $this->config->lang_target;
$this->config->lang_target = 'admin';
// dashboard methods
$component->dashboard_tab = (isset($component->dashboard_tab)
&& JsonHelper::check($component->dashboard_tab))
? json_decode((string) $component->dashboard_tab, true) : null;
if (ArrayHelper::check($component->dashboard_tab))
{
$component->dashboard_tab = array_map(
function ($array) {
$array['html'] =
$this->customcode->update($array['html']);
return $array;
}, array_values($component->dashboard_tab)
);
}
else
{
$component->dashboard_tab = '';
}
// add the php of the dashboard if set
if (isset($component->php_dashboard_methods)
&& StringHelper::check(
$component->php_dashboard_methods
))
{
// load the php for the dashboard model
$component->php_dashboard_methods = $this->gui->set(
$this->customcode->update(
base64_decode((string) $component->php_dashboard_methods)
),
[
'table' => 'component_dashboard',
'field' => 'php_dashboard_methods',
'id' => (int) $component->component_dashboard_id,
'type' => 'php'
]
);
}
else
{
$component->php_dashboard_methods = '';
}
// reset back to now lang
$this->config->lang_target = $nowLang;
// catch empty URL to update server TODO: we need to fix this in better
way later
if (empty($component->add_update_server) ||
($component->add_update_server == 1 &&
$component->update_server_target != 3
&& (
!StringHelper::check($component->update_server_url)
|| strpos($component->update_server_url, 'http') ===
false
)))
{
// we fall back to other, since we can't work with an empty update
server URL
$component->add_update_server = 0;
$component->update_server_target = 3;
$component->update_server_url = '';
}
// add the update/sales server FTP details if that is the expected
protocol
$serverArray = array('update_server',
'sales_server');
foreach ($serverArray as $server)
{
if ($component->{'add_' . $server} == 1
&& is_numeric($component->{$server})
&& $component->{$server} > 0)
{
// get the server protocol
$component->{$server . '_protocol'}
= GetHelper::var(
'server', (int) $component->{$server}, 'id',
'protocol'
);
}
else
{
$component->{$server} = 0;
// only change this for sales server (update server can be added
loacaly to the zip file)
if ('sales_server' === $server)
{
$component->{'add_' . $server} = 0;
}
$component->{$server . '_protocol'} = 0;
}
}
// set the ignore folders for repo if found
if (isset($component->toignore)
&& StringHelper::check(
$component->toignore
))
{
if (strpos((string) $component->toignore, ',') !== false)
{
$component->toignore = array_map(
'trim', (array) explode(',', (string)
$component->toignore)
);
}
else
{
$component->toignore = array(trim((string)
$component->toignore));
}
}
else
{
// the default is to ignore the repo folder
$component->toignore = array('.git');
}
// set all modules
$this->modules->set($component);
// 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',
[&$component]
);
// return found component data
return $component;
}
}
src/Componentbuilder/Compiler/Component/JoomlaFive/Settings.php000064400000043754151162054100020734
0ustar00<?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(); // soon
$this->addUikitFolder();
$this->addFooTableFolder();
}
}
/**
* Add Import and Export Folder
*
* @return void
* @since 3.2.0
*/
private function addImportViewFolder()
{
if ($this->config->get('add_eximport', false))
{
// soon
}
}
/**
* Add Php Spreadsheet Folder
*
* @return void
* @since 3.2.0
*/
private function addPhpSpreadsheetFolder()
{
// move the phpspreadsheet Folder (TODO we must move this to a library
package)
if ($this->config->get('add_eximport', false))
{
$this->component->appendArray('folders', [
'folderpath' =>
'JPATH_LIBRARIES/phpspreadsheet/vendor',
'path' => '/libraries/phpspreadsheet/',
'rename' => 0
]);
}
}
/**
* Add Uikit Folders
*
* @return void
* @since 3.2.0
*/
private function addUikitFolder()
{
$uikit = $this->config->get('uikit', 0);
if (2 == $uikit || 1 == $uikit)
{
// move the UIKIT Folder into place
$this->component->appendArray('folders', [
'folder' => 'uikit-v2',
'path' => 'media',
'rename' => 0
]);
}
if (2 == $uikit || 3 == $uikit)
{
// move the UIKIT-3 Folder into place
$this->component->appendArray('folders', [
'folder' => 'uikit-v3',
'path' => 'media',
'rename' => 0
]);
}
}
/**
* Add Foo Table Folder
*
* @return void
* @since 3.2.0
*/
private function addFooTableFolder()
{
if (!$this->config->get('footable', false))
{
return;
}
$footable_version =
$this->config->get('footable_version', 2);
if (2 == $footable_version)
{
// move the footable folder into place
$this->component->appendArray('folders', [
'folder' => 'footable-v2',
'path' => 'media',
'rename' => 0
]);
}
elseif (3 == $footable_version)
{
// move the footable folder into place
$this->component->appendArray('folders', [
'folder' => 'footable-v3',
'path' => 'media',
'rename' => 0
]);
}
}
/**
* Add Extra/Dynamic files
*
* @return void
* @since 3.2.0
*/
private function loadExtraFiles()
{
if ($this->component->isArray('files') ||
$this->config->get('google_chart', false))
{
$this->addGoogleChartFiles();
}
}
/**
* Add Google Chart Files
*
* @return void
* @since 3.2.0
*/
private function addGoogleChartFiles()
{
if ($this->config->get('google_chart', false))
{
// move the google chart files
$this->component->appendArray('files', [
'file' => 'google.jsapi.js',
'path' => 'media/js',
'rename' => 0
]);
$this->component->appendArray('files', [
'file' => 'chartbuilder.php',
'path' => 'admin/helpers',
'rename' => 0
]);
}
}
/**
* Add Folders
*
* @param object $versionData
*
* @return void
* @since 3.2.0
*/
private function addFolders(object &$versionData)
{
if (!$this->component->isArray('folders'))
{
return;
}
// pointer tracker
$pointer_tracker = 'h';
foreach ($this->component->get('folders') as $custom)
{
// check type of target type
$_target_type = 'c0mp0n3nt';
if (isset($custom['target_type']))
{
$_target_type = $custom['target_type'];
}
// for good practice
$this->pathfix->set(
$custom, ['path', 'folder',
'folderpath']
);
// fix custom path
if (isset($custom['path'])
&& StringHelper::check($custom['path']))
{
$custom['path'] = trim((string) $custom['path'],
'/');
}
// by default custom path is true
$customPath = 'custom';
// set full path if this is a full path folder
if (!isset($custom['folder']) &&
isset($custom['folderpath']))
{
// update the dynamic path
$custom['folderpath'] = $this->dynamicpath->update(
$custom['folderpath']
);
// set the folder path with / if does not have a drive/windows full
path
$custom['folder'] = (preg_match(
'/^[a-z]:/i', $custom['folderpath']
)) ? trim($custom['folderpath'], '/')
: '/' . trim($custom['folderpath'],
'/');
// remove the file path
unset($custom['folderpath']);
// triget fullpath
$customPath = 'full';
}
// make sure we use the correct name
$pathArray = (array) explode('/', (string)
$custom['path']);
$lastFolder = end($pathArray);
// only rename folder if last has folder name
if (isset($custom['rename']) &&
$custom['rename'] == 1)
{
$custom['path'] = str_replace(
'/' . $lastFolder, '', (string)
$custom['path']
);
$rename = 'new';
$newname = $lastFolder;
}
elseif ('full' === $customPath)
{
// make sure we use the correct name
$folderArray = (array) explode('/', (string)
$custom['folder']);
$lastFolder = end($folderArray);
$rename = 'new';
$newname = $lastFolder;
}
else
{
$rename = false;
$newname = '';
}
// insure we have no duplicates
$key_pointer = StringHelper::safe(
$custom['folder']
) . '_f' . $pointer_tracker;
$pointer_tracker++;
// fix custom path
$custom['path'] = ltrim((string) $custom['path'],
'/');
// set new folder to object
$versionData->move->static->{$key_pointer} = new \stdClass();
$versionData->move->static->{$key_pointer}->naam =
str_replace('//', '/', (string)
$custom['folder']);
$versionData->move->static->{$key_pointer}->path =
$_target_type . '/' . $custom['path'];
$versionData->move->static->{$key_pointer}->rename =
$rename;
$versionData->move->static->{$key_pointer}->newName =
$newname;
$versionData->move->static->{$key_pointer}->type =
'folder';
$versionData->move->static->{$key_pointer}->custom =
$customPath;
// set the target if type and id is found
if (isset($custom['target_id']) &&
isset($custom['target_type']))
{
$versionData->move->static->{$key_pointer}->_target = [
'key' => $custom['target_id'] . '_'
. $custom['target_type'],
'type' => $custom['target_type']
];
}
}
$this->component->remove('folders');
}
/**
* Add Files
*
* @param object $versionData
*
* @return void
* @since 3.2.0
*/
private function addFiles(object &$versionData)
{
if (!$this->component->isArray('files')) {
return;
}
// pointer tracker
$pointer_tracker = 'h';
foreach ($this->component->get('files') as $custom)
{
// check type of target type
$_target_type = 'c0mp0n3nt';
if (isset($custom['target_type']))
{
$_target_type = $custom['target_type'];
}
// for good practice
$this->pathfix->set(
$custom, ['path', 'file', 'filepath']
);
// by default custom path is true
$customPath = 'custom';
// set full path if this is a full path file
if (!isset($custom['file']) &&
isset($custom['filepath']))
{
// update the dynamic path
$custom['filepath'] = $this->dynamicpath->update(
$custom['filepath']
);
// set the file path with / if does not have a drive/windows full path
$custom['file'] = (preg_match('/^[a-z]:/i',
$custom['filepath']))
? trim($custom['filepath'], '/') : '/' .
trim($custom['filepath'], '/');
// remove the file path
unset($custom['filepath']);
// triget fullpath
$customPath = 'full';
}
// make sure we have not duplicates
$key_pointer = StringHelper::safe(
$custom['file']
) . '_g' . $pointer_tracker;
$pointer_tracker++;
// set new file to object
$versionData->move->static->{$key_pointer} = new \stdClass();
$versionData->move->static->{$key_pointer}->naam =
str_replace('//', '/', (string)
$custom['file']);
// update the dynamic component name placholders in file names
$custom['path'] = $this->placeholder->update_(
$custom['path']
);
// get the path info
$pathInfo = pathinfo((string) $custom['path']);
if (isset($pathInfo['extension']) &&
$pathInfo['extension'])
{
$pathInfo['dirname'] = trim($pathInfo['dirname'],
'/');
// set the info
$versionData->move->static->{$key_pointer}->path =
$_target_type . '/' . $pathInfo['dirname'];
$versionData->move->static->{$key_pointer}->rename =
'new';
$versionData->move->static->{$key_pointer}->newName =
$pathInfo['basename'];
}
elseif ('full' === $customPath)
{
// fix custom path
$custom['path'] = ltrim((string) $custom['path'],
'/');
// get file array
$fileArray = (array) explode('/', (string)
$custom['file']);
// set the info
$versionData->move->static->{$key_pointer}->path =
$_target_type . '/' . $custom['path'];
$versionData->move->static->{$key_pointer}->rename =
'new';
$versionData->move->static->{$key_pointer}->newName =
end($fileArray);
}
else
{
// fix custom path
$custom['path'] = ltrim((string) $custom['path'],
'/');
// set the info
$versionData->move->static->{$key_pointer}->path =
$_target_type . '/' . $custom['path'];
$versionData->move->static->{$key_pointer}->rename =
false;
}
$versionData->move->static->{$key_pointer}->type =
'file';
$versionData->move->static->{$key_pointer}->custom =
$customPath;
// set the target if type and id is found
if (isset($custom['target_id'])
&& isset($custom['target_type']))
{
$versionData->move->static->{$key_pointer}->_target = [
'key' => $custom['target_id'] . '_'
. $custom['target_type'],
'type' => $custom['target_type']
];
}
// check if file should be updated
if (!isset($custom['notnew']) || $custom['notnew']
== 0
|| $custom['notnew'] != 1)
{
$this->registry->appendArray('files.not.new',
$key_pointer);
}
else
{
// update the file content
$this->registry->set('update.file.content.' .
$key_pointer, true);
}
}
$this->component->remove('files');
}
}
src/Componentbuilder/Compiler/Component/JoomlaFive/index.html000064400000000054151162054100020402
0ustar00<html><body
bgcolor="#FFFFFF"></body></html>src/Componentbuilder/Compiler/Component/JoomlaFour/Settings.php000064400000043754151162054100020756
0ustar00<?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(); // soon
$this->addUikitFolder();
$this->addFooTableFolder();
}
}
/**
* Add Import and Export Folder
*
* @return void
* @since 3.2.0
*/
private function addImportViewFolder()
{
if ($this->config->get('add_eximport', false))
{
// soon
}
}
/**
* Add Php Spreadsheet Folder
*
* @return void
* @since 3.2.0
*/
private function addPhpSpreadsheetFolder()
{
// move the phpspreadsheet Folder (TODO we must move this to a library
package)
if ($this->config->get('add_eximport', false))
{
$this->component->appendArray('folders', [
'folderpath' =>
'JPATH_LIBRARIES/phpspreadsheet/vendor',
'path' => '/libraries/phpspreadsheet/',
'rename' => 0
]);
}
}
/**
* Add Uikit Folders
*
* @return void
* @since 3.2.0
*/
private function addUikitFolder()
{
$uikit = $this->config->get('uikit', 0);
if (2 == $uikit || 1 == $uikit)
{
// move the UIKIT Folder into place
$this->component->appendArray('folders', [
'folder' => 'uikit-v2',
'path' => 'media',
'rename' => 0
]);
}
if (2 == $uikit || 3 == $uikit)
{
// move the UIKIT-3 Folder into place
$this->component->appendArray('folders', [
'folder' => 'uikit-v3',
'path' => 'media',
'rename' => 0
]);
}
}
/**
* Add Foo Table Folder
*
* @return void
* @since 3.2.0
*/
private function addFooTableFolder()
{
if (!$this->config->get('footable', false))
{
return;
}
$footable_version =
$this->config->get('footable_version', 2);
if (2 == $footable_version)
{
// move the footable folder into place
$this->component->appendArray('folders', [
'folder' => 'footable-v2',
'path' => 'media',
'rename' => 0
]);
}
elseif (3 == $footable_version)
{
// move the footable folder into place
$this->component->appendArray('folders', [
'folder' => 'footable-v3',
'path' => 'media',
'rename' => 0
]);
}
}
/**
* Add Extra/Dynamic files
*
* @return void
* @since 3.2.0
*/
private function loadExtraFiles()
{
if ($this->component->isArray('files') ||
$this->config->get('google_chart', false))
{
$this->addGoogleChartFiles();
}
}
/**
* Add Google Chart Files
*
* @return void
* @since 3.2.0
*/
private function addGoogleChartFiles()
{
if ($this->config->get('google_chart', false))
{
// move the google chart files
$this->component->appendArray('files', [
'file' => 'google.jsapi.js',
'path' => 'media/js',
'rename' => 0
]);
$this->component->appendArray('files', [
'file' => 'chartbuilder.php',
'path' => 'admin/helpers',
'rename' => 0
]);
}
}
/**
* Add Folders
*
* @param object $versionData
*
* @return void
* @since 3.2.0
*/
private function addFolders(object &$versionData)
{
if (!$this->component->isArray('folders'))
{
return;
}
// pointer tracker
$pointer_tracker = 'h';
foreach ($this->component->get('folders') as $custom)
{
// check type of target type
$_target_type = 'c0mp0n3nt';
if (isset($custom['target_type']))
{
$_target_type = $custom['target_type'];
}
// for good practice
$this->pathfix->set(
$custom, ['path', 'folder',
'folderpath']
);
// fix custom path
if (isset($custom['path'])
&& StringHelper::check($custom['path']))
{
$custom['path'] = trim((string) $custom['path'],
'/');
}
// by default custom path is true
$customPath = 'custom';
// set full path if this is a full path folder
if (!isset($custom['folder']) &&
isset($custom['folderpath']))
{
// update the dynamic path
$custom['folderpath'] = $this->dynamicpath->update(
$custom['folderpath']
);
// set the folder path with / if does not have a drive/windows full
path
$custom['folder'] = (preg_match(
'/^[a-z]:/i', $custom['folderpath']
)) ? trim($custom['folderpath'], '/')
: '/' . trim($custom['folderpath'],
'/');
// remove the file path
unset($custom['folderpath']);
// triget fullpath
$customPath = 'full';
}
// make sure we use the correct name
$pathArray = (array) explode('/', (string)
$custom['path']);
$lastFolder = end($pathArray);
// only rename folder if last has folder name
if (isset($custom['rename']) &&
$custom['rename'] == 1)
{
$custom['path'] = str_replace(
'/' . $lastFolder, '', (string)
$custom['path']
);
$rename = 'new';
$newname = $lastFolder;
}
elseif ('full' === $customPath)
{
// make sure we use the correct name
$folderArray = (array) explode('/', (string)
$custom['folder']);
$lastFolder = end($folderArray);
$rename = 'new';
$newname = $lastFolder;
}
else
{
$rename = false;
$newname = '';
}
// insure we have no duplicates
$key_pointer = StringHelper::safe(
$custom['folder']
) . '_f' . $pointer_tracker;
$pointer_tracker++;
// fix custom path
$custom['path'] = ltrim((string) $custom['path'],
'/');
// set new folder to object
$versionData->move->static->{$key_pointer} = new \stdClass();
$versionData->move->static->{$key_pointer}->naam =
str_replace('//', '/', (string)
$custom['folder']);
$versionData->move->static->{$key_pointer}->path =
$_target_type . '/' . $custom['path'];
$versionData->move->static->{$key_pointer}->rename =
$rename;
$versionData->move->static->{$key_pointer}->newName =
$newname;
$versionData->move->static->{$key_pointer}->type =
'folder';
$versionData->move->static->{$key_pointer}->custom =
$customPath;
// set the target if type and id is found
if (isset($custom['target_id']) &&
isset($custom['target_type']))
{
$versionData->move->static->{$key_pointer}->_target = [
'key' => $custom['target_id'] . '_'
. $custom['target_type'],
'type' => $custom['target_type']
];
}
}
$this->component->remove('folders');
}
/**
* Add Files
*
* @param object $versionData
*
* @return void
* @since 3.2.0
*/
private function addFiles(object &$versionData)
{
if (!$this->component->isArray('files')) {
return;
}
// pointer tracker
$pointer_tracker = 'h';
foreach ($this->component->get('files') as $custom)
{
// check type of target type
$_target_type = 'c0mp0n3nt';
if (isset($custom['target_type']))
{
$_target_type = $custom['target_type'];
}
// for good practice
$this->pathfix->set(
$custom, ['path', 'file', 'filepath']
);
// by default custom path is true
$customPath = 'custom';
// set full path if this is a full path file
if (!isset($custom['file']) &&
isset($custom['filepath']))
{
// update the dynamic path
$custom['filepath'] = $this->dynamicpath->update(
$custom['filepath']
);
// set the file path with / if does not have a drive/windows full path
$custom['file'] = (preg_match('/^[a-z]:/i',
$custom['filepath']))
? trim($custom['filepath'], '/') : '/' .
trim($custom['filepath'], '/');
// remove the file path
unset($custom['filepath']);
// triget fullpath
$customPath = 'full';
}
// make sure we have not duplicates
$key_pointer = StringHelper::safe(
$custom['file']
) . '_g' . $pointer_tracker;
$pointer_tracker++;
// set new file to object
$versionData->move->static->{$key_pointer} = new \stdClass();
$versionData->move->static->{$key_pointer}->naam =
str_replace('//', '/', (string)
$custom['file']);
// update the dynamic component name placholders in file names
$custom['path'] = $this->placeholder->update_(
$custom['path']
);
// get the path info
$pathInfo = pathinfo((string) $custom['path']);
if (isset($pathInfo['extension']) &&
$pathInfo['extension'])
{
$pathInfo['dirname'] = trim($pathInfo['dirname'],
'/');
// set the info
$versionData->move->static->{$key_pointer}->path =
$_target_type . '/' . $pathInfo['dirname'];
$versionData->move->static->{$key_pointer}->rename =
'new';
$versionData->move->static->{$key_pointer}->newName =
$pathInfo['basename'];
}
elseif ('full' === $customPath)
{
// fix custom path
$custom['path'] = ltrim((string) $custom['path'],
'/');
// get file array
$fileArray = (array) explode('/', (string)
$custom['file']);
// set the info
$versionData->move->static->{$key_pointer}->path =
$_target_type . '/' . $custom['path'];
$versionData->move->static->{$key_pointer}->rename =
'new';
$versionData->move->static->{$key_pointer}->newName =
end($fileArray);
}
else
{
// fix custom path
$custom['path'] = ltrim((string) $custom['path'],
'/');
// set the info
$versionData->move->static->{$key_pointer}->path =
$_target_type . '/' . $custom['path'];
$versionData->move->static->{$key_pointer}->rename =
false;
}
$versionData->move->static->{$key_pointer}->type =
'file';
$versionData->move->static->{$key_pointer}->custom =
$customPath;
// set the target if type and id is found
if (isset($custom['target_id'])
&& isset($custom['target_type']))
{
$versionData->move->static->{$key_pointer}->_target = [
'key' => $custom['target_id'] . '_'
. $custom['target_type'],
'type' => $custom['target_type']
];
}
// check if file should be updated
if (!isset($custom['notnew']) || $custom['notnew']
== 0
|| $custom['notnew'] != 1)
{
$this->registry->appendArray('files.not.new',
$key_pointer);
}
else
{
// update the file content
$this->registry->set('update.file.content.' .
$key_pointer, true);
}
}
$this->component->remove('files');
}
}
src/Componentbuilder/Compiler/Component/JoomlaFour/index.html000064400000000054151162054100020424
0ustar00<html><body
bgcolor="#FFFFFF"></body></html>src/Componentbuilder/Compiler/Component/JoomlaThree/Settings.php000064400000044147151162054100021107
0ustar00<?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\JoomlaThree;
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))
{
$this->component->appendArray('folders', [
'folder' => 'importViews',
'path' => 'admin/views/import',
'rename' => 1
]);
}
}
/**
* 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');
}
}
src/Componentbuilder/Compiler/Component/JoomlaThree/index.html000064400000000054151162054100020560
0ustar00<html><body
bgcolor="#FFFFFF"></body></html>src/Componentbuilder/Compiler/Component/Placeholder.php000064400000010542151162054100017310
0ustar00<?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;
use Joomla\CMS\Factory;
use VDM\Joomla\Utilities\StringHelper;
use VDM\Joomla\Utilities\GetHelper;
use VDM\Joomla\Utilities\JsonHelper;
use VDM\Joomla\Utilities\ArrayHelper;
use VDM\Joomla\Utilities\String\NamespaceHelper;
use VDM\Joomla\Componentbuilder\Compiler\Factory as Compiler;
use VDM\Joomla\Componentbuilder\Compiler\Config;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Placefix;
use
VDM\Joomla\Componentbuilder\Compiler\Interfaces\Component\PlaceholderInterface;
/**
* Get a Components Global Placeholders
*
* @since 3.2.0
*/
final class Placeholder implements PlaceholderInterface
{
/**
* Placeholders
*
* @var array
* @since 3.2.0
**/
protected $placeholders = null;
/**
* Compiler Config
*
* @var Config
* @since 3.2.0
**/
protected $config;
/**
* Database object to query local DB
*
* @since 3.2.0
**/
protected $db;
/**
* Constructor.
*
* @param Config $config The compiler config object.
* @param \JDatabaseDriver $db The Database Driver object.
*
* @since 3.2.0
**/
public function __construct(?Config $config = null)
{
$this->config = $config ?: Compiler::_('Config');
$this->db = Factory::getDbo();
}
/**
* get all System Placeholders
*
* @return array The global placeholders
*
* @since 3.2.0
*/
public function get(): array
{
// set only once
if (is_array($this->placeholders))
{
return $this->placeholders;
}
// load the config
$config = $this->config;
// load the db
$db = $this->db;
// reset bucket
$bucket = [];
// Create a new query object.
$query = $db->getQuery(true);
$query->select($db->quoteName(array('a.target',
'a.value')));
// from these tables
$query->from('#__componentbuilder_placeholder AS a');
// Reset the query using our newly populated query object.
$db->setQuery($query);
// Load the items
$db->execute();
if ($db->getNumRows())
{
$bucket = $db->loadAssocList('target', 'value');
// open all the code
foreach ($bucket as $key => &$code)
{
$code = base64_decode((string) $code);
}
}
// set component place holders
$bucket[Placefix::_h('component')] =
$config->component_code_name;
$bucket[Placefix::_h('Component')] =
StringHelper::safe($config->component_code_name, 'F');
$bucket[Placefix::_h('COMPONENT')] =
StringHelper::safe($config->component_code_name, 'U');
$bucket[Placefix::_('component')] =
$bucket[Placefix::_h('component')];
$bucket[Placefix::_('Component')] =
$bucket[Placefix::_h('Component')];
$bucket[Placefix::_('COMPONENT')] =
$bucket[Placefix::_h('COMPONENT')];
$bucket[Placefix::_h('LANG_PREFIX')] =
$config->lang_prefix;
$bucket[Placefix::_('LANG_PREFIX')] =
$bucket[Placefix::_h('LANG_PREFIX')];
$bucket[Placefix::_h('ComponentNamespace')] =
NamespaceHelper::safeSegment(StringHelper::safe($config->component_code_name,
'F'));
$bucket[Placefix::_('ComponentNamespace')] =
$bucket[Placefix::_h('ComponentNamespace')];
$bucket[Placefix::_h('NamespacePrefix')] =
$config->namespace_prefix;
$bucket[Placefix::_('NamespacePrefix')] =
$config->namespace_prefix;
$bucket[Placefix::_h('NAMESPACEPREFIX')] =
$config->namespace_prefix;
$bucket[Placefix::_('NAMESPACEPREFIX')] =
$config->namespace_prefix;
// get the current components overrides
if (($_placeholders = GetHelper::var(
'component_placeholders', $config->component_id,
'joomla_component', 'addplaceholders'
)) !== false
&& JsonHelper::check($_placeholders))
{
$_placeholders = json_decode((string) $_placeholders, true);
if (ArrayHelper::check($_placeholders))
{
foreach ($_placeholders as $row)
{
$bucket[$row['target']] = str_replace(array_keys($bucket),
array_values($bucket), $row['value']);
}
}
}
$this->placeholders = $bucket;
return $bucket;
}
}
src/Componentbuilder/Compiler/Component/Structure.php000064400000005334151162054100017071
0ustar00<?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;
use VDM\Joomla\Componentbuilder\Compiler\Factory as Compiler;
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;
/**
* Build/Create Component Structure
*
* @since 3.2.0
*/
final class Structure
{
/**
* Compiler Component Joomla Version Settings
*
* @var Settings
* @since 3.2.0
*/
protected Settings $settings;
/**
* Compiler Paths
*
* @var Paths
* @since 3.2.0
*/
protected Paths $paths;
/**
* Compiler Utilities Folder
*
* @var Folder
* @since 3.2.0
*/
protected Folder $folder;
/**
* Constructor
*
* @param Settings|null $settings The compiler component joomla
version settings object.
* @param Paths|null $paths The compiler paths object.
* @param Folder|null $folder The compiler folder object.
*
* @since 3.2.0
*/
public function __construct(?Settings $settings = null, ?Paths $paths =
null, ?Folder $folder = null)
{
$this->settings = $settings ?:
Compiler::_('Component.Settings');
$this->paths = $paths ?: Compiler::_('Utilities.Paths');
$this->folder = $folder ?: Compiler::_('Utilities.Folder');
}
/**
* Build the Component Structure
*
* @return bool
* @since 3.2.0
*/
public function build(): bool
{
if ($this->settings->exists())
{
// setup the main component path
$this->folder->create($this->paths->component_path);
// build the version structure
$this->folders(
$this->settings->structure(),
$this->paths->component_path
);
return true;
}
return false;
}
/**
* Create the folder and subfolders
*
* @param object $folders The object[] of folders
* @param string $path The path
*
* @return void
* @since 3.2.0
*/
protected function folders(object $folders, string $path)
{
foreach ($folders as $folder => $sub_folders)
{
$new_path = $path . '/' . $folder;
$this->folder->create($new_path);
if (ObjectHelper::check($sub_folders))
{
$this->folders($sub_folders, $new_path);
}
}
}
}
src/Componentbuilder/Compiler/Component/Structuremultiple.php000064400000023445151162054100020650
0ustar00<?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;
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\Component\SettingsInterface
as Settings;
use VDM\Joomla\Componentbuilder\Compiler\Component;
use VDM\Joomla\Componentbuilder\Compiler\Model\Createdate;
use VDM\Joomla\Componentbuilder\Compiler\Model\Modifieddate;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Structure;
use VDM\Joomla\Utilities\ObjectHelper;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Placefix;
/**
* Multiple Files and Folders Builder Class
*
* @since 3.2.0
*/
final class Structuremultiple
{
/**
* Compiler Config
*
* @var Config
* @since 3.2.0
*/
protected Config $config;
/**
* The compiler registry
*
* @var Registry
* @since 3.2.0
*/
protected Registry $registry;
/**
* Compiler Component Joomla Version Settings
*
* @var Settings
* @since 3.2.0
*/
protected Settings $settings;
/**
* Compiler Component
*
* @var Component
* @since 3.2.0
**/
protected Component $component;
/**
* Compiler Model Createdate
*
* @var Createdate
* @since 3.2.0
**/
protected Createdate $createdate;
/**
* Compiler Model Modifieddate
*
* @var Modifieddate
* @since 3.2.0
**/
protected Modifieddate $modifieddate;
/**
* Compiler Utility to Build Structure
*
* @var Structure
* @since 3.2.0
**/
protected Structure $structure;
/**
* Constructor
*
* @param Config|null $config The compiler config
object.
* @param Registry|null $registry The compiler registry
object.
* @param Settings|null $settings The compiler component
Joomla version settings object.
* @param Component|null $component The component class.
* @param Createdate|null $createdate The compiler model to
get create date class.
* @param Modifieddate|null $modifieddate The compiler model to
get modified date class.
* @param Structure|null $structure The compiler structure
to build dynamic folder and files class.
*
* @since 3.2.0
*/
public function __construct(?Config $config = null, ?Registry $registry =
null,
?Settings $settings = null, ?Component $component = null,
?Createdate $createdate = null, ?Modifieddate $modifieddate = null,
?Structure $structure = null)
{
$this->config = $config ?: Compiler::_('Config');
$this->registry = $registry ?: Compiler::_('Registry');
$this->settings = $settings ?:
Compiler::_('Component.Settings');
$this->component = $component ?: Compiler::_('Component');
$this->createdate = $createdate ?:
Compiler::_('Model.Createdate');
$this->modifieddate = $modifieddate ?:
Compiler::_('Model.Modifieddate');
$this->structure = $structure ?:
Compiler::_('Utilities.Structure');
}
/**
* Build the Multiple Files & Folders
*
* @return bool
* @since 3.2.0
*/
public function build(): bool
{
$success = false;
if ($this->settings->exists())
{
$success = $this->admin();
$success = $this->site() || $success;
$success = $this->custom() || $success;
}
return $success;
}
/**
* Build the Dynamic Admin Files & Folders
*
* @return bool
* @since 3.2.0
*/
protected function admin(): bool
{
if (!$this->component->isArray('admin_views'))
{
return false;
}
// check if we have a dynamic dashboard
if (!$this->registry->get('build.dashboard'))
{
// setup the default dashboard
$target = ['admin' =>
$this->component->get('name_code')];
$this->structure->build($target, 'dashboard');
}
$config = [];
$checkin = false;
$api = null;
foreach ($this->component->get('admin_views') as $view)
{
if (!$this->isValidAdminView($view, $config))
{
continue;
}
$this->buildAdminView($view, $config);
// quick set of checkin once
if (!$checkin && isset($view['checkin']) &&
$view['checkin'] == 1)
{
// switch to add checking to config
$checkin = true;
$this->config->set('add_checkin', $checkin);
}
if (($target = $this->hasApi($view)) > 0)
{
$this->buildApi($view, $config, $target);
$api = 1;
}
}
$this->config->set('add_api', $api);
return true;
}
/**
* Build the Dynamic Site Files & Folders
*
* @return bool
* @since 3.2.0
*/
protected function site(): bool
{
if (!$this->component->isArray('site_views'))
{
return false;
}
$config = [];
foreach ($this->component->get('site_views') as $view)
{
if (!$this->isValidView($view, $config))
{
continue;
}
$this->buildView($view, $config, 'site');
}
return true;
}
/**
* Build the Dynamic Custom Admin Files & Folders
*
* @return bool
* @since 3.2.0
*/
protected function custom(): bool
{
if (!$this->component->isArray('custom_admin_views'))
{
return false;
}
$config = [];
foreach ($this->component->get('custom_admin_views') as
$view)
{
if (!$this->isValidView($view, $config))
{
continue;
}
$this->buildView($view, $config, 'custom_admin');
}
return true;
}
/**
* Check if the view is a valid view
*
* @param array $view
* @param array $config
*
* @return bool
* @since 3.2.0
*/
private function isValidAdminView(array $view, array &$config): bool
{
if (!isset($view['settings']) ||
!ObjectHelper::check($view['settings'])
|| ((!isset($view['settings']->name_list) ||
$view['settings']->name_list == 'null')
&& (!isset($view['settings']->name_single) ||
$view['settings']->name_single == 'null')))
{
return false;
}
$created = $this->createdate->get($view);
$modified = $this->modifieddate->get($view);
$config = [
Placefix::_h('CREATIONDATE') => $created,
Placefix::_h('BUILDDATE') => $modified,
Placefix::_h('VERSION') =>
$view['settings']->version
];
return true;
}
/**
* Check if the view has an API
*
* @param array $view
*
* @return int
* @since 5.0.2
*/
private function hasApi(array $view): int
{
// only for Joomla 4 and above
if ($this->config->get('joomla_version', 3) < 4 ||
!isset($view['add_api']))
{
return 0;
}
return (int) $view['add_api'];
}
/**
* Check if the view is a valid view
*
* @param array $view
* @param array $config
*
* @return bool
* @since 3.2.0
*/
private function isValidView(array $view, array &$config): bool
{
if (!isset($view['settings']) ||
!ObjectHelper::check($view['settings'])
|| !isset($view['settings']->main_get)
|| !ObjectHelper::check($view['settings']->main_get)
|| !isset($view['settings']->main_get->gettype)
|| ($view['settings']->main_get->gettype != 1 &&
$view['settings']->main_get->gettype != 2))
{
return false;
}
$created = $this->createdate->get($view);
$modified = $this->modifieddate->get($view);
$config = [
Placefix::_h('CREATIONDATE') => $created,
Placefix::_h('BUILDDATE') => $modified,
Placefix::_h('VERSION') =>
$view['settings']->version
];
return true;
}
/**
* Build the admin view
*
* @param array $view
* @param array $config
*
* @return void
* @since 3.2.0
*/
private function buildAdminView(array $view, array $config)
{
// build the admin edit view
if ($view['settings']->name_single != 'null')
{
$target = ['admin' =>
$view['settings']->name_single];
$this->structure->build($target, 'single', false,
$config);
// build the site edit view (of this admin view)
if (isset($view['edit_create_site_view'])
&& is_numeric($view['edit_create_site_view'])
&& $view['edit_create_site_view'] > 0)
{
// setup the front site edit-view files
$target = ['site' =>
$view['settings']->name_single];
$this->structure->build($target, 'edit', false,
$config);
}
}
// build the list view
if ($view['settings']->name_list != 'null')
{
$target = ['admin' =>
$view['settings']->name_list];
$this->structure->build($target, 'list', false,
$config);
}
}
/**
* Build the api
*
* @param array $view
* @param array $config
* @param int $targetArea
*
* @return void
* @since 5.0.2
*/
private function buildApi(array $view, array $config, int $targetArea)
{
$settings = $view['settings'];
// build the api
if ($settings->name_single != 'null' && $targetArea
!== 1)
{
$target = ['api' => $settings->name_single];
$this->structure->build($target, 'single', false,
$config);
}
// build the list view
if ($settings->name_list != 'null' && $targetArea
!== 3)
{
$target = ['api' => $settings->name_list];
$this->structure->build($target, 'list', false,
$config);
}
}
/**
* Build the custom view
*
* @param array $view
* @param array $config
* @param string $type
*
* @return void
* @since 3.2.0
*/
private function buildView(array $view, array $config, string $type)
{
$target = [$type => $view['settings']->code];
$view_type = ($view['settings']->main_get->gettype == 1)
? 'single' : 'list';
$this->structure->build($target, $view_type, false, $config);
}
}
src/Componentbuilder/Compiler/Component/Structuresingle.php000064400000036105151162054100020273
0ustar00<?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;
use Joomla\CMS\Factory;
use Joomla\CMS\Application\CMSApplication;
use Joomla\CMS\Language\Text;
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\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;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Paths;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Files;
use VDM\Joomla\Utilities\StringHelper;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Indent;
/**
* Single Files and Folders Builder Class
*
* @since 3.2.0
*/
final class Structuresingle
{
/**
* The new name
*
* @var string
* @since 3.2.0
*/
protected string $newName;
/**
* Current Full Path
*
* @var string
* @since 3.2.0
*/
protected string $currentFullPath;
/**
* Package Full Path
*
* @var string
* @since 3.2.0
*/
protected string $packageFullPath;
/**
* ZIP Full Path
*
* @var string
* @since 3.2.0
*/
protected string $zipFullPath;
/**
* The Config Class.
*
* @var Config
* @since 3.2.0
*/
protected Config $config;
/**
* The Registry Class.
*
* @var Registry
* @since 3.2.0
*/
protected Registry $registry;
/**
* The Placeholder Class.
*
* @var Placeholder
* @since 3.2.0
*/
protected Placeholder $placeholder;
/**
* The SettingsInterface Class.
*
* @var Settings
* @since 3.2.0
*/
protected Settings $settings;
/**
* The Component Class.
*
* @var Component
* @since 3.2.0
*/
protected Component $component;
/**
* The ContentOne Class.
*
* @var Content
* @since 3.2.0
*/
protected Content $content;
/**
* The Counter Class.
*
* @var Counter
* @since 3.2.0
*/
protected Counter $counter;
/**
* The Paths Class.
*
* @var Paths
* @since 3.2.0
*/
protected Paths $paths;
/**
* The Files Class.
*
* @var Files
* @since 3.2.0
*/
protected Files $files;
/**
* Application object.
*
* @var CMSApplication
* @since 3.2.0
**/
protected CMSApplication $app;
/**
* Constructor.
*
* @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,
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;
$this->counter = $counter;
$this->paths = $paths;
$this->files = $files;
$this->app = $app ?: Factory::getApplication();
}
/**
* Build the Single Files & Folders
*
* @return bool
* @since 3.2.0
*/
public function build(): bool
{
if ($this->settings->exists())
{
// TODO needs more looking at this must be dynamic actually
$this->registry->appendArray('files.not.new',
'LICENSE.txt');
// do license check
$LICENSE = $this->doLicenseCheck();
// do README check
$README = $this->doReadmeCheck();
// do CHANGELOG check
$CHANGELOG = $this->doChangelogCheck();
// start moving
foreach ($this->settings->single() as $target => $details)
{
// if not gnu/gpl license dont add the LICENSE.txt file
if ($details->naam === 'LICENSE.txt' &&
!$LICENSE)
{
continue;
}
// if not needed do not add
if (($details->naam === 'README.md' || $details->naam
=== 'README.txt')
&& !$README)
{
continue;
}
// if not needed do not add
if ($details->naam === 'CHANGELOG.md' &&
!$CHANGELOG)
{
continue;
}
// set new name
$this->setNewName($details);
// set all paths
$this->setPaths($details);
// check if the path exists
if ($this->pathExist($details))
{
// set the target
$this->setTarget($target, $details);
}
// set dynamic target as needed
$this->setDynamicTarget($details);
}
return true;
}
return false;
}
/**
* Check if license must be added
*
* @return bool
* @since 3.2.0
*/
private function doLicenseCheck(): bool
{
$licenseChecker = strtolower((string)
$this->component->get('license', ''));
if (strpos($licenseChecker, 'gnu') !== false
&& strpos(
$licenseChecker, '2'
) !== false
&& (strpos($licenseChecker, 'gpl') !== false
|| strpos(
$licenseChecker, 'general public license'
) !== false))
{
return true;
}
return false;
}
/**
* Check if readme must be added
*
* @return bool
* @since 3.2.0
*/
private function doReadmeCheck(): bool
{
return (bool) $this->component->get('addreadme', false);
}
/**
* Check if changelog must be added
*
* @return bool
* @since 3.2.0
*/
private function doChangelogCheck(): bool
{
return (bool) $this->component->get('changelog', false);
}
/**
* Set the new name
*
* @param object $details
*
* @return void
* @since 3.2.0
*/
private function setNewName(object $details)
{
// do the file renaming
if (isset($details->rename) && $details->rename)
{
if ($details->rename === 'new')
{
$newName = $details->newName;
}
else
{
$naam = $details->naam ?? 'error';
$newName = str_replace(
$details->rename,
$this->config->component_code_name,
(string) $naam
);
}
}
else
{
$newName = $details->naam ?? 'error';
}
$this->newName = $this->placeholder->update_($newName);
}
/**
* Set all needed paths
*
* @param object $details
*
* @return void
* @since 3.2.0
*/
private function setPaths(object $details)
{
// check if we have a target value
if (isset($details->_target))
{
// set destination path
$zipPath = str_replace(
$details->_target['type'] . '/', '',
(string) $details->path
);
$path = str_replace(
$details->_target['type'] . '/',
$this->registry->get('dynamic_paths.' .
$details->_target['key'], '') . '/',
(string) $details->path
);
}
else
{
// set destination path
$zipPath = str_replace('c0mp0n3nt/', '', (string)
$details->path);
$path = str_replace(
'c0mp0n3nt/', $this->paths->component_path .
'/', (string) $details->path
);
}
// set the template folder path
$templatePath = (isset($details->custom) &&
$details->custom)
? (($details->custom !== 'full') ?
$this->paths->template_path_custom
. '/' : '') : $this->paths->template_path .
'/';
// set the final paths
$currentFullPath = (preg_match('/^[a-z]:/i', (string)
$details->naam)) ? $details->naam
: $templatePath . '/' . $details->naam;
$this->currentFullPath = str_replace('//', '/',
(string) $currentFullPath);
$this->packageFullPath = str_replace('//', '/',
$path . '/' . $this->newName);
$this->zipFullPath = str_replace(
'//', '/', $zipPath . '/' .
$this->newName
);
}
/**
* Check if path exists
*
* @param object $details
*
* @return bool
* @since 3.2.0
*/
private function pathExist(object $details): bool
{
// check if this has a type
if (!isset($details->type))
{
return false;
}
// take action based on type
elseif ($details->type === 'file' &&
!File::exists($this->currentFullPath))
{
$this->app->enqueueMessage(
Text::_('COM_COMPONENTBUILDER_HR_HTHREEFILE_PATH_ERRORHTHREE'),
'Error'
);
$this->app->enqueueMessage(
Text::sprintf('COM_COMPONENTBUILDER_THE_FILE_PATH_BSB_DOES_NOT_EXIST_AND_WAS_NOT_ADDED',
$this->currentFullPath
), 'Error'
);
return false;
}
elseif ($details->type === 'folder' &&
!Folder::exists($this->currentFullPath))
{
$this->app->enqueueMessage(
Text::_('COM_COMPONENTBUILDER_HR_HTHREEFOLDER_PATH_ERRORHTHREE'),
'Error'
);
$this->app->enqueueMessage(
Text::sprintf('COM_COMPONENTBUILDER_THE_FOLDER_PATH_BSB_DOES_NOT_EXIST_AND_WAS_NOT_ADDED',
$this->currentFullPath
), 'Error'
);
return false;
}
return true;
}
/**
* Set the target based on target type
*
* @param string $target
* @param object $details
*
* @return void
* @since 3.2.0
*/
private function setTarget(string $target, object $details)
{
// take action based on type
if ($details->type === 'file')
{
// move the file
$this->moveFile();
// register the file
$this->registerFile($target, $details);
}
elseif ($details->type === 'folder')
{
// move the folder to its place
Folder::copy(
$this->currentFullPath, $this->packageFullPath, '',
true
);
// count the folder created
$this->counter->folder++;
}
}
/**
* Move/Copy the file into place
*
* @return void
* @since 3.2.0
*/
private function moveFile()
{
// get base name && get the path only
$packageFullPath0nly = str_replace(
basename($this->packageFullPath), '',
$this->packageFullPath
);
// check if path exist, if not creat it
if (!Folder::exists($packageFullPath0nly))
{
Folder::create($packageFullPath0nly);
}
// move the file to its place
File::copy($this->currentFullPath, $this->packageFullPath);
// count the file created
$this->counter->file++;
}
/**
* Register the file
*
* @param string $target
* @param object $details
*
* @return void
* @since 3.2.0
*/
private function registerFile(string $target, object $details)
{
// store the new files
if (!in_array($target,
$this->registry->get('files.not.new', [])))
{
if (isset($details->_target))
{
$this->files->appendArray($details->_target['key'],
[
'path' => $this->packageFullPath,
'name' => $this->newName,
'zip' => $this->zipFullPath
]
);
}
else
{
$this->files->appendArray('static',
[
'path' => $this->packageFullPath,
'name' => $this->newName,
'zip' => $this->zipFullPath
]
);
}
}
// ensure we update this file if needed
if ($this->registry->exists('update.file.content.' .
$target))
{
// remove the pointer
$this->registry->remove('update.file.content.' .
$target);
// set the full path
$this->registry->set('update.file.content.' .
$this->packageFullPath, $this->packageFullPath);
}
}
/**
* Set Dynamic Target
*
* @param object $details
*
* @return void
* @since 3.2.0
*/
private function setDynamicTarget(object $details)
{
// only add if no target found since those belong to plugins and modules
if (!isset($details->_target))
{
// check if we should add the dynamic folder moving script to the
installer script
$checker = array_values((array) explode('/',
$this->zipFullPath));
// TODO <-- this may not be the best way, will keep an eye on this.
// We basicly only want to check if a folder is added that is not in the
stdFolders array
if (isset($checker[0])
&& StringHelper::check($checker[0])
&& !$this->settings->standardFolder($checker[0]))
{
// activate dynamic folders
$this->setDynamicFolders();
}
elseif (count((array) $checker) == 2
&& StringHelper::check($checker[0]))
{
$add_to_extra = false;
// set the target
$eNAME = 'FILES';
$ename = 'filename';
// this should not happen and must have been caught by the above if
statment
if ($details->type === 'folder')
{
// only folders outside the standard folder are added
$eNAME = 'FOLDERS';
$ename = 'folder';
$add_to_extra = true;
}
// if this is a file, it can only be added to the admin/site/media
folders
// all other folders are moved as a whole so their files do not need to
be declared
elseif ($this->settings->standardFolder($checker[0])
&& !$this->settings->standardRootFile($checker[1]))
{
$add_to_extra = true;
}
// add if valid folder/file
if ($add_to_extra)
{
// set the tab
$eTab = Indent::_(2);
if ('admin' === $checker[0])
{
$eTab = Indent::_(3);
}
// set the xml file
$key_ = 'EXSTRA_'
. StringHelper::safe(
$checker[0], 'U'
) . '_' . $eNAME;
$this->content->add($key_,
PHP_EOL . $eTab . "<" . $ename . ">"
. $checker[1] . "</" . $ename . ">");
}
}
}
}
/**
* Add the dynamic folders
*
* @return void
* @since 3.2.0
*/
private function setDynamicFolders()
{
// check if we should add the dynamic folder moving script to the
installer script
if
(!$this->registry->get('set_move_folders_install_script'))
{
// 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_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'
);
}
}
}
src/Componentbuilder/Compiler/Component/index.html000064400000000054151162054100016347
0ustar00<html><body
bgcolor="#FFFFFF"></body></html>src/Componentbuilder/Compiler/Config.php000064400000065327151162054100014344
0ustar00<?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;
use Joomla\Registry\Registry as JoomlaRegistry;
use Joomla\CMS\Factory as JoomlaFactory;
use Joomla\Input\Input;
use VDM\Joomla\Utilities\GetHelper;
use VDM\Joomla\Utilities\StringHelper;
use VDM\Joomla\Componentbuilder\Utilities\RepoHelper;
use VDM\Joomla\Componentbuilder\Abstraction\BaseConfig;
/**
* Compiler Configurations
*
* All these functions are accessed via the direct name without the get:
* example: $this->component_code_name calls:
$this->getComponentcodename()
*
* All values once called are cached, yet can be updated directly:
* example: $this->component_code_name = 'new_code_name'; //
be warned!
*
* @since 3.2.0
*/
class Config extends BaseConfig
{
/**
* The Global Joomla Configuration
*
* @var JoomlaRegistry
* @since 3.2.0
*/
protected JoomlaRegistry $config;
/**
* Constructor
*
* @param Input|null $input Input
* @param JoomlaRegistry|null $params The component parameters
* @param JoomlaRegistry|null $config The Joomla configuration
*
* @throws \Exception
* @since 3.2.0
*/
public function __construct(?Input $input = null, ?JoomlaRegistry $params
= null, ?JoomlaRegistry $config = null)
{
parent::__construct($input, $params);
$this->config = $config ?: JoomlaFactory::getConfig();
}
/**
* get Gitea Username
*
* @return string the access token
* @since 3.2.0
*/
protected function getGiteausername(): ?string
{
return $this->params->get('gitea_username');
}
/**
* get Gitea Access Token
*
* @return string the access token
* @since 3.2.0
*/
protected function getGiteatoken(): ?string
{
return $this->params->get('gitea_token');
}
/**
* Get super power core organisation
*
* @return string The super power core organisation
* @since 3.2.0
*/
protected function getSuperpowerscoreorganisation(): string
{
// the VDM default organisation is [joomla]
$organisation = 'joomla';
return $organisation;
}
/**
* Get super power core repos
*
* @return array The core repositories on Gitea
* @since 3.2.0
*/
protected function getSuperpowerscorerepos(): array
{
// some defaults repos we need by JCB
$repos = [];
// get the users own power repo (can overwrite all)
if ($this->gitea_username !== null)
{
$repos[$this->gitea_username . '.super-powers'] = (object)
[
'organisation' => $this->gitea_username,
'repository' => 'super-powers',
'read_branch' => 'master'
];
}
$repos[$this->super_powers_core_organisation .
'.super-powers'] = (object) [
'organisation' =>
$this->super_powers_core_organisation,
'repository' => 'super-powers',
'read_branch' => 'master'
];
$repos[$this->super_powers_core_organisation .
'.jcb-compiler'] = (object) [
'organisation' =>
$this->super_powers_core_organisation,
'repository' => 'jcb-compiler',
'read_branch' => 'master'
];
$repos[$this->super_powers_core_organisation .
'.jcb-packager'] = (object) [
'organisation' =>
$this->super_powers_core_organisation,
'repository' => 'jcb-packager',
'read_branch' => 'master'
];
$repos[$this->super_powers_core_organisation . '.phpseclib']
= (object) [
'organisation' =>
$this->super_powers_core_organisation,
'repository' => 'phpseclib',
'read_branch' => 'master'
];
$repos[$this->super_powers_core_organisation . '.search'] =
(object) [
'organisation' =>
$this->super_powers_core_organisation,
'repository' => 'search',
'read_branch' => 'master'
];
$repos[$this->super_powers_core_organisation . '.gitea'] =
(object) [
'organisation' =>
$this->super_powers_core_organisation,
'repository' => 'gitea',
'read_branch' => 'master'
];
$repos[$this->super_powers_core_organisation . '.openai'] =
(object) [
'organisation' =>
$this->super_powers_core_organisation,
'repository' => 'openai',
'read_branch' => 'master'
];
$repos[$this->super_powers_core_organisation . '.minify'] =
(object) [
'organisation' =>
$this->super_powers_core_organisation,
'repository' => 'minify',
'read_branch' => 'master'
];
$repos[$this->super_powers_core_organisation . '.psr'] =
(object) [
'organisation' =>
$this->super_powers_core_organisation,
'repository' => 'psr',
'read_branch' => 'master'
];
$repos[$this->super_powers_core_organisation . '.fof'] =
(object) [
'organisation' =>
$this->super_powers_core_organisation,
'repository' => 'fof',
'read_branch' => 'master'
];
return $repos;
}
/**
* get add contributors switch
*
* @return bool Add contributors switch
* @since 3.2.0
*/
protected function getAddcontributors(): bool
{
return false; // default is false
}
/**
* get Add Ajax Switch
*
* @return bool Add Ajax Switch
* @since 3.2.0
*/
protected function getAddajax(): bool
{
return false; // default is false
}
/**
* get Add Site Ajax Switch
*
* @return bool Add Site Ajax Switch
* @since 3.2.0
*/
protected function getAddsiteajax(): bool
{
return false; // default is false
}
/**
* get add eximport
*
* @return bool add eximport switch
* @since 3.2.0
*/
protected function getAddeximport(): bool
{
return false; // default is false
}
/**
* get add checkin
*
* @return bool add checkin switch
* @since 3.2.0
*/
protected function getAddcheckin(): bool
{
return false; // default is false
}
/**
* get posted component id
*
* @return int Component id
* @since 3.2.0
*/
protected function getComponentid(): int
{
return $this->input->post->get('component_id', 0,
'INT');
}
/**
* get component version
*
* @return string Component version
* @since 3.2.0
*/
protected function getComponentversion(): string
{
return '1.0.0';
}
/**
* get components code name
*
* @return string The components code name
* @since 3.2.0
*/
protected function getComponentcodename(): string
{
// get components code name
return StringHelper::safe(GetHelper::var(
'joomla_component', $this->component_id, 'id',
'name_code'
));
}
/**
* get component context
*
* @return string The component context
* @since 3.2.0
*/
protected function getComponentcontext(): string
{
// get component context
return $this->component_code_name . '.' .
$this->component_id;
}
/**
* get component code name length
*
* @return int The component code name length
* @since 3.2.0
*/
protected function getComponentcodenamelength(): int
{
// get component name length
return strlen((string) $this->component_code_name);
}
/**
* get component autoloader path
*
* @return string The component autoloader path
* @since 3.2.0
*/
protected function getComponentautoloaderpath(): string
{
if ($this->joomla_version == 3)
{
return 'helpers/powerloader.php';
}
else
{
return 'src/Helper/PowerloaderHelper.php';
}
}
/**
* get component installer autoloader path
*
* @return string The component installer autoloader path
* @since 5.0.2
*/
protected function getComponentinstallerautoloaderpath(): string
{
if ($this->joomla_version == 3)
{
return 'script_powerloader.php';
}
else
{
return ucfirst($this->component_codename) .
'InstallerPowerloader.php';
}
}
/**
* get add namespace prefix
*
* @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
*
* @return int Joomla version code
* @since 3.2.0
*/
protected function getJoomlaversion(): int
{
return $this->input->post->get('joomla_version', 3,
'INT');
}
/**
* get Joomla versions
*
* @return array Joomla versions
* @since 3.2.0
*/
protected function getJoomlaversions(): array
{
return [
3 => ['folder_key' => 3, 'xml_version' =>
'3.10'],
4 => ['folder_key' => 4, 'xml_version' =>
'4.0'],
5 => ['folder_key' => 4, 'xml_version' =>
'5.0'] // for now we build 4 and 5 from same templates ;)
];
}
/**
* get posted Joomla version name
*
* @return string Joomla version code name
* @since 3.2.0
*/
protected function getJoomlaversionname(): string
{
return StringHelper::safe($this->joomla_version);
}
/**
* set joomla fields
*
* @return bool set joomla fields
* @since 3.2.0
*/
protected function getSetjoomlafields(): bool
{
return false;
}
/**
* get show advanced options switch
*
* @return bool show advanced options
* @since 3.2.0
*/
protected function getShowadvancedoptions(): bool
{
return (bool)
$this->input->post->get('show_advanced_options', 0,
'INT');
}
/**
* get indentation value
*
* @return string Indentation value
* @since 3.2.0
*/
protected function getIndentationvalue(): string
{
// if advanced options is active
if ($this->show_advanced_options)
{
$indentation_value =
$this->input->post->get('indentation_value', 1,
'INT');
switch($indentation_value)
{
case 2:
// two spaces
return " ";
break;
case 4:
// four spaces
return " ";
break;
}
}
return "\t";
}
/**
* get add build date switch
*
* @return int add build date options
* @since 3.2.0
*/
protected function getAddbuilddate(): int
{
// if advanced options is active
if ($this->show_advanced_options)
{
// 1=default 2=manual 3=component
return $this->input->post->get('add_build_date', 1,
'INT');
}
return 1;
}
/**
* get build date
*
* @return string build date
* @since 3.2.0
*/
protected function getBuilddate(): string
{
// if advanced options is active and manual date selected
if ($this->show_advanced_options && $this->add_build_date
== 2)
{
return $this->input->post->get('build_date',
'now', 'STRING');
}
return "now";
}
/**
* get posted backup switch
*
* @return int Backup switch number
* @since 3.2.0
*/
protected function getBackup(): int
{
return $this->input->post->get('backup', 0,
'INT');
}
/**
* get posted repository switch
*
* @return int Repository switch number
* @since 3.2.0
*/
protected function getRepository(): int
{
return $this->input->post->get('repository', 0,
'INT');
}
/**
* get posted debuglinenr switch
*
* @return int Debuglinenr switch number
* @since 3.2.0
*/
protected function getDebuglinenr(): int
{
// get posted value
$value = $this->input->post->get('debug_line_nr', 2,
'INT');
// get global value
if ($value > 1)
{
return (int) GetHelper::var('joomla_component',
$this->component_id, 'id', 'debug_linenr');
}
return $value;
}
/**
* get posted minify switch
*
* @return int Minify switch number
* @since 3.2.0
*/
protected function getMinify(): int
{
// get posted value
$minify = $this->input->post->get('minify', 2,
'INT');
// if value is 2 use global value
return ($minify != 2) ? $minify :
$this->params->get('minify', 0);
}
/**
* get posted remove line breaks switch
*
* @return bool Remove line breaks switch number
* @since 3.2.0
*/
protected function getRemovelinebreaks(): bool
{
return (bool) true;
}
/**
* get system tidy state
*
* @return bool Tidy is active
* @since 3.2.0
*/
protected function getTidy(): bool
{
// check if we have Tidy enabled
return \extension_loaded('Tidy');
}
/**
* add tidy warning
*
* @return bool Set tidy warning
* @since 3.2.0
*/
protected function getSettidywarning(): bool
{
// add warning once
return true;
}
/**
* get history tag switch
*
* @return bool get history tag switch
* @since 3.2.0
*/
protected function getSettaghistory(): bool
{
// add warning once
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
*
* @return string The active language tag
* @since 3.2.0
*/
protected function getLangtag(): string
{
// get the global language
return $this->params->get('language',
'en-GB');
}
/**
* get language prefix
*
* @return string The language prefix
* @since 3.2.0
*/
protected function getLangprefix(): string
{
// get components code name
return 'COM_' . StringHelper::safe(GetHelper::var(
'joomla_component', $this->component_id, 'id',
'name_code'
), 'U');
}
/**
* get language target
*
* @return string The language active target
* @since 3.2.0
*/
protected function getLangtarget(): string
{
// we start with admin
// but this is a switch value and is changed many times
return 'admin';
}
/**
* get language string targets
*
* @return array The language prefix
* @since 3.2.0
*/
protected function getLangstringtargets(): array
{
// these strings are used to search for language strings in all content
return array_values($this->lang_string_key_targets);
}
/**
* get language string targets (by key name)
*
* @return array The language prefix
* @since 3.2.0
*/
protected function getLangstringkeytargets(): array
{
// these strings are used to search for language strings in all content
return [
'jjt' => 'Joomla' . '.JText._(',
'js' => 'Text:' . ':script(',
't' => 'Text:' . ':_(', //
namespace and J version will be found
'ts' => 'Text:' . ':sprintf(', //
namespace and J version will be found
'jt' => 'JustTEXT:' . ':_(',
'spjs' => 'Joomla__' .
'_ba6326ef_cb79_4348_80f4_ab086082e3c5___Power:' .
':script(', // the joomla power version
'spt' => 'Joomla__' .
'_ba6326ef_cb79_4348_80f4_ab086082e3c5___Power:' .
':_(', // the joomla power version
'spts' => 'Joomla__' .
'_ba6326ef_cb79_4348_80f4_ab086082e3c5___Power:' .
':sprintf(' // the joomla power version
];
}
/**
* get field builder type
*
* @return int The field builder type
* @since 3.2.0
*/
protected function getFieldbuildertype(): int
{
// get the field type builder
return $this->params->get(
'compiler_field_builder_type', 2
);
}
/**
* get default fields
*
* @return array The default fields
* @since 3.2.0
*/
protected function getDefaultfields(): array
{
// get the field type builder
return ['created', 'created_by',
'modified', 'modified_by', 'published',
'ordering', 'access', 'version',
'hits', 'id'];
}
/**
* get temporary path
*
* @return string The temporary path
* @since 3.2.0
*/
protected function getTmppath(): string
{
// get the temporary path
return $this->config->get('tmp_path');
}
/**
* get compiler path
*
* @return string The compiler path
* @since 3.2.0
*/
protected function getCompilerpath(): string
{
// get the compiler path
return $this->params->get(
'compiler_folder_path',
JPATH_COMPONENT_ADMINISTRATOR . '/compiler'
);
}
/**
* get jcb powers path
*
* @return string The jcb powers path
* @since 3.2.0
*/
protected function getJcbpowerspath(): string
{
$add = GetHelper::var(
'joomla_component', $this->component_id, 'id',
'add_jcb_powers_path'
);
if ($add == 1)
{
$path = GetHelper::var(
'joomla_component', $this->component_id, 'id',
'jcb_powers_path'
);
if (StringHelper::check($path))
{
return $path;
}
}
// get jcb powers path
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
*
* @return string The path to the local repository
* @since 3.2.0
*/
protected function getLocalpowersrepositorypath(): string
{
$default = $this->tmp_path . '/super_powers';
if (!$this->add_super_powers)
{
return $default;
}
$global =
$this->params->get('local_powers_repository_path',
$default);
if (!$this->show_advanced_options)
{
return $global;
}
$value = $this->input->post->get('powers_repository',
2, 'INT');
return $value == 1
?
$this->input->post->get('local_powers_repository_path',
$global, 'PATH')
: $global;
}
/**
* Get super power approved paths
*
* @return array The approved paths to the repositories on Gitea
* @since 3.2.0
*/
protected function getApprovedpaths(): array
{
// some defaults repos we need by JCB
$approved = $this->super_powers_core_repos;
$paths = RepoHelper::get(1); // super powers = 1
if ($paths !== null)
{
foreach ($paths as $path)
{
$owner = $path->organisation ?? null;
$repo = $path->repository ?? null;
if ($owner !== null && $repo !== null)
{
// we make sure to get only the objects
$approved = ["{$owner}.{$repo}" => $path] + $approved;
}
}
}
return array_values($approved);
}
/**
* Get super power core organisation
*
* @return string The super power core organisation
* @since 3.2.0
*/
protected function getJoomlapowerscoreorganisation(): string
{
// the VDM default organisation is [joomla]
$organisation = 'joomla';
return
$this->params->get('joomla_powers_core_organisation',
$organisation);
}
/**
* Get Joomla power init repos
*
* @return array The init repositories on Gitea
* @since 3.2.0
*/
protected function getJoomlapowersinitrepos(): array
{
// some defaults repos we need by JCB
$repos = [];
// get the users own power repo (can overwrite all)
if ($this->gitea_username !== null)
{
$repos[$this->gitea_username . '.joomla-powers'] = (object)
[
'organisation' => $this->gitea_username,
'repository' => 'joomla-powers',
'read_branch' => 'master'
];
}
$repos[$this->joomla_powers_core_organisation .
'.joomla-powers'] = (object) [
'organisation' =>
$this->joomla_powers_core_organisation,
'repository' => 'joomla-powers',
'read_branch' => 'master'
];
return $repos;
}
/**
* Get local joomla super powers repository path
*
* @return string The path to the local repository
* @since 3.2.0
*/
protected function getLocaljoomlapowersrepositorypath(): string
{
$default = $this->tmp_path . '/joomla_powers';
return
$this->params->get('local_joomla_powers_repository_path',
$default);
}
/**
* Get joomla power approved paths
*
* @return array The approved paths to the repositories on Gitea
* @since 3.2.0
*/
protected function getApprovedjoomlapaths(): array
{
// some defaults repos we need by JCB
$approved = $this->joomla_powers_init_repos;
$paths = RepoHelper::get(2); // Joomla Power = 2
if ($paths !== null)
{
foreach ($paths as $path)
{
$owner = $path->organisation ?? null;
$repo = $path->repository ?? null;
if ($owner !== null && $repo !== null)
{
// we make sure to get only the objects
$approved = ["{$owner}.{$repo}" => $path] + $approved;
}
}
}
return array_values($approved);
}
/**
* get bom path
*
* @return string The bom path
* @since 3.2.0
*/
protected function getBompath(): string
{
// get default bom path
return $this->compiler_path . '/default.txt';
}
/**
* get custom folder path
*
* @return string The custom folder path
* @since 3.2.0
*/
protected function getCustomfolderpath(): string
{
// get the custom folder path
return $this->params->get(
'custom_folder_path',
JPATH_COMPONENT_ADMINISTRATOR . '/custom'
);
}
/**
* get switch to add assets table fix
*
* @return int Switch number to add assets table fix
* @since 3.2.0
*/
protected function getAddassetstablefix(): int
{
// get global add assets table fix
$global = $this->params->get(
'assets_table_fix', 1
);
// get component value
return (($add_assets_table_fix = (int) GetHelper::var(
'joomla_component', $this->component_id, 'id',
'assets_table_fix'
)) == 3) ? $global : $add_assets_table_fix;
}
/**
* get switch to add assets table name fix
*
* @return bool Switch number to add assets table name fix
* @since 3.2.0
*/
protected function getAddassetstablenamefix(): bool
{
// get global is false
return false;
}
/**
* get access worse case size
*
* @return int access worse case size
* @since 3.2.0
*/
protected function getAccessworsecase(): int
{
// we start at zero
return 0;
}
/**
* get mysql table keys
*
* @return array
* @since 3.2.0
*/
protected function getMysqltablekeys(): array
{
return [
'engine' => ['default' =>
'MyISAM'],
'charset' => ['default' =>
'utf8'],
'collate' => ['default' =>
'utf8_general_ci'],
'row_format' => ['default' => '']
];
}
/**
* get switch add placeholders
*
* @return bool Switch to add placeholders
* @since 3.2.0
*/
protected function getAddplaceholders(): bool
{
// get posted value
$value = $this->input->post->get('add_placeholders',
2, 'INT');
// get global value
if ($value > 1)
{
return (bool) GetHelper::var('joomla_component',
$this->component_id, 'id', 'add_placeholders');
}
return (bool) $value;
}
/**
* get switch add power
*
* @return bool Switch to add power
* @since 3.2.0
*/
protected function getAddpower(): bool
{
// get posted value
$value = $this->input->post->get('powers', 2,
'INT');
// get global value
if ($value > 1)
{
return (bool) GetHelper::var('joomla_component',
$this->component_id, 'id', 'add_powers');
}
return (bool) $value;
}
/**
* Get switch to add super powers
*
* @return bool Switch to add super powers
* @since 3.2.0
*/
protected function getAddsuperpowers(): bool
{
$default = (bool) $this->params->get('powers_repository',
0);
if (!$this->show_advanced_options)
{
return $default;
}
$value = $this->input->post->get('powers_repository',
2, 'INT');
return $value == 2 ? $default : (bool) $value;
}
/**
* Get switch to add own super powers
*
* @return bool Switch to add own super powers
* @since 3.2.0
*/
protected function getAddownpowers(): bool
{
if ($this->add_super_powers)
{
return (bool)
$this->params->get('super_powers_repositories', 0);
}
return false;
}
/**
* get switch build target switch
*
* @return string Switch to control the build flow
* @since 3.2.0
*/
protected function getBuildtarget(): string
{
// we start with admin
// but this is a switch value and is changed many times
return 'admin';
}
/**
* get encryption types
*
* @return array encryption types
* @since 3.2.0
*/
protected function getCryptiontypes(): array
{
return ['basic', 'medium', 'whmcs',
'expert'];
}
/**
* get basic encryption switch
*
* @return bool Switch to control the encryption
* @since 3.2.0
*/
protected function getBasicencryption(): bool
{
return false;
}
/**
* get medium encryption switch
*
* @return bool Switch to control the encryption
* @since 3.2.0
*/
protected function getMediumencryption(): bool
{
return false;
}
/**
* get whmcs encryption switch
*
* @return bool Switch to control the encryption
* @since 3.2.0
*/
protected function getWhmcsencryption(): bool
{
return false;
}
/**
* Should we remove the site folder
*
* @return bool Switch to control the removal
* @since 3.2.0
*/
protected function getRemovesitefolder(): bool
{
return false;
}
/**
* Should we remove the site edit folder
*
* @return bool Switch to control the removal
* @since 3.2.0
*/
protected function getRemovesiteeditfolder(): bool
{
return true;
}
/**
* The Uikit switch
*
* @return int Switch to control the adding uikit
* @since 3.2.0
*/
protected function getUikit(): int
{
return 0; // default its not added
}
/**
* The google chart switch
*
* @return bool Switch to control the adding googlechart
* @since 3.2.0
*/
protected function getGooglechart(): bool
{
return false; // default its not added
}
/**
* The footable switch
*
* @return bool Switch to control the adding footable
* @since 3.2.0
*/
protected function getFootable(): bool
{
return false; // default its not added
}
/**
* The footable version
*
* @return int Switch to control the adding footable
* @since 3.2.0
*/
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;
}
}
src/Componentbuilder/Compiler/Creator/AccessSections.php000064400000051711151162054100017437
0ustar00<?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;
}
}
src/Componentbuilder/Compiler/Creator/AccessSectionsCategory.php000064400000004625151162054100021137
0ustar00<?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;
}
}
src/Componentbuilder/Compiler/Creator/AccessSectionsJoomlaFields.php000064400000005227151162054100021731
0ustar00<?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;
}
}
src/Componentbuilder/Compiler/Creator/Builders.php000064400000127552151162054100016306
0ustar00<?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 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;
use VDM\Joomla\Componentbuilder\Compiler\Creator\SiteFieldData;
use VDM\Joomla\Componentbuilder\Compiler\Builder\Tags;
use VDM\Joomla\Componentbuilder\Compiler\Builder\DatabaseTables;
use VDM\Joomla\Componentbuilder\Compiler\Builder\DatabaseUniqueKeys;
use VDM\Joomla\Componentbuilder\Compiler\Builder\DatabaseKeys;
use VDM\Joomla\Componentbuilder\Compiler\Builder\DatabaseUniqueGuid;
use VDM\Joomla\Componentbuilder\Compiler\Builder\ListJoin;
use VDM\Joomla\Componentbuilder\Compiler\Builder\History;
use VDM\Joomla\Componentbuilder\Compiler\Builder\Alias;
use VDM\Joomla\Componentbuilder\Compiler\Builder\Title;
use VDM\Joomla\Componentbuilder\Compiler\Builder\CategoryOtherName;
use VDM\Joomla\Componentbuilder\Compiler\Builder\Lists;
use VDM\Joomla\Componentbuilder\Compiler\Builder\CustomList;
use VDM\Joomla\Componentbuilder\Compiler\Builder\FieldRelations;
use VDM\Joomla\Componentbuilder\Compiler\Builder\HiddenFields;
use VDM\Joomla\Componentbuilder\Compiler\Builder\IntegerFields;
use VDM\Joomla\Componentbuilder\Compiler\Builder\DynamicFields;
use VDM\Joomla\Componentbuilder\Compiler\Builder\MainTextField;
use VDM\Joomla\Componentbuilder\Compiler\Builder\CustomField;
use VDM\Joomla\Componentbuilder\Compiler\Builder\CustomFieldLinks;
use VDM\Joomla\Componentbuilder\Compiler\Builder\ScriptUserSwitch;
use VDM\Joomla\Componentbuilder\Compiler\Builder\ScriptMediaSwitch;
use VDM\Joomla\Componentbuilder\Compiler\Builder\Category;
use VDM\Joomla\Componentbuilder\Compiler\Builder\CategoryCode;
use VDM\Joomla\Componentbuilder\Compiler\Builder\CheckBox;
use VDM\Joomla\Componentbuilder\Compiler\Builder\JsonString;
use VDM\Joomla\Componentbuilder\Compiler\Builder\BaseSixFour;
use VDM\Joomla\Componentbuilder\Compiler\Builder\ModelBasicField;
use VDM\Joomla\Componentbuilder\Compiler\Builder\ModelWhmcsField;
use VDM\Joomla\Componentbuilder\Compiler\Builder\ModelMediumField;
use VDM\Joomla\Componentbuilder\Compiler\Builder\ModelExpertFieldInitiator;
use VDM\Joomla\Componentbuilder\Compiler\Builder\ModelExpertField;
use VDM\Joomla\Componentbuilder\Compiler\Builder\JsonItem;
use VDM\Joomla\Componentbuilder\Compiler\Builder\ItemsMethodListString;
use VDM\Joomla\Componentbuilder\Compiler\Builder\JsonItemArray;
use VDM\Joomla\Componentbuilder\Compiler\Builder\ItemsMethodEximportString;
use VDM\Joomla\Componentbuilder\Compiler\Builder\SelectionTranslation;
use VDM\Joomla\Componentbuilder\Compiler\Builder\AdminFilterType;
use VDM\Joomla\Componentbuilder\Compiler\Builder\Sort;
use VDM\Joomla\Componentbuilder\Compiler\Builder\Search;
use VDM\Joomla\Componentbuilder\Compiler\Builder\Filter;
use VDM\Joomla\Componentbuilder\Compiler\Builder\ComponentFields;
use VDM\Joomla\Utilities\String\FieldHelper;
use VDM\Joomla\Utilities\StringHelper;
use VDM\Joomla\Utilities\GetHelper;
use VDM\Joomla\Utilities\ArrayHelper;
/**
* Compiler Creator Builders
*
* @since 3.2.0
*/
final class Builders
{
/**
* The Config Class.
*
* @var Config
* @since 3.2.0
*/
protected Config $config;
/**
* The Power Class.
*
* @var Power
* @since 3.2.0
*/
protected Power $power;
/**
* The Language Class.
*
* @var Language
* @since 3.2.0
*/
protected Language $language;
/**
* The Placeholder Class.
*
* @var Placeholder
* @since 3.2.0
*/
protected Placeholder $placeholder;
/**
* The Layout Class.
*
* @var Layout
* @since 3.2.0
*/
protected Layout $layout;
/**
* The SiteFieldData Class.
*
* @var SiteFieldData
* @since 3.2.0
*/
protected SiteFieldData $sitefielddata;
/**
* The Tags Class.
*
* @var Tags
* @since 3.2.0
*/
protected Tags $tags;
/**
* The DatabaseTables Class.
*
* @var DatabaseTables
* @since 3.2.0
*/
protected DatabaseTables $databasetables;
/**
* The DatabaseUniqueKeys Class.
*
* @var DatabaseUniqueKeys
* @since 3.2.0
*/
protected DatabaseUniqueKeys $databaseuniquekeys;
/**
* The DatabaseKeys Class.
*
* @var DatabaseKeys
* @since 3.2.0
*/
protected DatabaseKeys $databasekeys;
/**
* The DatabaseUniqueGuid Class.
*
* @var DatabaseUniqueGuid
* @since 3.2.0
*/
protected DatabaseUniqueGuid $databaseuniqueguid;
/**
* The ListJoin Class.
*
* @var ListJoin
* @since 3.2.0
*/
protected ListJoin $listjoin;
/**
* The History Class.
*
* @var History
* @since 3.2.0
*/
protected History $history;
/**
* The Alias Class.
*
* @var Alias
* @since 3.2.0
*/
protected Alias $alias;
/**
* The Title Class.
*
* @var Title
* @since 3.2.0
*/
protected Title $title;
/**
* The CategoryOtherName Class.
*
* @var CategoryOtherName
* @since 3.2.0
*/
protected CategoryOtherName $categoryothername;
/**
* The Lists Class.
*
* @var Lists
* @since 3.2.0
*/
protected Lists $lists;
/**
* The CustomList Class.
*
* @var CustomList
* @since 3.2.0
*/
protected CustomList $customlist;
/**
* The FieldRelations Class.
*
* @var FieldRelations
* @since 3.2.0
*/
protected FieldRelations $fieldrelations;
/**
* The HiddenFields Class.
*
* @var HiddenFields
* @since 3.2.0
*/
protected HiddenFields $hiddenfields;
/**
* The IntegerFields Class.
*
* @var IntegerFields
* @since 3.2.0
*/
protected IntegerFields $integerfields;
/**
* The DynamicFields Class.
*
* @var DynamicFields
* @since 3.2.0
*/
protected DynamicFields $dynamicfields;
/**
* The MainTextField Class.
*
* @var MainTextField
* @since 3.2.0
*/
protected MainTextField $maintextfield;
/**
* The CustomField Class.
*
* @var CustomField
* @since 3.2.0
*/
protected CustomField $customfield;
/**
* The CustomFieldLinks Class.
*
* @var CustomFieldLinks
* @since 3.2.0
*/
protected CustomFieldLinks $customfieldlinks;
/**
* The ScriptUserSwitch Class.
*
* @var ScriptUserSwitch
* @since 3.2.0
*/
protected ScriptUserSwitch $scriptuserswitch;
/**
* The ScriptMediaSwitch Class.
*
* @var ScriptMediaSwitch
* @since 3.2.0
*/
protected ScriptMediaSwitch $scriptmediaswitch;
/**
* The Category Class.
*
* @var Category
* @since 3.2.0
*/
protected Category $category;
/**
* The CategoryCode Class.
*
* @var CategoryCode
* @since 3.2.0
*/
protected CategoryCode $categorycode;
/**
* The CheckBox Class.
*
* @var CheckBox
* @since 3.2.0
*/
protected CheckBox $checkbox;
/**
* The JsonString Class.
*
* @var JsonString
* @since 3.2.0
*/
protected JsonString $jsonstring;
/**
* The BaseSixFour Class.
*
* @var BaseSixFour
* @since 3.2.0
*/
protected BaseSixFour $basesixfour;
/**
* The ModelBasicField Class.
*
* @var ModelBasicField
* @since 3.2.0
*/
protected ModelBasicField $modelbasicfield;
/**
* The ModelWhmcsField Class.
*
* @var ModelWhmcsField
* @since 3.2.0
*/
protected ModelWhmcsField $modelwhmcsfield;
/**
* The ModelMediumField Class.
*
* @var ModelMediumField
* @since 3.2.0
*/
protected ModelMediumField $modelmediumfield;
/**
* The ModelExpertFieldInitiator Class.
*
* @var ModelExpertFieldInitiator
* @since 3.2.0
*/
protected ModelExpertFieldInitiator $modelexpertfieldinitiator;
/**
* The ModelExpertField Class.
*
* @var ModelExpertField
* @since 3.2.0
*/
protected ModelExpertField $modelexpertfield;
/**
* The JsonItem Class.
*
* @var JsonItem
* @since 3.2.0
*/
protected JsonItem $jsonitem;
/**
* The ItemsMethodListString Class.
*
* @var ItemsMethodListString
* @since 3.2.0
*/
protected ItemsMethodListString $itemsmethodliststring;
/**
* The JsonItemArray Class.
*
* @var JsonItemArray
* @since 3.2.0
*/
protected JsonItemArray $jsonitemarray;
/**
* The ItemsMethodEximportString Class.
*
* @var ItemsMethodEximportString
* @since 3.2.0
*/
protected ItemsMethodEximportString $itemsmethodeximportstring;
/**
* The SelectionTranslation Class.
*
* @var SelectionTranslation
* @since 3.2.0
*/
protected SelectionTranslation $selectiontranslation;
/**
* The AdminFilterType Class.
*
* @var AdminFilterType
* @since 3.2.0
*/
protected AdminFilterType $adminfiltertype;
/**
* The Sort Class.
*
* @var Sort
* @since 3.2.0
*/
protected Sort $sort;
/**
* The Search Class.
*
* @var Search
* @since 3.2.0
*/
protected Search $search;
/**
* The Filter Class.
*
* @var Filter
* @since 3.2.0
*/
protected Filter $filter;
/**
* The ComponentFields Class.
*
* @var ComponentFields
* @since 3.2.0
*/
protected ComponentFields $componentfields;
/**
* Application object.
*
* @var CMSApplication
* @since 3.2.0
**/
protected CMSApplication $app;
/**
* 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.
* @param SiteFieldData $sitefielddata The
SiteFieldData Class.
* @param Tags $tags The
Tags Class.
* @param DatabaseTables $databasetables The
DatabaseTables Class.
* @param DatabaseUniqueKeys $databaseuniquekeys The
DatabaseUniqueKeys Class.
* @param DatabaseKeys $databasekeys The
DatabaseKeys Class.
* @param DatabaseUniqueGuid $databaseuniqueguid The
DatabaseUniqueGuid Class.
* @param ListJoin $listjoin The
ListJoin Class.
* @param History $history The
History Class.
* @param Alias $alias The
Alias Class.
* @param Title $title The
Title Class.
* @param CategoryOtherName $categoryothername The
CategoryOtherName Class.
* @param Lists $lists The
Lists Class.
* @param CustomList $customlist The
CustomList Class.
* @param FieldRelations $fieldrelations The
FieldRelations Class.
* @param HiddenFields $hiddenfields The
HiddenFields Class.
* @param IntegerFields $integerfields The
IntegerFields Class.
* @param DynamicFields $dynamicfields The
DynamicFields Class.
* @param MainTextField $maintextfield The
MainTextField Class.
* @param CustomField $customfield The
CustomField Class.
* @param CustomFieldLinks $customfieldlinks The
CustomFieldLinks Class.
* @param ScriptUserSwitch $scriptuserswitch The
ScriptUserSwitch Class.
* @param ScriptMediaSwitch $scriptmediaswitch The
ScriptMediaSwitch Class.
* @param Category $category The
Category Class.
* @param CategoryCode $categorycode The
CategoryCode Class.
* @param CheckBox $checkbox The
CheckBox Class.
* @param JsonString $jsonstring The
JsonString Class.
* @param BaseSixFour $basesixfour The
BaseSixFour Class.
* @param ModelBasicField $modelbasicfield The
ModelBasicField Class.
* @param ModelWhmcsField $modelwhmcsfield The
ModelWhmcsField Class.
* @param ModelMediumField $modelmediumfield The
ModelMediumField Class.
* @param ModelExpertFieldInitiator $modelexpertfieldinitiator The
ModelExpertFieldInitiator Class.
* @param ModelExpertField $modelexpertfield The
ModelExpertField Class.
* @param JsonItem $jsonitem The
JsonItem Class.
* @param ItemsMethodListString $itemsmethodliststring The
ItemsMethodListString Class.
* @param JsonItemArray $jsonitemarray The
JsonItemArray Class.
* @param ItemsMethodEximportString $itemsmethodeximportstring The
ItemsMethodEximportString Class.
* @param SelectionTranslation $selectiontranslation The
SelectionTranslation Class.
* @param AdminFilterType $adminfiltertype The
AdminFilterType Class.
* @param Sort $sort The
Sort Class.
* @param Search $search The
Search Class.
* @param Filter $filter The
Filter Class.
* @param ComponentFields $componentfields The
ComponentFields Class.
* @param CMSApplication|null $app The app
object.
*
* @since 3.2.0
*/
public function __construct(Config $config, Power $power, Language
$language,
Placeholder $placeholder, Layout $layout,
SiteFieldData $sitefielddata, Tags $tags,
DatabaseTables $databasetables,
DatabaseUniqueKeys $databaseuniquekeys,
DatabaseKeys $databasekeys,
DatabaseUniqueGuid $databaseuniqueguid,
ListJoin $listjoin, History $history, Alias $alias,
Title $title, CategoryOtherName $categoryothername,
Lists $lists, CustomList $customlist,
FieldRelations $fieldrelations,
HiddenFields $hiddenfields, IntegerFields $integerfields,
DynamicFields $dynamicfields,
MainTextField $maintextfield, CustomField $customfield,
CustomFieldLinks $customfieldlinks,
ScriptUserSwitch $scriptuserswitch,
ScriptMediaSwitch $scriptmediaswitch, Category $category,
CategoryCode $categorycode, CheckBox $checkbox,
JsonString $jsonstring, BaseSixFour $basesixfour,
ModelBasicField $modelbasicfield,
ModelWhmcsField $modelwhmcsfield,
ModelMediumField $modelmediumfield,
ModelExpertFieldInitiator $modelexpertfieldinitiator,
ModelExpertField $modelexpertfield, JsonItem $jsonitem,
ItemsMethodListString $itemsmethodliststring,
JsonItemArray $jsonitemarray,
ItemsMethodEximportString $itemsmethodeximportstring,
SelectionTranslation $selectiontranslation,
AdminFilterType $adminfiltertype, Sort $sort,
Search $search, Filter $filter,
ComponentFields $componentfields, ?CMSApplication $app = null)
{
$this->config = $config;
$this->power = $power;
$this->language = $language;
$this->placeholder = $placeholder;
$this->layout = $layout;
$this->sitefielddata = $sitefielddata;
$this->tags = $tags;
$this->databasetables = $databasetables;
$this->databaseuniquekeys = $databaseuniquekeys;
$this->databasekeys = $databasekeys;
$this->databaseuniqueguid = $databaseuniqueguid;
$this->listjoin = $listjoin;
$this->history = $history;
$this->alias = $alias;
$this->title = $title;
$this->categoryothername = $categoryothername;
$this->lists = $lists;
$this->customlist = $customlist;
$this->fieldrelations = $fieldrelations;
$this->hiddenfields = $hiddenfields;
$this->integerfields = $integerfields;
$this->dynamicfields = $dynamicfields;
$this->maintextfield = $maintextfield;
$this->customfield = $customfield;
$this->customfieldlinks = $customfieldlinks;
$this->scriptuserswitch = $scriptuserswitch;
$this->scriptmediaswitch = $scriptmediaswitch;
$this->category = $category;
$this->categorycode = $categorycode;
$this->checkbox = $checkbox;
$this->jsonstring = $jsonstring;
$this->basesixfour = $basesixfour;
$this->modelbasicfield = $modelbasicfield;
$this->modelwhmcsfield = $modelwhmcsfield;
$this->modelmediumfield = $modelmediumfield;
$this->modelexpertfieldinitiator = $modelexpertfieldinitiator;
$this->modelexpertfield = $modelexpertfield;
$this->jsonitem = $jsonitem;
$this->itemsmethodliststring = $itemsmethodliststring;
$this->jsonitemarray = $jsonitemarray;
$this->itemsmethodeximportstring = $itemsmethodeximportstring;
$this->selectiontranslation = $selectiontranslation;
$this->adminfiltertype = $adminfiltertype;
$this->sort = $sort;
$this->search = $search;
$this->filter = $filter;
$this->componentfields = $componentfields;
$this->app = $app ?: Factory::getApplication();
}
/**
* set Builders
*
* @param string $langLabel The language string for field
label
* @param string $langView The language string of the view
* @param string $nameSingleCode The single view name
* @param string $nameListCode The list view name
* @param string $name The field name
* @param array $view The view data
* @param array $field The field data
* @param string $typeName The field type
* @param bool $multiple The switch to set multiple
selection option
* @param array|null $custom The custom field switch
* @param array|null $options The options switch
*
* @return void
* @since 3.2.0
*/
public function set(string $langLabel, string $langView, string
$nameSingleCode,
string $nameListCode, string $name, array $view, array $field,
string $typeName, bool $multiple, ?array $custom = null,
?array $options = null): void
{
// check if this is a tag field
if ($typeName === 'tag')
{
// set tags for this view but don't load to DB
$this->tags->set($nameSingleCode, true);
}
// dbSwitch
$dbSwitch = true;
if (isset($field['list']) && $field['list']
== 2)
{
// do not add this field to the database
$dbSwitch = false;
}
elseif (isset($field['settings']->datatype))
{
// insure default not none if number type
$numberKeys = array('INT', 'TINYINT',
'BIGINT', 'FLOAT', 'DECIMAL',
'DOUBLE');
// don't use these as index or uniqe keys
$textKeys = array('TEXT', 'TINYTEXT',
'MEDIUMTEXT', 'LONGTEXT',
'BLOB', 'TINYBLOB', 'MEDIUMBLOB',
'LONGBLOB');
// build the query values
$this->databasetables->set($nameSingleCode . '.' . $name
. '.type',
$field['settings']->datatype);
// check if this is a number
if (in_array($field['settings']->datatype, $numberKeys))
{
if ($field['settings']->datadefault ===
'Other')
{
// setup the checking
$number_check = $field['settings']->datadefault_other;
// Decimals in SQL needs some help
if ('DECIMAL' === $field['settings']->datatype
&& !is_numeric($number_check))
{
$number_check = str_replace(
',', '.', (string)
$field['settings']->datadefault_other
);
}
// check if we have a valid number value
if (!is_numeric($number_check))
{
$field['settings']->datadefault_other = '0';
}
}
elseif (!is_numeric($field['settings']->datadefault))
{
$field['settings']->datadefault = '0';
}
}
// check if this is not text
if (!in_array($field['settings']->datatype, $textKeys))
{
$this->databasetables->set($nameSingleCode . '.' .
$name . '.lenght',
$field['settings']->datalenght);
$this->databasetables->set($nameSingleCode . '.' .
$name . '.lenght_other',
$field['settings']->datalenght_other);
$this->databasetables->set($nameSingleCode . '.' .
$name . '.default',
$field['settings']->datadefault);
$this->databasetables->set($nameSingleCode . '.' .
$name . '.other',
$field['settings']->datadefault_other);
}
// fall back unto EMPTY for text
else
{
$this->databasetables->set($nameSingleCode . '.' .
$name . '.default',
'EMPTY');
}
// to identify the field
$this->databasetables->set($nameSingleCode . '.' . $name
. '.ID',
$field['settings']->id);
$this->databasetables->set($nameSingleCode . '.' . $name
. '.null_switch',
$field['settings']->null_switch);
// set index types
$_guid = true;
$databaseuniquekey = false;
$databasekey = false;
if ($field['settings']->indexes == 1
&& !in_array(
$field['settings']->datatype, $textKeys
))
{
// build unique keys of this view for db
$this->databaseuniquekeys->add($nameSingleCode, $name, true);
$databaseuniquekey = true;
// prevent guid from being added twice
if ('guid' === $name)
{
$_guid = false;
}
}
elseif (($field['settings']->indexes == 2
|| (isset($field['alias'])
&& $field['alias'])
|| (isset($field['title']) &&
$field['title'])
|| $typeName === 'category')
&& !in_array($field['settings']->datatype,
$textKeys))
{
// build keys of this view for db
$this->databasekeys->add($nameSingleCode, $name, true);
$databasekey = true;
}
// special treatment for GUID
if ('guid' === $name && $_guid)
{
$this->databaseuniqueguid->set($nameSingleCode, true);
}
}
// set list switch
$listSwitch = (isset($field['list'])
&& ($field['list'] == 1
|| $field['list'] == 3
|| $field['list'] == 4));
// set list join
$listJoin
= $this->listjoin->exists($nameListCode . '.' . (int)
$field['field']);
// add history to this view
if (isset($view['history']) &&
$view['history'])
{
$this->history->set($nameSingleCode, true);
}
// set Alias (only one title per view)
if ($dbSwitch && isset($field['alias']) &&
$field['alias']
&& !$this->alias->get($nameSingleCode))
{
$this->alias->set($nameSingleCode, $name);
}
// set Titles (only one title per view)
if ($dbSwitch && isset($field['title']) &&
$field['title']
&& !$this->title->get($nameSingleCode))
{
$this->title->set($nameSingleCode, $name);
}
// category name fix
if ($typeName === 'category')
{
$tempName = $this->categoryothername->
get($nameListCode . '.name', $nameListCode . '
categories');
// set lang
$listLangName = $langView . '_'
. FieldHelper::safe($tempName, true);
// set field name
$listFieldName = StringHelper::safe($tempName, 'W');
// add to lang array
$this->language->set(
$this->config->lang_target, $listLangName, $listFieldName
);
}
else
{
// if label was set use instead
if (StringHelper::check($langLabel))
{
$listLangName = $langLabel;
// get field label from the lang label
if ($this->language->exist($this->config->lang_target,
$langLabel))
{
$listFieldName
= $this->language->get($this->config->lang_target,
$langLabel);
}
else
{
// get it from the field xml string
$listFieldName = (string) $this->placeholder->update_(
GetHelper::between(
$field['settings']->xml, 'label="',
'"'
)
);
}
// make sure there is no html in the list field name
$listFieldName = strip_tags($listFieldName);
}
else
{
// set lang (just in case)
$listLangName = $langView . '_'
. FieldHelper::safe($name, true);
// set field name
$listFieldName = StringHelper::safe($name, 'W');
// add to lang array
$this->language->set(
$this->config->lang_target, $listLangName, $listFieldName
);
}
}
// extends value
$extends_field = $custom['extends'] ?? '';
// build the list values
if (($listSwitch || $listJoin) && $typeName !=
'repeatable'
&& $typeName != 'subform')
{
// load to list builder
if ($listSwitch)
{
// append values
$this->lists->add($nameListCode, [
'id' => (int) $field['field'],
'type' => $typeName,
'code' => $name,
'lang' => $listLangName,
'title' => (isset($field['title'])
&& $field['title'])
? true : false,
'alias' => (isset($field['alias'])
&& $field['alias'])
? true : false,
'link' => (isset($field['link']) &&
$field['link'])
? true : false,
'sort' => (isset($field['sort']) &&
$field['sort'])
? true : false,
'custom' => $custom,
'multiple' => $multiple,
'options' => $options,
'target' => (int) $field['list']
], true);
}
// build custom builder list
if ($listSwitch || $listJoin)
{
$this->customlist->set($nameSingleCode . '.' . $name,
true);
}
}
// load the list join builder
if ($listJoin)
{
$this->listjoin->set($nameListCode . '.' . (int)
$field['field'], [
'type' => $typeName,
'code' => $name,
'lang' => $listLangName,
'title' => (isset($field['title']) &&
$field['title']) ? true
: false,
'alias' => (isset($field['alias']) &&
$field['alias']) ? true
: false,
'link' => (isset($field['link']) &&
$field['link']) ? true
: false,
'sort' => (isset($field['sort']) &&
$field['sort']) ? true
: false,
'custom' => $custom,
'multiple' => $multiple,
'options' => $options
]);
}
// update the field relations
if (($field_relations =
$this->fieldrelations->get($nameListCode . '.' . (int)
$field['field'])) !== null)
{
$field_relations = (array) $field_relations;
foreach ($field_relations as $area => &$field_values)
{
$field_values['type'] = $typeName;
$field_values['code'] = $name;
$field_values['custom'] = $custom;
}
$this->fieldrelations->set($nameListCode . '.' . (int)
$field['field'], $field_relations);
}
// set the hidden field of this view
if ($dbSwitch && $typeName === 'hidden')
{
$this->hiddenfields->add($nameSingleCode, ',"' .
$name . '"', true);
}
// set all int fields of this view
if ($dbSwitch &&
isset($field['settings']->datatype)
&& ($field['settings']->datatype ===
'INT'
|| $field['settings']->datatype === 'TINYINT'
|| $field['settings']->datatype === 'BIGINT'))
{
$this->integerfields->add($nameSingleCode, ',"' .
$name . '"', true);
}
// Get the default fields
$default_fields = $this->config->default_fields;
// set all dynamic field of this view
if ($dbSwitch && $typeName != 'category' &&
$typeName != 'repeatable'
&& $typeName != 'subform' && !in_array($name,
$default_fields))
{
$this->dynamicfields->add($nameSingleCode, '"' .
$name . '":"' . $name . '"', true);
}
// TODO we may need to add a switch instead (since now it uses the first
editor field)
// set the main(biggest) text field of this view
if ($dbSwitch && $typeName === 'editor')
{
if (!$this->maintextfield->exists($nameSingleCode))
{
$this->maintextfield->set($nameSingleCode, $name);
}
}
// set the custom builder
if (ArrayHelper::check($custom)
&& $typeName != 'category'
&& $typeName != 'repeatable'
&& $typeName != 'subform')
{
$this->customfield->add($nameListCode, [
'type' => $typeName,
'code' => $name,
'lang' => $listLangName,
'custom' => $custom,
'method' => $field['settings']->store
], true);
// only load this if table is set
if (isset($custom['table'])
&& StringHelper::check(
$custom['table']
))
{
// set the custom fields needed in content type data
$this->customfieldlinks->add(
$nameSingleCode,
',{"sourceColumn": "' . $name .
'","targetTable": "' .
$custom['table']
. '","targetColumn": "' .
$custom['id'] . '","displayColumn":
"' . $custom['text'] . '"}',
true
);
}
// build script switch for user
if ($extends_field === 'user')
{
$this->scriptuserswitch->set($typeName, $typeName);
}
}
if ($typeName === 'media')
{
$this->scriptmediaswitch->set($typeName, $typeName);
}
// setup category for this view
if ($dbSwitch && $typeName === 'category')
{
$otherViews = $this->categoryothername->
get($nameListCode . '.views', $nameListCode);
$otherView = $this->categoryothername->
get($nameListCode . '.view', $nameSingleCode);
// get the xml extension name
$_extension = $this->placeholder->update_(
GetHelper::between(
$field['settings']->xml, 'extension="',
'"'
)
);
// if they left out the extension for some reason
if (!StringHelper::check($_extension))
{
$_extension = 'com_' .
$this->config->component_code_name . '.'
. $otherView;
}
// check the context (does our target match)
if (strpos((string) $_extension, '.') !== false)
{
$target_view = trim(explode('.', (string) $_extension)[1]);
// from my understanding the target extension view and the otherView
must align
// so I will here check that it does, and if not raise an error message
to fix this
if ($target_view !== $otherView)
{
$target_extension = trim(explode('.', (string)
$_extension)[0]);
$correction = $target_extension . '.' . $otherView;
$this->app->enqueueMessage(
Text::sprintf(
'<hr /><h3>Category targeting view
mismatch</h3>
<p>The <a
href="index.php?option=com_componentbuilder&view=fields&task=field.edit&id=%s"
target="_blank" title="open field">
category field</a> in <b>(%s) admin view</b> has
a mismatching target view.
<br />To correct the mismatch, the
<b>extension</b> value <code>%s</code> in the <a
href="index.php?option=com_componentbuilder&view=fields&task=field.edit&id=%s"
target="_blank" title="open category field">
field</a> must be changed to <code>%s</code>
for <a
href="https://github.com/vdm-io/Joomla-Component-Builder/issues/561"
target="_blank" title="view issue on gitHub">
best category integration with Joomla</a>.
<br /><b>Please watch <a
href="https://youtu.be/R4WQgcu6Xns" target="_blank"
title="very important info on the topic">
this tutorial</a> before proceeding!!!</b>,
<a
href="https://gist.github.com/Llewellynvdm/e053dc39ae3b2bf769c76a3e62c75b95"
target="_blank" title="first watch the tutorial to
understand how to use this code">code
fix</a></p>',
$field['field'], $nameSingleCode, $_extension,
$field['field'], $correction
), 'Error'
);
}
}
// load the category builder - TODO must move all to single view
$this->category->set($nameListCode, [
'code' => $name,
'name' => $listLangName,
'extension' => $_extension,
'filter' => $field['filter'],
'add_icon' =>
StringHelper::check($view['settings']->icon_category)
]);
// also set code name for title alias fix
$this->categorycode->set($nameSingleCode, [
'code' => $name,
'views' => $otherViews,
'view' => $otherView
]);
}
// setup checkbox for this view
if ($dbSwitch && ($typeName === 'checkbox' ||
(ArrayHelper::check($custom) && $extends_field ===
'checkboxes')))
{
$this->checkbox->add($nameSingleCode, $name, true);
}
// setup checkboxes and other json items for this view
// if we have advance field modeling and the field is not being set in
the DB
// this could mean that field is modeled manually (so we add it)
if (($dbSwitch || $field['settings']->store == 6)
&& (($typeName === 'subform' || $typeName ===
'checkboxes'
|| $multiple
|| $field['settings']->store != 0)
&& $typeName != 'tag'))
{
$subformJsonSwitch = true;
switch ($field['settings']->store)
{
case 1:
// JSON_STRING_ENCODE
$this->jsonstring->add($nameSingleCode, $name, true);
// Site settings of each field if needed
$this->sitefielddata->set(
$nameSingleCode, $name, 'json', $typeName
);
// add open close method to field data
$field['store'] = 'json';
break;
case 2:
// BASE_SIXTY_FOUR
$this->basesixfour->add($nameSingleCode, $name, true);
// Site settings of each field if needed
$this->sitefielddata->set(
$nameSingleCode, $name, 'base64', $typeName
);
// add open close method to field data
$field['store'] = 'base64';
break;
case 3:
// BASIC_ENCRYPTION_LOCALKEY
$this->modelbasicfield->add($nameSingleCode, $name, true);
// Site settings of each field if needed
$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;
case 4:
// WHMCS_ENCRYPTION_VDMKEY (DUE REMOVAL)
$this->modelwhmcsfield->add($nameSingleCode, $name, true);
// Site settings of each field if needed
$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;
case 5:
// MEDIUM_ENCRYPTION_LOCALFILE
$this->modelmediumfield->add($nameSingleCode, $name, true);
// Site settings of each field if needed
$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;
case 6:
// EXPERT_MODE
if (isset($field['settings']->model_field))
{
if (isset($field['settings']->initiator_save_key))
{
$this->modelexpertfieldinitiator->set(
$nameSingleCode . '.save.' .
$field['settings']->initiator_save_key
, $field['settings']->initiator_save
);
}
if (isset($field['settings']->initiator_get_key))
{
$this->modelexpertfieldinitiator->set(
$nameSingleCode . '.get.' .
$field['settings']->initiator_get_key
, $field['settings']->initiator_get
);
}
$this->modelexpertfield->set(
$nameSingleCode . '.' . $name,
$field['settings']->model_field
);
// Site settings of each field if needed
$this->sitefielddata->set(
$nameSingleCode, $name, 'expert_mode', $typeName
);
}
break;
default:
// JSON_ARRAY_ENCODE
$this->jsonitem->add($nameSingleCode, $name, true);
// Site settings of each field if needed
$this->sitefielddata->set(
$nameSingleCode, $name, 'json', $typeName
);
// no londer add the json again (already added)
$subformJsonSwitch = false;
// add open close method to field data
$field['store'] = 'json';
break;
}
// just a heads-up for usergroups set to multiple
if ($typeName === 'usergroup' || $typeName ===
'usergrouplist')
{
$this->sitefielddata->set(
$nameSingleCode, $name, 'json', $typeName
);
}
// load the model list display fix
if (($listSwitch || $listJoin)
&& (($typeName != 'repeatable' && $typeName
!= 'subform') || $field['settings']->store == 6))
{
$this->itemsmethodliststring->add($nameSingleCode, [
'name' => $name,
'type' => $typeName,
'translation' => (bool) ArrayHelper::check($options),
'custom' => $custom,
'method' => $field['settings']->store
], true);
}
// subform housekeeping (only if not advance modeling)
if ('subform' === $typeName &&
$field['settings']->store != 6)
{
// the values must revert to array
$this->jsonitemarray->add($nameSingleCode, $name, true);
// should the json builder still be added
if ($subformJsonSwitch)
{
// and insure the if is converted to json
$this->jsonitem->add($nameSingleCode, $name, true);
// Site settings of each field if needed
$this->sitefielddata->set(
$nameSingleCode, $name, 'json', $typeName
);
}
}
}
// build the data for the export & import methods $typeName ===
'repeatable' ||
if ($dbSwitch && (($typeName === 'checkboxes' ||
$multiple || $field['settings']->store != 0)
&& !ArrayHelper::check($options)))
{
$this->itemsmethodeximportstring->add($nameSingleCode, [
'name' => $name,
'type' => $typeName,
'translation' => false,
'custom' => $custom,
'method' => $field['settings']->store
], true);
}
// check if field should be added to uikit
$this->sitefielddata->set($nameSingleCode, $name,
'uikit', $typeName);
// load the selection translation fix
if (ArrayHelper::check($options) && ($listSwitch || $listJoin)
&& $typeName != 'repeatable' && $typeName !=
'subform')
{
$this->selectiontranslation->set($nameListCode . '.' .
$name, $options);
}
// main lang filter prefix
$lang_filter_ = $this->config->lang_prefix . '_FILTER_';
// build the sort values
if ($dbSwitch && (isset($field['sort']) &&
$field['sort'] == 1)
&& ($listSwitch || $listJoin)
&& (!$multiple && $typeName != 'checkbox'
&& $typeName != 'checkboxes'
&& $typeName != 'repeatable' && $typeName !=
'subform'))
{
// add the language only for new filter option
$filter_name_asc_lang = '';
$filter_name_desc_lang = '';
if ($this->adminfiltertype->get($nameListCode, 1) == 2)
{
// set the language strings for ascending
$filter_name_asc = $listFieldName . ' ascending';
$filter_name_asc_lang = $lang_filter_
. StringHelper::safe(
$filter_name_asc, 'U'
);
// and to translation
$this->language->set(
$this->config->lang_target, $filter_name_asc_lang,
$filter_name_asc
);
// set the language strings for descending
$filter_name_desc = $listFieldName . ' descending';
$filter_name_desc_lang = $lang_filter_
. StringHelper::safe(
$filter_name_desc, 'U'
);
// and to translation
$this->language->set(
$this->config->lang_target, $filter_name_desc_lang,
$filter_name_desc
);
}
$this->sort->add($nameListCode, [
'type' => $typeName,
'code' => $name,
'lang' => $listLangName,
'lang_asc' => $filter_name_asc_lang,
'lang_desc' => $filter_name_desc_lang,
'custom' => $custom,
'options' => $options
], true);
}
// build the search values
if ($dbSwitch && isset($field['search']) &&
$field['search'] == 1)
{
$_list = (isset($field['list'])) ? $field['list'] :
0;
$this->search->add($nameListCode, [
'type' => $typeName,
'code' => $name,
'custom' => $custom,
'list' => $_list
], true);
}
// build the filter values
if ($dbSwitch && (isset($field['filter']) &&
$field['filter'] >= 1)
&& ($listSwitch || $listJoin)
&& (!$multiple && $typeName != 'checkbox'
&& $typeName != 'checkboxes'
&& $typeName != 'repeatable'
&& $typeName != 'subform'))
{
// this pains me... but to avoid collusion
$filter_type_code = StringHelper::safe(
$nameListCode . 'filter' . $name
);
$filter_type_code = preg_replace('/_+/', '',
(string) $filter_type_code);
$filter_function_name = StringHelper::safe(
$name, 'F'
);
// add the language only for new filter option
$filter_name_select_lang = '';
if ($this->adminfiltertype->get($nameListCode, 1) == 2)
{
// set the language strings for selection
$filter_name_select = 'Select ' . $listFieldName;
$filter_name_select_lang = $lang_filter_
. StringHelper::safe(
$filter_name_select, 'U'
);
// and to translation
$this->language->set(
$this->config->lang_target, $filter_name_select_lang,
$filter_name_select
);
}
// add the filter details
$this->filter->add($nameListCode, [
'id' => (int) $field['field'],
'type' => $typeName,
'multi' => $field['filter'],
'code' => $name,
'label' => $langLabel,
'lang' => $listLangName,
'lang_select' => $filter_name_select_lang,
'database' => $nameSingleCode,
'function' => $filter_function_name,
'custom' => $custom,
'options' => $options,
'filter_type' => $filter_type_code
], true);
}
// build the layout
$tabName = '';
if (isset($view['settings']->tabs)
&& isset($view['settings']->tabs[(int)
$field['tab']]))
{
$tabName = $view['settings']->tabs[(int)
$field['tab']];
}
elseif ((int) $field['tab'] == 15)
{
// set to publishing tab
$tabName = 'publishing';
}
$this->layout->set($nameSingleCode, $tabName, $name, $field);
// load all fields that are in the database
if ($dbSwitch)
{
// load array of view, field, and [encryption, type, tab]
$title_ = $this->title->get($nameSingleCode);
$this->componentfields->set($nameSingleCode . '.' .
$name,
[
'name' => $name,
'label' => $langLabel,
'type' => $typeName,
'title' => (is_string($title_) && $name ===
$title_) ? true : false,
'list' => $nameListCode,
'store' => (isset($field['store'])) ?
$field['store'] : null,
'tab_name' => $tabName,
'db' =>
$this->normalizeDatabaseValues($nameSingleCode, $name,
$databaseuniquekey, $databasekey)
]
);
}
}
/**
* Normalizes database values by adjusting the 'length' and
'default' fields based on specific conditions.
* This function modifies the database values by replacing placeholder
texts and appending specifications
* to types based on the 'length' field. It removes unnecessary
fields from the result array.
*
* @param string $nameSingleCode The code for naming single entries.
* @param string $name The name of the database entry.
* @param string $uniquekey Is this field a uniquekey
* @param string $iskey Is this field a key
*
* @return array|null Returns the modified database values array or null
if no values are found.
* @since 3.2.1
*/
private function normalizeDatabaseValues($nameSingleCode, $name,
$uniquekey, $iskey): ?array
{
$db_values = $this->databasetables->get($nameSingleCode .
'.' . $name, null);
if ($db_values === null)
{
return null;
}
if (isset($db_values['lenght']))
{
if ($db_values['lenght'] === 'Other' &&
isset($db_values['lenght_other']))
{
$db_values['lenght'] = $db_values['lenght_other'];
}
$db_values['lenght'] = trim($db_values['lenght']);
if (strlen($db_values['lenght']))
{
$db_values['type'] .= '(' .
$db_values['lenght'] . ')';
}
}
if (isset($db_values['default']))
{
if ($db_values['default'] === 'Other' &&
isset($db_values['other']))
{
$db_values['default'] = $db_values['other'];
}
}
$db_values['unique_key'] = $uniquekey;
$db_values['key'] = $iskey;
unset($db_values['ID'], $db_values['lenght'],
$db_values['lenght_other'], $db_values['other']);
return $db_values;
}
}
src/Componentbuilder/Compiler/Creator/ConfigFieldsets.php000064400000031131151162054100017570
0ustar00<?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 or object if found
if (((strpos((string) $field['custom_value'],
'["') !== false)
&& (strpos((string) $field['custom_value'],
'"]') !== false)) ||
((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]
);
}
}
src/Componentbuilder/Compiler/Creator/ConfigFieldsetsCustomfield.php000064400000007444151162054100022001
0ustar00<?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);
}
}
}
}
src/Componentbuilder/Compiler/Creator/ConfigFieldsetsEmailHelper.php000064400000132717151162054100021714
0ustar00<?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 "From:" 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 "Reply To:" 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>");
}
}
}
src/Componentbuilder/Compiler/Creator/ConfigFieldsetsEncryption.php000064400000035070151162054100021651
0ustar00<?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>");
}
}
}
src/Componentbuilder/Compiler/Creator/ConfigFieldsetsGlobal.php000064400000067630151162054100020726
0ustar00<?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>");
}
}
src/Componentbuilder/Compiler/Creator/ConfigFieldsetsGooglechart.php000064400000100503151162054100021747
0ustar00<?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"
);
}
}
}
src/Componentbuilder/Compiler/Creator/ConfigFieldsetsGroupControl.php000064400000011701151162054100022147
0ustar00<?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="usergrouplist"');
$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>");
}
}
}
src/Componentbuilder/Compiler/Creator/ConfigFieldsetsSiteControl.php000064400000014327151162054100021766
0ustar00<?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);
}
}
}
}
}
src/Componentbuilder/Compiler/Creator/ConfigFieldsetsUikit.php000064400000035344151162054100020610
0ustar00<?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>");
}
}
}
src/Componentbuilder/Compiler/Creator/CustomButtonPermissions.php000064400000007310151162054100021424
0ustar00<?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++;
}
}
}
}
src/Componentbuilder/Compiler/Creator/CustomFieldTypeFile.php000064400000072454151162054100020415
0ustar00<?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 Joomla\CMS\Factory;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Application\CMSApplication;
use VDM\Joomla\Componentbuilder\Compiler\Config;
use VDM\Joomla\Componentbuilder\Compiler\Builder\ContentOne as Content;
use VDM\Joomla\Componentbuilder\Compiler\Builder\ContentMulti as Contents;
use VDM\Joomla\Componentbuilder\Compiler\Builder\SiteFieldData as
SiteField;
use VDM\Joomla\Componentbuilder\Compiler\Placeholder;
use VDM\Joomla\Componentbuilder\Compiler\Language;
use VDM\Joomla\Componentbuilder\Compiler\Component\Placeholder as
ComponentPlaceholder;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Structure;
use
VDM\Joomla\Componentbuilder\Compiler\Interfaces\Field\InputButtonInterface
as InputButton;
use VDM\Joomla\Componentbuilder\Compiler\Builder\FieldGroupControl;
use VDM\Joomla\Componentbuilder\Compiler\Builder\ExtensionCustomFields;
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\HeaderInterface as
Header;
use
VDM\Joomla\Componentbuilder\Compiler\Interfaces\Field\CoreFieldInterface as
CoreField;
use VDM\Joomla\Utilities\ArrayHelper;
use VDM\Joomla\Utilities\StringHelper;
use VDM\Joomla\Utilities\String\ClassfunctionHelper;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Indent;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Placefix;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Line;
use VDM\Joomla\Utilities\String\FieldHelper;
/**
* Custom Field Type File Creator Class
*
* @since 3.2.0
*/
final class CustomFieldTypeFile
{
/**
* The Config Class.
*
* @var Config
* @since 3.2.0
*/
protected Config $config;
/**
* The ContentOne Class.
*
* @var Content
* @since 3.2.0
*/
protected Content $content;
/**
* The ContentMulti Class.
*
* @var Contents
* @since 3.2.0
*/
protected Contents $contents;
/**
* The SiteFieldData Class.
*
* @var SiteField
* @since 3.2.0
*/
protected SiteField $sitefield;
/**
* The Placeholder Class.
*
* @var Placeholder
* @since 3.2.0
*/
protected Placeholder $placeholder;
/**
* The Language Class.
*
* @var Language
* @since 3.2.0
*/
protected Language $language;
/**
* The Placeholder Class.
*
* @var ComponentPlaceholder
* @since 3.2.0
*/
protected ComponentPlaceholder $componentplaceholder;
/**
* The Structure Class.
*
* @var Structure
* @since 3.2.0
*/
protected Structure $structure;
/**
* The InputButton Class.
*
* @var InputButton
* @since 3.2.0
*/
protected InputButton $inputbutton;
/**
* The FieldGroupControl Class.
*
* @var FieldGroupControl
* @since 3.2.0
*/
protected FieldGroupControl $fieldgroupcontrol;
/**
* The ExtensionCustomFields Class.
*
* @var ExtensionCustomFields
* @since 3.2.0
*/
protected ExtensionCustomFields $extensioncustomfields;
/**
* The HeaderInterface Class.
*
* @var Header
* @since 3.2.0
*/
protected Header $header;
/**
* The CoreFieldInterface Class.
*
* @var CoreField
* @since 3.2.0
*/
protected CoreField $corefield;
/**
* The core field mapper.
*
* @var array
* @since 3.2.0
*/
protected array $fieldmap = [];
/**
* Application object.
*
* @var CMSApplication
* @since 3.2.0
**/
protected CMSApplication $app;
/**
* Array of php fields Allowed (15)
*
* @var array
* @since 3.2.0
**/
protected array $phpFieldArray = ['', 'a',
'b', 'c', 'd', 'e', 'f',
'g', 'h', 'i', 'j', 'k',
'l', 'm', 'n', 'x'];
/**
* The Local Placeholder Values.
*
* @var array
* @since 3.2.0
*/
protected array $placeholders = [];
/**
* The field data values.
*
* @var array
* @since 3.2.0
*/
protected array $data;
/**
* The List Code Name value.
*
* @var string
* @since 3.2.0
*/
protected string $nameListCode;
/**
* The Single Code Name value.
*
* @var string
* @since 3.2.0
*/
protected string $nameSingleCode;
/**
* The contents key value.
*
* @var string
* @since 3.2.0
*/
protected string $contentsKey;
/**
* The type field value.
*
* @var string
* @since 3.2.0
*/
protected string $type;
/**
* The base type field value.
*
* @var string
* @since 3.2.0
*/
protected string $baseType;
/**
* The raw type field value.
*
* @var string
* @since 3.2.0
*/
protected string $rawType;
/**
* The switch to check if the custom
* type field value was set.
*
* @var bool
* @since 3.2.0
*/
protected bool $customTypeWasSet;
/**
* The extends field value.
*
* @var string
* @since 3.2.0
*/
protected string $extends;
/**
* Constructor.
*
* @param Config $config The Config
Class.
* @param Content $content The ContentOne
Class.
* @param Contents $contents The
ContentMulti Class.
* @param SiteField $sitefield The
SiteFieldData Class.
* @param Placeholder $placeholder The Placeholder
Class.
* @param Language $language The Language
Class.
* @param ComponentPlaceholder $componentplaceholder The Placeholder
Class.
* @param Structure $structure The Structure
Class.
* @param InputButton $inputbutton The InputButton
Class.
* @param FieldGroupControl $fieldgroupcontrol The
FieldGroupControl Class.
* @param ExtensionCustomFields $extensioncustomfields The
ExtensionCustomFields Class.
* @param Header $header The
HeaderInterface Class.
* @param CoreField $corefield The
CoreFieldInterface Class.
* @param CMSApplication|null $app The app
object.
*
* @since 3.2.0
*/
public function __construct(Config $config, Content $content, Contents
$contents,
SiteField $sitefield, Placeholder $placeholder,
Language $language,
ComponentPlaceholder $componentplaceholder,
Structure $structure, InputButton $inputbutton,
FieldGroupControl $fieldgroupcontrol,
ExtensionCustomFields $extensioncustomfields,
Header $header, CoreField $corefield, ?CMSApplication $app = null)
{
$this->config = $config;
$this->content = $content;
$this->contents = $contents;
$this->sitefield = $sitefield;
$this->placeholder = $placeholder;
$this->language = $language;
$this->componentplaceholder = $componentplaceholder;
$this->structure = $structure;
$this->inputbutton = $inputbutton;
$this->fieldgroupcontrol = $fieldgroupcontrol;
$this->extensioncustomfields = $extensioncustomfields;
$this->header = $header;
$this->corefield = $corefield;
$this->app = $app ?: Factory::getApplication();
}
/**
* Set Custom Field Type File
*
* This method handles the setting of a custom field type. It checks if
the field has already been built,
* handles namespace in the custom field type name, sets various
placeholders, and loads the global placeholders.
* Additionally, it manages the setting of dynamic contents based on the
field type and other configurations.
*
* @param array $data The field complete data set
* @param string $nameListCode The list view code name
* @param string $nameSingleCode The single view code name
*
* @return void
* @since 3.2.0
*/
public function set(array $data, string $nameListCode, string
$nameSingleCode): void
{
$this->setTypeName($data);
if (!$this->isFieldBuildable($data))
{
return;
}
$this->init($data, $nameSingleCode, $nameListCode);
if (isset($data['custom']['own_custom']))
{
$this->handleOwnCustomField();
}
else
{
$this->handleStandardCustomField();
}
// Extension custom fields tracking for plugins or modules
$this->trackExtensionCustomFields();
}
/**
* Set the type name of the custom field.
*
* This function checks if there is a namespace in the field type name
(indicated by a dot).
* If a namespace exists, it extracts and removes the namespace from the
type name.
*
* @param array $data The field data which contains the type name.
*
* @return void
* @since 3.2.0
*/
private function setTypeName(array $data): void
{
$type_name = $this->rawType = $data['type'] ??
'';
$this->customTypeWasSet =
isset($data['custom']['type']);
// Check if the field type name contains a dot, indicating a namespace
if (strpos($type_name, '.') !== false)
{
$dot_type_array = explode('.', $type_name);
// If there are more than one parts, remove the first part (namespace)
if (count($dot_type_array) > 1)
{
array_shift($dot_type_array); // Remove the namespace part
}
// Update the type name by concatenating the remaining parts
$type_name = implode('', $dot_type_array);
$data['custom']['type'] =
ClassfunctionHelper::safe($type_name);
}
$base_type = $data['custom']['type'] ?? $type_name;
$this->baseType = ClassfunctionHelper::safe($base_type);
$this->type = ClassfunctionHelper::safe($type_name);
}
/**
* Checks if the field is eligible to be built.
*
* This method examines the 'custom' attribute of the field data
to determine if the field has
* already been built or if it is marked as 'prime'. It returns
true if the field should be built,
* and false otherwise.
*
* @param array $data The field data.
*
* @return bool True if the field is buildable, false otherwise.
* @since 3.2.0
*/
private function isFieldBuildable(array $data): bool
{
// Check if 'custom' key is set in the data.
if (!isset($data['custom']))
{
return false;
}
// Check if 'extends' key is set under 'custom'.
if (!isset($data['custom']['extends']))
{
return false;
}
// Check if the field is marked as 'prime' or if it hasn't
been built yet.
$isPrime = isset($data['custom']['prime_php'])
&& $data['custom']['prime_php'] == 1;
$notBuilt = !$this->contents->isArray('customfield_' .
$this->type);
return $isPrime || $notBuilt;
}
/**
* The function to set the class values to the current field being build.
*
* @param array $data The field complete data set
* @param string $nameListCode The list view code name
* @param string $nameSingleCode The single view code name
*
* @return void
* @since 3.2.0
*/
private function init(array $data, string $nameListCode, string
$nameSingleCode): void
{
$this->data = $data;
$this->nameListCode = $nameListCode;
$this->nameSingleCode = $nameSingleCode;
$this->contentsKey = "customfield_{$this->baseType}|";
$this->jprefix = $this->determineJPrefix();
$this->extends =
ClassfunctionHelper::safe($data['custom']['extends']);
$this->setLocalPlaceholders();
$this->setContentPlaceholders();
}
/**
* The function to set the default content placeholder.
*
* @return void
* @since 3.2.0
*/
private function setContentPlaceholders(): void
{
$contents_key = $this->contentsKey;
// Start loading the field type
$this->contents->set("{$contents_key}JPREFIX",
$this->jprefix);
$this->contents->set("{$contents_key}JFORM_extends",
$this->extends);
$this->contents->set("{$contents_key}JFORM_EXTENDS",
StringHelper::safe($this->extends, 'F')
);
// if own custom field
if (isset($this->data['custom']['own_custom']))
{
$this->contents->set("{$contents_key}FORM_EXTENDS",
$this->getClassNameExtends()
);
}
$this->contents->set("{$contents_key}type",
$this->baseType);
$this->contents->set("{$contents_key}Type",
StringHelper::safe($this->baseType, 'F')
);
}
/**
* Determines the J prefix for the field type.
*
* This method extracts the prefix from the field type name if it contains
a dot, indicating namespace usage.
* If no dot is present, it defaults to 'J'.
*
* @return string The determined J prefix.
* @since 3.2.0
*/
private function determineJPrefix(): string
{
// Default prefix
$jprefix = 'J';
// Check if the field type name contains a dot, indicating namespace
usage
if (strpos($this->rawType, '.') !== false)
{
// Explode the type by dot to get the namespace parts
$dot_type_array = explode('.', $this->rawType);
// If there are multiple parts, use the first part as the prefix
if (count($dot_type_array) > 1)
{
$jprefix = strtoupper(array_shift($dot_type_array));
}
}
return $jprefix;
}
/**
* Set placeholder options for the custom field.
*
* This method maps various data points to their corresponding
placeholders.
* It takes custom field data, view codes, and a J prefix, and prepares an
associative array
* of placeholders and their values.
*
* @return void
* @since 3.2.0
*/
private function setLocalPlaceholders(): void
{
// The data set for the custom field
$data = $this->data;
// Initialize the array for placeholder options
$placeholders = [];
// Populate the array with specific placeholder options
$placeholders[Placefix::_('JPREFIX')] = $this->jprefix;
$placeholders[Placefix::_('JFORM_extends')] =
$this->extends;
$placeholders[Placefix::_('JFORM_EXTENDS')] =
StringHelper::safe($this->extends, 'F');
// if own custom field
if (isset($data['custom']['own_custom']))
{
$placeholders[Placefix::_('FORM_EXTENDS')] =
$this->getClassNameExtends();
}
$placeholders[Placefix::_('TABLE')] =
$data['custom']['table'] ?? '';
$placeholders[Placefix::_('ID')] =
$data['custom']['id'] ?? '';
$placeholders[Placefix::_('TEXT')] =
$data['custom']['text'] ?? '';
$placeholders[Placefix::_('CODE_TEXT')] =
isset($data['code'],
$data['custom']['text']) ? $data['code'] .
'_' . $data['custom']['text'] :
'';
$placeholders[Placefix::_('CODE')] = $data['code'] ??
'';
$placeholders[Placefix::_('com_component')] =
$this->getComComponentName();
$placeholders[Placefix::_('component')] =
$this->config->component_code_name;
$placeholders[Placefix::_('Component')] =
$this->content->get('Component');
$placeholders[Placefix::_('type')] = $this->baseType;
$placeholders[Placefix::_('Type')] =
StringHelper::safe($this->baseType, 'F');
$placeholders[Placefix::_('view_type')] =
$this->getViewName() . '_' . $this->baseType;
$placeholders[Placefix::_('view')] = $this->getViewName();
$placeholders[Placefix::_('views')] =
$this->getViewsName();
// Gymnastics to help with transition to Joomla 4 and above
if ($this->config->get('joomla_version', 3) != 3)
{
$placeholders['JFactory::getUser()'] =
'Factory::getApplication()->getIdentity()';
$placeholders['\JFactory::getUser()'] =
'Factory::getApplication()->getIdentity()';
$placeholders['Factory::getUser()'] =
'Factory::getApplication()->getIdentity()';
$placeholders['JFactory::'] = 'Factory::';
$placeholders['\JFactory::'] = 'Factory::';
$placeholders['JHtml::'] = 'Html::';
$placeholders['\JHtml::'] = 'Html::';
$placeholders['JText::'] = 'Text::';
$placeholders['\JText::'] = 'Text::';
$placeholders['JComponentHelper::'] =
'ComponentHelper::';
$placeholders['\JComponentHelper::'] =
'ComponentHelper::';
}
$this->placeholders = $placeholders;
$this->updatePlaceholderValues();
$this->loadGlobalPlaceholders();
}
/**
* Gets the component name for the custom field.
*
* This method extracts the component name from the custom field data.
* If the component name is explicitly set in the custom field data,
* it returns that name after ensuring it's a safe string.
Otherwise,
* it defaults to a name constructed from the component code name in the
configuration.
*
* @return string The name of the component.
* @since 3.2.0
*/
private function getComComponentName(): string
{
// Check if the component name is explicitly set in the custom field
data
if (isset($this->data['custom']['component'])
&&
StringHelper::check($this->data['custom']['component']))
{
// Return the safe version of the component name
return
StringHelper::safe($this->data['custom']['component']);
}
// Default to a component name constructed from the component code name
in the configuration
return 'com_' . $this->config->component_code_name;
}
/**
* Determines the view name for a custom field.
*
* This method extracts the view name from the custom field data, with a
fallback
* to a provided single view code name if the view name is not explicitly
set in the data.
*
* @return string The determined view name.
* @since 3.2.0
*/
private function getViewName(): string
{
// Check if a specific view name is set in the custom field data
if (isset($this->data['custom']['view'])
&&
StringHelper::check($this->data['custom']['view']))
{
// If a specific view name is set, use it after sanitizing
return
StringHelper::safe($this->data['custom']['view']);
}
// If no specific view name is set, use the single view code name as a
fallback
return $this->nameSingleCode;
}
/**
* Gets the formatted name for the views associated with the custom
field.
*
* This method checks if a specific views name is provided in the custom
field data.
* If it is, it formats and returns this name. If not, it defaults to the
provided list view name.
*
* @return string The formatted name for the views.
* @since 3.2.0
*/
private function getViewsName(): string
{
// Check if specific views name is provided in the custom field data
if (isset($this->data['custom']['views'])
&&
StringHelper::check($this->data['custom']['views']))
{
// If yes, use the provided name after ensuring it is properly
formatted
return
StringHelper::safe($this->data['custom']['views']);
}
// If no specific name is provided, default to the provided list view
name
return $this->nameListCode;
}
/**
* Gets the class name being extended.
*
* This method is for the new namespace class name in Joomla 4 and above.
*
* @return string The class being name extended.
* @since 3.2.0
*/
private function getClassNameExtends(): string
{
if (isset($this->fieldmap[$this->extends]))
{
return $this->fieldmap[$this->extends];
}
$core_fields = $this->corefield->get();
$extends = $this->extends;
$found = null;
foreach ($core_fields as $core_field)
{
$field = strtolower((string) $core_field);
if ($extends === $field)
{
$found = $core_field;
break;
}
}
$extends = $found ?? StringHelper::safe($extends, 'F');
if ($this->config->get('joomla_version', 3) != 3)
{
$fix = strtolower($extends);
if ('checkboxes' === $fix)
{
$extends = 'CheckboxesField';
}
elseif ('list' === $fix)
{
$extends = 'FormField';
}
elseif ('radio' === $fix)
{
$extends = 'RadioField';
}
elseif ('combo' === $fix)
{
$extends = 'ComboField';
}
elseif (strpos($extends, 'Field') === false)
{
$extends = StringHelper::safe($extends, 'F') .
'Field';
}
}
$this->fieldmap[$this->extends] = $extends;
return $extends;
}
/**
* Update placeholder values in the field data.
*
* This function iterates over the given replacements and applies them to
the placeholders.
* It updates both the key and value of each placeholder, ensuring that
they are correctly set.
*
* @return void
* @since 3.2.0
*/
private function updatePlaceholderValues(): void
{
foreach ($this->placeholders as $placeholder => $value)
{
// Update the key by replacing the placeholders for before and after
$updatedPlaceholder = str_replace(
[Placefix::b(), Placefix::d()],
[Placefix::h(), Placefix::h()],
$placeholder
);
// Update the value in the replacements array
$this->placeholders[$updatedPlaceholder] = $value;
}
}
/**
* Load global placeholders into the placeholders array.
*
* This method iterates over the global placeholders and adds them to the
replace array.
*
* @return void
* @since 3.2.0
*/
private function loadGlobalPlaceholders(): void
{
foreach ($this->componentplaceholder->get() as $globalPlaceholder
=> $globalValue)
{
$this->placeholders[$globalPlaceholder] = $globalValue;
}
}
/**
* Handle the setting of a own custom field.
*
* This method manages the building of the custom field type file, the
handling of PHP scripts,
* and specific operations for certain field types like user fields.
*
* @return void
* @since 3.2.0
*/
private function handleOwnCustomField(): void
{
if ($this->isButtonOptionSet())
{
$this->setButtonOptionErrorMessages();
}
$targets = [['admin' => 'customfield'],
['site' => 'customfield']];
foreach ($targets as $target)
{
$this->structure->build($target, 'fieldcustom',
$this->baseType);
}
$this->prepareCustomFieldHeader();
$this->prepareCustomFieldBody();
}
/**
* Handle the setting of a standard custom field.
*
* This method manages the building of the custom field type file, the
handling of PHP scripts,
* and specific operations for certain field types like user fields.
*
* @return void
* @since 3.2.0
*/
private function handleStandardCustomField(): void
{
// The key used for setting contents.
$contents_key = $this->contentsKey;
// Build the custom field type file
$targets = [['admin' => 'customfield'],
['site' => 'customfield']];
foreach ($targets as $target)
{
$this->structure->build(
$target, 'field' . $this->extends, $this->baseType
);
}
$php_code = $this->loadPhpScript('php');
if ($this->extends === 'user')
{
$this->fieldgroupcontrol->set(
$this->type, $this->generateGroupLanguageName()
);
$phpx_code = $this->loadPhpScript('phpx');
$this->contents->set("{$contents_key}JFORM_GETGROUPS_PHP",
$php_code);
$this->contents->set("{$contents_key}JFORM_GETEXCLUDED_PHP",
$phpx_code);
}
else
{
$this->contents->set("{$contents_key}JFORM_GETOPTIONS_PHP",
$php_code);
}
$this->contents->set("{$contents_key}ADD_BUTTON",
$this->inputbutton->get($this->data['custom']));
}
/**
* Checks if the button option is set for the custom field.
*
* This function examines the custom field data to determine if the
'add_button' option
* is set and configured to a truthy value. It's used to manage
specific behaviors or
* display messages related to the button option in custom fields.
*
* @return bool Returns true if the button option is set and true,
otherwise false.
* @since 3.2.0
*/
private function isButtonOptionSet(): bool
{
// Check if 'own_custom' field is set and if
'add_button' option is available and truthy
if (isset($this->data['custom']['own_custom'],
$this->data['custom']['add_button']))
{
$addButton =
$this->data['custom']['add_button'];
return $addButton === 'true' || $addButton === 1;
}
return false;
}
/**
* Enqueue error messages related to the dynamic button option in custom
fields.
*
* This method adds error messages to the queue when there's an
attempt to use the dynamic button
* option in custom field types where it's not supported. It's
specifically used in the context of 'own custom'
* field types.
*
* @return void
* @since 3.2.0
*/
private function setButtonOptionErrorMessages(): void
{
$headerMessage = '<hr /><h3>' .
Text::_('COM_COMPONENTBUILDER_DYNAMIC_BUTTON_ERROR') .
'</h3>';
$detailMessage =
Text::_('COM_COMPONENTBUILDER_THE_OPTION_TO_ADD_A_DYNAMIC_BUTTON_IS_NOT_AVAILABLE_IN_BOWN_CUSTOM_FIELD_TYPESB_YOU_WILL_HAVE_TO_CUSTOM_CODE_IT');
$this->app->enqueueMessage($headerMessage, 'Error');
$this->app->enqueueMessage($detailMessage, 'Error');
}
/**
* Prepare the header for a custom field file.
*
* This method sets up the necessary imports and configurations for the
header section of a custom field.
* It handles the dynamic setting of comments and import statements based
on the field's extension name.
*
* @return void
* @since 3.2.0
*/
private function prepareCustomFieldHeader(): void
{
// The data set for the custom field
$data = $this->data['custom'];
// get the default headers
$headers = array_map(function ($h) {
return $this->placeholder->update($h, $this->placeholders);
}, explode(
PHP_EOL, $this->header->get('form.custom.field',
$this->baseType)
)
);
if (isset($data['phpHEADER']) &&
ArrayHelper::check($data['phpHEADER']))
{
// set tab and break replacements
$tab_break = array(
'\t' => Indent::_(1),
'\n' => PHP_EOL
);
foreach ($data['phpHEADER'] as $line => $code)
{
if (StringHelper::check($code))
{
$h = array_map(function ($h) {
return $this->placeholder->update($h, $this->placeholders);
}, explode(PHP_EOL, $this->placeholder->update(
$code, $tab_break
)));
$headers = array_merge($headers, $h);
}
}
}
// Remove duplicate values
$headers = array_unique($headers);
// add to the content updating engine
$this->contents->set("{$this->contentsKey}FORM_CUSTOM_FIELD_HEADER",
implode(PHP_EOL, $headers)
);
}
/**
* Prepare the body for a custom field file.
*
* This method sets up the necessary imports and configurations for the
body section of a custom field.
* It handles the dynamic setting of php code.
*
* @return void
* @since 3.2.0
*/
private function prepareCustomFieldBody(): void
{
// The own custom string value
$own_custom = $this->data['custom']['own_custom']
?? $this->baseType;
// reset the body
$body = [];
// load the other PHP options
foreach ($this->phpFieldArray as $x)
{
if (($code = $this->loadPhpScript('php' . $x, null)) !==
null)
{
$body[] = $code;
}
}
$php_body = PHP_EOL . PHP_EOL . Indent::_(1) . "//" .
Line::_(__LINE__,__CLASS__) .
" A " . $own_custom . " Field" . PHP_EOL;
$php_body .= $this->placeholder->update(
implode(PHP_EOL, $body),
$this->placeholders
);
// add to the content updating engine
$this->contents->set("{$this->contentsKey}FORM_CUSTOM_FIELD_PHP",
$php_body);
}
/**
* Load and process a PHP script for the custom field.
*
* @param string $scriptType The type of script to load
('php' or 'phpx').
* @param string|null $default The default if none is found
*
* @return string|null The processed PHP code.
* @since 3.2.0
*/
private function loadPhpScript(string $scriptType, ?string $default =
'return null;'): ?string
{
$php_code = '';
// The data set for the custom field
$data = $this->data['custom'];
if (isset($data[$scriptType]) &&
ArrayHelper::check($data[$scriptType]))
{
$tab_break = [
'\t' => Indent::_(1),
'\n' => PHP_EOL
];
foreach ($data[$scriptType] as $line => $code)
{
if (StringHelper::check($code))
{
$php_code .= $line == 1 ? $this->placeholder->update($code,
$tab_break)
: PHP_EOL . Indent::_(2) . $this->placeholder->update($code,
$tab_break);
}
}
$php_code = $this->placeholder->update($php_code,
$this->placeholders);
}
return StringHelper::check($php_code) ? $php_code : $default;
}
/**
* Generate a group language name for the custom field.
*
* @return string The generated group language name.
* @since 3.2.0
*/
private function generateGroupLanguageName(): string
{
$label = $this->data['custom']['label'] ??
'(error: label not set)';
$temp_name = $label . ' Group';
$group_lang_name = $this->config->lang_prefix . '_' .
FieldHelper::safe($temp_name, true);
$this->language->set(
$this->config->lang_target,
$group_lang_name,
StringHelper::safe($temp_name, 'W')
);
return $group_lang_name;
}
/**
* Tracks extension custom fields for plugins or modules.
*
* This method is used to track custom fields when they are utilized in
plugins or modules.
* If the field is used in a plugin or module, it records this
information, potentially to facilitate
* actions like copying the field over to other parts of the system.
*
* @return void
* @since 3.2.0
*/
private function trackExtensionCustomFields(): void
{
if ($this->isUsedInPluginOrModule() &&
$this->customTypeWasSet)
{
$this->extensioncustomfields->set($this->type,
$this->baseType);
}
}
/**
* Determines if the field is used in a plugin or module.
*
* @return bool Returns true if the field is used in a plugin or module,
false otherwise.
* @since 3.2.0
*/
private function isUsedInPluginOrModule(): bool
{
return strpos($this->nameSingleCode, 'pLuG!n') !== false ||
strpos($this->nameSingleCode, 'M0dUl3') !== false;
}
}
src/Componentbuilder/Compiler/Creator/FieldAsString.php000064400000005414151162054100017223
0ustar00<?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\Creator\FieldDynamic;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Xml;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Indent;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Line;
/**
* Get any field as a string Creator Class
*
* @since 3.2.0
*/
final class FieldAsString
{
/**
* The FieldDynamic Class.
*
* @var FieldDynamic
* @since 3.2.0
*/
protected FieldDynamic $fielddynamic;
/**
* The Xml Class.
*
* @var Xml
* @since 3.2.0
*/
protected Xml $xml;
/**
* Constructor.
*
* @param FieldDynamic $fielddynamic The FieldDynamic Class.
* @param Xml $xml The Xml Class.
*
* @since 3.2.0
*/
public function __construct(FieldDynamic $fielddynamic, Xml $xml)
{
$this->fielddynamic = $fielddynamic;
$this->xml = $xml;
}
/**
* Get field as a string (no matter the build type)
*
* @param array $field The field data
* @param array $view The view data
* @param int $viewType The view type
* @param string $langView The language string of the view
* @param string $nameSingleCode The single view name
* @param string $nameListCode The list view name
* @param array $placeholders The placeholder and replace values
* @param string $dbkey The custom table key
* @param boolean $build The switch to set the build option
*
* @return string The complete field in xml-string
* @since 3.2.0
*/
public function get(array &$field, array &$view, int $viewType,
string $langView,
string $nameSingleCode, string $nameListCode, array &$placeholders,
string &$dbkey, bool $build = false): string
{
// get field
$field_xml = $this->fielddynamic->get(
$field, $view, $viewType, $langView,
$nameSingleCode, $nameListCode,
$placeholders, $dbkey, $build
);
if (is_string($field_xml))
{
return $field_xml;
}
elseif (is_object($field_xml) && isset($field_xml->fieldXML))
{
return PHP_EOL . Indent::_(2) . "<!--"
. Line::_(__Line__, __Class__) . " "
. $field_xml->comment . ' -->' . PHP_EOL
. Indent::_(1) . $this->xml->pretty(
$field_xml->fieldXML, 'field'
);
}
return '';
}
}
src/Componentbuilder/Compiler/Creator/FieldDynamic.php000064400000020115151162054100017050
0ustar00<?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\Field\Name;
use VDM\Joomla\Componentbuilder\Compiler\Field\TypeName;
use VDM\Joomla\Componentbuilder\Compiler\Field\Attributes;
use VDM\Joomla\Componentbuilder\Compiler\Field\Groups;
use VDM\Joomla\Componentbuilder\Compiler\Builder\FieldNames;
use
VDM\Joomla\Componentbuilder\Compiler\Interfaces\Creator\Fieldtypeinterface
as Field;
use VDM\Joomla\Componentbuilder\Compiler\Creator\Builders;
use VDM\Joomla\Componentbuilder\Compiler\Creator\Layout;
use VDM\Joomla\Utilities\ObjectHelper;
use VDM\Joomla\Utilities\ArrayHelper;
use
VDM\Joomla\Componentbuilder\Compiler\Interfaces\Creator\Fielddynamicinterface;
/**
* Dynamic Field Creator Class
*
* @since 3.2.0
*/
final class FieldDynamic implements Fielddynamicinterface
{
/**
* The Name Class.
*
* @var Name
* @since 3.2.0
*/
protected Name $name;
/**
* The TypeName Class.
*
* @var TypeName
* @since 3.2.0
*/
protected TypeName $typename;
/**
* The Attributes Class.
*
* @var Attributes
* @since 3.2.0
*/
protected Attributes $attributes;
/**
* The Groups Class.
*
* @var Groups
* @since 3.2.0
*/
protected Groups $groups;
/**
* The FieldNames Class.
*
* @var FieldNames
* @since 3.2.0
*/
protected FieldNames $fieldnames;
/**
* The Fieldtypeinterface Class.
*
* @var Field
* @since 3.2.0
*/
protected Field $field;
/**
* The Builders Class.
*
* @var Builders
* @since 3.2.0
*/
protected Builders $builders;
/**
* The Layout Class.
*
* @var Layout
* @since 3.2.0
*/
protected Layout $layout;
/**
* Constructor.
*
* @param Name $name The Name Class.
* @param TypeName $typename The TypeName Class.
* @param Attributes $attributes The Attributes Class.
* @param Groups $groups The Groups Class.
* @param FieldNames $fieldnames The FieldNames Class.
* @param Field $field The Fieldtypeinterface Class.
* @param Builders $builders The Builders Class.
* @param Layout $layout The Layout Class.
*
* @since 3.2.0
*/
public function __construct(Name $name, TypeName $typename,
Attributes $attributes, Groups $groups, FieldNames $fieldnames,
Field $field, Builders $builders, Layout $layout)
{
$this->name = $name;
$this->typename = $typename;
$this->attributes = $attributes;
$this->groups = $groups;
$this->fieldnames = $fieldnames;
$this->field = $field;
$this->builders = $builders;
$this->layout = $layout;
}
/**
* Get the Dynamic field and build all it needs
*
* @param array $field The field data
* @param array $view The view data
* @param int $viewType The view type
* @param string $langView The language string of the view
* @param string $nameSingleCode The single view name
* @param string $nameListCode The list view name
* @param array $placeholders The placeholder and replace values
* @param string $dbkey The custom table key
* @param boolean $build The switch to set the build option
*
* @return mixed The complete field
* @since 3.2.0
*/
public function get(array &$field, array &$view, int
&$viewType, string &$langView, string &$nameSingleCode,
string &$nameListCode, array &$placeholders, string &$dbkey,
bool $build)
{
// set default return
$dynamicField = null;
// make sure we have settings
if (isset($field['settings'])
&& ObjectHelper::check($field['settings']))
{
// reset some values
$name = $this->name->get($field, $nameListCode);
$typeName = $this->typename->get($field);
$multiple = false;
$langLabel = '';
$fieldSet = '';
// set field attributes
$fieldAttributes = $this->attributes->set(
$field, $viewType, $name, $typeName, $multiple, $langLabel,
$langView, $nameListCode, $nameSingleCode, $placeholders
);
// check if values were set
if (ArrayHelper::check($fieldAttributes))
{
// set the array of field names
$this->fieldnames->set(
$nameSingleCode . '.' . $fieldAttributes['name'],
$fieldAttributes['name']
);
// set options as null
$optionArray = null;
if ($this->groups->check($typeName, 'option'))
{
// set options array
$optionArray = array();
// now add to the field set
$dynamicField = $this->field->get(
'option', $fieldAttributes, $name, $typeName, $langView,
$nameSingleCode, $nameListCode, $placeholders,
$optionArray
);
if ($build)
{
// set builders
$this->builders->set(
$langLabel, $langView, $nameSingleCode,
$nameListCode, $name, $view, $field, $typeName,
$multiple, null, $optionArray
);
}
}
elseif ($this->groups->check($typeName, 'spacer'))
{
if ($build)
{
// make sure spacers gets loaded to layout
$tabName = '';
if (isset($view['settings']->tabs)
&& isset($view['settings']->tabs[(int)
$field['tab']]))
{
$tabName
= $view['settings']->tabs[(int)
$field['tab']];
}
elseif ((int) $field['tab'] == 15)
{
// set to publishing tab
$tabName = 'publishing';
}
$this->layout->set(
$nameSingleCode, $tabName, $name, $field
);
}
// now add to the field set
$dynamicField = $this->field->get(
'spacer', $fieldAttributes, $name, $typeName, $langView,
$nameSingleCode, $nameListCode, $placeholders,
$optionArray
);
}
elseif ($this->groups->check($typeName, 'special'))
{
// set the repeatable field or subform field
if ($typeName === 'repeatable' || $typeName ===
'subform')
{
if ($build)
{
// set builders
$this->builders->set(
$langLabel, $langView, $nameSingleCode,
$nameListCode, $name, $view, $field,
$typeName, $multiple, null
);
}
// now add to the field set
$dynamicField = $this->field->get(
'special', $fieldAttributes, $name, $typeName,
$langView, $nameSingleCode, $nameListCode,
$placeholders, $optionArray
);
}
}
elseif (isset($fieldAttributes['custom'])
&& ArrayHelper::check($fieldAttributes['custom']))
{
// set the custom array
$custom = $fieldAttributes['custom'];
unset($fieldAttributes['custom']);
// set db key
$custom['db'] = $dbkey;
// increment the db key
$dbkey++;
if ($build)
{
// set builders
$this->builders->set(
$langLabel, $langView, $nameSingleCode,
$nameListCode, $name, $view, $field, $typeName,
$multiple, $custom
);
}
// now add to the field set
$dynamicField = $this->field->get(
'custom', $fieldAttributes, $name, $typeName, $langView,
$nameSingleCode, $nameListCode, $placeholders,
$optionArray, $custom
);
}
else
{
if ($build)
{
// set builders
$this->builders->set(
$langLabel, $langView, $nameSingleCode,
$nameListCode, $name, $view, $field, $typeName,
$multiple
);
}
// now add to the field set
$dynamicField = $this->field->get(
'plain', $fieldAttributes, $name, $typeName, $langView,
$nameSingleCode, $nameListCode, $placeholders,
$optionArray
);
}
}
}
return $dynamicField;
}
}
src/Componentbuilder/Compiler/Creator/FieldString.php000064400000106334151162054100016742
0ustar00<?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\Field;
use VDM\Joomla\Componentbuilder\Compiler\Field\Groups;
use VDM\Joomla\Componentbuilder\Compiler\Field\Name;
use VDM\Joomla\Componentbuilder\Compiler\Field\TypeName;
use VDM\Joomla\Componentbuilder\Compiler\Field\Attributes;
use VDM\Joomla\Componentbuilder\Compiler\Creator\CustomFieldTypeFile;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Counter;
use VDM\Joomla\Utilities\ArrayHelper;
use VDM\Joomla\Utilities\ObjectHelper;
use VDM\Joomla\Utilities\StringHelper;
use VDM\Joomla\Utilities\String\FieldHelper;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Indent;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Line;
use
VDM\Joomla\Componentbuilder\Compiler\Interfaces\Creator\Fieldtypeinterface;
/**
* Field String Creator Class
*
* @since 3.2.0
*/
final class FieldString implements Fieldtypeinterface
{
/**
* 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 Field Class.
*
* @var Field
* @since 3.2.0
*/
protected Field $field;
/**
* The Groups Class.
*
* @var Groups
* @since 3.2.0
*/
protected Groups $groups;
/**
* The Name Class.
*
* @var Name
* @since 3.2.0
*/
protected Name $name;
/**
* The TypeName Class.
*
* @var TypeName
* @since 3.2.0
*/
protected TypeName $typename;
/**
* The Attributes Class.
*
* @var Attributes
* @since 3.2.0
*/
protected Attributes $attributes;
/**
* The CustomFieldTypeFile Class.
*
* @var CustomFieldTypeFile
* @since 3.2.0
*/
protected CustomFieldTypeFile $customfieldtypefile;
/**
* 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 Field $field The Field Class.
* @param Groups $groups The Groups Class.
* @param Name $name The Name Class.
* @param TypeName $typename The TypeName
Class.
* @param Attributes $attributes The Attributes
Class.
* @param CustomFieldTypeFile $customfieldtypefile The
CustomFieldTypeFile Class.
* @param Counter $counter The Counter Class.
*
* @since 3.2.0
*/
public function __construct(Config $config, Language $language, Field
$field,
Groups $groups, Name $name, TypeName $typename,
Attributes $attributes,
CustomFieldTypeFile $customfieldtypefile,
Counter $counter)
{
$this->config = $config;
$this->language = $language;
$this->field = $field;
$this->groups = $groups;
$this->name = $name;
$this->typename = $typename;
$this->attributes = $attributes;
$this->customfieldtypefile = $customfieldtypefile;
$this->counter = $counter;
}
/**
* Create a field using string manipulation
*
* @param string $setType The set of fields type
* @param array $fieldAttributes The field values
* @param string $name The field name
* @param string $typeName The field type
* @param string $langView The language string of the view
* @param string $nameSingleCode The single view name
* @param string $nameListCode The list view name
* @param array $placeholders The place holder and replace
values
* @param array|null $optionArray The option bucket array used to
set the field options if needed.
* @param array|null $custom Used when field is from config
* @param string $taber The tabs to add in layout
*
* @return string The field in a string
* @since 3.2.0
*/
public function get(string $setType, array &$fieldAttributes, string
&$name,
string &$typeName, string &$langView, string
&$nameSingleCode, string &$nameListCode,
array $placeholders, ?array &$optionArray, ?array $custom = null,
string $taber = ''): string
{
// count the dynamic fields created
$this->counter->field++;
// build field set using string manipulation
$field = '';
if ($setType === 'option')
{
// now add to the field set
$field .= PHP_EOL . Indent::_(1) . $taber . Indent::_(1)
. "<!--" . Line::_(__Line__, __Class__) . " " .
ucfirst($name)
. " Field. Type: " . StringHelper::safe(
$typeName, 'F'
) . ". (joomla) -->";
$field .= PHP_EOL . Indent::_(1) . $taber . Indent::_(1)
. "<field";
$optionSet = '';
foreach ($fieldAttributes as $property => $value)
{
if ($property != 'option')
{
$field .= PHP_EOL . Indent::_(2) . $taber . Indent::_(1)
. $property . '="' . $value . '"';
}
elseif ($property === 'option')
{
$optionSet = '';
if (strtolower($typeName) === 'groupedlist'
&& strpos(
(string) $value, ','
) !== false
&& strpos((string) $value, '@@') !== false)
{
// reset the group temp arrays
$groups_ = array();
$grouped_ = array('group' => array(),
'option' => array());
$order_ = array();
// mulitpal options
$options = explode(',', (string) $value);
foreach ($options as $option)
{
if (strpos($option, '@@') !== false)
{
// set the group label
$valueKeyArray = explode('@@', $option);
if (count((array) $valueKeyArray) == 2)
{
$langValue = $langView . '_'
. FieldHelper::safe(
$valueKeyArray[0], true
);
// add to lang array
$this->language->set(
$this->config->lang_target, $langValue,
$valueKeyArray[0]
);
// now add group label
$groups_[$valueKeyArray[1]] = PHP_EOL
. Indent::_(1) . $taber . Indent::_(2)
. '<group label="' . $langValue .
'">';
// set order
$order_['group' . $valueKeyArray[1]]
= $valueKeyArray[1];
}
}
elseif (strpos($option, '|') !== false)
{
// has other value then text
$valueKeyArray = explode('|', $option);
if (count((array) $valueKeyArray) == 3)
{
$langValue = $langView . '_'
. FieldHelper::safe(
$valueKeyArray[1], true
);
// add to lang array
$this->language->set(
$this->config->lang_target, $langValue,
$valueKeyArray[1]
);
// now add to option set
$grouped_['group'][$valueKeyArray[2]][]
= PHP_EOL . Indent::_(1) . $taber
. Indent::_(3) . '<option value="'
. $valueKeyArray[0] . '">' . PHP_EOL
. Indent::_(1) . $taber . Indent::_(4)
. $langValue . '</option>';
$optionArray[$valueKeyArray[0]]
= $langValue;
// set order
$order_['group' . $valueKeyArray[2]]
= $valueKeyArray[2];
}
else
{
$langValue = $langView . '_'
. FieldHelper::safe(
$valueKeyArray[1], true
);
// add to lang array
$this->language->set(
$this->config->lang_target, $langValue,
$valueKeyArray[1]
);
// now add to option set
$grouped_['option'][$valueKeyArray[0]]
= PHP_EOL . Indent::_(1) . $taber
. Indent::_(2) . '<option value="'
. $valueKeyArray[0] . '">' . PHP_EOL
. Indent::_(1) . $taber . Indent::_(3)
. $langValue . '</option>';
$optionArray[$valueKeyArray[0]]
= $langValue;
// set order
$order_['option' . $valueKeyArray[0]]
= $valueKeyArray[0];
}
}
else
{
// text is also the value
$langValue = $langView . '_'
. FieldHelper::safe(
$option, true
);
// add to lang array
$this->language->set(
$this->config->lang_target, $langValue, $option
);
// now add to option set
$grouped_['option'][$option] = PHP_EOL
. Indent::_(1) . $taber . Indent::_(2)
. '<option value="' . $option .
'">'
. PHP_EOL . Indent::_(1) . $taber
. Indent::_(3) . $langValue . '</option>';
$optionArray[$option] = $langValue;
// set order
$order_['option' . $option] = $option;
}
}
// now build the groups
foreach ($order_ as $pointer_ => $_id)
{
// load the default key
$key_ = 'group';
if (strpos($pointer_, 'option') !== false)
{
// load the option field
$key_ = 'option';
}
// check if this is a group loader
if ('group' === $key_ && isset($groups_[$_id])
&& isset($grouped_[$key_][$_id])
&& ArrayHelper::check(
$grouped_[$key_][$_id]
))
{
// set group label
$optionSet .= $groups_[$_id];
foreach ($grouped_[$key_][$_id] as $option_)
{
$optionSet .= $option_;
}
unset($groups_[$_id]);
unset($grouped_[$key_][$_id]);
// close the group
$optionSet .= PHP_EOL . Indent::_(1) . $taber
. Indent::_(2) . '</group>';
}
elseif (isset($grouped_[$key_][$_id])
&& StringHelper::check(
$grouped_[$key_][$_id]
))
{
$optionSet .= $grouped_[$key_][$_id];
}
}
}
elseif (strpos((string) $value, ',') !== false)
{
// mulitpal options
$options = explode(',', (string) $value);
foreach ($options as $option)
{
if (strpos($option, '|') !== false)
{
// has other value then text
list($v, $t) = explode('|', $option);
$langValue = $langView . '_'
. FieldHelper::safe(
$t, true
);
// add to lang array
$this->language->set(
$this->config->lang_target, $langValue, $t
);
// now add to option set
$optionSet .= PHP_EOL . Indent::_(1)
. $taber . Indent::_(2) . '<option value="'
. $v . '">' . PHP_EOL . Indent::_(1)
. $taber . Indent::_(3) . $langValue
. '</option>';
$optionArray[$v] = $langValue;
}
else
{
// text is also the value
$langValue = $langView . '_'
. FieldHelper::safe(
$option, true
);
// add to lang array
$this->language->set(
$this->config->lang_target, $langValue, $option
);
// now add to option set
$optionSet .= PHP_EOL . Indent::_(2)
. $taber . Indent::_(1) . '<option value="'
. $option . '">' . PHP_EOL . Indent::_(2)
. $taber . Indent::_(2) . $langValue
. '</option>';
$optionArray[$option] = $langValue;
}
}
}
else
{
// one option
if (strpos((string) $value, '|') !== false)
{
// has other value then text
list($v, $t) = explode('|', (string) $value);
$langValue = $langView . '_'
. FieldHelper::safe(
$t, true
);
// add to lang array
$this->language->set($this->config->lang_target,
$langValue, $t);
// now add to option set
$optionSet .= PHP_EOL . Indent::_(2) . $taber
. Indent::_(1) . '<option value="' . $v .
'">'
. PHP_EOL . Indent::_(2) . $taber . Indent::_(2)
. $langValue . '</option>';
$optionArray[$v] = $langValue;
}
else
{
// text is also the value
$langValue = $langView . '_'
. FieldHelper::safe(
$value, true
);
// add to lang array
$this->language->set(
$this->config->lang_target, $langValue, $value
);
// now add to option set
$optionSet .= PHP_EOL . Indent::_(2)
. $taber . Indent::_(1) . '<option value="'
. $value . '">' . PHP_EOL . Indent::_(2)
. $taber . Indent::_(2) . $langValue
. '</option>';
$optionArray[$value] = $langValue;
}
}
}
}
// if options were found
if (StringHelper::check($optionSet))
{
$field .= '>';
$field .= PHP_EOL . Indent::_(3) . $taber . "<!--"
. Line::_(__Line__, __Class__) . " Option Set. -->";
$field .= $optionSet;
$field .= PHP_EOL . Indent::_(2) . $taber .
"</field>";
}
// if no options found and must have a list of options
elseif ($this->groups->check($typeName, 'list'))
{
$optionArray = null;
$field .= PHP_EOL . Indent::_(2) . $taber . "/>";
$field .= PHP_EOL . Indent::_(2) . $taber . "<!--"
. Line::_(__Line__, __Class__)
. " No Manual Options Were Added In Field Settings. -->"
. PHP_EOL;
}
else
{
$optionArray = null;
$field .= PHP_EOL . Indent::_(2) . $taber . "/>";
}
}
elseif ($setType === 'plain')
{
// now add to the field set
$field .= PHP_EOL . Indent::_(2) . $taber . "<!--" .
Line::_(
__LINE__,__CLASS__
) . " " . ucfirst($name) . " Field. Type: "
. StringHelper::safe($typeName, 'F')
. ". (joomla) -->";
$field .= PHP_EOL . Indent::_(2) . $taber . "<field";
foreach ($fieldAttributes as $property => $value)
{
if ($property != 'option')
{
$field .= PHP_EOL . Indent::_(2) . $taber . Indent::_(1)
. $property . '="' . $value . '"';
}
}
$field .= PHP_EOL . Indent::_(2) . $taber . "/>";
}
elseif ($setType === 'spacer')
{
// now add to the field set
$field .= PHP_EOL . Indent::_(2) . "<!--" .
Line::_(__Line__, __Class__)
. " " . ucfirst($name) . " Field. Type: "
. StringHelper::safe($typeName, 'F')
. ". A None Database Field. (joomla) -->";
$field .= PHP_EOL . Indent::_(2) . "<field";
foreach ($fieldAttributes as $property => $value)
{
if ($property != 'option')
{
$field .= " " . $property . '="' . $value .
'"';
}
}
$field .= " />";
}
elseif ($setType === 'special')
{
// set the repeatable field
if ($typeName === 'repeatable')
{
// now add to the field set
$field .= PHP_EOL . Indent::_(2) . "<!--" . Line::_(
__LINE__,__CLASS__
) . " " . ucfirst($name) . " Field. Type: "
. StringHelper::safe($typeName, 'F')
. ". (joomla) -->";
$field .= PHP_EOL . Indent::_(2) . "<field";
$fieldsSet = array();
foreach ($fieldAttributes as $property => $value)
{
if ($property != 'fields')
{
$field .= PHP_EOL . Indent::_(3) . $property . '="'
. $value . '"';
}
}
$field .= ">";
$field .= PHP_EOL . Indent::_(3) . '<fields name="'
. $fieldAttributes['name'] . '_fields"
label="">';
$field .= PHP_EOL . Indent::_(4)
. '<fieldset hidden="true" name="'
. $fieldAttributes['name'] . '_modal"
repeat="true">';
if (strpos((string) $fieldAttributes['fields'],
',') !== false)
{
// mulitpal fields
$fieldsSets = (array) explode(
',', (string) $fieldAttributes['fields']
);
}
elseif (is_numeric($fieldAttributes['fields']))
{
// single field
$fieldsSets[] = (int) $fieldAttributes['fields'];
}
// only continue if we have a field set
if (ArrayHelper::check($fieldsSets))
{
// set the resolver
$_resolverKey = $fieldAttributes['name'];
// load the field data
$fieldsSets = array_map(
function ($id) use (
$nameSingleCode, $nameListCode, $_resolverKey
) {
// start field
$field = array();
$field['field'] = $id;
// set the field details
$this->field->set(
$field, $nameSingleCode, $nameListCode,
$_resolverKey
);
// return field
return $field;
}, array_values($fieldsSets)
);
// start the build
foreach ($fieldsSets as $fieldData)
{
// if we have settings continue
if (ObjectHelper::check(
$fieldData['settings']
))
{
$r_name = $this->name->get(
$fieldData, $nameListCode, $_resolverKey
);
$r_typeName = $this->typename->get($fieldData);
$r_multiple = false;
$viewType = 0;
$r_langLabel = '';
// add the tabs needed
$r_taber = Indent::_(3);
// get field values
$r_fieldValues = $this->attributes->set(
$fieldData, $viewType, $r_name, $r_typeName,
$r_multiple, $r_langLabel, $langView,
$nameListCode, $nameSingleCode,
$placeholders, true
);
// check if values were set
if (ArrayHelper::check(
$r_fieldValues
))
{
//reset options array
$r_optionArray = array();
if ($this->groups->check(
$r_typeName, 'option'
))
{
// now add to the field set
$field .= $this->get(
'option', $r_fieldValues, $r_name,
$r_typeName, $langView,
$nameSingleCode, $nameListCode,
$placeholders, $r_optionArray, null,
$r_taber
);
}
elseif (isset($r_fieldValues['custom'])
&& ArrayHelper::check(
$r_fieldValues['custom']
))
{
// add to custom
$custom = $r_fieldValues['custom'];
unset($r_fieldValues['custom']);
// now add to the field set
$field .= $this->get(
'custom', $r_fieldValues, $r_name,
$r_typeName, $langView,
$nameSingleCode, $nameListCode,
$placeholders, $r_optionArray, null,
$r_taber
);
// set lang (just incase)
$r_listLangName = $langView . '_'
. FieldHelper::safe(
$r_name, true
);
// add to lang array
$this->language->set(
$this->config->lang_target, $r_listLangName,
StringHelper::safe(
$r_name, 'W'
)
);
// if label was set use instead
if (StringHelper::check(
$r_langLabel
))
{
$r_listLangName = $r_langLabel;
}
// set the custom array
$data = array('type' => $r_typeName,
'code' => $r_name,
'lang' => $r_listLangName,
'custom' => $custom);
// set the custom field file
$this->customfieldtypefile->set(
$data, $nameListCode,
$nameSingleCode
);
}
else
{
// now add to the field set
$field .= $this->get(
'plain', $r_fieldValues, $r_name,
$r_typeName, $langView,
$nameSingleCode, $nameListCode,
$placeholders, $r_optionArray, null,
$r_taber
);
}
}
}
}
}
$field .= PHP_EOL . Indent::_(4) . "</fieldset>";
$field .= PHP_EOL . Indent::_(3) . "</fields>";
$field .= PHP_EOL . Indent::_(2) . "</field>";
}
// set the subform fields (it is a repeatable without the modal)
elseif ($typeName === 'subform')
{
// now add to the field set
$field .= PHP_EOL . Indent::_(2) . $taber . "<!--"
. Line::_(__Line__, __Class__) . " " . ucfirst($name)
. " Field. Type: " . StringHelper::safe(
$typeName, 'F'
) . ". (joomla) -->";
$field .= PHP_EOL . Indent::_(2) . $taber . "<field";
$fieldsSet = array();
foreach ($fieldAttributes as $property => $value)
{
if ($property != 'fields')
{
$field .= PHP_EOL . Indent::_(3) . $taber . $property
. '="' . $value . '"';
}
}
$field .= ">";
$field .= PHP_EOL . Indent::_(3) . $taber
. '<form hidden="true" name="list_'
. $fieldAttributes['name'] . '_modal"
repeat="true">';
if (strpos((string) $fieldAttributes['fields'],
',') !== false)
{
// mulitpal fields
$fieldsSets = (array) explode(
',', (string) $fieldAttributes['fields']
);
}
elseif (is_numeric($fieldAttributes['fields']))
{
// single field
$fieldsSets[] = (int) $fieldAttributes['fields'];
}
// only continue if we have a field set
if (ArrayHelper::check($fieldsSets))
{
// set the resolver
$_resolverKey = $fieldAttributes['name'];
// load the field data
$fieldsSets = array_map(
function ($id) use (
$nameSingleCode, $nameListCode, $_resolverKey
) {
// start field
$field = array();
$field['field'] = $id;
// set the field details
$this->field->set(
$field, $nameSingleCode, $nameListCode,
$_resolverKey
);
// return field
return $field;
}, array_values($fieldsSets)
);
// start the build
foreach ($fieldsSets as $fieldData)
{
// if we have settings continue
if (ObjectHelper::check(
$fieldData['settings']
))
{
$r_name = $this->name->get(
$fieldData, $nameListCode, $_resolverKey
);
$r_typeName = $this->typename->get($fieldData);
$r_multiple = false;
$viewType = 0;
$r_langLabel = '';
// add the tabs needed
$r_taber = Indent::_(2) . $taber;
// get field values
$r_fieldValues = $this->attributes->set(
$fieldData, $viewType, $r_name, $r_typeName,
$r_multiple, $r_langLabel, $langView,
$nameListCode, $nameSingleCode,
$placeholders, true
);
// check if values were set
if (ArrayHelper::check(
$r_fieldValues
))
{
//reset options array
$r_optionArray = array();
if ($this->groups->check(
$r_typeName, 'option'
))
{
// now add to the field set
$field .= $this->get(
'option', $r_fieldValues, $r_name,
$r_typeName, $langView,
$nameSingleCode, $nameListCode,
$placeholders, $r_optionArray, null,
$r_taber
);
}
elseif ($r_typeName === 'subform')
{
// set nested depth
if (isset($fieldAttributes['nested_depth']))
{
$r_fieldValues['nested_depth']
= ++$fieldAttributes['nested_depth'];
}
else
{
$r_fieldValues['nested_depth'] = 1;
}
// only continue if nest is bellow 20 (this should be a safe
limit)
if ($r_fieldValues['nested_depth'] <= 20)
{
// now add to the field set
$field .= $this->get(
'special', $r_fieldValues, $r_name,
$r_typeName, $langView,
$nameSingleCode, $nameListCode,
$placeholders, $r_optionArray, null,
$r_taber
);
}
}
elseif (isset($r_fieldValues['custom'])
&& ArrayHelper::check(
$r_fieldValues['custom']
))
{
// add to custom
$custom = $r_fieldValues['custom'];
unset($r_fieldValues['custom']);
// now add to the field set
$field .= $this->get(
'custom', $r_fieldValues, $r_name,
$r_typeName, $langView,
$nameSingleCode, $nameListCode,
$placeholders, $r_optionArray, null,
$r_taber
);
// set lang (just incase)
$r_listLangName = $langView . '_'
. FieldHelper::safe(
$r_name, true
);
// add to lang array
$this->language->set(
$this->config->lang_target, $r_listLangName,
StringHelper::safe(
$r_name, 'W'
)
);
// if label was set use instead
if (StringHelper::check(
$r_langLabel
))
{
$r_listLangName = $r_langLabel;
}
// set the custom array
$data = array('type' => $r_typeName,
'code' => $r_name,
'lang' => $r_listLangName,
'custom' => $custom);
// set the custom field file
$this->customfieldtypefile->set(
$data, $nameListCode,
$nameSingleCode
);
}
else
{
// now add to the field set
$field .= $this->get(
'plain', $r_fieldValues, $r_name,
$r_typeName, $langView,
$nameSingleCode, $nameListCode,
$placeholders, $r_optionArray, null,
$r_taber
);
}
}
}
}
}
$field .= PHP_EOL . Indent::_(3) . $taber . "</form>";
$field .= PHP_EOL . Indent::_(2) . $taber .
"</field>";
}
}
elseif ($setType === 'custom')
{
// now add to the field set
$field .= PHP_EOL . Indent::_(2) . $taber . "<!--"
. Line::_(
__LINE__,__CLASS__
) . " " . ucfirst($name) . " Field. Type: "
. StringHelper::safe($typeName, 'F')
. ". (custom) -->";
$field .= PHP_EOL . Indent::_(2) . $taber . "<field";
$optionSet = '';
foreach ($fieldAttributes as $property => $value)
{
if ($property != 'option')
{
$field .= PHP_EOL . Indent::_(2) . $taber . Indent::_(1)
. $property . '="' . $value . '"';
}
elseif ($property === 'option')
{
$optionSet = '';
if (strtolower($typeName) === 'groupedlist'
&& strpos(
(string) $value, ','
) !== false
&& strpos((string) $value, '@@') !== false)
{
// reset the group temp arrays
$groups_ = array();
$grouped_ = array('group' => array(),
'option' => array());
$order_ = array();
// mulitpal options
$options = explode(',', (string) $value);
foreach ($options as $option)
{
if (strpos($option, '@@') !== false)
{
// set the group label
$valueKeyArray = explode('@@', $option);
if (count((array) $valueKeyArray) == 2)
{
$langValue = $langView . '_'
. FieldHelper::safe(
$valueKeyArray[0], true
);
// add to lang array
$this->language->set(
$this->config->lang_target, $langValue,
$valueKeyArray[0]
);
// now add group label
$groups_[$valueKeyArray[1]] = PHP_EOL
. Indent::_(1) . $taber . Indent::_(2)
. '<group label="' . $langValue .
'">';
// set order
$order_['group' . $valueKeyArray[1]]
= $valueKeyArray[1];
}
}
elseif (strpos($option, '|') !== false)
{
// has other value then text
$valueKeyArray = explode('|', $option);
if (count((array) $valueKeyArray) == 3)
{
$langValue = $langView . '_'
. FieldHelper::safe(
$valueKeyArray[1], true
);
// add to lang array
$this->language->set(
$this->config->lang_target, $langValue,
$valueKeyArray[1]
);
// now add to option set
$grouped_['group'][$valueKeyArray[2]][]
= PHP_EOL . Indent::_(1) . $taber
. Indent::_(3) . '<option value="'
. $valueKeyArray[0] . '">' . PHP_EOL
. Indent::_(1) . $taber . Indent::_(4)
. $langValue . '</option>';
$optionArray[$valueKeyArray[0]]
= $langValue;
// set order
$order_['group' . $valueKeyArray[2]]
= $valueKeyArray[2];
}
else
{
$langValue = $langView . '_'
. FieldHelper::safe(
$valueKeyArray[1], true
);
// add to lang array
$this->language->set(
$this->config->lang_target, $langValue,
$valueKeyArray[1]
);
// now add to option set
$grouped_['option'][$valueKeyArray[0]]
= PHP_EOL . Indent::_(1) . $taber
. Indent::_(2) . '<option value="'
. $valueKeyArray[0] . '">' . PHP_EOL
. Indent::_(1) . $taber . Indent::_(3)
. $langValue . '</option>';
$optionArray[$valueKeyArray[0]]
= $langValue;
// set order
$order_['option' . $valueKeyArray[0]]
= $valueKeyArray[0];
}
}
else
{
// text is also the value
$langValue = $langView . '_'
. FieldHelper::safe(
$option, true
);
// add to lang array
$this->language->set(
$this->config->lang_target, $langValue, $option
);
// now add to option set
$grouped_['option'][$option] = PHP_EOL
. Indent::_(1) . $taber . Indent::_(2)
. '<option value="' . $option .
'">'
. PHP_EOL . Indent::_(1) . $taber
. Indent::_(3) . $langValue . '</option>';
$optionArray[$option] = $langValue;
// set order
$order_['option' . $option] = $option;
}
}
// now build the groups
foreach ($order_ as $pointer_ => $_id)
{
// load the default key
$key_ = 'group';
if (strpos($pointer_, 'option') !== false)
{
// load the option field
$key_ = 'option';
}
// check if this is a group loader
if ('group' === $key_ && isset($groups_[$_id])
&& isset($grouped_[$key_][$_id])
&& ArrayHelper::check(
$grouped_[$key_][$_id]
))
{
// set group label
$optionSet .= $groups_[$_id];
foreach ($grouped_[$key_][$_id] as $option_)
{
$optionSet .= $option_;
}
unset($groups_[$_id]);
unset($grouped_[$key_][$_id]);
// close the group
$optionSet .= PHP_EOL . Indent::_(1) . $taber
. Indent::_(2) . '</group>';
}
elseif (isset($grouped_[$key_][$_id])
&& StringHelper::check(
$grouped_[$key_][$_id]
))
{
$optionSet .= $grouped_[$key_][$_id];
}
}
}
elseif (strpos((string) $value, ',') !== false)
{
// mulitpal options
$options = explode(',', (string) $value);
foreach ($options as $option)
{
if (strpos($option, '|') !== false)
{
// has other value then text
list($v, $t) = explode('|', $option);
$langValue = $langView . '_'
. FieldHelper::safe(
$t, true
);
// add to lang array
$this->language->set(
$this->config->lang_target, $langValue, $t
);
// now add to option set
$optionSet .= PHP_EOL . Indent::_(1)
. $taber . Indent::_(2) . '<option value="'
. $v . '">' . PHP_EOL . Indent::_(1)
. $taber . Indent::_(3) . $langValue
. '</option>';
$optionArray[$v] = $langValue;
}
else
{
// text is also the value
$langValue = $langView . '_'
. FieldHelper::safe(
$option, true
);
// add to lang array
$this->language->set(
$this->config->lang_target, $langValue, $option
);
// now add to option set
$optionSet .= PHP_EOL . Indent::_(2)
. $taber . Indent::_(1) . '<option value="'
. $option . '">' . PHP_EOL . Indent::_(2)
. $taber . Indent::_(2) . $langValue
. '</option>';
$optionArray[$option] = $langValue;
}
}
}
else
{
// one option
if (strpos((string) $value, '|') !== false)
{
// has other value then text
list($v, $t) = explode('|', (string) $value);
$langValue = $langView . '_'
. FieldHelper::safe(
$t, true
);
// add to lang array
$this->language->set($this->config->lang_target,
$langValue, $t);
// now add to option set
$optionSet .= PHP_EOL . Indent::_(2) . $taber
. Indent::_(1) . '<option value="' . $v .
'">'
. PHP_EOL . Indent::_(2) . $taber . Indent::_(2)
. $langValue . '</option>';
$optionArray[$v] = $langValue;
}
else
{
// text is also the value
$langValue = $langView . '_'
. FieldHelper::safe(
$value, true
);
// add to lang array
$this->language->set(
$this->config->lang_target, $langValue, $value
);
// now add to option set
$optionSet .= PHP_EOL . Indent::_(2)
. $taber . Indent::_(1) . '<option value="'
. $value . '">' . PHP_EOL . Indent::_(2)
. $taber . Indent::_(2) . $langValue
. '</option>';
$optionArray[$value] = $langValue;
}
}
}
}
// if options were found
if (StringHelper::check($optionSet))
{
$field .= '>';
$field .= PHP_EOL . Indent::_(3) . $taber . "<!--"
. Line::_(__Line__, __Class__) . " Option Set. -->";
$field .= $optionSet;
$field .= PHP_EOL . Indent::_(2) . $taber .
"</field>";
}
// if no options found and must have a list of options
elseif ($this->groups->check($typeName, 'list'))
{
$optionArray = null;
$field .= PHP_EOL . Indent::_(2) . $taber . "/>";
$field .= PHP_EOL . Indent::_(2) . $taber . "<!--"
. Line::_(__Line__, __Class__)
. " No Manual Options Were Added In Field Settings. -->"
. PHP_EOL;
}
else
{
$optionArray = null;
$field .= PHP_EOL . Indent::_(2) . $taber . "/>";
}
// incase the field is in the config and has not been set
if ('config' === $nameSingleCode &&
'configs' === $nameListCode
|| (strpos($nameSingleCode, 'pLuG!n') !== false
|| strpos(
$nameSingleCode, 'M0dUl3'
) !== false))
{
// set lang (just incase)
$listLangName = $langView . '_'
. StringHelper::safe($name, 'U');
// set the custom array
$data = array('type' => $typeName, 'code' =>
$name,
'lang' => $listLangName, 'custom' =>
$custom);
// set the custom field file
$this->customfieldtypefile->set(
$data, $nameListCode, $nameSingleCode
);
}
}
// return field
return $field;
}
}
src/Componentbuilder/Compiler/Creator/FieldXML.php000064400000101702151162054100016126
0ustar00<?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\Field;
use VDM\Joomla\Componentbuilder\Compiler\Field\Groups;
use VDM\Joomla\Componentbuilder\Compiler\Field\Name;
use VDM\Joomla\Componentbuilder\Compiler\Field\TypeName;
use VDM\Joomla\Componentbuilder\Compiler\Field\Attributes;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Xml;
use VDM\Joomla\Componentbuilder\Compiler\Creator\CustomFieldTypeFile;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Counter;
use VDM\Joomla\Utilities\StringHelper;
use VDM\Joomla\Utilities\String\FieldHelper;
use VDM\Joomla\Utilities\ArrayHelper;
use VDM\Joomla\Utilities\ObjectHelper;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Line;
use
VDM\Joomla\Componentbuilder\Compiler\Interfaces\Creator\Fieldtypeinterface;
/**
* Field Simple XML Creator Class
*
* @since 3.2.0
*/
final class FieldXML implements Fieldtypeinterface
{
/**
* 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 Field Class.
*
* @var Field
* @since 3.2.0
*/
protected Field $field;
/**
* The Groups Class.
*
* @var Groups
* @since 3.2.0
*/
protected Groups $groups;
/**
* The Name Class.
*
* @var Name
* @since 3.2.0
*/
protected Name $name;
/**
* The TypeName Class.
*
* @var TypeName
* @since 3.2.0
*/
protected TypeName $typename;
/**
* The Attributes Class.
*
* @var Attributes
* @since 3.2.0
*/
protected Attributes $attributes;
/**
* The Xml Class.
*
* @var Xml
* @since 3.2.0
*/
protected Xml $xml;
/**
* The CustomFieldTypeFile Class.
*
* @var CustomFieldTypeFile
* @since 3.2.0
*/
protected CustomFieldTypeFile $customfieldtypefile;
/**
* 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 Field $field The Field Class.
* @param Groups $groups The Groups Class.
* @param Name $name The Name Class.
* @param TypeName $typename The TypeName
Class.
* @param Attributes $attributes The Attributes
Class.
* @param Xml $xml The Xml Class.
* @param CustomFieldTypeFile $customfieldtypefile The
CustomFieldTypeFile Class.
* @param Counter $counter The Counter Class.
*
* @since 3.2.0
*/
public function __construct(Config $config, Language $language, Field
$field,
Groups $groups, Name $name, TypeName $typename,
Attributes $attributes, Xml $xml,
CustomFieldTypeFile $customfieldtypefile,
Counter $counter)
{
$this->config = $config;
$this->language = $language;
$this->field = $field;
$this->groups = $groups;
$this->name = $name;
$this->typename = $typename;
$this->attributes = $attributes;
$this->xml = $xml;
$this->customfieldtypefile = $customfieldtypefile;
$this->counter = $counter;
}
/**
* Create a field with simpleXMLElement class
*
* @param string $setType The set of fields type
* @param array $fieldAttributes The field values
* @param string $name The field name
* @param string $typeName The field type
* @param string $langView The language string of the view
* @param string $nameSingleCode The single view name
* @param string $nameListCode The list view name
* @param array $placeholders The place holder and replace
values
* @param array|null $optionArray The option bucket array used to
set the field options if needed.
* @param array|null $custom Used when field is from config
* @param string $taber The tabs not used... hmm
*
* @return \stdClass The field in xml object
* @since 3.2.0
*/
public function get(string $setType, array &$fieldAttributes, string
&$name,
string &$typeName, string &$langView, string
&$nameSingleCode, string &$nameListCode,
array $placeholders, ?array &$optionArray, ?array $custom = null,
string $taber = ''): \stdClass
{
// count the dynamic fields created
$this->counter->field++;
$field = new \stdClass();
if ($setType === 'option')
{
// now add to the field set
$field->fieldXML = new
\SimpleXMLElement('<field/>');
$field->comment = Line::_(__Line__, __Class__) . " " .
ucfirst($name)
. " Field. Type: " . StringHelper::safe(
$typeName, 'F'
) . ". (joomla)";
foreach ($fieldAttributes as $property => $value)
{
if ($property != 'option')
{
$field->fieldXML->addAttribute($property, $value);
}
elseif ($property === 'option')
{
$this->xml->comment(
$field->fieldXML,
Line::_(__Line__, __Class__) . " Option Set."
);
if (strtolower($typeName) === 'groupedlist'
&& strpos(
(string) $value, ','
) !== false
&& strpos((string) $value, '@@') !== false)
{
// reset the group temp arrays
$groups_ = array();
$grouped_ = array('group' => array(),
'option' => array());
$order_ = array();
// mulitpal options
$options = explode(',', (string) $value);
foreach ($options as $option)
{
if (strpos($option, '@@') !== false)
{
// set the group label
$valueKeyArray = explode('@@', $option);
if (count((array) $valueKeyArray) == 2)
{
$langValue = $langView . '_'
. FieldHelper::safe(
$valueKeyArray[0], true
);
// add to lang array
$this->language->set(
$this->config->lang_target, $langValue,
$valueKeyArray[0]
);
// now add group label
$groups_[$valueKeyArray[1]] = $langValue;
// set order
$order_['group' . $valueKeyArray[1]]
= $valueKeyArray[1];
}
}
elseif (strpos($option, '|') !== false)
{
// has other value then text
$valueKeyArray = explode('|', $option);
if (count((array) $valueKeyArray) == 3)
{
$langValue = $langView . '_'
. FieldHelper::safe(
$valueKeyArray[1], true
);
// add to lang array
$this->language->set(
$this->config->lang_target, $langValue,
$valueKeyArray[1]
);
// now add to option set
$grouped_['group'][$valueKeyArray[2]][]
= array('value' => $valueKeyArray[0],
'text' => $langValue);
$optionArray[$valueKeyArray[0]]
= $langValue;
// set order
$order_['group' . $valueKeyArray[2]]
= $valueKeyArray[2];
}
else
{
$langValue = $langView . '_'
. FieldHelper::safe(
$valueKeyArray[1], true
);
// add to lang array
$this->language->set(
$this->config->lang_target, $langValue,
$valueKeyArray[1]
);
// now add to option set
$grouped_['option'][$valueKeyArray[0]]
= array('value' => $valueKeyArray[0],
'text' => $langValue);
$optionArray[$valueKeyArray[0]]
= $langValue;
// set order
$order_['option' . $valueKeyArray[0]]
= $valueKeyArray[0];
}
}
else
{
// text is also the value
$langValue = $langView . '_'
. FieldHelper::safe(
$option, true
);
// add to lang array
$this->language->set(
$this->config->lang_target, $langValue, $option
);
// now add to option set
$grouped_['option'][$option]
= array('value' => $option,
'text' => $langValue);
$optionArray[$option] = $langValue;
// set order
$order_['option' . $option] = $option;
}
}
// now build the groups
foreach ($order_ as $pointer_ => $_id)
{
// load the default key
$key_ = 'group';
if (strpos($pointer_, 'option') !== false)
{
// load the option field
$key_ = 'option';
}
// check if this is a group loader
if ('group' === $key_ && isset($groups_[$_id])
&& isset($grouped_[$key_][$_id])
&& ArrayHelper::check(
$grouped_[$key_][$_id]
))
{
// set group label
$groupXML = $field->fieldXML->addChild('group');
$groupXML->addAttribute(
'label', $groups_[$_id]
);
foreach ($grouped_[$key_][$_id] as $option_)
{
$groupOptionXML = $groupXML->addChild(
'option'
);
$groupOptionXML->addAttribute(
'value', $option_['value']
);
$groupOptionXML[] = $option_['text'];
}
unset($groups_[$_id]);
unset($grouped_[$key_][$_id]);
}
elseif (isset($grouped_[$key_][$_id])
&& StringHelper::check(
$grouped_[$key_][$_id]
))
{
$optionXML = $field->fieldXML->addChild(
'option'
);
$optionXML->addAttribute(
'value', $grouped_[$key_][$_id]['value']
);
$optionXML[] = $grouped_[$key_][$_id]['text'];
}
}
}
elseif (strpos((string) $value, ',') !== false)
{
// mulitpal options
$options = explode(',', (string) $value);
foreach ($options as $option)
{
$optionXML = $field->fieldXML->addChild('option');
if (strpos($option, '|') !== false)
{
// has other value then text
list($v, $t) = explode('|', $option);
$langValue = $langView . '_'
. FieldHelper::safe(
$t, true
);
// add to lang array
$this->language->set(
$this->config->lang_target, $langValue, $t
);
// now add to option set
$optionXML->addAttribute('value', $v);
$optionArray[$v] = $langValue;
}
else
{
// text is also the value
$langValue = $langView . '_'
. FieldHelper::safe(
$option, true
);
// add to lang array
$this->language->set(
$this->config->lang_target, $langValue, $option
);
// now add to option set
$optionXML->addAttribute('value', $option);
$optionArray[$option] = $langValue;
}
$optionXML[] = $langValue;
}
}
else
{
// one option
$optionXML = $field->fieldXML->addChild('option');
if (strpos((string) $value, '|') !== false)
{
// has other value then text
list($v, $t) = explode('|', (string) $value);
$langValue = $langView . '_'
. FieldHelper::safe(
$t, true
);
// add to lang array
$this->language->set($this->config->lang_target,
$langValue, $t);
// now add to option set
$optionXML->addAttribute('value', $v);
$optionArray[$v] = $langValue;
}
else
{
// text is also the value
$langValue = $langView . '_'
. FieldHelper::safe(
$value, true
);
// add to lang array
$this->language->set(
$this->config->lang_target, $langValue, $value
);
// now add to option set
$optionXML->addAttribute('value', $value);
$optionArray[$value] = $langValue;
}
$optionXML[] = $langValue;
}
}
}
// if no options found and must have a list of options
if (!$field->fieldXML->count()
&& $this->groups->check($typeName, 'list'))
{
$this->xml->comment(
$field->fieldXML, Line::_(__Line__, __Class__)
. " No Manual Options Were Added In Field Settings."
);
}
}
elseif ($setType === 'plain')
{
// now add to the field set
$field->fieldXML = new
\SimpleXMLElement('<field/>');
$field->comment = Line::_(__Line__, __Class__) . " " .
ucfirst($name)
. " Field. Type: " . StringHelper::safe(
$typeName, 'F'
) . ". (joomla)";
foreach ($fieldAttributes as $property => $value)
{
if ($property != 'option')
{
$field->fieldXML->addAttribute($property, $value);
}
}
}
elseif ($setType === 'spacer')
{
// now add to the field set
$field->fieldXML = new
\SimpleXMLElement('<field/>');
$field->comment = Line::_(__Line__, __Class__) . " " .
ucfirst($name)
. " Field. Type: " . StringHelper::safe(
$typeName, 'F'
) . ". A None Database Field. (joomla)";
foreach ($fieldAttributes as $property => $value)
{
if ($property != 'option')
{
$field->fieldXML->addAttribute($property, $value);
}
}
}
elseif ($setType === 'special')
{
// set the repeatable field
if ($typeName === 'repeatable')
{
// now add to the field set
$field->fieldXML = new
\SimpleXMLElement('<field/>');
$field->comment = Line::_(__Line__, __Class__) . " " .
ucfirst(
$name
) . " Field. Type: " . StringHelper::safe(
$typeName, 'F'
) . ". (depreciated)";
foreach ($fieldAttributes as $property => $value)
{
if ($property != 'fields')
{
$field->fieldXML->addAttribute($property, $value);
}
}
$fieldsXML = $field->fieldXML->addChild('fields');
$fieldsXML->addAttribute(
'name', $fieldAttributes['name'] .
'_fields'
);
$fieldsXML->addAttribute('label', '');
$fieldSetXML = $fieldsXML->addChild('fieldset');
$fieldSetXML->addAttribute('hidden', 'true');
$fieldSetXML->addAttribute(
'name', $fieldAttributes['name'] .
'_modal'
);
$fieldSetXML->addAttribute('repeat', 'true');
if (strpos((string) $fieldAttributes['fields'],
',') !== false)
{
// mulitpal fields
$fieldsSets = (array) explode(
',', (string) $fieldAttributes['fields']
);
}
elseif (is_numeric($fieldAttributes['fields']))
{
// single field
$fieldsSets[] = (int) $fieldAttributes['fields'];
}
// only continue if we have a field set
if (ArrayHelper::check($fieldsSets))
{
// set the resolver
$_resolverKey = $fieldAttributes['name'];
// load the field data
$fieldsSets = array_map(
function ($id) use (
$nameSingleCode, $nameListCode, $_resolverKey
) {
// start field
$field = array();
$field['field'] = $id;
// set the field details
$this->field->set(
$field, $nameSingleCode, $nameListCode,
$_resolverKey
);
// return field
return $field;
}, array_values($fieldsSets)
);
// start the build
foreach ($fieldsSets as $fieldData)
{
// if we have settings continue
if (ObjectHelper::check(
$fieldData['settings']
))
{
$r_name = $this->name->get(
$fieldData, $nameListCode, $_resolverKey
);
$r_typeName = $this->typename->get($fieldData);
$r_multiple = false;
$viewType = 0;
$r_langLabel = '';
// get field values
$r_fieldValues = $this->attributes->set(
$fieldData, $viewType, $r_name, $r_typeName,
$r_multiple, $r_langLabel, $langView,
$nameListCode, $nameSingleCode,
$placeholders, true
);
// check if values were set
if (ArrayHelper::check(
$r_fieldValues
))
{
//reset options array
$r_optionArray = array();
if ($this->groups->check(
$r_typeName, 'option'
))
{
// now add to the field set
$this->xml->append(
$fieldSetXML, $this->get(
'option', $r_fieldValues, $r_name,
$r_typeName, $langView,
$nameSingleCode, $nameListCode,
$placeholders, $r_optionArray
)
);
}
elseif (isset($r_fieldValues['custom'])
&& ArrayHelper::check(
$r_fieldValues['custom']
))
{
// add to custom
$custom = $r_fieldValues['custom'];
unset($r_fieldValues['custom']);
// now add to the field set
$this->xml->append(
$fieldSetXML, $this->get(
'custom', $r_fieldValues, $r_name,
$r_typeName, $langView,
$nameSingleCode, $nameListCode,
$placeholders, $r_optionArray
)
);
// set lang (just incase)
$r_listLangName = $langView . '_'
. FieldHelper::safe(
$r_name, true
);
// add to lang array
$this->language->set(
$this->config->lang_target, $r_listLangName,
StringHelper::safe(
$r_name, 'W'
)
);
// if label was set use instead
if (StringHelper::check(
$r_langLabel
))
{
$r_listLangName = $r_langLabel;
}
// set the custom array
$data = array('type' => $r_typeName,
'code' => $r_name,
'lang' => $r_listLangName,
'custom' => $custom);
// set the custom field file
$this->customfieldtypefile->set(
$data, $nameListCode,
$nameSingleCode
);
}
else
{
// now add to the field set
$this->xml->append(
$fieldSetXML, $this->get(
'plain', $r_fieldValues, $r_name,
$r_typeName, $langView,
$nameSingleCode, $nameListCode,
$placeholders, $r_optionArray
)
);
}
}
}
}
}
}
// set the subform fields (it is a repeatable without the modal)
elseif ($typeName === 'subform')
{
// now add to the field set
$field->fieldXML = new
\SimpleXMLElement('<field/>');
$field->comment = Line::_(__Line__, __Class__) . " " .
ucfirst(
$name
) . " Field. Type: " . StringHelper::safe(
$typeName, 'F'
) . ". (joomla)";
// add all properties
foreach ($fieldAttributes as $property => $value)
{
if ($property != 'fields' && $property !=
'formsource')
{
$field->fieldXML->addAttribute($property, $value);
}
}
// if we detect formsource we do not add the form
if (isset($fieldAttributes['formsource'])
&& StringHelper::check(
$fieldAttributes['formsource']
))
{
$field->fieldXML->addAttribute(
'formsource', $fieldAttributes['formsource']
);
}
// add the form
else
{
$form = $field->fieldXML->addChild('form');
$attributes = array(
'hidden' => 'true',
'name' => 'list_' .
$fieldAttributes['name']
. '_modal',
'repeat' => 'true'
);
$this->xml->attributes(
$form, $attributes
);
if (strpos((string) $fieldAttributes['fields'],
',') !== false)
{
// multiple fields
$fieldsSets = (array) explode(
',', (string) $fieldAttributes['fields']
);
}
elseif (is_numeric($fieldAttributes['fields']))
{
// single field
$fieldsSets[] = (int) $fieldAttributes['fields'];
}
// only continue if we have a field set
if (ArrayHelper::check($fieldsSets))
{
// set the resolver
$_resolverKey = $fieldAttributes['name'];
// load the field data
$fieldsSets = array_map(
function ($id) use (
$nameSingleCode, $nameListCode,
$_resolverKey
) {
// start field
$field = array();
$field['field'] = $id;
// set the field details
$this->field->set(
$field, $nameSingleCode, $nameListCode,
$_resolverKey
);
// return field
return $field;
}, array_values($fieldsSets)
);
// start the build
foreach ($fieldsSets as $fieldData)
{
// if we have settings continue
if (ObjectHelper::check(
$fieldData['settings']
))
{
$r_name = $this->name->get(
$fieldData, $nameListCode, $_resolverKey
);
$r_typeName = $this->typename->get($fieldData);
$r_multiple = false;
$viewType = 0;
$r_langLabel = '';
// get field values
$r_fieldValues = $this->attributes->set(
$fieldData, $viewType, $r_name, $r_typeName,
$r_multiple, $r_langLabel, $langView,
$nameListCode, $nameSingleCode,
$placeholders, true
);
// check if values were set
if (ArrayHelper::check(
$r_fieldValues
))
{
//reset options array
$r_optionArray = array();
if ($this->groups->check(
$r_typeName, 'option'
))
{
// now add to the field set
$this->xml->append(
$form, $this->get(
'option', $r_fieldValues, $r_name,
$r_typeName, $langView,
$nameSingleCode, $nameListCode,
$placeholders, $r_optionArray
)
);
}
elseif ($r_typeName === 'subform')
{
// set nested depth
if (isset($fieldAttributes['nested_depth']))
{
$r_fieldValues['nested_depth']
= ++$fieldAttributes['nested_depth'];
}
else
{
$r_fieldValues['nested_depth'] = 1;
}
// only continue if nest is bellow 20 (this should be a safe
limit)
if ($r_fieldValues['nested_depth']
<= 20)
{
// now add to the field set
$this->xml->append(
$form, $this->get(
'special', $r_fieldValues,
$r_name, $r_typeName, $langView,
$nameSingleCode,
$nameListCode, $placeholders,
$r_optionArray
)
);
}
}
elseif (isset($r_fieldValues['custom'])
&& ArrayHelper::check(
$r_fieldValues['custom']
))
{
// add to custom
$custom = $r_fieldValues['custom'];
unset($r_fieldValues['custom']);
// now add to the field set
$this->xml->append(
$form, $this->get(
'custom', $r_fieldValues, $r_name,
$r_typeName, $langView,
$nameSingleCode, $nameListCode,
$placeholders, $r_optionArray
)
);
// set lang (just incase)
$r_listLangName = $langView . '_'
. FieldHelper::safe(
$r_name, true
);
// add to lang array
$this->language->set(
$this->config->lang_target, $r_listLangName,
StringHelper::safe(
$r_name, 'W'
)
);
// if label was set use instead
if (StringHelper::check(
$r_langLabel
))
{
$r_listLangName = $r_langLabel;
}
// set the custom array
$data = array('type' => $r_typeName,
'code' => $r_name,
'lang' => $r_listLangName,
'custom' => $custom);
// set the custom field file
$this->customfieldtypefile->set(
$data, $nameListCode,
$nameSingleCode
);
}
else
{
// now add to the field set
$this->xml->append(
$form, $this->get(
'plain', $r_fieldValues, $r_name,
$r_typeName, $langView,
$nameSingleCode, $nameListCode,
$placeholders, $r_optionArray
)
);
}
}
}
}
}
}
}
}
elseif ($setType === 'custom')
{
// now add to the field set
$field->fieldXML = new
\SimpleXMLElement('<field/>');
$field->comment = Line::_(__Line__, __Class__) . " " .
ucfirst($name)
. " Field. Type: " . StringHelper::safe(
$typeName, 'F'
) . ". (custom)";
foreach ($fieldAttributes as $property => $value)
{
if ($property != 'option')
{
$field->fieldXML->addAttribute($property, $value);
}
elseif ($property === 'option')
{
$this->xml->comment(
$field->fieldXML,
Line::_(__Line__, __Class__) . " Option Set."
);
if (strtolower($typeName) === 'groupedlist'
&& strpos(
(string) $value, ','
) !== false
&& strpos((string) $value, '@@') !== false)
{
// reset the group temp arrays
$groups_ = array();
$grouped_ = array('group' => array(),
'option' => array());
$order_ = array();
// mulitpal options
$options = explode(',', (string) $value);
foreach ($options as $option)
{
if (strpos($option, '@@') !== false)
{
// set the group label
$valueKeyArray = explode('@@', $option);
if (count((array) $valueKeyArray) == 2)
{
$langValue = $langView . '_'
. FieldHelper::safe(
$valueKeyArray[0], true
);
// add to lang array
$this->language->set(
$this->config->lang_target, $langValue,
$valueKeyArray[0]
);
// now add group label
$groups_[$valueKeyArray[1]] = $langValue;
// set order
$order_['group' . $valueKeyArray[1]]
= $valueKeyArray[1];
}
}
elseif (strpos($option, '|') !== false)
{
// has other value then text
$valueKeyArray = explode('|', $option);
if (count((array) $valueKeyArray) == 3)
{
$langValue = $langView . '_'
. FieldHelper::safe(
$valueKeyArray[1], true
);
// add to lang array
$this->language->set(
$this->config->lang_target, $langValue,
$valueKeyArray[1]
);
// now add to option set
$grouped_['group'][$valueKeyArray[2]][]
= array('value' => $valueKeyArray[0],
'text' => $langValue);
$optionArray[$valueKeyArray[0]]
= $langValue;
// set order
$order_['group' . $valueKeyArray[2]]
= $valueKeyArray[2];
}
else
{
$langValue = $langView . '_'
. FieldHelper::safe(
$valueKeyArray[1], true
);
// add to lang array
$this->language->set(
$this->config->lang_target, $langValue,
$valueKeyArray[1]
);
// now add to option set
$grouped_['option'][$valueKeyArray[0]]
= array('value' => $valueKeyArray[0],
'text' => $langValue);
$optionArray[$valueKeyArray[0]]
= $langValue;
// set order
$order_['option' . $valueKeyArray[0]]
= $valueKeyArray[0];
}
}
else
{
// text is also the value
$langValue = $langView . '_'
. FieldHelper::safe(
$option, true
);
// add to lang array
$this->language->set(
$this->config->lang_target, $langValue, $option
);
// now add to option set
$grouped_['option'][$option]
= array('value' => $option,
'text' => $langValue);
$optionArray[$option] = $langValue;
// set order
$order_['option' . $option] = $option;
}
}
// now build the groups
foreach ($order_ as $pointer_ => $_id)
{
// load the default key
$key_ = 'group';
if (strpos($pointer_, 'option') !== false)
{
// load the option field
$key_ = 'option';
}
// check if this is a group loader
if ('group' === $key_ && isset($groups_[$_id])
&& isset($grouped_[$key_][$_id])
&& ArrayHelper::check(
$grouped_[$key_][$_id]
))
{
// set group label
$groupXML = $field->fieldXML->addChild('group');
$groupXML->addAttribute(
'label', $groups_[$_id]
);
foreach ($grouped_[$key_][$_id] as $option_)
{
$groupOptionXML = $groupXML->addChild(
'option'
);
$groupOptionXML->addAttribute(
'value', $option_['value']
);
$groupOptionXML[] = $option_['text'];
}
unset($groups_[$_id]);
unset($grouped_[$key_][$_id]);
}
elseif (isset($grouped_[$key_][$_id])
&& StringHelper::check(
$grouped_[$key_][$_id]
))
{
$optionXML = $field->fieldXML->addChild(
'option'
);
$optionXML->addAttribute(
'value', $grouped_[$key_][$_id]['value']
);
$optionXML[] = $grouped_[$key_][$_id]['text'];
}
}
}
elseif (strpos((string) $value, ',') !== false)
{
// municipal options
$options = explode(',', (string) $value);
foreach ($options as $option)
{
$optionXML = $field->fieldXML->addChild('option');
if (strpos($option, '|') !== false)
{
// has other value then text
list($v, $t) = explode('|', $option);
$langValue = $langView . '_'
. FieldHelper::safe(
$t, true
);
// add to lang array
$this->language->set(
$this->config->lang_target, $langValue, $t
);
// now add to option set
$optionXML->addAttribute('value', $v);
$optionArray[$v] = $langValue;
}
else
{
// text is also the value
$langValue = $langView . '_'
. FieldHelper::safe(
$option, true
);
// add to lang array
$this->language->set(
$this->config->lang_target, $langValue, $option
);
// now add to option set
$optionXML->addAttribute('value', $option);
$optionArray[$option] = $langValue;
}
$optionXML[] = $langValue;
}
}
else
{
// one option
$optionXML = $field->fieldXML->addChild('option');
if (strpos((string) $value, '|') !== false)
{
// has other value then text
list($v, $t) = explode('|', (string) $value);
$langValue = $langView . '_'
. FieldHelper::safe(
$t, true
);
// add to lang array
$this->language->set($this->config->lang_target,
$langValue, $t);
// now add to option set
$optionXML->addAttribute('value', $v);
$optionArray[$v] = $langValue;
}
else
{
// text is also the value
$langValue = $langView . '_'
. FieldHelper::safe(
$value, true
);
// add to lang array
$this->language->set(
$this->config->lang_target, $langValue, $value
);
// now add to option set
$optionXML->addAttribute('value', $value);
$optionArray[$value] = $langValue;
}
$optionXML[] = $langValue;
}
}
}
// incase the field is in the config and has not been set (or is part of
a plugin or module)
if (('config' === $nameSingleCode
&& 'configs' === $nameListCode)
|| (strpos($nameSingleCode, 'pLuG!n') !== false
|| strpos(
$nameSingleCode, 'M0dUl3'
) !== false))
{
// set lang (just incase)
$listLangName = $langView . '_'
. StringHelper::safe($name, 'U');
// set the custom array
$data = array('type' => $typeName, 'code' =>
$name,
'lang' => $listLangName, 'custom' =>
$custom);
// set the custom field file
$this->customfieldtypefile->set(
$data, $nameListCode, $nameSingleCode
);
}
}
return $field;
}
}
src/Componentbuilder/Compiler/Creator/FieldsetDynamic.php000064400000005244151162054100017572
0ustar00<?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\Creator\FieldAsString;
use VDM\Joomla\Utilities\StringHelper;
use VDM\Joomla\Utilities\ArrayHelper;
/**
* Fieldset Dynamic Creator Class
*
* @since 3.2.0
*/
final class FieldsetDynamic
{
/**
* The FieldAsString Class.
*
* @var FieldAsString
* @since 3.2.0
*/
protected FieldAsString $fieldasstring;
/**
* Constructor.
*
* @param FieldAsString $fieldasstring The FieldAsString Class.
*
* @since 3.2.0
*/
public function __construct(FieldAsString $fieldasstring)
{
$this->fieldasstring = $fieldasstring;
}
/**
* build field set
*
* @param array $fields The fields data
* @param string $langView The language string of the view
* @param string $nameSingleCode The single view name
* @param string $nameListCode The list view name
* @param array $placeholders The placeholder and replace values
* @param string $dbkey The custom table key
* @param boolean $build The switch to set the build option
* @param int $return_type The return type 1 = string, 2 =
array
*
* @return mixed The complete field in string or array
* @since 3.2.0
*/
public function get(array &$fields, string &$langView, string
&$nameSingleCode,
string &$nameListCode, array &$placeholders, string &$dbkey,
bool $build = false,
int $returnType = 1)
{
// set some defaults
$view = [];
$view_type = 0;
// build the fieldset
if ($returnType == 1)
{
$fieldset = '';
}
else
{
$fieldset = [];
}
// loop over the fields to build
if (ArrayHelper::check($fields))
{
foreach ($fields as $field)
{
// get the field
$field_xml_string = $this->fieldasstring->get(
$field, $view, $view_type, $langView,
$nameSingleCode, $nameListCode,
$placeholders, $dbkey, $build
);
// make sure the xml is set and a string
if (StringHelper::check($field_xml_string))
{
if ($returnType == 1)
{
$fieldset .= $field_xml_string;
}
else
{
$fieldset[] = $field_xml_string;
}
}
}
}
return $fieldset;
}
}
src/Componentbuilder/Compiler/Creator/FieldsetExtension.php000064400000003674151162054100020167
0ustar00<?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\Placeholder;
use VDM\Joomla\Componentbuilder\Compiler\Creator\FieldsetDynamic;
/**
* Extension Fieldset Creator Class
*
* @since 5.0.2
*/
final class FieldsetExtension
{
/**
* The Placeholder Class.
*
* @var Placeholder
* @since 5.0.2
*/
protected Placeholder $placeholder;
/**
* The FieldsetDynamic Class.
*
* @var FieldsetDynamic
* @since 5.0.2
*/
protected FieldsetDynamic $fieldsetdynamic;
/**
* Constructor.
*
* @param Placeholder $placeholder The Placeholder Class.
* @param FieldsetDynamic $fieldsetdynamic The Fieldset Dynamic
Class.
*
* @since 5.0.2
*/
public function __construct(Placeholder $placeholder, FieldsetDynamic
$fieldsetdynamic)
{
$this->placeholder = $placeholder;
$this->fieldsetdynamic = $fieldsetdynamic;
}
/**
* build field set for an extention
*
* @param object $extension The extention object
* @param array $fields The fields to build
* @param string $dbkey The database key
*
* @return string The fields set in xml
*
* @since 5.0.2
*/
public function get(object $extension, array $fields, string $dbkey =
'zz'): string
{
// get global placeholders
$placeholder = $this->placeholder->get();
// build the fieldset
return $this->fieldsetdynamic->get(
$fields, $extension->lang_prefix, $extension->key,
$extension->key,
$placeholder, $dbkey
);
}
}
src/Componentbuilder/Compiler/Creator/FieldsetString.php000064400000052011151162054100017446
0ustar00<?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\Placeholder;
use VDM\Joomla\Componentbuilder\Compiler\Language\Fieldset as Language;
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\EventInterface as
Event;
use VDM\Joomla\Componentbuilder\Compiler\Adminview\Permission;
use VDM\Joomla\Componentbuilder\Compiler\Creator\FieldDynamic;
use VDM\Joomla\Componentbuilder\Compiler\Builder\FieldNames;
use VDM\Joomla\Componentbuilder\Compiler\Builder\AccessSwitch;
use VDM\Joomla\Componentbuilder\Compiler\Builder\MetaData;
use VDM\Joomla\Componentbuilder\Compiler\Creator\Layout;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Counter;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Indent;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Line;
use VDM\Joomla\Utilities\StringHelper;
use VDM\Joomla\Utilities\ArrayHelper;
use
VDM\Joomla\Componentbuilder\Compiler\Interfaces\Creator\Fieldsetinterface;
/**
* Fieldset String Creator Class
*
* @since 3.2.0
*/
final class FieldsetString implements Fieldsetinterface
{
/**
* 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 Fieldset Class.
*
* @var Language
* @since 3.2.0
*/
protected Language $language;
/**
* The EventInterface Class.
*
* @var Event
* @since 3.2.0
*/
protected Event $event;
/**
* The Permission Class.
*
* @var Permission
* @since 3.2.0
*/
protected Permission $permission;
/**
* The FieldDynamic Class.
*
* @var FieldDynamic
* @since 3.2.0
*/
protected FieldDynamic $fielddynamic;
/**
* The FieldNames Class.
*
* @var FieldNames
* @since 3.2.0
*/
protected FieldNames $fieldnames;
/**
* The AccessSwitch Class.
*
* @var AccessSwitch
* @since 3.2.0
*/
protected AccessSwitch $accessswitch;
/**
* The MetaData Class.
*
* @var MetaData
* @since 3.2.0
*/
protected MetaData $metadata;
/**
* The Layout Class.
*
* @var Layout
* @since 3.2.0
*/
protected Layout $layout;
/**
* The Counter Class.
*
* @var Counter
* @since 3.2.0
*/
protected Counter $counter;
/**
* Constructor.
*
* @param Config $config The Config Class.
* @param Placeholder $placeholder The Placeholder Class.
* @param Language $language The Fieldset Class.
* @param Event $event The EventInterface Class.
* @param Permission $permission The Permission Class.
* @param FieldDynamic $fielddynamic The FieldDynamic Class.
* @param FieldNames $fieldnames The FieldNames Class.
* @param AccessSwitch $accessswitch The AccessSwitch Class.
* @param MetaData $metadata The MetaData Class.
* @param Layout $layout The Layout Class.
* @param Counter $counter The Counter Class.
*
* @since 3.2.0
*/
public function __construct(Config $config, Placeholder $placeholder,
Language $language, Event $event, Permission $permission,
FieldDynamic $fielddynamic, FieldNames $fieldnames,
AccessSwitch $accessswitch, MetaData $metadata,
Layout $layout, Counter $counter)
{
$this->config = $config;
$this->placeholder = $placeholder;
$this->language = $language;
$this->event = $event;
$this->permission = $permission;
$this->fielddynamic = $fielddynamic;
$this->fieldnames = $fieldnames;
$this->accessswitch = $accessswitch;
$this->metadata = $metadata;
$this->layout = $layout;
$this->counter = $counter;
}
/**
* Get a fieldset
*
* @param array $view The view data
* @param string $component The component name
* @param string $nameSingleCode The single view name
* @param string $nameListCode The list view name
*
* @return string The fields set as a string or empty string if no field
found.
* @since 3.2.0
*/
public function get(array $view, string $component, string
$nameSingleCode,
string $nameListCode): string
{
// setup the fieldset language values of this view
if (!isset($view['settings']->fields)
|| !ArrayHelper::check($view['settings']->fields))
{
return '';
}
// add metadata to the view
$metadata = false;
if (isset($view['metadata']) &&
$view['metadata'])
{
$metadata = true;
}
// add access to the view
$access = false;
if (isset($view['access']) &&
$view['access'])
{
$access = true;
}
// main lang prefix
$lang_view = $this->config->lang_prefix . '_'
. $this->placeholder->get('VIEW');
$lang_views = $this->config->lang_prefix . '_'
. $this->placeholder->get('VIEWS');
$name_single = $view['settings']->name_single ??
'Error';
$name_list = $view['settings']->name_list ??
'Error';
$lang_target = $this->config->lang_target ?? 'both';
// load the language values
$this->language->set(
$access,
$metadata,
$lang_target,
$lang_view,
$lang_views,
$name_single,
$name_list,
$nameSingleCode,
$nameListCode
);
// set the read only
$read_only = false;
if ($view['settings']->type == 2)
{
$read_only = Indent::_(3) . 'readonly="true"' .
PHP_EOL . Indent::_(
3
) . 'disabled="true"';
}
// start adding dynamic fields
$dynamic_fields = '';
// set the custom table key
$dbkey = 'g';
// Trigger Event: jcb_ce_onBeforeBuildFields
$this->event->trigger(
'jcb_ce_onBeforeBuildFields',
[&$dynamic_fields, &$read_only,
&$dbkey, &$view, &$component, &$nameSingleCode,
&$nameListCode, &$lang_view,
&$lang_views]
);
// TODO we should add the global and local view switch if field for front
end
foreach ($view['settings']->fields as $field)
{
$dynamic_fields .= $this->fielddynamic->get(
$field, $view, $view['settings']->type, $lang_view,
$nameSingleCode, $nameListCode, $this->placeholder->active,
$dbkey,
true
);
}
// Trigger Event: jcb_ce_onAfterBuildFields
$this->event->trigger(
'jcb_ce_onAfterBuildFields',
[&$dynamic_fields, &$read_only,
&$dbkey, &$view, &$component, &$nameSingleCode,
&$nameListCode, &$lang_view,
&$lang_views]
);
// set the default fields
$field_set = array();
$field_set[] = '<fieldset name="details">';
$field_set[] = Indent::_(2) . "<!--" . Line::_(__Line__,
__Class__)
. " Default Fields. -->";
$field_set[] = Indent::_(2) . "<!--" . Line::_(__Line__,
__Class__)
. " Id Field. Type: Text (joomla) -->";
// if id is not set
if (!$this->fieldnames->isString($nameSingleCode .
'.id'))
{
$field_set[] = Indent::_(2) . "<field";
$field_set[] = Indent::_(3) . "name=" .
'"id"';
$field_set[] = Indent::_(3)
. 'type="text" class="readonly"
label="JGLOBAL_FIELD_ID_LABEL"';
$field_set[] = Indent::_(3)
. 'description ="JGLOBAL_FIELD_ID_DESC"
size="10" default="0"';
$field_set[] = Indent::_(3) . 'readonly="true"';
$field_set[] = Indent::_(2) . "/>";
// count the static field created
$this->counter->field++;
}
// if created is not set
if (!$this->fieldnames->isString($nameSingleCode .
'.created'))
{
$field_set[] = Indent::_(2) . "<!--" . Line::_(__Line__,
__Class__)
. " Date Created Field. Type: Calendar (joomla) -->";
$field_set[] = Indent::_(2) . "<field";
$field_set[] = Indent::_(3) . "name=" .
'"created"';
$field_set[] = Indent::_(3) . "type=" .
'"calendar"';
$field_set[] = Indent::_(3) . "label=" . '"' .
$lang_view
. '_CREATED_DATE_LABEL"';
$field_set[] = Indent::_(3) . "description=" .
'"' . $lang_view
. '_CREATED_DATE_DESC"';
$field_set[] = Indent::_(3) . "size=" .
'"22"';
if ($read_only)
{
$field_set[] = $read_only;
}
$field_set[] = Indent::_(3) . "format=" . '"%Y-%m-%d
%H:%M:%S"';
$field_set[] = Indent::_(3) . "filter=" .
'"user_utc"';
$field_set[] = Indent::_(2) . "/>";
// count the static field created
$this->counter->field++;
}
// if created_by is not set
if (!$this->fieldnames->isString($nameSingleCode .
'.created_by'))
{
$field_set[] = Indent::_(2) . "<!--" . Line::_(__Line__,
__Class__)
. " User Created Field. Type: User (joomla) -->";
$field_set[] = Indent::_(2) . "<field";
$field_set[] = Indent::_(3) . "name=" .
'"created_by"';
$field_set[] = Indent::_(3) . "type=" .
'"user"';
$field_set[] = Indent::_(3) . "label=" . '"' .
$lang_view
. '_CREATED_BY_LABEL"';
if ($read_only)
{
$field_set[] = $read_only;
}
$field_set[] = Indent::_(3) . "description=" .
'"' . $lang_view
. '_CREATED_BY_DESC"';
$field_set[] = Indent::_(2) . "/>";
// count the static field created
$this->counter->field++;
}
// if published is not set
if (!$this->fieldnames->isString($nameSingleCode .
'.published'))
{
$field_set[] = Indent::_(2) . "<!--" . Line::_(__Line__,
__Class__)
. " Published Field. Type: List (joomla) -->";
$field_set[] = Indent::_(2) . "<field name="
. '"published" type="list"
label="JSTATUS"';
$field_set[] = Indent::_(3) . "description="
. '"JFIELD_PUBLISHED_DESC"
class="chzn-color-state"';
if ($read_only)
{
$field_set[] = $read_only;
}
$field_set[] = Indent::_(3) . "filter="
. '"intval" size="1" default="1"
>';
$field_set[] = Indent::_(3) . "<option value=" .
'"1">';
$field_set[] = Indent::_(4) . "JPUBLISHED</option>";
$field_set[] = Indent::_(3) . "<option value=" .
'"0">';
$field_set[] = Indent::_(4) . "JUNPUBLISHED</option>";
$field_set[] = Indent::_(3) . "<option value=" .
'"2">';
$field_set[] = Indent::_(4) . "JARCHIVED</option>";
$field_set[] = Indent::_(3) . "<option value=" .
'"-2">';
$field_set[] = Indent::_(4) . "JTRASHED</option>";
$field_set[] = Indent::_(2) . "</field>";
// count the static field created
$this->counter->field++;
}
// if modified is not set
if (!$this->fieldnames->isString($nameSingleCode .
'.modified'))
{
$field_set[] = Indent::_(2) . "<!--" . Line::_(__Line__,
__Class__)
. " Date Modified Field. Type: Calendar (joomla) -->";
$field_set[] = Indent::_(2)
. '<field name="modified" type="calendar"
class="readonly"';
$field_set[] = Indent::_(3) . 'label="' . $lang_view
. '_MODIFIED_DATE_LABEL" description="' .
$lang_view
. '_MODIFIED_DATE_DESC"';
$field_set[] = Indent::_(3)
. 'size="22" readonly="true"
format="%Y-%m-%d %H:%M:%S" filter="user_utc"
/>';
// count the static field created
$this->counter->field++;
}
// if modified_by is not set
if (!$this->fieldnames->isString($nameSingleCode .
'.modified_by'))
{
$field_set[] = Indent::_(2) . "<!--" . Line::_(__Line__,
__Class__)
. " User Modified Field. Type: User (joomla) -->";
$field_set[] = Indent::_(2)
. '<field name="modified_by"
type="user"';
$field_set[] = Indent::_(3) . 'label="' . $lang_view
. '_MODIFIED_BY_LABEL"';
$field_set[] = Indent::_(3) . "description=" .
'"' . $lang_view
. '_MODIFIED_BY_DESC"';
$field_set[] = Indent::_(3) . 'class="readonly"';
$field_set[] = Indent::_(3) . 'readonly="true"';
$field_set[] = Indent::_(3) . 'filter="unset"';
$field_set[] = Indent::_(2) . "/>";
// count the static field created
$this->counter->field++;
}
// check if view has access
if ($this->accessswitch->exists($nameSingleCode)
&& !$this->fieldnames->isString($nameSingleCode .
'.access'))
{
$field_set[] = Indent::_(2) . "<!--" . Line::_(__Line__,
__Class__)
. " Access Field. Type: Accesslevel (joomla) -->";
$field_set[] = Indent::_(2) . '<field
name="access"';
$field_set[] = Indent::_(3) . 'type="accesslevel"';
$field_set[] = Indent::_(3) .
'label="JFIELD_ACCESS_LABEL"';
$field_set[] = Indent::_(3) .
'description="JFIELD_ACCESS_DESC"';
$field_set[] = Indent::_(3) . 'default="1"';
if ($read_only)
{
$field_set[] = $read_only;
}
$field_set[] = Indent::_(3) . 'required="false"';
$field_set[] = Indent::_(2) . "/>";
// count the static field created
$this->counter->field++;
}
// if ordering is not set
if (!$this->fieldnames->isString($nameSingleCode .
'.ordering'))
{
$field_set[] = Indent::_(2) . "<!--" . Line::_(__Line__,
__Class__)
. " Ordering Field. Type: Numbers (joomla) -->";
$field_set[] = Indent::_(2) . "<field";
$field_set[] = Indent::_(3) . 'name="ordering"';
$field_set[] = Indent::_(3) . 'type="number"';
$field_set[] = Indent::_(3) . 'class="inputbox
validate-ordering"';
$field_set[] = Indent::_(3) . 'label="' . $lang_view
. '_ORDERING_LABEL' . '"';
$field_set[] = Indent::_(3) . 'description=""';
$field_set[] = Indent::_(3) . 'default="0"';
$field_set[] = Indent::_(3) . 'size="6"';
if ($read_only)
{
$field_set[] = $read_only;
}
$field_set[] = Indent::_(3) . 'required="false"';
$field_set[] = Indent::_(2) . "/>";
// count the static field created
$this->counter->field++;
}
// if version is not set
if (!$this->fieldnames->isString($nameSingleCode .
'.version'))
{
$field_set[] = Indent::_(2) . "<!--" . Line::_(__Line__,
__Class__)
. " Version Field. Type: Text (joomla) -->";
$field_set[] = Indent::_(2) . "<field";
$field_set[] = Indent::_(3) . 'name="version"';
$field_set[] = Indent::_(3) . 'type="text"';
$field_set[] = Indent::_(3) . 'class="readonly"';
$field_set[] = Indent::_(3) . 'label="' . $lang_view
. '_VERSION_LABEL"';
$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) . "/>";
// count the static field created
$this->counter->field++;
}
// check if metadata is added to this view
if ($this->metadata->isString($nameSingleCode))
{
// metakey
if (!$this->fieldnames->isString($nameSingleCode .
'.metakey'))
{
$field_set[] = Indent::_(2) . "<!--" . Line::_(__Line__,
__Class__)
. " Metakey Field. Type: Textarea (joomla) -->";
$field_set[] = Indent::_(2) . "<field";
$field_set[] = Indent::_(3) . 'name="metakey"';
$field_set[] = Indent::_(3) . 'type="textarea"';
$field_set[] = Indent::_(3)
. 'label="JFIELD_META_KEYWORDS_LABEL"';
$field_set[] = Indent::_(3)
. 'description="JFIELD_META_KEYWORDS_DESC"';
$field_set[] = Indent::_(3) . 'rows="3"';
$field_set[] = Indent::_(3) . 'cols="30"';
$field_set[] = Indent::_(2) . "/>";
// count the static field created
$this->counter->field++;
}
// metadesc
if (!$this->fieldnames->isString($nameSingleCode .
'.metadesc'))
{
$field_set[] = Indent::_(2) . "<!--" . Line::_(__Line__,
__Class__)
. " Metadesc Field. Type: Textarea (joomla) -->";
$field_set[] = Indent::_(2) . "<field";
$field_set[] = Indent::_(3) . 'name="metadesc"';
$field_set[] = Indent::_(3) . 'type="textarea"';
$field_set[] = Indent::_(3)
. 'label="JFIELD_META_DESCRIPTION_LABEL"';
$field_set[] = Indent::_(3)
. 'description="JFIELD_META_DESCRIPTION_DESC"';
$field_set[] = Indent::_(3) . 'rows="3"';
$field_set[] = Indent::_(3) . 'cols="30"';
$field_set[] = Indent::_(2) . "/>";
// count the static field created
$this->counter->field++;
}
}
// fix the permissions field "title" issue gh-629
// check if the title is not already set
if (!$this->fieldnames->isString($nameSingleCode .
'.title')
&& $this->permission->check($view, $nameSingleCode))
{
// set the field/tab name
$field_name = "title";
$tab_name = "publishing";
$field_set[] = Indent::_(2) . "<!--" . Line::_(__Line__,
__Class__)
. " Was added due to Permissions JS needing a Title field
-->";
$field_set[] = Indent::_(2) . "<!--" . Line::_(__Line__,
__Class__)
. " Let us know at gh-629 should this change -->";
$field_set[] = Indent::_(2) . "<!--" . Line::_(__Line__,
__Class__)
. "
https://github.com/vdm-io/Joomla-Component-Builder/issues/629#issuecomment-750117235
-->";
// at this point we know that we must add a hidden title field
// and make sure it does not get stored to the database
$field_set[] = Indent::_(2) . "<field";
$field_set[] = Indent::_(3) . "name=" . '"' .
$field_name . '"';
$field_set[] = Indent::_(3)
. 'type="hidden"';
$field_set[] = Indent::_(3) . 'default="' . $component .
' '
. $nameSingleCode . '"';
$field_set[] = Indent::_(2) . "/>";
// count the static field created
$this->counter->field++;
// setup needed field values for layout
$field_array = array();
$field_array['order_edit'] = 0;
$field_array['tab'] = 15;
$field_array['alignment'] = 1;
// make sure it gets added to view
$this->layout->set(
$nameSingleCode, $tab_name, $field_name, $field_array
);
}
// load the dynamic fields now
if (StringHelper::check($dynamic_fields))
{
$field_set[] = Indent::_(2) . "<!--" . Line::_(__Line__,
__Class__)
. " Dynamic Fields. -->" . $dynamic_fields;
}
// close fieldset
$field_set[] = Indent::_(1) . "</fieldset>";
// check if metadata is added to this view
if ($this->metadata->isString($nameSingleCode))
{
if (!$this->fieldnames->isString($nameSingleCode .
'.robots')
|| !$this->fieldnames->isString($nameSingleCode .
'.rights')
|| !$this->fieldnames->isString($nameSingleCode .
'.author'))
{
$field_set[] = PHP_EOL . Indent::_(1) . "<!--" . Line::_(
__LINE__,__CLASS__
) . " Metadata Fields. -->";
$field_set[] = Indent::_(1) . "<fields"
. ' name="metadata"
label="JGLOBAL_FIELDSET_METADATA_OPTIONS">';
$field_set[] = Indent::_(2) . '<fieldset
name="vdmmetadata"';
$field_set[] = Indent::_(3)
.
'label="JGLOBAL_FIELDSET_METADATA_OPTIONS">';
// robots
if (!$this->fieldnames->isString($nameSingleCode .
'.robots'))
{
$field_set[] = Indent::_(3) . "<!--" . Line::_(
__LINE__,__CLASS__
) . " Robots Field. Type: List (joomla) -->";
$field_set[] = Indent::_(3) . '<field
name="robots"';
$field_set[] = Indent::_(4) . 'type="list"';
$field_set[] = Indent::_(4)
. 'label="JFIELD_METADATA_ROBOTS_LABEL"';
$field_set[] = Indent::_(4)
. 'description="JFIELD_METADATA_ROBOTS_DESC"
>';
$field_set[] = Indent::_(4)
. '<option
value="">JGLOBAL_USE_GLOBAL</option>';
$field_set[] = Indent::_(4)
. '<option value="index,
follow">JGLOBAL_INDEX_FOLLOW</option>';
$field_set[] = Indent::_(4)
. '<option value="noindex,
follow">JGLOBAL_NOINDEX_FOLLOW</option>';
$field_set[] = Indent::_(4)
. '<option value="index,
nofollow">JGLOBAL_INDEX_NOFOLLOW</option>';
$field_set[] = Indent::_(4)
. '<option value="noindex,
nofollow">JGLOBAL_NOINDEX_NOFOLLOW</option>';
$field_set[] = Indent::_(3) . '</field>';
// count the static field created
$this->counter->field++;
}
// author
if (!$this->fieldnames->isString($nameSingleCode .
'.author'))
{
$field_set[] = Indent::_(3) . "<!--" . Line::_(
__LINE__,__CLASS__
) . " Author Field. Type: Text (joomla) -->";
$field_set[] = Indent::_(3) . '<field
name="author"';
$field_set[] = Indent::_(4) . 'type="text"';
$field_set[] = Indent::_(4)
. 'label="JAUTHOR"
description="JFIELD_METADATA_AUTHOR_DESC"';
$field_set[] = Indent::_(4) . 'size="20"';
$field_set[] = Indent::_(3) . "/>";
// count the static field created
$this->counter->field++;
}
// rights
if (!$this->fieldnames->isString($nameSingleCode .
'.rights'))
{
$field_set[] = Indent::_(3) . "<!--" . Line::_(
__LINE__,__CLASS__
) . " Rights Field. Type: Textarea (joomla) -->";
$field_set[] = Indent::_(3)
. '<field name="rights" type="textarea"
label="JFIELD_META_RIGHTS_LABEL"';
$field_set[] = Indent::_(4)
. 'description="JFIELD_META_RIGHTS_DESC"
required="false" filter="string"';
$field_set[] = Indent::_(4) . 'cols="30"
rows="2"';
$field_set[] = Indent::_(3) . "/>";
// count the static field created
$this->counter->field++;
}
$field_set[] = Indent::_(2) . "</fieldset>";
$field_set[] = Indent::_(1) . "</fields>";
}
}
// return the set
return implode(PHP_EOL, $field_set);
}
}
src/Componentbuilder/Compiler/Creator/FieldsetXML.php000064400000050323151162054100016644
0ustar00<?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\Placeholder;
use VDM\Joomla\Componentbuilder\Compiler\Language\Fieldset as Language;
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\EventInterface as
Event;
use VDM\Joomla\Componentbuilder\Compiler\Adminview\Permission;
use VDM\Joomla\Componentbuilder\Compiler\Creator\FieldDynamic;
use VDM\Joomla\Componentbuilder\Compiler\Builder\FieldNames;
use VDM\Joomla\Componentbuilder\Compiler\Builder\AccessSwitch;
use VDM\Joomla\Componentbuilder\Compiler\Builder\MetaData;
use VDM\Joomla\Componentbuilder\Compiler\Creator\Layout;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Counter;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Xml;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Line;
use VDM\Joomla\Utilities\ArrayHelper;
use
VDM\Joomla\Componentbuilder\Compiler\Interfaces\Creator\Fieldsetinterface;
/**
* Fieldset XML Creator Class
*
* @since 3.2.0
*/
final class FieldsetXML implements Fieldsetinterface
{
/**
* 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 Fieldset Class.
*
* @var Language
* @since 3.2.0
*/
protected Language $language;
/**
* The EventInterface Class.
*
* @var Event
* @since 3.2.0
*/
protected Event $event;
/**
* The Permission Class.
*
* @var Permission
* @since 3.2.0
*/
protected Permission $permission;
/**
* The FieldDynamic Class.
*
* @var FieldDynamic
* @since 3.2.0
*/
protected FieldDynamic $fielddynamic;
/**
* The FieldNames Class.
*
* @var FieldNames
* @since 3.2.0
*/
protected FieldNames $fieldnames;
/**
* The AccessSwitch Class.
*
* @var AccessSwitch
* @since 3.2.0
*/
protected AccessSwitch $accessswitch;
/**
* The MetaData Class.
*
* @var MetaData
* @since 3.2.0
*/
protected MetaData $metadata;
/**
* The Layout Class.
*
* @var Layout
* @since 3.2.0
*/
protected Layout $layout;
/**
* The Counter Class.
*
* @var Counter
* @since 3.2.0
*/
protected Counter $counter;
/**
* The Xml Class.
*
* @var Xml
* @since 3.2.0
*/
protected Xml $xml;
/**
* Constructor.
*
* @param Config $config The Config Class.
* @param Placeholder $placeholder The Placeholder Class.
* @param Language $language The Fieldset Class.
* @param Event $event The EventInterface Class.
* @param Permission $permission The Permission Class.
* @param FieldDynamic $fielddynamic The FieldDynamic Class.
* @param FieldNames $fieldnames The FieldNames Class.
* @param AccessSwitch $accessswitch The AccessSwitch Class.
* @param MetaData $metadata The MetaData Class.
* @param Layout $layout The Layout Class.
* @param Counter $counter The Counter Class.
* @param Xml $xml The Xml Class.
*
* @since 3.2.0
*/
public function __construct(Config $config, Placeholder $placeholder,
Language $language, Event $event, Permission $permission,
FieldDynamic $fielddynamic, FieldNames $fieldnames,
AccessSwitch $accessswitch, MetaData $metadata,
Layout $layout, Counter $counter, Xml $xml)
{
$this->config = $config;
$this->placeholder = $placeholder;
$this->language = $language;
$this->event = $event;
$this->permission = $permission;
$this->fielddynamic = $fielddynamic;
$this->fieldnames = $fieldnames;
$this->accessswitch = $accessswitch;
$this->metadata = $metadata;
$this->layout = $layout;
$this->counter = $counter;
$this->xml = $xml;
}
/**
* Get a fieldset
*
* @param array $view The view data
* @param string $component The component name
* @param string $nameSingleCode The single view name
* @param string $nameListCode The list view name
*
* @return string The fields set as a string or empty string if no field
found.
* @since 3.2.0
*/
public function get(array $view, string $component, string
$nameSingleCode,
string $nameListCode): string
{
// setup the fieldset language values of this view
if (!isset($view['settings']->fields)
|| !ArrayHelper::check($view['settings']->fields))
{
return '';
}
// add metadata to the view
$metadata = false;
if (isset($view['metadata']) &&
$view['metadata'])
{
$metadata = true;
}
// add access to the view
$access = false;
if (isset($view['access']) &&
$view['access'])
{
$access = true;
}
// main lang prefix
$lang_view = $this->config->lang_prefix . '_'
. $this->placeholder->get('VIEW');
$lang_views = $this->config->lang_prefix . '_'
. $this->placeholder->get('VIEWS');
$name_single = $view['settings']->name_single ??
'Error';
$name_list = $view['settings']->name_list ??
'Error';
$lang_target = $this->config->lang_target ?? 'both';
// load the language values
$this->language->set(
$access,
$metadata,
$lang_target,
$lang_view,
$lang_views,
$name_single,
$name_list,
$nameSingleCode,
$nameListCode
);
// set the read only
$read_only_xml = [];
if ($view['settings']->type == 2)
{
$read_only_xml['readonly'] = true;
$read_only_xml['disabled'] = true;
}
// start adding dynamc fields
$dynamic_fields_xml = [];
// set the custom table key
$dbkey = 'g';
// Trigger Event: jcb_ce_onBeforeBuildFields
$this->event->trigger(
'jcb_ce_onBeforeBuildFields',
[&$dynamic_fields_xml, &$read_only_xml,
&$dbkey, &$view, &$component, &$nameSingleCode,
&$nameListCode, &$lang_view,
&$lang_views]
);
// TODO we should add the global and local view switch if field for front
end
foreach ($view['settings']->fields as $field)
{
$dynamic_fields_xml[] = $this->fielddynamic->get(
$field, $view, $view['settings']->type, $lang_view,
$nameSingleCode, $nameListCode, $this->placeholder->active,
$dbkey,
true
);
}
// Trigger Event: jcb_ce_onAfterBuildFields
$this->event->trigger(
'jcb_ce_onAfterBuildFields',
[&$dynamic_fields_xml, &$read_only_xml,
&$dbkey, &$view, &$component, &$nameSingleCode,
&$nameListCode, &$lang_view,
&$lang_views]
);
// set the default fields
$main_xml = new \simpleXMLElement('<a/>');
$field_set_xml = $main_xml->addChild('fieldset');
$field_set_xml->addAttribute('name', 'details');
$this->xml->comment(
$field_set_xml, Line::_(__Line__, __Class__) . " Default
Fields."
);
$this->xml->comment(
$field_set_xml,
Line::_(__Line__, __Class__) . " Id Field. Type: Text
(joomla)"
);
// if id is not set
if (!$this->fieldnames->isString($nameSingleCode .
'.id'))
{
$attributes = [
'name' => 'id',
'type' => 'text',
'class' => 'readonly',
'readonly' => "true",
'label' => 'JGLOBAL_FIELD_ID_LABEL',
'description' => 'JGLOBAL_FIELD_ID_DESC',
'size' => 10,
'default' => 0
];
$field_xml = $field_set_xml->addChild('field');
$this->xml->attributes($field_xml, $attributes);
// count the static field created
$this->counter->field++;
}
// if created is not set
if (!$this->fieldnames->isString($nameSingleCode .
'.created'))
{
$attributes = [
'name' => 'created',
'type' => 'calendar',
'label' => $lang_view .
'_CREATED_DATE_LABEL',
'description' => $lang_view .
'_CREATED_DATE_DESC',
'size' => 22,
'format' => '%Y-%m-%d %H:%M:%S',
'filter' => 'user_utc'
];
$attributes = array_merge($attributes, $read_only_xml);
$this->xml->comment(
$field_set_xml, Line::_(__Line__, __Class__)
. " Date Created Field. Type: Calendar (joomla)"
);
$field_xml = $field_set_xml->addChild('field');
$this->xml->attributes($field_xml, $attributes);
// count the static field created
$this->counter->field++;
}
// if created_by is not set
if (!$this->fieldnames->isString($nameSingleCode .
'.created_by'))
{
$attributes = [
'name' => 'created_by',
'type' => 'user',
'label' => $lang_view .
'_CREATED_BY_LABEL',
'description' => $lang_view .
'_CREATED_BY_DESC',
];
$attributes = array_merge($attributes, $read_only_xml);
$this->xml->comment(
$field_set_xml, Line::_(__Line__, __Class__)
. " User Created Field. Type: User (joomla)"
);
$field_xml = $field_set_xml->addChild('field');
$this->xml->attributes($field_xml, $attributes);
// count the static field created
$this->counter->field++;
}
// if published is not set
if (!$this->fieldnames->isString($nameSingleCode .
'.published'))
{
$attributes = [
'name' => 'published',
'type' => 'list',
'label' => 'JSTATUS'
];
$attributes = array_merge($attributes, $read_only_xml);
$this->xml->comment(
$field_set_xml, Line::_(__Line__, __Class__)
. " Published Field. Type: List (joomla)"
);
$field_xml = $field_set_xml->addChild('field');
$this->xml->attributes($field_xml, $attributes);
// count the static field created
$this->counter->field++;
foreach (['JPUBLISHED' => 1, 'JUNPUBLISHED' =>
0,
'JARCHIVED' => 2, 'JTRASHED' => -2] as
$text => $value
)
{
$optionXML = $field_xml->addChild('option');
$optionXML->addAttribute('value', $value);
$optionXML[] = $text;
}
}
// if modified is not set
if (!$this->fieldnames->isString($nameSingleCode .
'.modified'))
{
$attributes = [
'name' => 'modified',
'type' => 'calendar',
'class' => 'readonly',
'label' => $lang_view .
'_MODIFIED_DATE_LABEL',
'description' => $lang_view .
'_MODIFIED_DATE_DESC',
'size' => 22,
'readonly' => "true",
'format' => '%Y-%m-%d %H:%M:%S',
'filter' => 'user_utc'
];
$this->xml->comment(
$field_set_xml, Line::_(__Line__, __Class__)
. " Date Modified Field. Type: Calendar (joomla)"
);
$field_xml = $field_set_xml->addChild('field');
$this->xml->attributes($field_xml, $attributes);
// count the static field created
$this->counter->field++;
}
// if modified_by is not set
if (!$this->fieldnames->isString($nameSingleCode .
'.modified_by'))
{
$attributes = [
'name' => 'modified_by',
'type' => 'user',
'label' => $lang_view .
'_MODIFIED_BY_LABEL',
'description' => $lang_view .
'_MODIFIED_BY_DESC',
'class' => 'readonly',
'readonly' => 'true',
'filter' => 'unset'
];
$this->xml->comment(
$field_set_xml, Line::_(__Line__, __Class__)
. " User Modified Field. Type: User (joomla)"
);
$field_xml = $field_set_xml->addChild('field');
$this->xml->attributes($field_xml, $attributes);
// count the static field created
$this->counter->field++;
}
// check if view has access
if ($this->accessswitch->exists($nameSingleCode)
&& !$this->fieldnames->isString($nameSingleCode .
'.access'))
{
$attributes = [
'name' => 'access',
'type' => 'accesslevel',
'label' => 'JFIELD_ACCESS_LABEL',
'description' => 'JFIELD_ACCESS_DESC',
'default' => 1,
'required' => "false"
];
$attributes = array_merge($attributes, $read_only_xml);
$this->xml->comment(
$field_set_xml, Line::_(__Line__, __Class__)
. " Access Field. Type: Accesslevel (joomla)"
);
$field_xml = $field_set_xml->addChild('field');
$this->xml->attributes($field_xml, $attributes);
// count the static field created
$this->counter->field++;
}
// if ordering is not set
if (!$this->fieldnames->isString($nameSingleCode .
'.ordering'))
{
$attributes = [
'name' => 'ordering',
'type' => 'number',
'class' => 'inputbox validate-ordering',
'label' => $lang_view .
'_ORDERING_LABEL',
'description' => '',
'default' => 0,
'size' => 6,
'required' => "false"
];
$attributes = array_merge($attributes, $read_only_xml);
$this->xml->comment(
$field_set_xml, Line::_(__Line__, __Class__)
. " Ordering Field. Type: Numbers (joomla)"
);
$field_xml = $field_set_xml->addChild('field');
$this->xml->attributes($field_xml, $attributes);
// count the static field created
$this->counter->field++;
}
// if version is not set
if (!$this->fieldnames->isString($nameSingleCode .
'.version'))
{
$attributes = [
'name' => 'version',
'type' => 'text',
'class' => 'readonly',
'label' => $lang_view . '_VERSION_LABEL',
'description' => $lang_view . '_VERSION_DESC',
'size' => 6,
'default' => 1,
'readonly' => "true",
'filter' => 'unset'
];
$this->xml->comment(
$field_set_xml,
Line::_(__Line__, __Class__) . " Version Field. Type: Text
(joomla)"
);
$field_xml = $field_set_xml->addChild('field');
$this->xml->attributes($field_xml, $attributes);
// count the static field created
$this->counter->field++;
}
// check if metadata is added to this view
if ($this->metadata->isString($nameSingleCode))
{
// metakey
if (!$this->fieldnames->isString($nameSingleCode .
'.metakey'))
{
$attributes = [
'name' => 'metakey',
'type' => 'textarea',
'label' => 'JFIELD_META_KEYWORDS_LABEL',
'description' => 'JFIELD_META_KEYWORDS_DESC',
'rows' => 3,
'cols' => 30
];
$this->xml->comment(
$field_set_xml, Line::_(__Line__, __Class__)
. " Metakey Field. Type: Textarea (joomla)"
);
$field_xml = $field_set_xml->addChild('field');
$this->xml->attributes(
$field_xml, $attributes
);
// count the static field created
$this->counter->field++;
}
// metadesc
if (!$this->fieldnames->isString($nameSingleCode .
'.metadesc'))
{
$attributes['name'] = 'metadesc';
$attributes['label'] =
'JFIELD_META_DESCRIPTION_LABEL';
$attributes['description'] =
'JFIELD_META_DESCRIPTION_DESC';
$this->xml->comment(
$field_set_xml, Line::_(__Line__, __Class__)
. " Metadesc Field. Type: Textarea (joomla)"
);
$field_xml = $field_set_xml->addChild('field');
$this->xml->attributes(
$field_xml, $attributes
);
// count the static field created
$this->counter->field++;
}
}
// fix the permissions field "title" issue gh-629
// check if the title is not already set
if (!$this->fieldnames->isString($nameSingleCode .
'.title')
&& $this->permission->check($view, $nameSingleCode))
{
// set the field/tab name
$field_name = "title";
$tab_name = "publishing";
$attributes = [
'name' => $field_name,
'type' => 'hidden',
'default' => $component . ' ' . $nameSingleCode
];
$this->xml->comment(
$field_set_xml, Line::_(__Line__, __Class__)
. " Was added due to Permissions JS needing a Title field"
);
$this->xml->comment(
$field_set_xml, Line::_(__Line__, __Class__)
. " Let us know at gh-629 should this change"
);
$this->xml->comment(
$field_set_xml, Line::_(__Line__, __Class__)
. "
https://github.com/vdm-io/Joomla-Component-Builder/issues/629#issuecomment-750117235"
);
$field_xml = $field_set_xml->addChild('field');
$this->xml->attributes($field_xml, $attributes);
// count the static field created
$this->counter->field++;
// setup needed field values for layout
$field_array = [];
$field_array['order_edit'] = 0;
$field_array['tab'] = 15;
$field_array['alignment'] = 1;
// make sure it gets added to view
$this->layout->set(
$nameSingleCode, $tab_name, $field_name, $field_array
);
}
// load the dynamic fields now
if (count((array) $dynamic_fields_xml))
{
$this->xml->comment(
$field_set_xml, Line::_(__Line__, __Class__) . " Dynamic
Fields."
);
foreach ($dynamic_fields_xml as $dynamicfield)
{
$this->xml->append($field_set_xml, $dynamicfield);
}
}
// check if metadata is added to this view
if ($this->metadata->isString($nameSingleCode))
{
if (!$this->fieldnames->isString($nameSingleCode .
'.robots')
|| !$this->fieldnames->isString($nameSingleCode .
'.author')
|| !$this->fieldnames->isString($nameSingleCode .
'.rights'))
{
$this->xml->comment(
$field_set_xml, Line::_(__Line__, __Class__) . " Metadata
Fields"
);
$fields_xml = $field_set_xml->addChild('fields');
$fields_xml->addAttribute('name', 'metadata');
$fields_xml->addAttribute(
'label', 'JGLOBAL_FIELDSET_METADATA_OPTIONS'
);
$fields_field_set_xml =
$fields_xml->addChild('fieldset');
$fields_field_set_xml->addAttribute('name',
'vdmmetadata');
$fields_field_set_xml->addAttribute(
'label', 'JGLOBAL_FIELDSET_METADATA_OPTIONS'
);
// robots
if (!$this->fieldnames->isString($nameSingleCode .
'.robots'))
{
$this->xml->comment(
$fields_field_set_xml, Line::_(__Line__, __Class__)
. " Robots Field. Type: List (joomla)"
);
$robots = $fields_field_set_xml->addChild('field');
$attributes = [
'name' => 'robots',
'type' => 'list',
'label' =>
'JFIELD_METADATA_ROBOTS_LABEL',
'description' =>
'JFIELD_METADATA_ROBOTS_DESC'
];
$this->xml->attributes(
$robots, $attributes
);
// count the static field created
$this->counter->field++;
$options = [
'JGLOBAL_USE_GLOBAL' => '',
'JGLOBAL_INDEX_FOLLOW' => 'index,
follow',
'JGLOBAL_NOINDEX_FOLLOW' => 'noindex,
follow',
'JGLOBAL_INDEX_NOFOLLOW' => 'index,
nofollow',
'JGLOBAL_NOINDEX_NOFOLLOW' => 'noindex,
nofollow',
];
foreach ($options as $text => $value)
{
$option = $robots->addChild('option');
$option->addAttribute('value', $value);
$option[] = $text;
}
}
// author
if (!$this->fieldnames->isString($nameSingleCode .
'.author'))
{
$this->xml->comment(
$fields_field_set_xml, Line::_(__Line__, __Class__)
. " Author Field. Type: Text (joomla)"
);
$author = $fields_field_set_xml->addChild('field');
$attributes = [
'name' => 'author',
'type' => 'text',
'label' => 'JAUTHOR',
'description' =>
'JFIELD_METADATA_AUTHOR_DESC',
'size' => 20
];
$this->xml->attributes(
$author, $attributes
);
// count the static field created
$this->counter->field++;
}
// rights
if (!$this->fieldnames->isString($nameSingleCode .
'.rights'))
{
$this->xml->comment(
$fields_field_set_xml, Line::_(__Line__, __Class__)
. " Rights Field. Type: Textarea (joomla)"
);
$rights = $fields_field_set_xml->addChild('field');
$attributes = [
'name' => 'rights',
'type' => 'textarea',
'label' => 'JFIELD_META_RIGHTS_LABEL',
'description' => 'JFIELD_META_RIGHTS_DESC',
'required' => 'false',
'filter' => 'string',
'cols' => 30,
'rows' => 2
];
$this->xml->attributes(
$rights, $attributes
);
// count the static field created
$this->counter->field++;
}
}
}
// return the set
return $this->xml->pretty($main_xml, 'fieldset');
}
}
src/Componentbuilder/Compiler/Creator/Layout.php000064400000014621151162054100016002
0ustar00<?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\Builder\OrderZero;
use VDM\Joomla\Componentbuilder\Compiler\Builder\TabCounter;
use VDM\Joomla\Componentbuilder\Compiler\Builder\Layout as BuilderLayout;
use VDM\Joomla\Componentbuilder\Compiler\Builder\MovedPublishingFields;
use VDM\Joomla\Componentbuilder\Compiler\Builder\NewPublishingFields;
use VDM\Joomla\Utilities\StringHelper;
/**
* Layout Creator Class
*
* @since 3.2.0
*/
final class Layout
{
/**
* The Config Class.
*
* @var Config
* @since 3.2.0
*/
protected Config $config;
/**
* The OrderZero Class.
*
* @var OrderZero
* @since 3.2.0
*/
protected OrderZero $orderzero;
/**
* The TabCounter Class.
*
* @var TabCounter
* @since 3.2.0
*/
protected TabCounter $tabcounter;
/**
* The Builder Layout Class.
*
* @var BuilderLayout
* @since 3.2.0
*/
protected BuilderLayout $layout;
/**
* The MovedPublishingFields Class.
*
* @var MovedPublishingFields
* @since 3.2.0
*/
protected MovedPublishingFields $movedpublishingfields;
/**
* The NewPublishingFields Class.
*
* @var NewPublishingFields
* @since 3.2.0
*/
protected NewPublishingFields $newpublishingfields;
/**
* Constructor.
*
* @param Config $config The Config
Class.
* @param OrderZero $orderzero The OrderZero
Class.
* @param TabCounter $tabcounter The TabCounter
Class.
* @param BuilderLayout $layout The Layout
Class.
* @param MovedPublishingFields $movedpublishingfields The
MovedPublishingFields Class.
* @param NewPublishingFields $newpublishingfields The
NewPublishingFields Class.
*
* @since 3.2.0
*/
public function __construct(Config $config, OrderZero $orderzero,
TabCounter $tabcounter, BuilderLayout $layout,
MovedPublishingFields $movedpublishingfields,
NewPublishingFields $newpublishingfields)
{
$this->config = $config;
$this->orderzero = $orderzero;
$this->tabcounter = $tabcounter;
$this->layout = $layout;
$this->movedpublishingfields = $movedpublishingfields;
$this->newpublishingfields = $newpublishingfields;
}
/**
* set the layout builders
*
* @param string $nameSingleCode The single edit view code name
* @param string $tabName The tab code name
* @param string $name The field code name
* @param array $field The field details
*
* @return void
* @since 3.2.0
*/
public function set(string $nameSingleCode, string $tabName, string $name,
array &$field): void
{
// first fix the zero order
// to insure it lands before all the other fields
// as zero is expected to behave
if ($field['order_edit'] == 0)
{
// get the value
$zero_counter = $this->orderzero->get($nameSingleCode .
'.' . $field['tab'], -999);
if ($zero_counter != -999)
{
$zero_counter++;
}
$field['order_edit'] = $zero_counter;
// set the value
$this->orderzero->set($nameSingleCode . '.' .
$field['tab'], $zero_counter);
}
// get the default fields
$default_fields = $this->config->default_fields;
// now build the layout
if (StringHelper::check($tabName)
&& strtolower($tabName) != 'publishing')
{
$this->tabcounter->set($nameSingleCode . '.' .
$field['tab'], $tabName);
if ($this->layout->exists($nameSingleCode . '.' .
$tabName . '.'
. $field['alignment'] . '.' .
$field['order_edit']))
{
$size = $this->layout->count($nameSingleCode . '.' .
$tabName . '.'
. $field['alignment']) + 1;
while ($this->layout->exists($nameSingleCode . '.' .
$tabName . '.'
. $field['alignment'] . '.' . $size))
{
$size++;
}
$this->layout->set($nameSingleCode . '.' . $tabName .
'.'
. $field['alignment'] . '.' . $size, $name);
}
else
{
$this->layout->set($nameSingleCode . '.'
. $tabName . '.' . $field['alignment'] .
'.' . $field['order_edit'], $name);
}
// check if default fields were overwritten
if (in_array($name, $default_fields))
{
// just to eliminate
$this->movedpublishingfields->set($nameSingleCode . '.'
. $name, true);
}
}
elseif ($tabName === 'publishing' || $tabName ===
'Publishing')
{
if (!in_array($name, $default_fields))
{
if ($this->newpublishingfields->exists($nameSingleCode .
'.' .
$field['alignment'] . '.' .
$field['order_edit']))
{
$size = $this->newpublishingfields->count($nameSingleCode .
'.' .
$field['alignment']) + 1;
while ($this->newpublishingfields->exists($nameSingleCode .
'.' .
$field['alignment'] . '.' . $size))
{
$size++;
}
$this->newpublishingfields->set($nameSingleCode . '.'
.
$field['alignment'] . '.' . $size, $name);
}
else
{
$this->newpublishingfields->set($nameSingleCode . '.'
.
$field['alignment'] . '.' .
$field['order_edit'], $name);
}
}
}
else
{
$this->tabcounter->set($nameSingleCode . '.1',
'Details');
if ($this->layout->exists($nameSingleCode . '.Details.'
. $field['alignment'] . '.' .
$field['order_edit']))
{
$size = $this->layout->count($nameSingleCode .
'.Details.'
. $field['alignment']) + 1;
while ($this->layout->exists($nameSingleCode .
'.Details.'
. $field['alignment'] . '.' . $size))
{
$size++;
}
$this->layout->set($nameSingleCode . '.Details.'
. $field['alignment'] . '.' . $size, $name);
}
else
{
$this->layout->set($nameSingleCode . '.Details.' .
$field['alignment'] . '.'
. $field['order_edit'], $name);
}
// check if default fields were overwritten
if (in_array($name, $default_fields))
{
// just to eliminate
$this->movedpublishingfields->set($nameSingleCode . '.'
. $name, true);
}
}
}
}
src/Componentbuilder/Compiler/Creator/Permission.php000064400000045572151162054100016666
0ustar00<?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\Builder\PermissionCore;
use VDM\Joomla\Componentbuilder\Compiler\Builder\PermissionViews;
use VDM\Joomla\Componentbuilder\Compiler\Builder\PermissionAction;
use VDM\Joomla\Componentbuilder\Compiler\Builder\PermissionComponent;
use VDM\Joomla\Componentbuilder\Compiler\Builder\PermissionGlobalAction;
use VDM\Joomla\Componentbuilder\Compiler\Builder\PermissionDashboard;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Counter;
use VDM\Joomla\Componentbuilder\Compiler\Language;
use VDM\Joomla\Utilities\ArrayHelper;
use VDM\Joomla\Utilities\StringHelper;
/**
* Permission Creator Class
*
* @since 3.2.0
*/
final class Permission
{
/**
* The Config Class.
*
* @var Config
* @since 3.2.0
*/
protected Config $config;
/**
* The PermissionCore Class.
*
* @var PermissionCore
* @since 3.2.0
*/
protected PermissionCore $permissioncore;
/**
* The PermissionViews Class.
*
* @var PermissionViews
* @since 3.2.0
*/
protected PermissionViews $permissionviews;
/**
* The PermissionAction Class.
*
* @var PermissionAction
* @since 3.2.0
*/
protected PermissionAction $permissionaction;
/**
* The PermissionComponent Class.
*
* @var PermissionComponent
* @since 3.2.0
*/
protected PermissionComponent $permissioncomponent;
/**
* The PermissionGlobalAction Class.
*
* @var PermissionGlobalAction
* @since 3.2.0
*/
protected PermissionGlobalAction $permissionglobalaction;
/**
* The PermissionDashboard Class.
*
* @var PermissionDashboard
* @since 3.2.0
*/
protected PermissionDashboard $permissiondashboard;
/**
* The Counter Class.
*
* @var Counter
* @since 3.2.0
*/
protected Counter $counter;
/**
* The Language Class.
*
* @var Language
* @since 3.2.0
*/
protected Language $language;
/**
* The permissions
*
* @var array
* @since 3.2.0
*/
protected array $permissions;
/**
* The Name List View
*
* @var string
* @since 3.2.0
*/
protected string $nameList;
/**
* The Lowercase Name List View
*
* @var string
* @since 3.2.0
*/
protected string $nameListLower;
/**
* The Lowercase Name Single View
*
* @var string
* @since 3.2.0
*/
protected string $nameSingleLower;
/**
* Constructor.
*
* @param Config $config The Config
Class.
* @param PermissionCore $permissioncore The
PermissionCore Class.
* @param PermissionViews $permissionviews The
PermissionViews Class.
* @param PermissionAction $permissionaction The
PermissionAction Class.
* @param PermissionComponent $permissioncomponent The
PermissionComponent Class.
* @param PermissionGlobalAction $permissionglobalaction The
PermissionGlobalAction Class.
* @param PermissionDashboard $permissiondashboard The
PermissionDashboard Class.
* @param Counter $counter The Counter
Class.
* @param Language $language The Language
Class.
*
* @since 3.2.0
*/
public function __construct(Config $config, PermissionCore
$permissioncore, PermissionViews $permissionviews,
PermissionAction $permissionaction, PermissionComponent
$permissioncomponent, PermissionGlobalAction $permissionglobalaction,
PermissionDashboard $permissiondashboard, Counter $counter, Language
$language)
{
$this->config = $config;
$this->permissioncore = $permissioncore;
$this->permissionviews = $permissionviews;
$this->permissionaction = $permissionaction;
$this->permissioncomponent = $permissioncomponent;
$this->permissionglobalaction = $permissionglobalaction;
$this->permissiondashboard = $permissiondashboard;
$this->counter = $counter;
$this->language = $language;
}
/**
* Get the permission action
*
* @param string $nameView View Single Code Name
* @param string $action The Permission Action
*
* @return string|null The action name if set
* @since 3.2.0
*/
public function getAction(string $nameView, string $action): ?string
{
if (($set_action = $this->getCore($nameView, $action)) !== null
&&
$this->permissionaction->exists("{$set_action}|{$nameView}"))
{
return $set_action;
}
return $action;
}
/**
* Get the global permission action
*
* @param string $nameView View Single Code Name
* @param string $action The Permission Action
*
* @return string The action name if set
* @since 3.2.0
*/
public function getGlobal(string $nameView, string $action): string
{
if (($set_action = $this->getCore($nameView, $action)) !== null
&&
$this->permissionglobalaction->exists("{$set_action}|{$nameView}"))
{
return $set_action;
}
return $action;
}
/**
* Check if the permission action exist
*
* @param string $nameView View Single Code Name
* @param string $action The Permission Action
*
* @return bool true if it exist
* @since 3.2.0
*/
public function actionExist(string $nameView, string $action): bool
{
if (($set_action = $this->getCore($nameView, $action)) !== null
&&
$this->permissionaction->exists("{$set_action}|{$nameView}"))
{
return true;
}
return false;
}
/**
* Check if the global permission action exist
*
* @param string $nameView View Single Code Name
* @param string $action The Permission Action
*
* @return bool true if it exist
* @since 3.2.0
*/
public function globalExist(string $nameView, string $action): bool
{
if (($set_action = $this->getCore($nameView, $action)) !== null
&&
$this->permissionglobalaction->exists("{$set_action}|{$nameView}"))
{
return true;
}
return false;
}
/**
* Set the permissions
*
* @param array $view View details
* @param string $nameView View Single Code Name
* @param string $nameViews View List Code Name
* @param array $menuControllers Menu Controllers
* @param string $type Type of permissions area
*
* @return void
* @since 3.2.0
*/
public function set(array &$view, string $nameView, string $nameViews,
array $menuControllers, string $type = 'admin'): void
{
if ($this->initialise($view, $type))
{
$this->build($view, $nameView, $nameViews, $menuControllers, $type);
}
}
/**
* Build of permissions
*
* @param array $view View details
* @param string $nameView View Single Code Name
* @param string $nameViews View List Code Name
* @param array $menuControllers Menu Controllers
* @param string $type Type of permissions area
*
* @return void
* @since 3.2.0
*/
private function build(array &$view, string $nameView, string
$nameViews,
array $menuControllers, string $type = 'admin'): void
{
// load the permissions
foreach ($this->permissions as &$permission)
{
// set action name
$arr = explode('.', trim((string)
$permission['action']));
if ($arr[0] != 'core' || $arr[0] === 'view')
{
array_shift($arr);
$action_main = implode('.', $arr);
$action = $nameView . '.' . $action_main;
}
else
{
if ($arr[0] === 'core')
{
// core is already set in global access
$permission['implementation'] = 1;
}
$action = $permission['action'];
}
// build action name
$action_name_builder = explode('.', trim((string)
$permission['action']));
array_shift($action_name_builder);
$name_builder = trim(implode('___', $action_name_builder));
$custom_name = trim(implode(' ', $action_name_builder));
// check if we have access set for this view (if not skip)
if ($name_builder === 'edit___access' && $type ===
'admin'
&& (!isset($view['access']) ||
$view['access'] != 1))
{
continue;
}
// set the names
$this->setNames($view['settings'], $custom_name, $type);
// set title (only if not set already)
if (!isset($permission['title']) ||
!StringHelper::check($permission['title']))
{
$permission['title'] = $this->getTitle($name_builder,
$custom_name);
}
// set description (only if not set already)
if (!isset($permission['description']) ||
!StringHelper::check($permission['description']))
{
$permission['description'] =
$this->getDescription($name_builder, $custom_name);
}
// if core is not used update all core strings
$core_check = explode('.', (string) $action);
$core_check[0] = 'core';
$core_target = implode('.', $core_check);
$this->permissioncore->set("{$nameView}|{$core_target}",
$action);
// set array sort name
$sort_key = StringHelper::safe($permission['title']);
// set title
$title = $this->config->lang_prefix . '_' .
StringHelper::safe($permission['title'], 'U');
// load the actions
if ($permission['implementation'] == 1)
{
// only related to view
$this->permissionviews->set("{$nameView}|{$action}", [
'name' => $action,
'title' => $title,
'description' => "{$title}_DESC"
]);
// load permission to action
$this->permissionaction->set("{$action}|{$nameView}",
$nameView);
}
elseif ($permission['implementation'] == 2)
{
// relation to whole component
$this->permissioncomponent->set($sort_key, [
'name' => $action,
'title' => $title,
'description' => "{$title}_DESC"
]);
// the size needs increase
$this->counter->accessSize++;
// build permission switch
$this->permissionglobalaction->set("{$action}|{$nameView}",
$nameView);
// add menu control view that has menus options
$this->setDashboard($nameView, $nameViews, $menuControllers,
$action, $core_target);
}
elseif ($permission['implementation'] == 3)
{
// only related to view
$this->permissionviews->set("{$nameView}|{$action}", [
'name' => $action,
'title' => $title,
'description' => "{$title}_DESC"
]);
// load permission to action
$this->permissionaction->set("{$action}|{$nameView}",
$nameView);
// relation to whole component
$this->permissioncomponent->set($sort_key, [
'name' => $action,
'title' => $title,
'description' => "{$title}_DESC"
]);
// the size needs increase
$this->counter->accessSize++;
// build permission switch
$this->permissionglobalaction->set("{$action}|{$nameView}",
$nameView);
// add menu control view that has menus options
$this->setDashboard($nameView, $nameViews, $menuControllers,
$action, $core_target);
}
// set to language file
$this->language->set(
'bothadmin', $title, $permission['title']
);
$this->language->set(
'bothadmin', "{$title}_DESC",
$permission['description']
);
}
// update permissions
$view['settings']->permissions = $this->permissions;
}
/**
* Set dashboard permissions
*
* @param string $nameView View Single Code Name
* @param string $nameViews View List Code Name
* @param array $menuControllers Menu Controllers
* @param string $action The targeted action
* @param string $coreTarget The core target
*
* @return void
* @since 3.2.0
*/
private function setDashboard(string $nameView, string $nameViews,
array $menuControllers, string $action, string $coreTarget): void
{
// dashboard icon checker
if ($coreTarget === 'core.access')
{
$this->permissiondashboard->set(
"{$nameViews}.access", $action
);
$this->permissiondashboard->set(
"{$nameView}.access", $action
);
}
if ($coreTarget === 'core.create')
{
$this->permissiondashboard->set(
"{$nameView}.create", $action
);
}
// add menu control view that has menus options
foreach ($menuControllers as $menu_controller)
{
if ($coreTarget === 'core.' . $menu_controller)
{
if ($menu_controller === 'dashboard_add')
{
$this->permissiondashboard->set(
"{$nameView}.{$menu_controller}", $action
);
}
else
{
$this->permissiondashboard->set(
"{$nameViews}.{$menu_controller}", $action
);
}
}
}
}
/**
* Initialise build of permissions
*
* @param array $view View details
* @param string $type Type of permissions area
*
* @return bool true if build can continue
* @since 3.2.0
*/
private function initialise(array $view, string $type): bool
{
if (isset($view['settings']) &&
(isset($view['settings']->permissions)
&&
ArrayHelper::check($view['settings']->permissions)
|| (isset($view['port']) && $view['port'])
|| (isset($view['history']) &&
$view['history'])))
{
if (isset($view['settings']->permissions)
&&
ArrayHelper::check($view['settings']->permissions))
{
$this->permissions = $view['settings']->permissions;
}
else
{
$this->permissions = [];
}
$this->initPort($view['port'] ?? 0);
$this->initHistory($view['history'] ?? 0);
$this->initBatch($type);
return true;
}
return false;
}
/**
* Initialise build of import and export permissions
*
* @param int $port The port adding switch
*
* @return void
* @since 3.2.0
*/
private function initPort(int $port): void
{
if ($port)
{
// export
$add = [];
$add['action'] = 'view.export';
$add['implementation'] = '2';
array_push($this->permissions, $add);
// import
$add = [];
$add['action'] = 'view.import';
$add['implementation'] = '2';
array_push($this->permissions, $add);
}
}
/**
* Initialise build of history permissions
*
* @param int $history The history adding switch
*
* @return void
* @since 3.2.0
*/
private function initHistory(int $history): void
{
if ($history)
{
// export
$add = [];
$add['action'] = 'view.version';
$add['implementation'] = '3';
array_push($this->permissions, $add);
}
}
/**
* Initialise build of batch permissions
*
* @param string $type Type of permissions area
*
* @return void
* @since 3.2.0
*/
private function initBatch(string $type): void
{
// add batch permissions
if ($type === 'admin')
{
// set batch control
$add = [];
$add['action'] = 'view.batch';
$add['implementation'] = '2';
array_push($this->permissions, $add);
}
}
/**
* Initialise build of names used in permissions
*
* @param object $settings The view settings object
* @param string $customName The custom name
* @param string $type Type of permissions area
*
* @return void
* @since 3.2.0
*/
private function setNames(object $settings, string $customName, string
$type): void
{
// build the names
if ($type === 'admin')
{
$this->nameList = StringHelper::safe(
$settings->name_list, 'W'
);
$this->nameListLower = StringHelper::safe(
$customName . ' ' . $settings->name_list, 'w'
);
$this->nameSingleLower = StringHelper::safe(
$settings->name_single, 'w'
);
}
elseif ($type === 'customAdmin')
{
$this->nameList = StringHelper::safe(
$settings->name, 'W'
);
$this->nameListLower = $settings->name;
$this->nameSingleLower = $settings->name;
}
}
/**
* Get the dynamic title
*
* @param string $nameBuilder The target builder name
* @param string $customName The dynamic custom name
*
* @return string The title
* @since 3.2.0
*/
private function getTitle(string $nameBuilder, string $customName):
string
{
$actionTitles = [
'edit' => 'Edit',
'edit___own' => 'Edit Own',
'edit___access' => 'Edit Access',
'edit___state' => 'Edit State',
'edit___created_by' => 'Edit Created By',
'edit___created' => 'Edit Created Date',
'create' => 'Create',
'delete' => 'Delete',
'access' => 'Access',
'export' => 'Export',
'import' => 'Import',
'version' => 'Edit Version',
'batch' => 'Batch Use',
];
$titleSuffix = $actionTitles[$nameBuilder] ??
StringHelper::safe($customName, 'W');
return $this->nameList . ' ' . $titleSuffix;
}
/**
* Get the dynamic description
*
* @param string $nameBuilder The target builder name
* @param string $customName The dynamic custom name
*
* @return string The description
* @since 3.2.0
*/
private function getDescription(string $nameBuilder, string $customName):
string
{
$actionDescriptions = [
'edit' => 'edit the ' .
$this->nameSingleLower,
'edit___own' => 'edit ' .
$this->nameListLower . ' created by them',
'edit___access' => 'change the access of the
' . $this->nameListLower,
'edit___state' => 'update the state of the
' . $this->nameSingleLower,
'edit___created_by' => 'update the created by of the
' . $this->nameListLower,
'edit___created' => 'update the created date of
the ' . $this->nameListLower,
'create' => 'create ' .
$this->nameListLower,
'delete' => 'delete ' .
$this->nameListLower,
'access' => 'access ' .
$this->nameListLower,
'export' => 'export ' .
$this->nameListLower,
'import' => 'import ' .
$this->nameListLower,
'version' => 'edit versions of ' .
$this->nameListLower,
'batch' => 'use batch copy/update method
of ' . $this->nameListLower
];
$description = $actionDescriptions[$nameBuilder] ??
StringHelper::safe($customName, 'w') . ' of ' .
$this->nameSingleLower;
return ' Allows the users in this group to ' . $description;
}
/**
* Get the core permission action
*
* @param string $nameView View Single Code Name
* @param string $action The Permission Action
*
* @return string|null The action name if set
* @since 3.2.0
*/
private function getCore(string $nameView, string $action): ?string
{
return
$this->permissioncore->get("{$nameView}|{$action}");
}
}
src/Componentbuilder/Compiler/Creator/Request.php000064400000003467151162054100016163
0ustar00<?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);
}
}
src/Componentbuilder/Compiler/Creator/Router.php000064400000013475151162054100016013
0ustar00<?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);
}
}
src/Componentbuilder/Compiler/Creator/RouterConstructorDefault.php000064400000003570151162054100021561
0ustar00<?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 '';
}
}
src/Componentbuilder/Compiler/Creator/RouterConstructorManual.php000064400000003576151162054100021420
0ustar00<?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 '';
}
}
src/Componentbuilder/Compiler/Creator/RouterMethodsDefault.php000064400000011775151162054100020645
0ustar00<?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 '';
}
}
src/Componentbuilder/Compiler/Creator/RouterMethodsManual.php000064400000012007151162054100020463
0ustar00<?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 '';
}
}
src/Componentbuilder/Compiler/Creator/SiteFieldData.php000064400000007065151162054100017173
0ustar00<?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\Builder\SiteFields;
use VDM\Joomla\Componentbuilder\Compiler\Builder\SiteFieldData as
SiteField;
/**
* Site Field Data Creator Class
*
* @since 3.2.0
*/
final class SiteFieldData
{
/**
* The Config Class.
*
* @var Config
* @since 3.2.0
*/
protected Config $config;
/**
* The SiteFields Class.
*
* @var SiteFields
* @since 3.2.0
*/
protected SiteFields $sitefields;
/**
* The SiteFieldData Class.
*
* @var SiteField
* @since 3.2.0
*/
protected SiteField $sitefield;
/**
* The decoding options
*
* @var array
* @since 3.2.0
*/
protected array $decode = [
'json',
'base64',
'basic_encryption',
'whmcs_encryption',
'medium_encryption',
'expert_mode'
];
/**
* The text areas
*
* @var array
* @since 3.2.0
*/
protected array $textareas = [
'textarea',
'editor'
];
/**
* Constructor.
*
* @param Config $config The Config Class.
* @param SiteFields $sitefields The SiteFields Class.
* @param SiteField $sitefield The SiteFieldData Class.
*
* @since 3.2.0
*/
public function __construct(Config $config, SiteFields $sitefields,
SiteField $sitefield)
{
$this->config = $config;
$this->sitefields = $sitefields;
$this->sitefield = $sitefield;
}
/**
* set the site field data needed
*
* @param string $view The single edit view code name
* @param string $field The field name
* @param string $set The decoding set this field belongs to
* @param string $type The field type
*
* @return void
*
*/
public function set(string $view, string $field, string $set, string
$type): void
{
if (($site_fields = $this->sitefields->get($view . '.' .
$field)) !== null)
{
foreach ($site_fields as $codeString => $site_field)
{
// get the code array
$codeArray = explode('___', (string) $codeString);
// set the code
$code = trim($codeArray[0]);
// set the path
$path = $site_field['site'] . '.' . $code .
'.' . $site_field['as'] . '.' .
$site_field['key'];
// set the decoding methods
if (in_array($set, $this->decode))
{
if ($this->sitefield->exists('decode.' . $path .
'.decode'))
{
if (!$this->sitefield->inArray($set, 'decode.' .
$path . '.decode'))
{
$this->sitefield->add('decode.' . $path .
'.decode', $set, true);
}
}
else
{
$this->sitefield->set('decode.' . $path, [
'decode' => [$set],
'type' => $type,
'admin_view' => $view
]);
}
}
// set the uikit checker
if ((2 == $this->config->uikit || 1 ==
$this->config->uikit)
&& in_array($type, $this->textareas))
{
$this->sitefield->add('uikit.' . $path, (array)
$site_field, true);
}
// set the text area checker
if (in_array($type, $this->textareas))
{
$this->sitefield->add('textareas.' . $path, (array)
$site_field, true);
}
}
}
}
}
src/Componentbuilder/Compiler/Creator/index.html000064400000000054151162054100016004
0ustar00<html><body
bgcolor="#FFFFFF"></body></html>src/Componentbuilder/Compiler/Customcode.php000064400000041624151162054100015236
0ustar00<?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;
use Joomla\CMS\Factory;
use VDM\Joomla\Componentbuilder\Compiler\Factory as Compiler;
use VDM\Joomla\Componentbuilder\Compiler\Config;
use VDM\Joomla\Componentbuilder\Compiler\Placeholder;
use VDM\Joomla\Componentbuilder\Compiler\Language\Extractor;
use VDM\Joomla\Componentbuilder\Compiler\Power\Extractor as Power;
use VDM\Joomla\Componentbuilder\Compiler\JoomlaPower\Extractor as
JoomlaPower;
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;
/**
* Compiler Custom Code
*
* @since 3.2.0
*/
class Customcode implements CustomcodeInterface
{
/**
* The function name memory ids
*
* @var array
* @since 3.2.0
**/
public array $functionNameMemory = [];
/**
* The active custom code
*
* @var array
* @since 3.2.0
*/
public $active = [];
/**
* The custom code memory
*
* @var array
* @since 3.2.0
*/
public $memory = [];
/**
* The placeholders for custom code keys
*
* @var array
*/
protected $keys
= array(
'[' => '[',
']' => ']',
',' => ',',
'+' => '+',
'=' => '='
);
/**
* The custom code to be added
*
* @var array
* @since 3.2.0
*/
protected $data = [];
/**
* Compiler Config
*
* @var Config
* @since 3.2.0
**/
protected Config $config;
/**
* Compiler Placeholder
*
* @var Placeholder
* @since 3.2.0
**/
protected Placeholder $placeholder;
/**
* Compiler Language Extractor
*
* @var Extractor
* @since 3.2.0
**/
protected Extractor $extractor;
/**
* Super Power Extractor
*
* @var Power
* @since 3.2.0
**/
protected Power $power;
/**
* Joomla Power Extractor
*
* @var Power
* @since 3.2.0
**/
protected JoomlaPower $joomla;
/**
* Compiler Custom Code External
*
* @var External
* @since 3.2.0
**/
protected External $external;
/**
* Database object to query local DB
*
* @since 3.2.0
**/
protected $db;
/**
* Constructor.
*
* @param Config $config The compiler config object.
* @param Placeholder $placeholder The compiler placeholder
object.
* @param Extractor $extractor The compiler language
extractor object.
* @param Power $power The compiler power extractor
object.
* @param JoomlaPower $joomla The compiler joomla power
extractor object.
* @param External $external The compiler external custom
code object.
* @param \JDatabaseDriver $db The Database Driver object.
*
* @since 3.2.0
*/
public function __construct(Config $config, Placeholder $placeholder,
Extractor $extractor, Power $power, JoomlaPower $joomla, External
$external)
{
$this->config = $config;
$this->placeholder = $placeholder;
$this->extractor = $extractor;
$this->power = $power;
$this->joomla = $joomla;
$this->external = $external;
$this->db = Factory::getDbo();
}
/**
* Update **ALL** dynamic values in a strings here
*
* @param string $string The content to check
* @param int $debug The switch to debug the update
* We can now at any time debug the
* dynamic build values if it gets broken
*
* @return string
* @since 3.2.0
*/
public function update(string $string, int $debug = 0): string
{
if (StringHelper::check($string))
{
$string = $this->extractor->engine(
$this->set(
$this->external->set($string, $debug), $debug
)
);
// extract any found powers
$this->power->search($string);
$this->joomla->search($string);
}
// if debug
if ($debug)
{
jexit();
}
return $string;
}
/**
* Set the custom code data & can load it in to string
*
* @param string $string The content to check
* @param int $debug The switch to debug the update
* @param int|null $not The not switch
*
* @return string
* @since 3.2.0
*/
public function set(string $string, int $debug = 0, ?int $not = null):
string
{
// insure the code is loaded
$loaded = false;
// check if content has custom code place holder
if (strpos($string, '[CUSTO' . 'MCODE=') !== false)
{
// if debug
if ($debug)
{
echo 'Custom Code String:';
var_dump($string);
}
// the ids found in this content
$bucket = [];
$found = GetHelper::allBetween(
$string, '[CUSTO' . 'MCODE=', ']'
);
if (ArrayHelper::check($found))
{
foreach ($found as $key)
{
// if debug
if ($debug)
{
echo '$key before update:';
var_dump($key);
}
// check if we have args
if (is_numeric($key))
{
$id = (int) $key;
}
elseif (StringHelper::check($key)
&& strpos((string) $key, '+') === false)
{
$getFuncName = trim((string) $key);
if (!isset($this->functionNameMemory[$getFuncName]))
{
if (!$found_local = GetHelper::var(
'custom_code', $getFuncName, 'function_name',
'id'
))
{
continue;
}
$this->functionNameMemory[$getFuncName]
= $found_local;
}
$id = (int) $this->functionNameMemory[$getFuncName];
}
elseif (StringHelper::check($key)
&& strpos(
(string) $key, '+'
) !== false)
{
$array = explode('+', (string) $key);
// set ID
if (is_numeric($array[0]))
{
$id = (int) $array[0];
}
elseif (StringHelper::check($array[0]))
{
$getFuncName = trim($array[0]);
if (!isset($this->functionNameMemory[$getFuncName]))
{
if (!$found_local
= GetHelper::var(
'custom_code', $getFuncName,
'function_name', 'id'
))
{
continue;
}
$this->functionNameMemory[$getFuncName]
= $found_local;
}
$id = (int) $this->functionNameMemory[$getFuncName];
}
else
{
continue;
}
// load args for this ID
if (isset($array[1]))
{
if (!isset($this->data[$id]['args']))
{
$this->data[$id]['args'] = [];
}
// only load if not already loaded
if (!isset($this->data[$id]['args'][$key]))
{
if (strpos($array[1], ',') !== false)
{
// update the function values with the custom code key
placeholders (this allow the use of [] + and , in the values)
$this->data[$id]['args'][$key] = array_map(
fn($_key) => $this->placeholder->update(
$_key,
$this->keys
), (array) explode(',', $array[1])
);
}
elseif (StringHelper::check(
$array[1]
))
{
$this->data[$id]['args'][$key] = [];
// update the function values with the custom code key
placeholders (this allow the use of [] + and , in the values)
$this->data[$id]['args'][$key][]
= $this->placeholder->update(
$array[1],
$this->keys
);
}
}
}
}
else
{
continue;
}
// make sure to remove the not if set
if ($not && is_numeric($not) && $not > 0 &&
$not == $id)
{
continue;
}
$bucket[$id] = $id;
}
}
// if debug
if ($debug)
{
echo 'Bucket:';
var_dump($bucket);
}
// check if any custom code placeholders where found
if (ArrayHelper::check($bucket))
{
$_tmpLang = $this->config->lang_target;
// insure we add the langs to both site and admin
$this->config->lang_target = 'both';
// now load the code to memory
$loaded = $this->get($bucket, false, $debug);
// revert lang to current setting
$this->config->lang_target = $_tmpLang;
}
// if debug
if ($debug)
{
echo 'Loaded:';
var_dump($loaded);
}
// when the custom code is loaded
if ($loaded === true)
{
$string = $this->insert($bucket, $string, $debug);
}
// if debug
if ($debug)
{
echo 'Custom Code String After Update:';
var_dump($string);
}
}
return $string;
}
/**
* Load the custom code from the system
*
* @param array|null $ids The custom code ides if known
* @param bool $setLang The set lang switch
* @param int $debug The switch to debug the update
*
* @return bool
* @since 3.2.0
*/
public function get(?array $ids = null, bool $setLang = true, $debug = 0):
bool
{
// should the result be stored in memory
$loadInMemory = false;
// Create a new query object.
$query = $this->db->getQuery(true);
$query->from(
$this->db->quoteName('#__componentbuilder_custom_code',
'a')
);
if (ArrayHelper::check($ids))
{
if (($idArray = $this->check($ids)) !== false)
{
$query->select(
$this->db->quoteName(
array('a.id', 'a.code',
'a.comment_type')
)
);
$query->where(
$this->db->quoteName('a.id') . ' IN (' .
implode(
',', $idArray
) . ')'
);
$query->where(
$this->db->quoteName('a.target') . ' = 2'
); // <--- to load the correct target
$loadInMemory = true;
}
else
{
// all values are already in memory continue
return true;
}
}
else
{
$query->select(
$this->db->quoteName(
array('a.id', 'a.code',
'a.comment_type', 'a.component',
'a.from_line', 'a.hashtarget',
'a.hashendtarget',
'a.path', 'a.to_line', 'a.type')
)
);
$query->where(
$this->db->quoteName('a.component') . ' = '
. (int) $this->config->component_id
);
$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
// reset custom code
$this->active = [];
}
$query->where($this->db->quoteName('a.published') .
' >= 1');
$this->db->setQuery($query);
$this->db->execute();
if ($this->db->getNumRows())
{
$bucket = $this->db->loadAssocList('id');
// open the code
foreach ($bucket as $nr => &$customCode)
{
$customCode['code'] = base64_decode((string)
$customCode['code']);
// always insure that the external code is loaded
$customCode['code'] = $this->external->set(
$customCode['code']
);
// set the lang only if needed (we do the other later when we add it to
the correct position)
if ($setLang)
{
$customCode['code'] = $this->extractor->engine(
$customCode['code']
);
}
// check for more custom code (since this is a custom code
placeholder)
else
{
$customCode['code'] = $this->set(
$customCode['code'], $debug, $nr
);
}
// build the hash array
if (isset($customCode['hashtarget']))
{
$customCode['hashtarget'] = explode(
"__", (string) $customCode['hashtarget']
);
// is this a replace code, set end has array
if ($customCode['type'] == 1
&& strpos((string) $customCode['hashendtarget'],
'__') !== false)
{
$customCode['hashendtarget'] = explode(
"__", (string) $customCode['hashendtarget']
);
// NOW see if this is an end of page target (TODO not sure if the
string is always d41d8cd98f00b204e9800998ecf8427e)
// I know this fix is not air-tight, but it should work as the value
of an empty line when md5'ed is ^^^^
// Then if the line number is only >>>one<<< it is
almost always end of the page.
// So I am using those two values to detect end of page replace
ending, to avoid mismatching the ending target hash.
if ($customCode['hashendtarget'][0] == 1
&& 'd41d8cd98f00b204e9800998ecf8427e' ===
$customCode['hashendtarget'][1])
{
// unset since this will force the replacement unto end of page.
unset($customCode['hashendtarget']);
}
}
}
}
// load this code into memory if needed
if ($loadInMemory === true)
{
$this->memory = $this->memory + $bucket;
}
// add to active set
$this->active = array_merge($this->active, $bucket);
return true;
}
return false;
}
/**
* Insert the custom code into the string
*
* @param array|null $ids The custom code ides if known
* @param string $string The string to insert custom code
into
* @param int $debug The switch to debug the update
*
* @return string on success
* @since 3.2.0
*/
protected function insert(array $ids, string $string, int $debug = 0):
string
{
$code = [];
// load the code
foreach ($ids as $id)
{
$this->buildPlaceholders(
$this->memory[$id], $code, $debug
);
}
// if debug
if ($debug)
{
echo 'Place holders to Update String:';
var_dump($code);
echo 'Custom Code String Before Update:';
var_dump($string);
}
// now update the string
return $this->placeholder->update($string, $code);
}
/**
* Build custom code placeholders
*
* @param array $item The memory item
* @param array $code The custom code bucket
* @param int $debug The switch to debug the update
*
* @return void
* @since 3.2.0
*/
protected function buildPlaceholders(array $item, array &$code, int
$debug = 0)
{
// check if there is args for this code
if (isset($this->data[$item['id']]['args'])
&& ArrayHelper::check(
$this->data[$item['id']]['args']
))
{
// since we have args we cant update this code via IDE (TODO)
$placeholder = $this->placeholder->keys(3, null);
// if debug
if ($debug)
{
echo 'Custom Code Placeholders:';
var_dump($placeholder);
}
// we have args and so need to load each
foreach (
$this->data[$item['id']]['args'] as $key =>
$args
)
{
$this->placeholder->setType('arg', $args);
// if debug
if ($debug)
{
echo 'Custom Code Global Placeholders:';
var_dump($this->placeholder->active);
}
$code['[CUSTOM' . 'CODE=' . $key . ']'] =
$placeholder['start']
. PHP_EOL . $this->placeholder->update_(
$item['code']
) . $placeholder['end'];
}
// always clear the args
$this->placeholder->clearType('arg');
}
else
{
if (($keyPlaceholder = array_search(
$item['id'], $this->functionNameMemory
)) === false)
{
$keyPlaceholder = $item['id'];
}
// check what type of place holders we should load here
$placeholderType = (int) $item['comment_type'] .
'2';
if (stripos((string) $item['code'], Placefix::b() .
'view') !== false
|| stripos((string) $item['code'], Placefix::b() .
'sview') !== false
|| stripos((string) $item['code'], Placefix::b() .
'arg') !== false)
{
// if view is being set dynamicly then we can't update this code
via IDE (TODO)
$placeholderType = 3;
}
// if now ars were found, clear it
$this->placeholder->clearType('arg');
// load args for this code
$placeholder = $this->placeholder->keys(
$placeholderType, $item['id']
);
$code['[CUSTOM' . 'CODE=' . $keyPlaceholder .
']']
= $placeholder['start'] . PHP_EOL
. $this->placeholder->update_(
$item['code']
) . $placeholder['end'];
}
}
/**
* check if we already have these ids in local memory
*
* @param array $ids The custom code ids
*
* @return Mixed
* @since 3.2.0
*/
protected function check(array $ids)
{
// reset custom code
$this->active = [];
foreach ($ids as $pointer => $id)
{
if (isset($this->memory[$id]))
{
$this->active[] = $this->memory[$id];
unset($ids[$pointer]);
}
}
// check if any ids left to fetch
if (ArrayHelper::check($ids))
{
return $ids;
}
return false;
}
}
src/Componentbuilder/Compiler/Customcode/Dispenser.php000064400000017636151162054100017200
0ustar00<?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\Customcode;
use VDM\Joomla\Componentbuilder\Compiler\Placeholder;
use VDM\Joomla\Componentbuilder\Compiler\Customcode;
use VDM\Joomla\Componentbuilder\Compiler\Customcode\Gui;
use VDM\Joomla\Componentbuilder\Compiler\Customcode\Hash;
use VDM\Joomla\Componentbuilder\Compiler\Customcode\LockBase;
use VDM\Joomla\Utilities\StringHelper;
use
VDM\Joomla\Componentbuilder\Compiler\Interfaces\Customcode\DispenserInterface;
/**
* Compiler Custom Code Dispenser
*
* @since 3.2.0
*/
class Dispenser implements DispenserInterface
{
/**
* Customcode Dispenser Hub
*
* @var array
* @since 3.2.0
**/
public array $hub;
/**
* Compiler Placeholder
*
* @var Placeholder
* @since 3.2.0
**/
protected Placeholder $placeholder;
/**
* Compiler Customcode
*
* @var Customcode
* @since 3.2.0
**/
protected Customcode $customcode;
/**
* Compiler Customcode in Gui
*
* @var Gui
* @since 3.2.0
**/
protected Gui $gui;
/**
* Compiler Customcode to Hash
*
* @var Hash
* @since 3.2.0
**/
protected Hash $hash;
/**
* Compiler Customcode to LockBase
*
* @var LockBase
* @since 3.2.0
**/
protected LockBase $base64;
/**
* Constructor.
*
* @param Placeholder $placeholder The Placeholder Class.
* @param Customcode $customcode The Customcode Class.
* @param Gui $gui The Gui Class.
* @param Hash $hash The Hash Class.
* @param LockBase $lockbase The LockBase Class.
*
* @since 3.2.0
*/
public function __construct(Placeholder $placeholder, Customcode
$customcode, Gui $gui,
Hash $hash, LockBase $lockbase)
{
$this->placeholder = $placeholder;
$this->customcode = $customcode;
$this->gui = $gui;
$this->hash = $hash;
$this->base64 = $lockbase;
}
/**
* Set the script for the customcode dispenser
*
* @param string $script The script
* @param string $first The first key
* @param string|null $second The second key (if not set we use only
first key)
* @param string|null $third The third key (if not set we use only
first and second key)
* @param array $config The config options
* @param bool $base64 The switch to decode base64 the script
* default: true
* @param bool $dynamic The switch to dynamic update the
script
* default: true
* @param bool $add The switch to add to exiting instead of
replace
* default: false
*
* @return bool true on success
* @since 3.2.0
*/
public function set(&$script, string $first, ?string $second = null,
?string $third = null,
array $config = [], bool $base64 = true, bool $dynamic = true, bool $add
= false): bool
{
// only load if we have a string
if (!StringHelper::check($script))
{
return false;
}
// init all needed arrays
$this->initHub($first, $second, $third, $add);
// prep the script string
if ($base64 && $dynamic)
{
$script = $this->customcode->update(base64_decode($script));
}
elseif ($base64)
{
$script = base64_decode($script);
}
elseif ($dynamic) // this does not happen (just in-case)
{
$script = $this->customcode->update($script);
}
// check if we still have a string
if (StringHelper::check($script))
{
// now load the placeholder snippet if needed
if ($base64 || $dynamic)
{
$script = $this->gui->set($script, $config);
}
// add Dynamic HASHING option of a file/string
$script = $this->hash->set($script);
// add base64 locking option of a string
$script = $this->base64->set($script);
// load the script
$this->setHub($script, $first, $second, $third, $add);
return true;
}
return false;
}
/**
* Get the script from the customcode dispenser
*
* @param string $first The first key
* @param string $second The second key
* @param string $prefix The prefix to add in front of the script
if found
* @param string|null $note The switch/note to add to the script
* @param bool $unset The switch to unset the value if found
* @param mixed|null $default The switch/string to use as default
return if script not found
* @param string $suffix The suffix to add after the script if
found
*
* @return mixed The string/script if found or the default value if not
found
* @since 3.2.0
*/
public function get(string $first, string $second, string $prefix =
'', ?string $note = null,
bool $unset = false, $default = null, string $suffix =
'')
{
// default is to return an empty string
$script = '';
// check if there is any custom script
if (isset($this->hub[$first][$second])
&& StringHelper::check(
$this->hub[$first][$second]
))
{
// add not if set
if ($note)
{
$script .= $note;
}
// load the actual script
$script .= $prefix . $this->placeholder->update_(
(string) $this->hub[$first][$second]
) . $suffix;
// clear some memory
if ($unset)
{
unset($this->hub[$first][$second]);
}
}
// if not found return default
if (!StringHelper::check($script) && $default)
{
return $default;
}
return $script;
}
/**
* Make sure the hub arrays are all set
*
* @param string $first The first key
* @param string|null $second The second key (if not set we use only
first key)
* @param string|null $third The third key (if not set we use only
first and second key)
* @param bool $add The switch to add to exiting instead of
replace
* default: false
*
* @return void
* @since 3.2.0
*/
protected function initHub(string $first, ?string $second = null, ?string
$third = null, bool $add = false)
{
if (!isset($this->hub[$first]))
{
$this->hub[$first] = ($second !== null || $add) ? ($second !== null ?
[] : '') : [];
}
if ($second !== null && !isset($this->hub[$first][$second]))
{
$this->hub[$first][$second] = ($third !== null || $add) ? ($third !==
null ? [] : '') : [];
}
if ($third !== null &&
!isset($this->hub[$first][$second][$third]))
{
$this->hub[$first][$second][$third] = $add ? '' : [];
}
}
/**
* Set a script in the hub
*
* @param string $script The script
* @param string $first The first key
* @param string|null $second The second key (if not set we use only
first key)
* @param string|null $third The third key (if not set we use only
first and second key)
* @param bool $add The switch to add to exiting instead of
replace
* default: false
*
* @return void
* @since 3.2.0
*/
protected function setHub(string $script, string $first, ?string $second =
null, ?string $third = null, bool $add = false)
{
// Load the script
if ($second !== null)
{
if ($third !== null)
{
$this->hub[$first][$second][$third] =
$add ? $this->hub[$first][$second][$third] . $script : $script;
}
else
{
$this->hub[$first][$second] =
$add ? $this->hub[$first][$second] . $script : $script;
}
}
else
{
$this->hub[$first] =
$add ? $this->hub[$first] . $script : $script;
}
}
}
src/Componentbuilder/Compiler/Customcode/External.php000064400000026635151162054130017030
0ustar00<?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\Customcode;
use Joomla\CMS\Factory;
use Joomla\CMS\User\User;
use Joomla\CMS\Application\CMSApplication;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Filesystem\Path;
use VDM\Joomla\Utilities\ArrayHelper;
use VDM\Joomla\Utilities\StringHelper;
use VDM\Joomla\Utilities\GetHelper;
use VDM\Joomla\Utilities\FileHelper;
use VDM\Joomla\Componentbuilder\Compiler\Factory as Compiler;
use VDM\Joomla\Componentbuilder\Compiler\Placeholder;
use
VDM\Joomla\Componentbuilder\Compiler\Interfaces\Customcode\ExternalInterface;
/**
* Compiler External Custom Code
*
* @since 3.2.0
*/
class External implements ExternalInterface
{
/**
* The external code/string to be added
*
* @var array
* @since 3.2.0
*/
protected array $code = [];
/**
* The external code/string cutter
*
* @var array
* @since 3.2.0
*/
protected array $cutter = [];
/**
* Compiler Placeholder
*
* @var Placeholder
* @since 3.2.0
**/
protected Placeholder $placeholder;
/**
* Database object to query local DB
*
* @since 3.2.0
**/
protected $db;
/**
* User object
*
* @since 3.2.0
**/
protected $user;
/**
* Database object to query local DB
*
* @since 3.2.0
**/
protected $app;
/**
* Constructor.
*
* @param Placeholder|null $placeholder The compiler placeholder
object.
*
* @throws \Exception
* @since 3.2.0
*/
public function __construct(?Placeholder $placeholder = null)
{
$this->placeholder = $placeholder ?:
Compiler::_('Placeholder');
$this->db = Factory::getDbo();
$this->user = Factory::getUser();
$this->app = Factory::getApplication();
}
/**
* Set the external code string & load it in to string
*
* @param string $string The content to check
* @param int $debug The switch to debug the update
*
* @return string
* @since 3.2.0
*/
public function set(string $string, int $debug = 0): string
{
// check if content has custom code placeholder
if (strpos($string, '[EXTERNA' . 'LCODE=') !==
false)
{
// if debug
if ($debug)
{
echo 'External Code String:';
var_dump($string);
}
// target content
$bucket = [];
$found = GetHelper::allBetween(
$string, '[EXTERNA' . 'LCODE=', ']'
);
if (ArrayHelper::check($found))
{
// build local bucket
foreach ($found as $target)
{
// check for cutting sequence
// example: >{3|4
// will cut 3 rows at top and 4 rows at bottom
// if the external code has 8 or more lines
if (($pos = strpos((string) $target, '>{')) !== false)
{
// the length
$target_len = strlen((string) $target);
// where to cut
$cutting = $target_len - $pos;
// get the sequence
$sequence = substr((string) $target, "-$cutting");
// remove from the URL
$target_url = str_replace($sequence, '', (string)
$target);
// set the cut key for this target if not set
$this->cutter[trim((string) $target)] =
str_replace('>{', '', $sequence);
}
else
{
$target_url = $target;
}
// check if the target is valid URL or path
if ((!filter_var($target_url, FILTER_VALIDATE_URL) === false
&& FileHelper::exists($target_url))
|| (Path::clean($target_url) === $target_url
&& FileHelper::exists($target_url)))
{
$this->getCode($target, $bucket);
}
// give notice that target is not a valid url/path
else
{
// set key
$key = '[EXTERNA' . 'LCODE=' . $target .
']';
// set the notice
$this->app->enqueueMessage(
Text::_('COM_COMPONENTBUILDER_HR_HTHREEEXTERNAL_CODE_WARNINGHTHREE'
), 'Warning'
);
$this->app->enqueueMessage(
Text::sprintf('COM_COMPONENTBUILDER_THE_BSB_IS_NOT_A_VALID_URLPATH',
$key
), 'Warning'
);
// remove the placeholder
$bucket[$key] = '';
}
}
// now update local string if bucket has values
if (ArrayHelper::check($bucket))
{
$string = $this->placeholder->update($string, $bucket);
}
}
// if debug
if ($debug)
{
echo 'External Code String After Update:';
var_dump($string);
}
}
return $string;
}
/**
* Get the External Code/String
*
* @param string $string The content to check
* @param array $bucket The Placeholders bucket
*
* @return void
* @since 3.2.0
*/
protected function getCode(string $target, array &$bucket)
{
// set URL key
$target_key = trim($target);
// set key
$key = '[EXTERNA' . 'LCODE=' . $target .
']';
// remove the cut sequence from the url
if (isset($this->cutter[$target_key]))
{
// remove from the URL
$target_url = trim(str_replace('>{' .
$this->cutter[$target_key], '', $target));
}
else
{
$target_url = trim($target);
}
// check if we already fetched this
if (!isset($this->code[$target_key]))
{
// get the data string (code)
$this->code[$target_key]
= FileHelper::getContent($target_url);
// check if we must cut this
if (isset($this->cutter[$target_key]) &&
$this->cutter[$target_key])
{
$this->code[$target_key] = $this->cut(
$this->code[$target_key],
$this->cutter[$target_key],
$key
);
}
// did we get any value
if (StringHelper::check(
$this->code[$target_key]
))
{
// check for changes
$live_hash = md5($this->code[$target_key]);
// check if it exists local
if ($hash = GetHelper::var(
'external_code', $target_key, 'target',
'hash'
))
{
// must be an admin make a change to use EXTERNAL code (we may add a
custom access switch - use ADMIN for now)
if ($hash !== $live_hash && $this->user->authorise(
'core.admin', 'com_componentbuilder'
))
{
// update the hash since it changed
$object = new \stdClass();
$object->target = $target_key;
$object->hash = $live_hash;
// update local hash
$this->db->updateObject(
'#__componentbuilder_external_code', $object,
'target'
);
// give notice of the change
$this->app->enqueueMessage(
Text::_('COM_COMPONENTBUILDER_HR_HTHREEEXTERNAL_CODE_WARNINGHTHREE'),
'Warning'
);
$this->app->enqueueMessage(
Text::sprintf('COM_COMPONENTBUILDER_THE_CODESTRING_FROM_BSB_HAS_BEEN_BCHANGEDB_SINCE_THE_LAST_COMPILATION_PLEASE_INVESTIGATE_TO_ENSURE_THE_CHANGES_ARE_SAFE_BSHOULD_YOU_NOT_EXPECT_THIS_CHANGE_TO_THE_EXTERNAL_CODESTRING_BEING_ADDED_THEN_THIS_IS_A_SERIOUS_ISSUE_AND_REQUIRES_IMMEDIATE_ATTENTIONB_DO_NOT_IGNORE_THIS_WARNING_AS_IT_WILL_ONLY_SHOW_BONCEB',
$key
), 'Warning'
);
}
elseif ($hash !== $live_hash)
{
// set the notice
$this->app->enqueueMessage(
Text::_('COM_COMPONENTBUILDER_HR_HTHREEEXTERNAL_CODE_ERRORHTHREE'),
'Error'
);
$this->app->enqueueMessage(
Text::sprintf('COM_COMPONENTBUILDER_S_WE_DETECTED_A_CHANGE_IN_BEXTERNALCODEB_BUT_YOU_DO_NOT_HAVE_PERMISSION_TO_ALLOW_THIS_CHANGE_SO_BSB_WAS_REMOVED_FROM_THE_COMPILATION_PLEASE_CONTACT_YOUR_SYSTEM_ADMINISTRATOR_FOR_MORE_INFOBR_SMALLADMIN_ACCESS_REQUIREDSMALL',
$this->user->get('name'), $key
), 'Error'
);
// remove the code/string
$this->code[$target_key] = '';
}
}
// only an admin can add new EXTERNAL code (we may add a custom access
switch - use ADMIN for now)
elseif ($this->user->authorise(
'core.admin', 'com_componentbuilder'
))
{
// add the hash to track changes
$object = new \stdClass();
$object->target = $target_key;
$object->hash = $live_hash;
// insert local hash
$this->db->insertObject(
'#__componentbuilder_external_code', $object
);
// give notice the first time this is added
$this->app->enqueueMessage(
Text::_('COM_COMPONENTBUILDER_HR_HTHREEEXTERNAL_CODE_NOTICEHTHREE'),
'Warning'
);
$this->app->enqueueMessage(
Text::sprintf('COM_COMPONENTBUILDER_THE_CODESTRING_FROM_BSB_HAS_BEEN_ADDED_FOR_THE_BFIRST_TIMEB_PLEASE_IINVESTIGATEI_TO_ENSURE_THE_CORRECT_CODESTRING_WAS_USED_BSHOULD_YOU_NOT_KNOW_ABOUT_THIS_NEW_EXTERNAL_CODESTRING_BEING_ADDED_THEN_THIS_IS_A_SERIOUS_DANGER_AND_REQUIRES_IMMEDIATE_ATTENTIONB_DO_NOT_IGNORE_THIS_WARNING_AS_IT_WILL_ONLY_SHOW_BONCEB',
$key
), 'Warning'
);
}
else
{
// set the notice
$this->app->enqueueMessage(
Text::_('COM_COMPONENTBUILDER_HR_HTHREEEXTERNAL_CODE_ERRORHTHREE'),
'Error'
);
$this->app->enqueueMessage(
Text::sprintf('COM_COMPONENTBUILDER_S_WE_DETECTED_BNEW_EXTERNALCODEB_BUT_YOU_DO_NOT_HAVE_PERMISSION_TO_ALLOW_THIS_NEW_CODESTRING_SO_BSB_WAS_REMOVED_FROM_THE_COMPILATION_PLEASE_CONTACT_YOU_SYSTEM_ADMINISTRATOR_FOR_MORE_INFOBR_SMALLADMIN_ACCESS_REQUIREDSMALL',
$this->user->get('name'), $key
), 'Error'
);
// remove the code/string
$this->code[$target_key] = '';
}
}
else
{
// set notice that we could not get a valid string from the target
$this->app->enqueueMessage(
Text::_('COM_COMPONENTBUILDER_HR_HTHREEEXTERNAL_CODE_WARNINGHTHREE'),
'Error'
);
$this->app->enqueueMessage(
Text::sprintf('COM_COMPONENTBUILDER_THE_BSB_RETURNED_AN_INVALID_STRING',
$key
), 'Error'
);
}
}
// add to local bucket
$bucket[$key] = $this->code[$target_key] ?? '';
}
/**
* Cut the External Code/String
*
* @param string $string The content to cut
* @param string $sequence The cutting sequence
* @param string $key The content key
*
* @return string
* @since 3.2.0
*/
protected function cut(string $string, string $sequence, string $key):
string
{
// we first break the string up in rows
$rows = (array) explode(PHP_EOL, $string);
// get the cutting sequence
$cutter = (array) explode('|', $sequence);
// we only continue if we have more rows than we have to cut
if (array_sum($cutter) < ArrayHelper::check($rows))
{
// remove the rows at the bottom if needed
if (isset($cutter[1]) && $cutter[1] > 0)
{
array_splice($rows, "-$cutter[1]");
}
// remove the rows at the top if needed
if ($cutter[0] > 0)
{
$rows = array_splice($rows, $cutter[0]);
}
// return the remaining rows
return implode(PHP_EOL, $rows);
}
// we set an error message about too few lines to cut
$this->app->enqueueMessage(
Text::_('COM_COMPONENTBUILDER_HR_HTHREEEXTERNAL_CODE_NOTICEHTHREE'),
'Error'
);
$this->app->enqueueMessage(
Text::sprintf('COM_COMPONENTBUILDER_THE_BSB_CUT_SEQUENCE_FAILED_ON_THE_RETURNED_EXTERNAL_CODESTRING_AS_MORE_LINES_HAS_TO_BE_CUT_THEN_WAS_FOUND_IN_THE_CODESTRING_WE_HAVE_COMPLETELY_REMOVED_THE_CODE_PLEASE_CHECK_THIS_CODESTRING',
$key
), 'Error'
);
return '';
}
}
src/Componentbuilder/Compiler/Customcode/Extractor.php000064400000064113151162054130017212
0ustar00<?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\Customcode;
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\Version;
use VDM\Joomla\Utilities\ArrayHelper;
use VDM\Joomla\Utilities\StringHelper;
use VDM\Joomla\Componentbuilder\Compiler\Factory as Compiler;
use VDM\Joomla\Componentbuilder\Compiler\Config;
use VDM\Joomla\Componentbuilder\Compiler\Customcode\Gui;
use VDM\Joomla\Componentbuilder\Compiler\Customcode\Extractor\Paths;
use VDM\Joomla\Componentbuilder\Compiler\Placeholder\Reverse;
use VDM\Joomla\Componentbuilder\Compiler\Component\Placeholder;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Pathfix;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Placefix;
use
VDM\Joomla\Componentbuilder\Compiler\Interfaces\Customcode\ExtractorInterface;
/**
* Compiler Custom Code Extractor
*
* The custom script placeholders - we use the (xxx) to avoid detection it
should be (***)
* ##################################---> PHP/JS
---####################################
*
* New Insert Code = /xxx[INSERT>$$$$]xxx/
/xxx[/INSERT>$$$$]xxx/
* New Replace Code = /xxx[REPLACE>$$$$]xxx/
/xxx[/REPLACE>$$$$]xxx/
*
* //////////////////////////////// when JCB adds it back
//////////////////////////////////
* JCB Add Inserted Code = /xxx[INSERTED$$$$]xxx//xx23xx/
/xxx[/INSERTED$$$$]xxx/
* JCB Add Replaced Code = /xxx[REPLACED$$$$]xxx//xx25xx/
/xxx[/REPLACED$$$$]xxx/
*
* /////////////////////////////// changeing existing custom code
/////////////////////////
* Update Inserted Code = /xxx[INSERTED>$$$$]xxx//xx23xx/
/xxx[/INSERTED>$$$$]xxx/
* Update Replaced Code = /xxx[REPLACED>$$$$]xxx//xx25xx/
/xxx[/REPLACED>$$$$]xxx/
*
* The custom script placeholders - we use the (==) to avoid detection it
should be (--)
* ###################################---> HTML
---#####################################
*
* New Insert Code = !==[INSERT>$$$$]==>
!==[/INSERT>$$$$]==>
* New Replace Code = !==[REPLACE>$$$$]==>
!==[/REPLACE>$$$$]==>
*
* ///////////////////////////////// when JCB adds it back
///////////////////////////////
* JCB Add Inserted Code =
* JCB Add Replaced Code =
*
* //////////////////////////// changeing existing custom code
///////////////////////////
* Update Inserted Code = !==[INSERTED>$$$$]==>
!==[/INSERTED>$$$$]==>
* Update Replaced Code = !==[REPLACED>$$$$]==>
!==[/REPLACED>$$$$]==>
*
* ////////23 is the ID of the code in the system don't change
it!!!!!!!!!!!!!!!!!!!!!!!!!!
*
* More info read:
https://git.vdm.dev/joomla/Component-Builder/wiki/TIPS:-Custom-Code
*
* @since 3.2.0
*/
class Extractor implements ExtractorInterface
{
/**
* The placeholder keys
*
* @var array
* @since 3.2.0
*/
protected array $PKeys
= [
1 => 'REPLACE<>$$$$]',
2 => 'INSERT<>$$$$]',
3 => 'REPLACED<>$$$$]',
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
*
* @var array
* @since 3.2.0
*/
protected array $existing = [];
/**
* The custom code in local files that are new
*
* @var array
* @since 3.2.0
*/
protected array $new = [];
/**
* The index of code already loaded
*
* @var array
* @since 3.2.0
*/
protected array $done = [];
/**
* The search counter
*
* @var array
* @since 3.2.0
*/
protected array $counter = [1 => 0, 2 => 0];
/**
* The file types to search
*
* @var array
* @since 3.2.0
*/
protected array $fileTypes = ['\.php', '\.js',
'\.xml'];
/**
* The local placeholders
*
* @var array
* @since 3.2.0
*/
protected array $placeholders;
/**
* Today's date in SQL format
*
* @var string
* @since 3.2.0
*/
protected string $today;
/**
* Compiler Config
*
* @var Config
* @since 3.2.0
**/
protected Config $config;
/**
* Compiler Customcode Gui
*
* @var Gui
* @since 3.2.0
**/
protected Gui $gui;
/**
* Compiler Customcode Extractor Paths
*
* @var Paths
* @since 3.2.0
**/
protected Paths $paths;
/**
* Compiler Placeholder Reverse
*
* @var Reverse
* @since 3.2.0
**/
protected Reverse $reverse;
/**
* Compiler Component Placeholder
*
* @var Placeholder
* @since 3.2.0
**/
protected Placeholder $componentPlaceholder;
/**
* Compiler Component Pathfix
*
* @var Pathfix
* @since 3.2.0
**/
protected Pathfix $pathfix;
/**
* Current User Object
*
* @since 3.2.0
**/
protected $user;
/**
* Database object to query local DB
*
* @since 3.2.0
**/
protected $db;
/**
* Database object to query local DB
*
* @since 3.2.0
**/
protected $app;
/**
* Constructor.
*
* @param Config|null $config The compiler config
object.
* @param Gui|null $gui The compiler customcode gui
object.
* @param Paths|null $paths The compiler customcode
extractor paths object.
* @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.
*
* @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)
{
$this->config = $config ?: Compiler::_('Config');
$this->gui = $gui ?: Compiler::_('Customcode.Gui');
$this->paths = $paths ?:
Compiler::_('Customcode.Extractor.Paths');
$this->reverse = $reverse ?:
Compiler::_('Placeholder.Reverse');
$this->componentPlaceholder = $placeholder ?:
Compiler::_('Component.Placeholder');
$this->pathfix = $pathfix ?:
Compiler::_('Utilities.Pathfix');
$this->user = Factory::getUser();
$this->db = Factory::getDbo();
$this->app = Factory::getApplication();
// set today's date
$this->today = Factory::getDate()->toSql();
// set some local placeholders
$placeholders = array_flip(
$this->componentPlaceholder->get()
);
$placeholders[StringHelper::safe(
$this->config->component_code_name, 'F'
) . 'Helper::'] = Placefix::_('Component') .
'Helper::';
$placeholders['COM_' . StringHelper::safe(
$this->config->component_code_name, 'U'
)] = 'COM_' . Placefix::_('COMPONENT');
$placeholders['com_' .
$this->config->component_code_name] = 'com_' .
Placefix::_('component');
// set the local placeholders
$this->placeholders = array_reverse($placeholders, true);
// set the current version
$this->currentVersion = (int) Version::MAJOR_VERSION;
}
/**
* get the custom code from the local files
*
* @return void
* @since 3.2.0
*/
public function run()
{
// we must first store the current working directory
$joomla = getcwd();
foreach ($this->paths->active as $target => $path)
{
// we are changing the working directory to the component path
chdir($path);
foreach ($this->fileTypes as $type)
{
// get a list of files in the current directory tree (only PHP, JS and
XML for now)
$files = Folder::files('.', $type, true, true);
// check if files found
if (ArrayHelper::check($files))
{
foreach ($files as $file)
{
// search the file
$this->searchFileContent($file, $target);
// insert new code
$this->insert(100);
// update existing custom code
$this->update(30);
}
}
}
}
// change back to Joomla working directory
chdir($joomla);
// make sure all code is stored
$this->insert();
// update existing custom code
$this->update();
}
/**
* search a file for placeholders and store result
*
* @param string $file The file path to search
*
* @return array on success
* @since 3.2.0
*/
protected function searchFileContent(&$file, &$target)
{
// we add a new search for the GUI CODE Blocks
$this->gui->search($file, $this->placeholders, $this->today,
$target);
// reset each time per file
$loadEndFingerPrint = false;
$endFingerPrint = [];
$fingerPrint = [];
$codeBucket = [];
$pointer = [];
$reading = [];
$reader = 0;
// reset found Start type
$commentType = 0;
// make sure we have the path correct (the script file is not in admin
path for example)
// there may be more... will nead to keep our eye on this... since files
could be moved during install
$file = str_replace('./', '', (string) $file); # TODO
(windows path issues)
$path = $file !== 'script.php' ? $target . '/' .
$file : $file;
// now we go line by line
foreach (new \SplFileObject($file) as $lineNumber => $lineContent)
{
// we must keep last few lines to dynamic find target entry later
$fingerPrint[$lineNumber] = trim($lineContent);
// load the end fingerprint
if ($loadEndFingerPrint)
{
$endFingerPrint[$lineNumber] = trim($lineContent);
}
foreach ($this->PKeys as $type => $search)
{
$i = (int) ($type == 3 || $type == 4) ? 2 : 1;
$_type = (int) ($type == 1 || $type == 3) ? 1 : 2;
if ($reader === 0 || $reader === $i)
{
$targetKey = $type;
$start = '/***[' . $search . '***/';
$end = '/***[/' . $search . '***/';
$startHTML = '<!--[' . $search . '-->';
$endHTML = '<!--[/' . $search . '-->';
// check if the ending placeholder was found
if (isset($reading[$targetKey]) && $reading[$targetKey]
&& ((trim((string) $lineContent) === $end
|| strpos((string) $lineContent, $end) !== false)
|| (trim((string) $lineContent) === $endHTML
|| strpos((string) $lineContent, $endHTML) !== false)))
{
// trim the placeholder and if there is still data then load it
if (isset($endReplace)
&& ($_line = $this->addLineChecker($endReplace, 2,
$lineContent)) !== false)
{
$codeBucket[$pointer[$targetKey]][] = $_line;
}
// deactivate the reader
$reading[$targetKey] = false;
if ($_type == 2)
{
// deactivate search
$reader = 0;
}
else
{
// activate fingerPrint for replacement end target
$loadEndFingerPrint = true;
$backupTargetKey = $targetKey;
$backupI = $i;
}
// all new records we can do a bulk insert
if ($i === 1)
{
// end the bucket info for this code block
$this->new[$pointer[$targetKey]][]
= $this->db->quote(
(int) $lineNumber
); // 'toline'
// first reverse engineer this code block
$c0de = $this->reverse->engine(
implode('', $codeBucket[$pointer[$targetKey]]),
$this->placeholders, $target
);
$this->new[$pointer[$targetKey]][]
= $this->db->quote(
base64_encode((string) $c0de)
); // 'code'
if ($_type == 2)
{
// load the last value
$this->new[$pointer[$targetKey]][]
= $this->db->quote(0); // 'hashendtarget'
}
}
// the record already exist so we must update instead
elseif ($i === 2)
{
// end the bucket info for this code block
$this->existing[$pointer[$targetKey]]['fields'][]
= $this->db->quoteName('to_line') . ' =
'
. $this->db->quote($lineNumber);
// first reverse engineer this code block
$c0de = $this->reverse->engine(
implode('', $codeBucket[$pointer[$targetKey]]),
$this->placeholders, $target,
$this->existing[$pointer[$targetKey]]['id']
);
$this->existing[$pointer[$targetKey]]['fields'][]
= $this->db->quoteName('code') . ' =
'
. $this->db->quote(base64_encode((string) $c0de));
if ($_type == 2)
{
// load the last value
$this->existing[$pointer[$targetKey]]['fields'][]
= $this->db->quoteName('hashendtarget')
. ' = ' . $this->db->quote(0);
}
}
}
// check if the endfingerprint is ready to save
if (count((array) $endFingerPrint) === 3)
{
$hashendtarget = '3__' . md5(
implode('', $endFingerPrint)
);
// all new records we can do a bulk insert
if ($i === 1)
{
// load the last value
$this->new[$pointer[$targetKey]][]
= $this->db->quote(
$hashendtarget
); // 'hashendtarget'
}
// the record already exist so we must update
elseif ($i === 2)
{
$this->existing[$pointer[$targetKey]]['fields'][]
= $this->db->quoteName('hashendtarget') . ' =
'
. $this->db->quote($hashendtarget);
}
// reset the needed values
$endFingerPrint = [];
$loadEndFingerPrint = false;
// deactivate reader (to allow other search)
$reader = 0;
}
// then read in the code
if (isset($reading[$targetKey]) && $reading[$targetKey])
{
$codeBucket[$pointer[$targetKey]][] = $lineContent;
}
// see if the custom code line starts now with PHP/JS comment type
if ((!isset($reading[$targetKey]) || !$reading[$targetKey])
&& (($i === 1 && trim((string) $lineContent) ===
$start)
|| strpos((string) $lineContent, $start) !== false))
{
$commentType = 1; // PHP/JS type
$startReplace = $start;
$endReplace = $end;
}
// see if the custom code line starts now with HTML comment type
elseif ((!isset($reading[$targetKey])
|| !$reading[$targetKey])
&& (($i === 1 && trim((string) $lineContent) ===
$startHTML)
|| strpos((string) $lineContent, $startHTML) !== false))
{
$commentType = 2; // HTML type
$startReplace = $startHTML;
$endReplace = $endHTML;
}
// check if the starting place holder was found
if ($commentType > 0)
{
// if we have all on one line we have a problem (don't load it
TODO)
if (strpos((string) $lineContent, (string) $endReplace) !== false)
{
// reset found comment type
$commentType = 0;
$this->app->enqueueMessage(
Text::_('COM_COMPONENTBUILDER_HR_HTHREECUSTOM_CODES_WARNINGHTHREE'),
'Warning'
);
$this->app->enqueueMessage(
Text::sprintf('COM_COMPONENTBUILDER_WE_FOUND_DYNAMIC_CODE_BALL_IN_ONE_LINEB_AND_IGNORED_IT_PLEASE_REVIEW_S_FOR_MORE_DETAILS',
$path
), 'Warning'
);
continue;
}
// do a quick check to insure we have an id
$id = false;
if ($i === 2)
{
$id = $this->getSystemID(
$lineContent,
array(1 => $start, 2 => $startHTML),
$commentType
);
}
if ($i === 2 && $id > 0)
{
// make sure we update it only once even if found again.
if (isset($this->done[$id]))
{
// reset found comment type
$commentType = 0;
continue;
}
// store the id to avoid duplication
$this->done[$id] = (int) $id;
}
// start replace
$startReplace = $this->setStartReplace(
$id, $commentType, $startReplace
);
// set active reader (to lock out other search)
$reader = $i;
// set pointer
$pointer[$targetKey] = $this->counter[$i];
// activate the reader
$reading[$targetKey] = true;
// start code bucket
$codeBucket[$pointer[$targetKey]] = [];
// trim the placeholder and if there is still data then load it
if ($_line = $this->addLineChecker(
$startReplace, 1, $lineContent
))
{
$codeBucket[$pointer[$targetKey]][] = $_line;
}
// get the finger print around the custom code
$inFinger = count($fingerPrint);
$getFinger = $inFinger - 1;
$hasharray = array_slice(
$fingerPrint, -$inFinger, $getFinger, true
);
$hasleng = count($hasharray);
$hashtarget = $hasleng . '__' . md5(
implode('', $hasharray)
);
// for good practice
$this->pathfix->set($path);
// all new records we can do a bulk insert
if ($i === 1 || !$id)
{
// start the bucket for this code
$this->new[$pointer[$targetKey]] = [];
$this->new[$pointer[$targetKey]][]
= $this->db->quote(
$path
); // 'path'
$this->new[$pointer[$targetKey]][]
= $this->db->quote(
(int) $_type
); // 'type'
$this->new[$pointer[$targetKey]][]
= $this->db->quote(
1
); // 'target'
$this->new[$pointer[$targetKey]][]
= $this->db->quote(
$this->currentVersion
); // 'joomla_version'
$this->new[$pointer[$targetKey]][]
= $this->db->quote(
$commentType
); // 'comment_type'
$this->new[$pointer[$targetKey]][]
= $this->db->quote(
(int) $this->config->component_id
); // 'component'
$this->new[$pointer[$targetKey]][]
= $this->db->quote(
1
); // 'published'
$this->new[$pointer[$targetKey]][]
= $this->db->quote(
$this->today
); // 'created'
$this->new[$pointer[$targetKey]][]
= $this->db->quote(
(int) $this->user->id
); // 'created_by'
$this->new[$pointer[$targetKey]][]
= $this->db->quote(
1
); // 'version'
$this->new[$pointer[$targetKey]][]
= $this->db->quote(
1
); // 'access'
$this->new[$pointer[$targetKey]][]
= $this->db->quote(
$hashtarget
); // 'hashtarget'
$this->new[$pointer[$targetKey]][]
= $this->db->quote(
(int) $lineNumber
); // 'fromline'
}
// the record already exist so we must update instead
elseif ($i === 2 && $id > 0)
{
// start the bucket for this code
$this->existing[$pointer[$targetKey]] = [];
$this->existing[$pointer[$targetKey]]['id']
= (int) $id;
$this->existing[$pointer[$targetKey]]['conditions'] =
[];
$this->existing[$pointer[$targetKey]]['conditions'][]
= $this->db->quoteName('id') . ' = '
. $this->db->quote($id);
$this->existing[$pointer[$targetKey]]['fields'] = [];
$this->existing[$pointer[$targetKey]]['fields'][]
= $this->db->quoteName('path') . ' = '
. $this->db->quote($path);
$this->existing[$pointer[$targetKey]]['fields'][]
= $this->db->quoteName('type') . ' = '
. $this->db->quote($_type);
$this->existing[$pointer[$targetKey]]['fields'][]
= $this->db->quoteName('comment_type') . ' =
'
. $this->db->quote($commentType);
$this->existing[$pointer[$targetKey]]['fields'][]
= $this->db->quoteName('component') . ' =
'
. $this->db->quote($this->config->component_id);
$this->existing[$pointer[$targetKey]]['fields'][]
= $this->db->quoteName('from_line') . ' =
'
. $this->db->quote($lineNumber);
$this->existing[$pointer[$targetKey]]['fields'][]
= $this->db->quoteName('modified') . ' =
'
. $this->db->quote($this->today);
$this->existing[$pointer[$targetKey]]['fields'][]
= $this->db->quoteName('modified_by') . ' =
'
. $this->db->quote($this->user->id);
$this->existing[$pointer[$targetKey]]['fields'][]
= $this->db->quoteName('hashtarget') . ' =
'
. $this->db->quote($hashtarget);
}
else // this should actualy never happen
{
// de activate the reader
$reading[$targetKey] = false;
$reader = 0;
}
// reset found comment type
$commentType = 0;
// update the counter
$this->counter[$i]++;
}
}
}
// make sure only a few lines is kept at a time
if (count((array) $fingerPrint) > 10)
{
$fingerPrint = array_slice($fingerPrint, -6, 6, true);
}
}
// if the code is at the end of the page and there were not three more
lines
if (count((array) $endFingerPrint) > 0 || $loadEndFingerPrint)
{
if (count((array) $endFingerPrint) > 0)
{
$leng = count($endFingerPrint);
$hashendtarget = $leng . '__' . md5(
implode('', $endFingerPrint)
);
}
else
{
$hashendtarget = 0;
}
// all new records we can do a buldk insert
if ($backupI === 1)
{
// load the last value
$this->new[$pointer[$backupTargetKey]][]
= $this->db->quote($hashendtarget); //
'hashendtarget'
}
// the record already exist so we must use module to update
elseif ($backupI === 2)
{
$this->existing[$pointer[$backupTargetKey]]['fields'][]
= $this->db->quoteName('hashendtarget') . ' =
'
. $this->db->quote($hashendtarget);
}
}
}
/**
* Insert the code
*
* @param int $when To set when to update
*
* @return void
* @since 3.2.0
*/
protected function insert(int $when = 1)
{
if (ArrayHelper::check($this->new) >= $when)
{
// Create a new query object.
$query = $this->db->getQuery(true);
$continue = false;
// Insert columns.
$columns = array('path', 'type', 'target',
'joomla_version', 'comment_type',
'component', 'published', 'created',
'created_by',
'version', 'access', 'hashtarget',
'from_line',
'to_line', 'code', 'hashendtarget');
// Prepare the insert query.
$query->insert(
$this->db->quoteName('#__componentbuilder_custom_code')
);
$query->columns($this->db->quoteName($columns));
foreach ($this->new as $values)
{
if (count((array) $values) == 16)
{
$query->values(implode(',', $values));
$continue = true;
}
else
{
// TODO line mismatch... should not happen
}
}
// clear the values array
$this->new = [];
if (!$continue)
{
return; // insure we don't continue if no values were loaded
}
// Set the query using our newly populated query object and execute it.
$this->db->setQuery($query);
$this->db->execute();
}
}
/**
* Update the code
*
* @param int $when To set when to update
*
* @return void
* @since 3.2.0
*/
protected function update(int $when = 1)
{
if (ArrayHelper::check($this->existing) >= $when)
{
foreach ($this->existing as $code)
{
// Create a new query object.
$query = $this->db->getQuery(true);
// Prepare the update query.
$query->update(
$this->db->quoteName('#__componentbuilder_custom_code')
)->set($code['fields'])->where($code['conditions']);
// Set the query using our newly populated query object and execute
it.
$this->db->setQuery($query);
$this->db->execute();
}
// clear the values array
$this->existing = [];
}
}
/**
* set the start replace placeholder
*
* @param int $id The comment id
* @param int $commentType The comment type
* @param string $startReplace The main replace string
*
* @return string on success
* @since 3.2.0
*/
protected function setStartReplace(int $id, int $commentType, string
$startReplace): string
{
if ($id > 0)
{
switch ($commentType)
{
case 1: // the PHP & JS type
$startReplace .= '/*' . $id . '*/';
break;
case 2: // the HTML type
$startReplace .= '<!--' . $id . '-->';
break;
}
}
return $startReplace;
}
/**
* Check if this line should be added
*
* @param string $replaceKey The key to remove from line
* @param int $type The line type
* @param string $lineContent The line to check
*
* @return bool|int true on success
* @since 3.2.0
*/
protected function addLineChecker(string $replaceKey, int $type, string
$lineContent)
{
$check = explode($replaceKey, $lineContent);
switch ($type)
{
case 1:
// beginning of code
if (isset($check[1]) && StringHelper::check($check[1]))
{
return trim($check[1]);
}
break;
case 2:
// end of code
if (isset($check[0]) && StringHelper::check($check[0]))
{
return trim($check[0]);
}
break;
}
return false;
}
/**
* search for the system id in the line given
*
* @param string $lineContent The file path to search
* @param array $placeholders The values to search for
* @param int $commentType The comment type
*
* @return mixed on success
* @since 3.2.0
*/
protected function getSystemID(string &$lineContent, array
$placeholders, int $commentType)
{
$trim = '/';
if ($commentType == 2)
{
$trim = '<!--';
}
// remove place holder from content
$string = trim(
str_replace($placeholders[$commentType] . $trim, '',
$lineContent)
);
// now get all numbers
$numbers = [];
preg_match_all('!\d+!', $string, $numbers);
// return the first number
if (isset($numbers[0])
&& ArrayHelper::check(
$numbers[0]
))
{
return reset($numbers[0]);
}
return false;
}
}
src/Componentbuilder/Compiler/Customcode/Extractor/Paths.php000064400000024733151162054130020275
0ustar00<?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\Customcode\Extractor;
use Joomla\CMS\Factory;
use Joomla\CMS\Filesystem\Folder;
use VDM\Joomla\Utilities\ArrayHelper;
use VDM\Joomla\Utilities\JsonHelper;
use VDM\Joomla\Utilities\GetHelper;
use VDM\Joomla\Utilities\String\ClassfunctionHelper;
use VDM\Joomla\Componentbuilder\Compiler\Factory as Compiler;
use VDM\Joomla\Componentbuilder\Compiler\Config;
use VDM\Joomla\Componentbuilder\Compiler\Placeholder;
use VDM\Joomla\Componentbuilder\Compiler\Component\Placeholder as
ComponentPlaceholder;
use VDM\Joomla\Componentbuilder\Compiler\Customcode;
use VDM\Joomla\Componentbuilder\Compiler\Language\Extractor;
/**
* Compiler Custom Code Paths
*
* @since 3.2.0
*/
class Paths
{
/**
* The local paths
*
* @var array
* @since 3.2.0
**/
public array $active = [];
/**
* Compiler Component Placeholder
*
* @var array
* @since 3.2.0
**/
protected array $componentPlaceholder;
/**
* Compiler Config
*
* @var Config
* @since 3.2.0
**/
protected Config $config;
/**
* Compiler Placeholder
*
* @var Placeholder
* @since 3.2.0
**/
protected Placeholder $placeholder;
/**
* Compiler Customcode
*
* @var Customcode
* @since 3.2.0
**/
protected Customcode $customcode;
/**
* Compiler Language Extractor
*
* @var Extractor
* @since 3.2.0
**/
protected Extractor $extractor;
/**
* Database object to query local DB
*
* @since 3.2.0
**/
protected $db;
/**
* Constructor.
*
* @param Config|null $config The compiler
config object.
* @param Placeholder|null $placeholder The compiler
placeholder object.
* @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.
*
* @throws \Exception
* @since 3.2.0
*/
public function __construct(?Config $config = null, ?Placeholder
$placeholder = null,
?ComponentPlaceholder $componentPlaceholder = null, ?Customcode
$customcode = null,
?Extractor $extractor = null)
{
$this->config = $config ?: Compiler::_('Config');
$this->placeholder = $placeholder ?:
Compiler::_('Placeholder');
/** @var ComponentPlaceholder $componentPlaceholder */
$componentPlaceholder = $componentPlaceholder ?:
Compiler::_('Component.Placeholder');
$this->customcode = $customcode ?:
Compiler::_('Customcode');
$this->extractor = $extractor ?:
Compiler::_('Language.Extractor');
$this->db = Factory::getDbo();
// load the placeholders to local array
$this->componentPlaceholder = $componentPlaceholder->get();
// load the paths on initialization
$this->load();
}
/**
* get the local installed path of this component
*
* @return void
* @since 3.2.0
*/
protected function load()
{
// set the local paths to search
$local_paths = [];
// admin path
$local_paths['admin'] = JPATH_ADMINISTRATOR .
'/components/com_'
. $this->config->component_code_name;
// site path
$local_paths['site'] = JPATH_ROOT .
'/components/com_'
. $this->config->component_code_name;
// media path
$local_paths['media'] = JPATH_ROOT . '/media/com_'
. $this->config->component_code_name;
// power path
$local_paths['power'] = JPATH_ROOT . '/' .
$this->config->get('jcb_powers_path',
'libraries/jcb_powers');
// lets also go over the REPOS - TODO
// Painful but we need to folder paths for the linked modules
if (($module_ids = $this->getModuleIDs()) !== false)
{
foreach ($module_ids as $module_id)
{
// get the module folder path
if (($path = $this->getModulePath($module_id)) !== false)
{
// set the path
$local_paths['module_' . str_replace('/',
'_', (string) $path)] = $path;
}
}
}
// Painful but we need to folder paths for the linked plugins
if (($plugin_ids = $this->getPluginIDs()) !== false)
{
foreach ($plugin_ids as $plugin_id)
{
// get the plugin group and folder name
if (($path = $this->getPluginPath($plugin_id)) !== false)
{
// set the path
$local_paths['plugin_' . str_replace('/',
'_', (string) $path)] = JPATH_ROOT . '/plugins/' .
$path;
}
}
}
// check if the local install is found
foreach ($local_paths as $key => $localPath)
{
if (!Folder::exists($localPath))
{
unset($local_paths[$key]);
}
}
if (ArrayHelper::check($local_paths))
{
$this->active = $local_paths;
}
}
/**
* get the Joomla Modules IDs
*
* @return mixed of IDs on success
* @since 3.2.0
*/
protected function getModuleIDs()
{
if (($addjoomla_modules = GetHelper::var(
'component_modules', $this->config->component_id,
'joomla_component',
'addjoomla_modules'
)) !== false)
{
$addjoomla_modules = (JsonHelper::check(
$addjoomla_modules
)) ? json_decode((string) $addjoomla_modules, true) : null;
if (ArrayHelper::check($addjoomla_modules))
{
$joomla_modules = array_filter(
array_values($addjoomla_modules),
// only load the modules whose target association call for it
fn($array): bool => !isset($array['target']) ||
$array['target'] != 2
);
// if we have values we return IDs
if (ArrayHelper::check($joomla_modules))
{
return array_map(
fn($array) => (int) $array['module'], $joomla_modules
);
}
}
}
return false;
}
/**
* get the Joomla module path
*
* @return mixed of module path and target site area on success
* @since 3.2.0
*/
protected function getModulePath($id)
{
if (is_numeric($id) && $id > 0)
{
// Create a new query object.
$query = $this->db->getQuery(true);
$query->select('a.*');
$query->select(
$this->db->quoteName(
array(
'a.name',
'a.target'
), array(
'name',
'target'
)
)
);
// from these tables
$query->from('#__componentbuilder_joomla_module AS a');
$query->where($this->db->quoteName('a.id') . ' =
' . (int) $id);
$this->db->setQuery($query);
$this->db->execute();
if ($this->db->getNumRows())
{
// get the module data
$module = $this->db->loadObject();
// update the name if it has dynamic values
$module->name = $this->placeholder->update(
$this->customcode->update($module->name),
$this->componentPlaceholder
);
// set safe class function name
$module->code_name
= ClassfunctionHelper::safe(
$module->name
);
// set module folder name
$module->folder_name = 'mod_' . strtolower((string)
$module->code_name);
// set the lang key
$this->extractor->langKeys[strtoupper($module->folder_name)] =
$module->id . '_M0dUl3';
// return the path
if ($module->target == 2)
{
// administrator client area
return JPATH_ADMINISTRATOR . '/modules/'
. $module->folder_name;
}
else
{
// default is the site client area
return JPATH_ROOT . '/modules/' . $module->folder_name;
}
}
}
return false;
}
/**
* get the Joomla plugins IDs
*
* @return mixed of IDs on success
* @since 3.2.0
*/
protected function getPluginIDs()
{
if (($addjoomla_plugins = GetHelper::var(
'component_plugins', $this->config->component_id,
'joomla_component',
'addjoomla_plugins'
)) !== false)
{
$addjoomla_plugins = (JsonHelper::check(
$addjoomla_plugins
)) ? json_decode((string) $addjoomla_plugins, true) : null;
if (ArrayHelper::check($addjoomla_plugins))
{
$joomla_plugins = array_filter(
array_values($addjoomla_plugins),
function ($array) {
// only load the plugins whose target association call for it
if (!isset($array['target']) || $array['target']
!= 2)
{
return true;
}
return false;
}
);
// if we have values we return IDs
if (ArrayHelper::check($joomla_plugins))
{
return array_map(
fn($array) => (int) $array['plugin'], $joomla_plugins
);
}
}
}
return false;
}
/**
* get the Joomla plugin path
*
* @return mixed of plugin path on success
* @deprecated 3.3
*/
protected function getPluginPath($id)
{
if (is_numeric($id) && $id > 0)
{
// Create a new query object.
$query = $this->db->getQuery(true);
$query->select('a.*');
$query->select(
$this->db->quoteName(
array(
'a.name',
'g.name'
), array(
'name',
'group'
)
)
);
// from these tables
$query->from('#__componentbuilder_joomla_plugin AS a');
$query->join(
'LEFT', $this->db->quoteName(
'#__componentbuilder_joomla_plugin_group', 'g'
) . ' ON (' .
$this->db->quoteName('a.joomla_plugin_group')
. ' = ' . $this->db->quoteName('g.id') .
')'
);
$query->where($this->db->quoteName('a.id') . ' =
' . (int) $id);
$this->db->setQuery($query);
$this->db->execute();
if ($this->db->getNumRows())
{
// get the plugin data
$plugin = $this->db->loadObject();
// update the name if it has dynamic values
$plugin->name = $this->placeholder->update(
$this->customcode->update($plugin->name),
$this->componentPlaceholder
);
// update the name if it has dynamic values
$plugin->code_name
= ClassfunctionHelper::safe(
$plugin->name
);
// set plugin folder name
$plugin->group = strtolower((string) $plugin->group);
// set plugin file name
$plugin->file_name = strtolower((string) $plugin->code_name);
// set the lang key
$this->extractor->langKeys['PLG_' . strtoupper(
$plugin->group . '_' . $plugin->file_name
)] = $plugin->id . '_pLuG!n';
// return the path
return $plugin->group . '/' . $plugin->file_name;
}
}
return false;
}
}
src/Componentbuilder/Compiler/Customcode/Extractor/index.html000064400000000054151162054130020470
0ustar00<html><body
bgcolor="#FFFFFF"></body></html>src/Componentbuilder/Compiler/Customcode/Gui.php000064400000017024151162054130015762
0ustar00<?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\Customcode;
use Joomla\CMS\Factory;
use Joomla\CMS\Application\CMSApplication;
use Joomla\CMS\Language\Text;
use VDM\Joomla\Utilities\ArrayHelper;
use VDM\Joomla\Utilities\StringHelper;
use VDM\Joomla\Utilities\GetHelper;
use VDM\Joomla\Utilities\FileHelper;
use VDM\Joomla\Utilities\String\FieldHelper;
use VDM\Joomla\Componentbuilder\Compiler\Factory as Compiler;
use VDM\Joomla\Componentbuilder\Compiler\Config;
use VDM\Joomla\Componentbuilder\Compiler\Placeholder\Reverse;
use VDM\Joomla\Componentbuilder\Power\Parser;
use
VDM\Joomla\Componentbuilder\Compiler\Interfaces\Customcode\GuiInterface;
/**
* Compiler Gui Custom Code
*
* @since 3.2.0
*/
class Gui implements GuiInterface
{
/**
* Compiler Config
*
* @var Config
* @since 3.2.0
**/
protected Config $config;
/**
* Compiler Placeholder Reverse
*
* @var Reverse
* @since 3.2.0
**/
protected Reverse $reverse;
/**
* Compiler Powers Parser
*
* @var Parser
* @since 3.2.0
**/
protected Parser $parser;
/**
* Database object to query local DB
*
* @since 3.2.0
**/
protected $db;
/**
* Database object to query local DB
*
* @since 3.2.0
**/
protected $app;
/**
* Constructor.
*
* @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.
*
* @throws \Exception
* @since 3.2.0
*/
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 = Factory::getDbo();
$this->app = Factory::getApplication();
}
/**
* Set the JCB GUI code placeholder
*
* @param string $string The code string
* @param array $config The placeholder config values
*
* @return string
* @since 3.2.0
*/
public function set(string $string, array $config): string
{
if (StringHelper::check($string))
{
if ($this->config->get('add_placeholders', false)
&& $this->check($string) &&
ArrayHelper::check($config)
&& isset($config['table']) &&
StringHelper::check($config['table'])
&& isset($config['field']) &&
StringHelper::check($config['field'])
&& isset($config['type']) &&
StringHelper::check($config['type'])
&& isset($config['id']) &&
is_numeric($config['id']))
{
// if we have a key we must get the ID
if (isset($config['key']) &&
StringHelper::check($config['key']) &&
$config['key'] !== 'id')
{
if (($id = GetHelper::var($config['table'],
$config['id'], $config['key'], 'id')) !==
false && is_numeric($id))
{
$config['id'] = $id;
}
else
{
// we must give a error message to inform the user of this issue.
(should never happen)
$this->app->enqueueMessage(
Text::sprintf('COM_COMPONENTBUILDER_ID_MISMATCH_WAS_DETECTED_WITH_THE_SSSS_GUI_CODE_FIELD_SO_THE_PLACEHOLDER_WAS_NOT_SET',
$config['table'], $config['field'],
$config['key'], $config['id']
), 'Error'
);
// check some config
if (!isset($config['prefix']))
{
$config['prefix'] = '';
}
return $config['prefix'] . $string;
}
}
// check some config
if (!isset($config['prefix']))
{
$config['prefix'] = PHP_EOL;
}
// add placeholder based on type of code
switch (strtolower((string) $config['type']))
{
// adding with html commenting
case 'html':
$front = $config['prefix'] . '<!--' .
'[JCBGUI.';
$sufix = '$$$$]-->' . PHP_EOL;
$back = '<!--[/JCBGUI' . $sufix;
break;
// adding with php commenting
default:
$front = $config['prefix'] . '/***' .
'[JCBGUI.';
$sufix = '$$$$]***/' . PHP_EOL;
$back = '/***[/JCBGUI' . $sufix;
break;
}
return $front . $config['table'] . '.' .
$config['field'] . '.'
. $config['id'] . '.' . $sufix . $string . $back;
}
// check some config
if (!isset($config['prefix']))
{
$config['prefix'] = '';
}
return $config['prefix'] . $string;
}
return $string;
}
/**
* search a file for gui code blocks that were updated in the IDE
*
* @param string $file The file path to search
* @param array $placeholders The values to replace in the code being
stored
* @param string $today The date for today
* @param string $target The target path type
*
* @return void
* @since 3.2.0
*/
public function search(string &$file, array &$placeholders, string
&$today, string &$target)
{
// get file content
$file_content = FileHelper::getContent($file);
// get the USE statements (to reverse engineer super power keys)
$use_statements = $this->parser->getUseStatements($file_content);
$guiCode = [];
// we add a new search for the GUI CODE Blocks
$guiCode[] = GetHelper::allBetween(
$file_content, '/***[JCB' . 'GUI<>',
'/***[/JCBGUI' . '$$$$]***/'
);
$guiCode[] = GetHelper::allBetween(
$file_content, '<!--[JCB' . 'GUI<>',
'<!--[/JCBGUI' . '$$$$]-->'
);
if (($guiCode = ArrayHelper::merge($guiCode)) !== false
&& ArrayHelper::check($guiCode, true))
{
foreach ($guiCode as $code)
{
$first_line = strtok($code, PHP_EOL);
// get the GUI target details
$query = explode('.', trim($first_line, '.'));
// only continue if we have 3 values in the query
if (is_array($query) && count($query) >= 3)
{
// cleanup the newlines around the code
$code = trim(str_replace($first_line, '', (string) $code),
PHP_EOL)
. PHP_EOL;
// set the ID
$id = (int) $query[2];
// make the field name save
$field = FieldHelper::safe($query[1]);
// make the table name save
$table = StringHelper::safe($query[0]);
// reverse placeholder as much as we can
$code = $this->reverse->engine(
$code, $placeholders, $target, $id, $field, $table, $use_statements
);
// update the GUI/Tables/Database
$object = new \stdClass();
$object->id = $id;
$object->{$field} = base64_encode(
(string) $code
); // (TODO) this may not always work...
// update the value in GUI
$this->db->updateObject(
'#__componentbuilder_' . (string) $table, $object,
'id'
);
}
}
}
}
/**
* search a code to see if there is already any custom
* code or other reasons not to add the GUI code placeholders
*
* @param string $code The code to check
*
* @return bool true if GUI code placeholders can be added
* @since 3.2.0
*/
protected function check(string &$code): bool
{
// check for customcode placeholders
// we do not add GUI wrapper placeholder to code
// that already has any customcode placeholders
return strpos($code, '$$$$') === false;
}
}
src/Componentbuilder/Compiler/Customcode/Hash.php000064400000005101151162054130016112
0ustar00<?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\Customcode;
use VDM\Joomla\Utilities\GetHelper;
use VDM\Joomla\Utilities\FileHelper;
use VDM\Joomla\Componentbuilder\Compiler\Factory as Compiler;
use VDM\Joomla\Componentbuilder\Compiler\Placeholder;
/**
* Compiler Custom Code MD5
*
* @since 3.2.0
*/
class Hash
{
/**
* Compiler Placeholder
*
* @var Placeholder
* @since 3.2.0
**/
protected Placeholder $placeholder;
/**
* Constructor.
*
* @param Placeholder|null $placeholder The compiler placeholder
object.
*
* @since 3.2.0
*/
public function __construct(?Placeholder $placeholder = null)
{
$this->placeholder = $placeholder ?:
Compiler::_('Placeholder');
}
/**
* Set the MD5 hashed string or file or string
*
* @param string $script The code string
*
* @return string
* @since 3.2.0
*/
public function set(string $script): string
{
// check if we should hash a string
if (strpos($script, 'HASH' . 'STRING((((') !==
false)
{
// get the strings
$values = GetHelper::allBetween(
$script, 'HASH' . 'STRING((((', '))))'
);
$locker = [];
// convert them
foreach ($values as $value)
{
$locker['HASH' . 'STRING((((' . $value .
'))))']
= md5((string) $value);
}
// update the script
return $this->placeholder->update($script, $locker);
}
// check if we should hash a file
if (strpos($script, 'HASH' . 'FILE((((') !== false)
{
// get the strings
$values = GetHelper::allBetween(
$script, 'HASH' . 'FILE((((', '))))'
);
$locker = [];
// convert them
foreach ($values as $path)
{
// we first get the file if it exists
if (FileHelper::exists($path) && $value =
FileHelper::getContent($path))
{
// now we hash the file content
$locker['HASH' . 'FILE((((' . $path .
'))))']
= md5((string) $value);
}
else
{
// could not retrieve the file so we show error
$locker['HASH' . 'FILE((((' . $path .
'))))']
= 'ERROR';
}
}
// update the script
return $this->placeholder->update($script, $locker);
}
return $script;
}
}
src/Componentbuilder/Compiler/Customcode/LockBase.php000064400000004057151162054130016723
0ustar00<?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\Customcode;
use VDM\Joomla\Utilities\GetHelper;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Indent;
use VDM\Joomla\Componentbuilder\Compiler\Factory as Compiler;
use VDM\Joomla\Componentbuilder\Compiler\Placeholder;
use
VDM\Joomla\Componentbuilder\Compiler\Interfaces\Customcode\LockBaseInterface;
/**
* Compiler Custom Code Base64
*
* @since 3.2.0
*/
class LockBase implements LockBaseInterface
{
/**
* Compiler Placeholder
*
* @var Placeholder
* @since 3.2.0
**/
protected Placeholder $placeholder;
/**
* Constructor.
*
* @param Placeholder|null $placeholder The compiler placeholder
object.
*
* @since 3.2.0
*/
public function __construct(?Placeholder $placeholder = null)
{
$this->placeholder = $placeholder ?:
Compiler::_('Placeholder');
}
/**
* Set a string as bsae64 (basic)
*
* @param string $script The code string
*
* @return string
* @since 3.2.0
*/
public function set(string $script): string
{
if (\strpos($script, 'LOCK'.'BASE64((((') !== false)
{
// get the strings
$values = GetHelper::allBetween(
$script, 'LOCK'.'BASE64((((', '))))'
);
$locker = [];
// convert them
foreach ($values as $value)
{
$locker['LOCK'.'BASE64((((' . $value .
'))))']
= "base64_decode( preg_replace('/\s+/',
''," .
PHP_EOL . Indent::_(2) . "'" .
wordwrap(
base64_encode((string) $value), 64, PHP_EOL . Indent::_(2), true
) .
"'))";
}
// update the script
return $this->placeholder->update($script, $locker);
}
return $script;
}
}
src/Componentbuilder/Compiler/Customcode/index.html000064400000000054151162054130016515
0ustar00<html><body
bgcolor="#FFFFFF"></body></html>src/Componentbuilder/Compiler/Customview/Data.php000064400000022730151162054130016147
0ustar00<?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\Customview;
use Joomla\CMS\Factory;
use VDM\Joomla\Componentbuilder\Compiler\Factory as Compiler;
use VDM\Joomla\Componentbuilder\Compiler\Config;
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\EventInterface;
use VDM\Joomla\Componentbuilder\Compiler\Customcode;
use VDM\Joomla\Componentbuilder\Compiler\Customcode\Gui;
use VDM\Joomla\Componentbuilder\Compiler\Model\Libraries;
use VDM\Joomla\Componentbuilder\Compiler\Templatelayout\Data as
Templatelayout;
use VDM\Joomla\Componentbuilder\Compiler\Dynamicget\Data as Dynamicget;
use VDM\Joomla\Componentbuilder\Compiler\Model\Loader;
use VDM\Joomla\Componentbuilder\Compiler\Model\Javascriptcustomview;
use VDM\Joomla\Componentbuilder\Compiler\Model\Csscustomview;
use VDM\Joomla\Componentbuilder\Compiler\Model\Phpcustomview;
use VDM\Joomla\Componentbuilder\Compiler\Model\Ajaxcustomview;
use VDM\Joomla\Componentbuilder\Compiler\Model\Custombuttons;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Unique;
use VDM\Joomla\Utilities\StringHelper;
use VDM\Joomla\Utilities\JsonHelper;
use VDM\Joomla\Utilities\ArrayHelper;
/**
* Admin Custom View Data Class
*
* @since 3.2.0
*/
class Data
{
/**
* Admin views
*
* @var array
* @since 3.2.0
*/
protected array $data;
/**
* Compiler Config
*
* @var Config
* @since 3.2.0
*/
protected Config $config;
/**
* Compiler Event
*
* @var EventInterface
* @since 3.2.0
*/
protected EventInterface $event;
/**
* Compiler Customcode
*
* @var Customcode
* @since 3.2.0
*/
protected Customcode $customcode;
/**
* Compiler Customcode in Gui
*
* @var Gui
* @since 3.2.0
**/
protected Gui $gui;
/**
* Compiler Libraries Model
*
* @var Libraries
* @since 3.2.0
*/
protected Libraries $libraries;
/**
* Compiler Template Layout
*
* @var Templatelayout
* @since 3.2.0
*/
protected Templatelayout $templateLayout;
/**
* Compiler Dynamic Get Data
*
* @var Dynamicget
* @since 3.2.0
*/
protected Dynamicget $dynamic;
/**
* Compiler Auto Loader
*
* @var Loader
* @since 3.2.0
*/
protected Loader $loader;
/**
* The modelling javascript
*
* @var Javascriptcustomview
* @since 3.2.0
*/
protected Javascriptcustomview $javascript;
/**
* The modelling css
*
* @var Csscustomview
* @since 3.2.0
*/
protected Csscustomview $css;
/**
* The modelling php admin view
*
* @var Phpcustomview
* @since 3.2.0
*/
protected Phpcustomview $php;
/**
* The modelling custom buttons
*
* @var Custombuttons
* @since 3.2.0
*/
protected Custombuttons $custombuttons;
/**
* The modelling ajax
*
* @var Ajaxcustomview
* @since 3.2.0
*/
protected Ajaxcustomview $ajax;
/**
* Database object to query local DB
*
* @since 3.2.0
**/
protected $db;
/**
* Constructor
*
* @param Config|null $config The compiler
config object.
* @param EventInterface|null $event The compiler
event api object.
* @param Customcode|null $customcode The compiler
customcode object.
* @param Gui|null $gui The compiler
customcode gui.
* @param Libraries|null $libraries The compiler
libraries model object.
* @param Templatelayout|null $templateLayout The compiler
template layout object.
* @param Dynamicget|null $dynamic The compiler
dynamic get data object.
* @param Loader|null $loader The compiler
loader object.
* @param Javascriptcustomview|null $javascript The modelling
javascript object.
* @param Csscustomview|null $css The modelling
css object.
* @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.
*
* @since 3.2.0
*/
public function __construct(?Config $config = null, ?EventInterface $event
= null,
?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)
{
$this->config = $config ?: Compiler::_('Config');
$this->event = $event ?: Compiler::_('Event');
$this->customcode = $customcode ?:
Compiler::_('Customcode');
$this->gui = $gui ?: Compiler::_('Customcode.Gui');
$this->libraries = $libraries ?:
Compiler::_('Model.Libraries');
$this->templateLayout = $templateLayout ?:
Compiler::_('Templatelayout.Data');
$this->dynamic = $dynamic ?:
Compiler::_('Dynamicget.Data');
$this->loader = $loader ?: Compiler::_('Model.Loader');
$this->javascript = $javascript ?:
Compiler::_('Model.Javascriptcustomview');
$this->css = $css ?: Compiler::_('Model.Csscustomview');
$this->php = $php ?: Compiler::_('Model.Phpcustomview');
$this->ajax = $ajax ?: Compiler::_('Model.Ajaxcustomview');
$this->custombuttons = $custombuttons ?:
Compiler::_('Model.Custombuttons');
$this->db = Factory::getDbo();
}
/**
* Get all Custom View Data
*
* @param int $id The view ID
* @param string $table The view table
*
* @return object|null The view data
* @since 3.2.0
*/
public function get(int $id, string $table = 'site_view'):
?object
{
if (!isset($this->data[$id . $table]))
{
// Create a new query object.
$query = $this->db->getQuery(true);
$query->select('a.*');
$query->from('#__componentbuilder_' . $table . ' AS
a');
$query->where($this->db->quoteName('a.id') . ' =
' . (int) $id);
// Trigger Event: jcb_ce_onBeforeQueryCustomViewData
$this->event->trigger(
'jcb_ce_onBeforeQueryCustomViewData', [&$id, &$table,
&$query, &$this->db]
);
// Reset the query using our newly populated query object.
$this->db->setQuery($query);
// Load the results as a list of stdClass objects (see later for more
options on retrieving data).
$item = $this->db->loadObject();
// fix alias to use in code
$item->code = Unique::code(
StringHelper::safe($item->codename),
$this->config->build_target
);
$item->Code = StringHelper::safe($item->code, 'F');
$item->CODE = StringHelper::safe($item->code, 'U');
// Trigger Event: jcb_ce_onBeforeModelCustomViewData
$this->event->trigger(
'jcb_ce_onBeforeModelCustomViewData', [&$item, &$id,
&$table]
);
// Make sure the icon is only an icon path
if (isset($item->icon) && strpos($item->icon,
'#') !== false)
{
$item->icon = strstr($item->icon, '#', true);
}
// set GUI mapper
$guiMapper = [
'table' => $table,
'id' => (int) $id,
'field' => 'default',
'type' => 'html'
];
// set the default data
$item->default = $this->gui->set(
$this->customcode->update(base64_decode((string)
$item->default)),
$guiMapper
);
// load context if not set
if (!isset($item->context)
|| !StringHelper::check(
$item->context
))
{
$item->context = $item->code;
}
else
{
// always make sure context is a safe string
$item->context = StringHelper::safe($item->context);
}
// set the libraries
$this->libraries->set($item->code, $item);
// setup template and layout data
$this->templateLayout->set($item->default, $item->code);
// set uikit version 2
$this->loader->uikit($item->code, $item->default);
// auto loaders
$this->loader->set($item->code, $item->default);
// set the main get data
$main_get = $this->dynamic->get(
array($item->main_get), $item->code, $item->context
);
$item->main_get = ArrayHelper::check($main_get) ? $main_get[0] :
null;
// set the custom_get data
$item->custom_get = (isset($item->custom_get)
&& JsonHelper::check($item->custom_get))
? json_decode((string) $item->custom_get, true) : null;
if (ArrayHelper::check($item->custom_get))
{
$item->custom_get = $this->dynamic->get(
$item->custom_get, $item->code, $item->context
);
}
// set php scripts
$this->php->set($item, $table);
// set javascript scripts
$this->javascript->set($item, $table);
// set css scripts
$this->css->set($item);
// set Ajax for this view
$this->ajax->set($item, $table);
// set the custom buttons
$this->custombuttons->set($item, $table);
// Trigger Event: jcb_ce_onAfterModelCustomViewData
$this->event->trigger(
'jcb_ce_onAfterModelCustomViewData', [&$item]
);
// set the found data
$this->data[$id . $table] = $item;
}
// return the found data
return $this->data[$id . $table];
}
}
src/Componentbuilder/Compiler/Customview/index.html000064400000000054151162054130016555
0ustar00<html><body
bgcolor="#FFFFFF"></body></html>src/Componentbuilder/Compiler/Dynamicget/Data.php000064400000020116151162054130016062
0ustar00<?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\Dynamicget;
use Joomla\CMS\Factory;
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\Customcode;
use VDM\Joomla\Componentbuilder\Compiler\Customcode\Dispenser;
use VDM\Joomla\Componentbuilder\Compiler\Customcode\Gui;
use VDM\Joomla\Componentbuilder\Compiler\Model\Dynamicget;
use VDM\Joomla\Utilities\JsonHelper;
use VDM\Joomla\Utilities\StringHelper;
/**
* Dynamic Get Data Class
*
* @since 3.2.0
*/
class Data
{
/**
* The gui mapper array
*
* @var array
* @since 3.2.0
*/
protected array $guiMapper = [
'table' => 'dynamic_get',
'id' => null,
'field' => null,
'type' => 'php'
];
/**
* 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 Customcode
*
* @var Customcode
* @since 3.2.0
*/
protected Customcode $customcode;
/**
* Compiler Customcode Dispenser
*
* @var Dispenser
* @since 3.2.0
*/
protected Dispenser $dispenser;
/**
* Compiler Customcode in Gui
*
* @var Gui
* @since 3.2.0
**/
protected Gui $gui;
/**
* Compiler Dynamicget Model
*
* @var Dynamicget
* @since 3.2.0
*/
protected Dynamicget $dynamic;
/**
* Database object to query local DB
*
* @since 3.2.0
**/
protected $db;
/**
* 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 Customcode|null $customcode The compiler
customcode object.
* @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.
*
* @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)
{
$this->config = $config ?: Compiler::_('Config');
$this->registry = $registry ?: Compiler::_('Registry');
$this->event = $event ?: Compiler::_('Event');
$this->customcode = $customcode ?:
Compiler::_('Customcode');
$this->dispenser = $dispenser ?:
Compiler::_('Customcode.Dispenser');
$this->gui = $gui ?: Compiler::_('Customcode.Gui');
$this->dynamic = $dynamic ?:
Compiler::_('Model.Dynamicget');
$this->db = Factory::getDbo();
}
/**
* Get Dynamic Get Data
*
* @param array $ids The ids of the dynamic get
* @param string $view_code The view code name
* @param string $context The context for events
*
* @return array|null array of object/s on success
* @since 3.2.0
*/
public function get(array $ids, string $view_code, string $context):
?array
{
if ($ids === [])
{
return null;
}
$ids = implode(',', $ids);
// Create a new query object.
$query = $this->db->getQuery(true);
$query->select('a.*');
$query->from('#__componentbuilder_dynamic_get AS a');
$query->where('a.id IN (' . $ids . ')');
$this->db->setQuery($query);
$this->db->execute();
if ($this->db->getNumRows())
{
$results = $this->db->loadObjectList();
foreach ($results as $_nr => &$result)
{
// Trigger Event: jcb_ce_onBeforeModelDynamicGetData
$this->event->trigger(
'jcb_ce_onBeforeModelDynamicGetData', [&$result,
&$result->id, &$view_code, &$context]
);
// set GUI mapper id
$this->guiMapper['id'] = (int) $result->id;
// add calculations if set
if ($result->addcalculation == 1
&& StringHelper::check(
$result->php_calculation
))
{
// set GUI mapper field
$guiMapper['field'] = 'php_calculation';
$result->php_calculation = $this->gui->set(
$this->customcode->update(
base64_decode((string) $result->php_calculation)
),
$this->guiMapper
);
}
// setup the router parse
if (isset($result->add_php_router_parse)
&& $result->add_php_router_parse == 1
&& isset($result->php_router_parse)
&& StringHelper::check(
$result->php_router_parse
))
{
// set GUI mapper field
$this->guiMapper['field'] =
'php_router_parse';
$result->php_router_parse = $this->gui->set(
$this->customcode->update(
base64_decode((string) $result->php_router_parse)
),
$this->guiMapper
);
}
else
{
$result->add_php_router_parse = 0;
}
// The array of the php scripts that should be added to the script
builder
$phpSripts = [
'php_before_getitem',
'php_after_getitem',
'php_before_getitems',
'php_after_getitems',
'php_getlistquery'
];
// load the php scripts
foreach ($phpSripts as $script)
{
// add php script to the script builder
if (isset($result->{'add_' . $script})
&& $result->{'add_' . $script} == 1
&& isset($result->{$script})
&& StringHelper::check(
$result->{$script}
))
{
// move all main gets out to the custom script builder
if ($result->gettype <= 2)
{
// set GUI mapper field
$this->guiMapper['field'] = $script;
$this->guiMapper['prefix'] = PHP_EOL . PHP_EOL;
$this->dispenser->set(
$result->{$script},
$this->config->build_target . '_' . $script,
$view_code,
null,
$this->guiMapper,
true,
true,
true
);
unset($this->guiMapper['prefix']);
// remove from local item
unset($result->{$script});
unset($result->{'add_' . $script});
}
else
{
// set GUI mapper field
$this->guiMapper['field'] = $script;
$this->guiMapper['prefix'] = PHP_EOL;
// only for custom gets
$result->{$script} = $this->gui->set(
$this->customcode->update(
base64_decode((string) $result->{$script})
),
$this->guiMapper
);
unset($this->guiMapper['prefix']);
}
}
else
{
// remove from local item
unset($result->{$script});
unset($result->{'add_' . $script});
}
}
// set the getmethod code name
$result->key = StringHelper::safe(
$view_code . ' ' . $result->name . ' ' .
$result->id
);
// set the dynamic get
$this->dynamic->set($result, $view_code, $context);
// load the events if any is set
if ($result->gettype == 1
&& JsonHelper::check(
$result->plugin_events
))
{
$result->plugin_events = json_decode(
(string) $result->plugin_events, true
);
}
else
{
$result->plugin_events = '';
}
// Trigger Event: jcb_ce_onAfterModelDynamicGetData
$this->event->trigger(
'jcb_ce_onAfterModelDynamicGetData', [&$result,
&$result->id, &$view_code, &$context]
);
}
return $results;
}
return null;
}
}
src/Componentbuilder/Compiler/Dynamicget/Selection.php000064400000016060151162054130017141
0ustar00<?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\Dynamicget;
use Joomla\CMS\Factory;
use VDM\Joomla\Componentbuilder\Compiler\Config;
use VDM\Joomla\Componentbuilder\Compiler\Builder\GetAsLookup;
use VDM\Joomla\Componentbuilder\Compiler\Builder\SiteFields;
use VDM\Joomla\Utilities\StringHelper;
use VDM\Joomla\Utilities\ArrayHelper;
use VDM\Joomla\Utilities\GetHelper;
use VDM\Joomla\Utilities\Component\Helper;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Indent;
/**
* Dynamic Get Selection Class
*
* @since 3.2.0
*/
class Selection
{
/**
* Admin view table names
*
* @var array
* @since 3.2.0
*/
protected array $name;
/**
* The Config Class.
*
* @var Config
* @since 3.2.0
*/
protected Config $config;
/**
* The GetAsLookup Class.
*
* @var GetAsLookup
* @since 3.2.0
*/
protected GetAsLookup $getaslookup;
/**
* The SiteFields Class.
*
* @var SiteFields
* @since 3.2.0
*/
protected SiteFields $sitefields;
/**
* Database object to query local DB
*
* @since 3.2.0
**/
protected $db;
/**
* Constructor.
*
* @param Config $config The Config Class.
* @param GetAsLookup $getaslookup The GetAsLookup Class.
* @param SiteFields $sitefields The SiteFields Class.
*
* @since 3.2.0
*/
public function __construct(Config $config, GetAsLookup $getaslookup,
SiteFields $sitefields)
{
$this->config = $config;
$this->getaslookup = $getaslookup;
$this->sitefields = $sitefields;
$this->db = Factory::getDbo();
}
/**
* Get Data Selection of the dynamic get
*
* @param string $methodKey The method unique key
* @param string $viewCode The code name of the view
* @param string $string The data string
* @param string $asset The asset in question
* @param string $as The as string
* @param string $type The target type (db||view)
* @param int|null $rowType The row type
*
* @return array|null the select query
* @since 3.2.0
*/
public function get(string $methodKey, string $viewCode,
string $string, string $asset, string $as, string $type, ?int $rowType =
null): ?array
{
if (StringHelper::check($string))
{
if ('db' === $type)
{
$table = '#__' . $asset;
$queryName = $asset;
$view = '';
}
elseif ('view' === $type)
{
$view = $this->name($asset);
$table = '#__' . $this->config->component_code_name
. '_' . $view;
$queryName = $view;
}
else
{
return null;
}
// just get all values from table if * is found
if ($string === '*' || strpos($string, '*') !==
false)
{
if ($type == 'view')
{
// TODO move getViewTableColumns to its own class
$_string = Helper::_('getViewTableColumns',
[$asset, $as, $rowType]
);
}
else
{
// TODO move getDbTableColumns to its own class
$_string = Helper::_('getDbTableColumns',
[$asset, $as, $rowType]
);
}
// get only selected values
$lines = explode(PHP_EOL, (string) $_string);
// make sure to set the string to *
$string = '*';
}
else
{
// get only selected values
$lines = explode(PHP_EOL, $string);
}
// only continue if lines are available
if (ArrayHelper::check($lines))
{
$gets = [];
$keys = [];
// first load all options
foreach ($lines as $line)
{
if (strpos($line, 'AS') !== false)
{
$lineArray = explode("AS", $line);
}
elseif (strpos($line, 'as') !== false)
{
$lineArray = explode("as", $line);
}
else
{
$lineArray = array($line, null);
}
// set the get and key
$get = trim($lineArray[0]);
$key = trim($lineArray[1]);
// only add the view (we must adapt this)
if ($this->getaslookup->exists($methodKey . '.' .
$get)
&& 'a' != $as
&& is_numeric($rowType) && 1 == $rowType
&& 'view' === $type
&& strpos('#' . $key, '#' . $view .
'_') === false)
{
// this is a problem (TODO) since we may want to not add the view
name.
$key = $view . '_' . trim($key);
}
// continue only if we have get
if (StringHelper::check($get))
{
$gets[] = $this->db->quote($get);
if (StringHelper::check($key))
{
$this->getaslookup->set($methodKey . '.' . $get,
$key);
}
else
{
$key = str_replace(
$as . '.', '', $get
);
$this->getaslookup->set($methodKey . '.' . $get,
$key);
}
// set the keys
$keys[] = $this->db->quote(
$key
);
// make sure we have the view name
if (StringHelper::check($view))
{
// prep the field name
$field = str_replace($as . '.', '', $get);
// load to the site fields memory bucket
$this->sitefields->set($view . '.' . $field .
'.' . $methodKey . '___' . $as,
['site' => $viewCode, 'get' => $get,
'as' => $as, 'key' => $key]
);
}
}
}
if (ArrayHelper::check($gets)
&& ArrayHelper::check($keys))
{
// single joined selection needs the prefix to the values to avoid
conflict in the names
// so we must still add then AS
if ($string == '*' && (is_null($rowType) || 1 !=
$rowType))
{
$querySelect = "\$query->select('" . $as .
".*');";
}
else
{
$querySelect = '$query->select($db->quoteName('
. PHP_EOL . Indent::_(3) . 'array(' . implode(
',', $gets
) . '),' . PHP_EOL . Indent::_(3) . 'array('
. implode(',', $keys) . ')));';
}
$queryFrom = '$db->quoteName(' .
$this->db->quote($table)
. ', ' . $this->db->quote($as) . ')';
// return the select query
return [
'select' => $querySelect,
'from' => $queryFrom,
'view' => $viewCode,
'name' => $queryName,
'table' => $table,
'type' => $type,
'select_gets' => $gets,
'select_keys' => $keys
];
}
}
}
return null;
}
/**
* Get the Admin view table name
*
* @param int $id The item id to add
*
* @return string the admin view code name
* @since 3.2.0
*/
protected function name(int $id): string
{
// get name if not set
if (!isset($this->name[$id]))
{
$this->name[$id] = StringHelper::safe(
GetHelper::var('admin_view', $id, 'id',
'name_single')
);
}
return $this->name[$id] ?? 'error';
}
}
src/Componentbuilder/Compiler/Dynamicget/index.html000064400000000054151162054130016474
0ustar00<html><body
bgcolor="#FFFFFF"></body></html>src/Componentbuilder/Compiler/Extension/JoomlaFive/InstallScript.php000064400000037370151162054130021741
0ustar00<?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' => []];
/**
* The paths of the old plugin class files
*
* @var array
* @since 5.0.2
*/
protected array $removeFilePaths = [];
/**
* The paths of the old plugin folders
*
* @var array
* @since 5.0.2
*/
protected array $removeFolderPaths = [];
/**
* get install script
*
* @param Object $extension The extension object
*
* @return string
* @since 3.2.0
*/
public function get(object $extension): string
{
// purge the object
$this->rest();
// set the remove path
$this->removeFilePaths = $extension->remove_file_paths ?? [];
$this->removeFolderPaths = $extension->remove_folder_paths ?? [];
// loop over methods and types
foreach ($this->methods as $method)
{
foreach ($this->types as $type)
{
if (isset($extension->{'add_' . $method . '_' .
$type})
&& $extension->{'add_' . $method . '_'
. $type} == 1
&& StringHelper::check(
$extension->{$method . '_' . $type}
))
{
// add to the main methods
if ('php_method' === $method || 'php_script' ===
$method)
{
$this->{$type}[] = $extension->{$method . '_' .
$type};
}
else
{
// get the flight key
$flight = str_replace('php_', '', (string)
$method);
// load the script to our bucket
$this->{$flight . 'Bucket'}[$type][] =
$extension->{$method . '_' . $type};
// show that the method is active
$this->{$flight . 'Active'} = true;
}
}
}
}
$this->extension = $extension;
// return the class
return $this->build();
}
/**
* Reset all bucket at the start of each build
*
* @return void
* @since 3.2.0
*/
protected function rest(): void
{
$this->removeFilePaths = [];
$this->removeFolderPaths = [];
$this->construct = [];
$this->install = [];
$this->update = [];
$this->uninstall = [];
$this->preflightActive = false;
$this->preflightBucket = ['install' => [],
'uninstall' => [], 'discover_install' => [],
'update' => []];
$this->postflightActive = false;
$this->postflightBucket = ['install' => [],
'uninstall' => [], 'discover_install' => [],
'update' => []];
}
/**
* build the install class
*
* @return string
* @since 3.2.0
*/
protected function build(): string
{
// start build
$script = $this->head();
// load constructor if set
$script .= $this->construct();
// load install method if set
$script .= $this->main('install');
// load update method if set
$script .= $this->main('update');
// load uninstall method if set
$script .= $this->main('uninstall');
// load preflight method if set
$script .= $this->flight('preflight');
// load postflight method if set
$script .= $this->flight('postflight');
// load remove files method
$script .= $this->removeFiles();
// close the class
$script .= PHP_EOL . '}' . PHP_EOL;
return $script;
}
/**
* get install script head
*
* @return string
* @since 3.2.0
*/
protected function head(): string
{
// get the extension
$extension = $this->extension;
// start build
$script = PHP_EOL . 'use Joomla\CMS\Factory;';
$script .= PHP_EOL . 'use Joomla\CMS\Version;';
$script .= PHP_EOL . 'use
Joomla\CMS\Installer\InstallerAdapter;';
$script .= PHP_EOL . 'use Joomla\CMS\Language\Text;';
$script .= PHP_EOL . 'use Joomla\Filesystem\File;';
$script .= PHP_EOL . 'use Joomla\Filesystem\Folder;' .
PHP_EOL;
$script .= PHP_EOL . '/**';
$script .= PHP_EOL . ' * ' . $extension->official_name
. ' script file.';
$script .= PHP_EOL . ' *';
$script .= PHP_EOL . ' * @package ' .
$extension->class_name;
$script .= PHP_EOL . ' */';
$script .= PHP_EOL . 'class ' .
$extension->installer_class_name;
$script .= PHP_EOL . '{';
return $script;
}
/**
* get constructor
*
* @return string
* @since 3.2.0
*/
protected function construct(): string
{
// the __construct script
$script = PHP_EOL . Indent::_(1) . '/**';
$script .= PHP_EOL . Indent::_(1) . ' *' . Line::_(__Line__,
__Class__)
.' The CMS Application.';
$script .= PHP_EOL . Indent::_(1) . ' *';
$script .= PHP_EOL . Indent::_(1) . ' * @since 4.4.2';
$script .= PHP_EOL . Indent::_(1) . ' */';
$script .= PHP_EOL . Indent::_(1) . 'protected $app;';
$script .= PHP_EOL . PHP_EOL . Indent::_(1) . '/**';
$script .= PHP_EOL . Indent::_(1) . ' *' . Line::_(__Line__,
__Class__)
.' A list of files to be deleted';
$script .= PHP_EOL . Indent::_(1) . ' *';
$script .= PHP_EOL . Indent::_(1) . ' * @var array';
$script .= PHP_EOL . Indent::_(1) . ' * @since 3.6';
$script .= PHP_EOL . Indent::_(1) . ' */';
$script .= PHP_EOL . Indent::_(1) . 'protected array $deleteFiles =
[];';
$script .= PHP_EOL . PHP_EOL . Indent::_(1) . '/**';
$script .= PHP_EOL . Indent::_(1) . ' *' . Line::_(__Line__,
__Class__)
.' A list of folders to be deleted';
$script .= PHP_EOL . Indent::_(1) . ' *';
$script .= PHP_EOL . Indent::_(1) . ' * @var array';
$script .= PHP_EOL . Indent::_(1) . ' * @since 3.6';
$script .= PHP_EOL . Indent::_(1) . ' */';
$script .= PHP_EOL . Indent::_(1) . 'protected array $deleteFolders
= [];';
$script .= PHP_EOL . PHP_EOL . Indent::_(1) . '/**';
$script .= PHP_EOL . Indent::_(1) . ' * Constructor';
$script .= PHP_EOL . Indent::_(1) . ' *';
$script .= PHP_EOL . Indent::_(1)
. ' * @param InstallerAdapter $adapter The object responsible
for running this script';
$script .= PHP_EOL . Indent::_(1) . ' */';
$script .= PHP_EOL . Indent::_(1)
. 'public function __construct($adapter)';
$script .= PHP_EOL . Indent::_(1) . '{';
$script .= PHP_EOL . Indent::_(2) . '//' . Line::_(__Line__,
__Class__)
. ' get application';
$script .= PHP_EOL . Indent::_(2)
. '$this->app = Factory::getApplication();' . PHP_EOL;
if (ArrayHelper::check($this->construct))
{
$script .= PHP_EOL . implode(PHP_EOL . PHP_EOL, $this->construct);
}
// check if custom remove file is set
if ($this->removeFilePaths !== [] && strpos($script,
'$this->deleteFiles') === false)
{
// add the default delete files
foreach ($this->removeFilePaths as $filePath)
{
$script .= PHP_EOL . Indent::_(2) . "if (is_file(JPATH_ROOT .
'$filePath'))";
$script .= PHP_EOL . Indent::_(2) . "{";
$script .= PHP_EOL . Indent::_(3) . "\$this->deleteFiles[] =
'$filePath';";
$script .= PHP_EOL . Indent::_(2) . "}";
}
}
// check if custom remove file is set
if ($this->removeFolderPaths !== [] && strpos($script,
'$this->deleteFolders') === false)
{
// add the default delete folders
foreach ($this->removeFolderPaths as $folderPath)
{
$script .= PHP_EOL . Indent::_(2) . "if (is_dir(JPATH_ROOT .
'$folderPath'))";
$script .= PHP_EOL . Indent::_(2) . "{";
$script .= PHP_EOL . Indent::_(3) . "\$this->deleteFolders[] =
'$folderPath';";
$script .= PHP_EOL . Indent::_(2) . "}";
}
}
// close the function
$script .= PHP_EOL . Indent::_(1) . '}';
// add remove files
$this->preflightBucket['bottom'][] = Indent::_(2) .
'//' . Line::_(__Line__, __Class__)
.' remove old files and folders';
$this->preflightBucket['bottom'][] = Indent::_(2) .
'$this->removeFiles();';
return $script;
}
/**
* build main methods
*
* @param string $name the method being called
*
* @return string
* @since 3.2.0
*/
protected function main(string $name): string
{
// return empty string if not set
if (!ArrayHelper::check($this->{$name}))
{
return '';
}
// load the install method
$script = PHP_EOL . PHP_EOL . Indent::_(1) . '/**';
$script .= PHP_EOL . Indent::_(1) . " * Called on $name";
$script .= PHP_EOL . Indent::_(1) . ' *';
$script .= PHP_EOL . Indent::_(1)
. ' * @param InstallerAdapter $adapter The object responsible
for running this script';
$script .= PHP_EOL . Indent::_(1) . ' *';
$script .= PHP_EOL . Indent::_(1)
. ' * @return boolean True on success';
$script .= PHP_EOL . Indent::_(1) . ' */';
$script .= PHP_EOL . Indent::_(1) . 'public function '
. $name . '($adapter)';
$script .= PHP_EOL . Indent::_(1) . '{';
$script .= PHP_EOL . implode(PHP_EOL . PHP_EOL, $this->{$name});
// return true
if ('uninstall' !== $name)
{
$script .= PHP_EOL . Indent::_(2) . 'return true;';
}
// close the function
$script .= PHP_EOL . Indent::_(1) . '}';
return $script;
}
/**
* build flight methods
*
* @param string $name the method being called
*
* @return string
* @since 3.2.0
*/
protected function flight(string $name): string
{
// the pre/post function types
$script = PHP_EOL . PHP_EOL . Indent::_(1) . '/**';
$script .= PHP_EOL . Indent::_(1)
. ' * Called before any type of action';
$script .= PHP_EOL . Indent::_(1) . ' *';
$script .= PHP_EOL . Indent::_(1)
. ' * @param string $route Which action is happening
(install|uninstall|discover_install|update)';
$script .= PHP_EOL . Indent::_(1)
. ' * @param InstallerAdapter $adapter The object responsible
for running this script';
$script .= PHP_EOL . Indent::_(1) . ' *';
$script .= PHP_EOL . Indent::_(1)
. ' * @return boolean True on success';
$script .= PHP_EOL . Indent::_(1) . ' */';
$script .= PHP_EOL . Indent::_(1) . 'public function '
. $name . '($route, $adapter)';
$script .= PHP_EOL . Indent::_(1) . '{';
$script .= PHP_EOL . Indent::_(2) . '//' . Line::_(__Line__,
__Class__)
. ' set application to local method var, just use $this->app in
future [we will drop $app in J6]';
$script .= PHP_EOL . Indent::_(2)
. '$app = $this->app;' . PHP_EOL;
// add the default version check (TODO) must make this dynamic
if ('preflight' === $name)
{
$script .= PHP_EOL . Indent::_(2) . '//' . Line::_(__Line__,
__Class__)
.' the default for both install and update';
$script .= PHP_EOL . Indent::_(2)
. '$jversion = new Version();';
$script .= PHP_EOL . Indent::_(2)
. "if (!\$jversion->isCompatible('5.0.0'))";
$script .= PHP_EOL . Indent::_(2) . '{';
$script .= PHP_EOL . Indent::_(3)
. "\$app->enqueueMessage('Please upgrade to at least
Joomla! 5.0.0 before continuing!', 'error');";
$script .= PHP_EOL . Indent::_(3) . 'return false;';
$script .= PHP_EOL . Indent::_(2) . '}' . PHP_EOL;
}
if (!empty($this->{$name . 'Active'}))
{
// now add the scripts
foreach ($this->{$name . 'Bucket'} as $route =>
$_script)
{
if (ArrayHelper::check($_script) && $route !==
'bottom')
{
// set the if and script
$script .= PHP_EOL . Indent::_(2) . "if ('" . $route
. "' === \$route)";
$script .= PHP_EOL . Indent::_(2) . '{';
$script .= PHP_EOL . implode(
PHP_EOL . PHP_EOL, $_script
);
$script .= PHP_EOL . Indent::_(2) . '}' . PHP_EOL;
}
}
}
if (isset($this->{$name . 'Bucket'}['bottom'])
&& ArrayHelper::check($this->{$name .
'Bucket'}['bottom']))
{
$script .= PHP_EOL . implode(
PHP_EOL , $this->{$name . 'Bucket'}['bottom']
) . PHP_EOL;
}
// return true
$script .= PHP_EOL . Indent::_(2) . 'return true;';
// close the function
$script .= PHP_EOL . Indent::_(1) . '}';
return $script;
}
/**
* build remove files methods
*
* @return string
* @since 5.0.2
*/
protected function removeFiles(): string
{
$script = PHP_EOL . PHP_EOL . Indent::_(1) . '/**';
$script .= PHP_EOL . Indent::_(1) . ' * Remove the files and folders
in the given array from';
$script .= PHP_EOL . Indent::_(1) . ' *';
$script .= PHP_EOL . Indent::_(1) . ' * @return void';
$script .= PHP_EOL . Indent::_(1) . ' * @since 5.0.2';
$script .= PHP_EOL . Indent::_(1) . ' */';
$script .= PHP_EOL . Indent::_(1) . 'protected function
removeFiles()';
$script .= PHP_EOL . Indent::_(1) . '{';
$script .= PHP_EOL . Indent::_(2) . 'if
(!empty($this->deleteFiles))';
$script .= PHP_EOL . Indent::_(2) . '{';
$script .= PHP_EOL . Indent::_(3) . 'foreach ($this->deleteFiles
as $file)';
$script .= PHP_EOL . Indent::_(3) . '{';
$script .= PHP_EOL . Indent::_(4) . 'if (is_file(JPATH_ROOT . $file)
&& !File::delete(JPATH_ROOT . $file))';
$script .= PHP_EOL . Indent::_(4) . '{';
$script .= PHP_EOL . Indent::_(5) . 'echo
Text::sprintf(\'JLIB_INSTALLER_ERROR_FILE_FOLDER\', $file) .
\'<br>\';';
$script .= PHP_EOL . Indent::_(4) . '}';
$script .= PHP_EOL . Indent::_(3) . '}';
$script .= PHP_EOL . Indent::_(2) . '}';
$script .= PHP_EOL . PHP_EOL . Indent::_(2) . 'if
(!empty($this->deleteFolders))';
$script .= PHP_EOL . Indent::_(2) . '{';
$script .= PHP_EOL . Indent::_(3) . 'foreach
($this->deleteFolders as $folder)';
$script .= PHP_EOL . Indent::_(3) . '{';
$script .= PHP_EOL . Indent::_(4) . 'if (is_dir(JPATH_ROOT .
$folder) && !Folder::delete(JPATH_ROOT . $folder))';
$script .= PHP_EOL . Indent::_(4) . '{';
$script .= PHP_EOL . Indent::_(5) . 'echo
Text::sprintf(\'JLIB_INSTALLER_ERROR_FILE_FOLDER\', $folder) .
\'<br>\';';
$script .= PHP_EOL . Indent::_(4) . '}';
$script .= PHP_EOL . Indent::_(3) . '}';
$script .= PHP_EOL . Indent::_(2) . '}';
$script .= PHP_EOL . Indent::_(1) . '}';
return $script;
}
}
src/Componentbuilder/Compiler/Extension/JoomlaFive/index.html000064400000000054151162054130020417
0ustar00<html><body
bgcolor="#FFFFFF"></body></html>src/Componentbuilder/Compiler/Extension/JoomlaFour/InstallScript.php000064400000024451151162054130021757
0ustar00<?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
{
// purge the object
$this->rest();
// loop over methods and types
foreach ($this->methods as $method)
{
foreach ($this->types as $type)
{
if (isset($extension->{'add_' . $method . '_' .
$type})
&& $extension->{'add_' . $method . '_'
. $type} == 1
&& StringHelper::check(
$extension->{$method . '_' . $type}
))
{
// add to the main methods
if ('php_method' === $method || 'php_script' ===
$method)
{
$this->{$type}[] = $extension->{$method . '_' .
$type};
}
else
{
// get the flight key
$flight = str_replace('php_', '', (string)
$method);
// load the script to our bucket
$this->{$flight . 'Bucket'}[$type][] =
$extension->{$method . '_' . $type};
// show that the method is active
$this->{$flight . 'Active'} = true;
}
}
}
}
$this->extension = $extension;
// return the class
return $this->build();
}
/**
* Reset all bucket at the start of each build
*
* @return void
* @since 3.2.0
*/
protected function rest(): void
{
$this->construct = [];
$this->install = [];
$this->update = [];
$this->uninstall = [];
$this->preflightActive = false;
$this->preflightBucket = ['install' => [],
'uninstall' => [], 'discover_install' => [],
'update' => []];
$this->postflightActive = false;
$this->postflightBucket = ['install' => [],
'uninstall' => [], 'discover_install' => [],
'update' => []];
}
/**
* build the install class
*
* @return string
* @since 3.2.0
*/
protected function build(): string
{
// start build
$script = $this->head();
// load constructor if set
$script .= $this->construct();
// load install method if set
$script .= $this->main('install');
// load update method if set
$script .= $this->main('update');
// load uninstall method if set
$script .= $this->main('uninstall');
// load preflight method if set
$script .= $this->flight('preflight');
// load postflight method if set
$script .= $this->flight('postflight');
// 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('4.0.0'))";
$script .= PHP_EOL . Indent::_(2) . '{';
$script .= PHP_EOL . Indent::_(3)
. "\$app->enqueueMessage('Please upgrade to at least
Joomla! 4.0.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;
}
}
src/Componentbuilder/Compiler/Extension/JoomlaFour/index.html000064400000000054151162054130020441
0ustar00<html><body
bgcolor="#FFFFFF"></body></html>src/Componentbuilder/Compiler/Extension/JoomlaThree/InstallScript.php000064400000024454151162054130022116
0ustar00<?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\JoomlaThree;
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
{
// purge the object
$this->rest();
// loop over methods and types
foreach ($this->methods as $method)
{
foreach ($this->types as $type)
{
if (isset($extension->{'add_' . $method . '_' .
$type})
&& $extension->{'add_' . $method . '_'
. $type} == 1
&& StringHelper::check(
$extension->{$method . '_' . $type}
))
{
// add to the main methods
if ('php_method' === $method || 'php_script' ===
$method)
{
$this->{$type}[] = $extension->{$method . '_' .
$type};
}
else
{
// get the flight key
$flight = str_replace('php_', '', (string)
$method);
// load the script to our bucket
$this->{$flight . 'Bucket'}[$type][] =
$extension->{$method . '_' . $type};
// show that the method is active
$this->{$flight . 'Active'} = true;
}
}
}
}
$this->extension = $extension;
// return the class
return $this->build();
}
/**
* Reset all bucket at the start of each build
*
* @return void
* @since 3.2.0
*/
protected function rest(): void
{
$this->construct = [];
$this->install = [];
$this->update = [];
$this->uninstall = [];
$this->preflightActive = false;
$this->preflightBucket = ['install' => [],
'uninstall' => [], 'discover_install' => [],
'update' => []];
$this->postflightActive = false;
$this->postflightBucket = ['install' => [],
'uninstall' => [], 'discover_install' => [],
'update' => []];
}
/**
* build the install class
*
* @return string
* @since 3.2.0
*/
protected function build(): string
{
// start build
$script = $this->head();
// load constructor if set
$script .= $this->construct();
// load install method if set
$script .= $this->main('install');
// load update method if set
$script .= $this->main('update');
// load uninstall method if set
$script .= $this->main('uninstall');
// load preflight method if set
$script .= $this->flight('preflight');
// load postflight method if set
$script .= $this->flight('postflight');
// 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;
}
}
src/Componentbuilder/Compiler/Extension/JoomlaThree/index.html000064400000000054151162054130020575
0ustar00<html><body
bgcolor="#FFFFFF"></body></html>src/Componentbuilder/Compiler/Factory.php000064400000014142151162054130014536
0ustar00<?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;
use Joomla\DI\Container;
use VDM\Joomla\Componentbuilder\Service\Crypt;
use VDM\Joomla\Componentbuilder\Service\Server;
use VDM\Joomla\Service\Database;
use VDM\Joomla\Service\Model as BaseModel;
use VDM\Joomla\Service\Data;
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;
use VDM\Joomla\Componentbuilder\Compiler\Service\Customcode;
use VDM\Joomla\Componentbuilder\Compiler\Service\Power;
use VDM\Joomla\Componentbuilder\Compiler\Service\JoomlaPower;
use VDM\Joomla\Componentbuilder\Compiler\Service\Component;
use VDM\Joomla\Componentbuilder\Compiler\Service\Adminview;
use VDM\Joomla\Componentbuilder\Compiler\Service\Library;
use VDM\Joomla\Componentbuilder\Compiler\Service\Customview;
use VDM\Joomla\Componentbuilder\Compiler\Service\Templatelayout;
use VDM\Joomla\Componentbuilder\Compiler\Service\Extension;
use VDM\Joomla\Componentbuilder\Service\CoreRules;
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\BuilderAJ;
use VDM\Joomla\Componentbuilder\Compiler\Service\BuilderLZ;
use VDM\Joomla\Componentbuilder\Compiler\Service\Creator;
use
VDM\Joomla\Componentbuilder\Compiler\Service\ArchitectureComHelperClass;
use VDM\Joomla\Componentbuilder\Compiler\Service\ArchitectureController;
use VDM\Joomla\Componentbuilder\Compiler\Service\ArchitectureModel;
use VDM\Joomla\Componentbuilder\Compiler\Service\ArchitecturePlugin;
use VDM\Joomla\Componentbuilder\Service\Gitea;
use VDM\Joomla\Gitea\Service\Utilities as GiteaUtilities;
use VDM\Joomla\Gitea\Service\Settings as GiteaSettings;
use VDM\Joomla\Gitea\Service\Organization as GiteaOrg;
use VDM\Joomla\Gitea\Service\User as GiteaUser;
use VDM\Joomla\Gitea\Service\Repository as GiteaRepo;
use VDM\Joomla\Gitea\Service\Package as GiteaPackage;
use VDM\Joomla\Gitea\Service\Issue as GiteaIssue;
use VDM\Joomla\Gitea\Service\Notifications as GiteNotifi;
use VDM\Joomla\Gitea\Service\Miscellaneous as GiteaMisc;
use VDM\Joomla\Gitea\Service\Admin as GiteaAdmin;
use VDM\Joomla\Interfaces\FactoryInterface;
use VDM\Joomla\Abstraction\Factory as ExtendingFactory;
/**
* Compiler Factory
*
* @since 3.2.0
*/
abstract class Factory extends ExtendingFactory implements FactoryInterface
{
/**
* Current Joomla Version Being Build
*
* @var int
* @since 3.2.0
**/
protected static int $JoomlaVersion;
/**
* Get array of all keys in container
*
* @return array
* @since 3.2.0
*/
public static function getKeys(): array
{
return self::getContainer()->getKeys();
}
/**
* Get version specific class from the compiler container
*
* @param string $key The container class key
*
* @return mixed
* @since 3.2.0
*/
public static function _J($key)
{
if (empty(self::$JoomlaVersion))
{
self::$JoomlaVersion =
self::getContainer()->get('Config')->joomla_version;
}
return self::getContainer()->get('J' . self::$JoomlaVersion
. '.' . $key);
}
/**
* Create a container object
*
* @return Container
* @since 3.2.0
*/
protected static function createContainer(): Container
{
return (new Container())
->registerServiceProvider(new Crypt())
->registerServiceProvider(new Server())
->registerServiceProvider(new Database())
->registerServiceProvider(new BaseModel())
->registerServiceProvider(new Data())
->registerServiceProvider(new Model())
->registerServiceProvider(new Compiler())
->registerServiceProvider(new Event())
->registerServiceProvider(new Header())
->registerServiceProvider(new History())
->registerServiceProvider(new Language())
->registerServiceProvider(new Placeholder())
->registerServiceProvider(new Customcode())
->registerServiceProvider(new Power())
->registerServiceProvider(new JoomlaPower())
->registerServiceProvider(new Component())
->registerServiceProvider(new Adminview())
->registerServiceProvider(new Library())
->registerServiceProvider(new Customview())
->registerServiceProvider(new Templatelayout())
->registerServiceProvider(new Extension())
->registerServiceProvider(new CoreRules())
->registerServiceProvider(new Field())
->registerServiceProvider(new Joomlamodule())
->registerServiceProvider(new Joomlaplugin())
->registerServiceProvider(new Utilities())
->registerServiceProvider(new BuilderAJ())
->registerServiceProvider(new BuilderLZ())
->registerServiceProvider(new Creator())
->registerServiceProvider(new ArchitectureComHelperClass())
->registerServiceProvider(new ArchitectureController())
->registerServiceProvider(new ArchitectureModel())
->registerServiceProvider(new ArchitecturePlugin())
->registerServiceProvider(new Gitea())
->registerServiceProvider(new GiteaUtilities())
->registerServiceProvider(new GiteaSettings())
->registerServiceProvider(new GiteaOrg())
->registerServiceProvider(new GiteaUser())
->registerServiceProvider(new GiteaRepo())
->registerServiceProvider(new GiteaPackage())
->registerServiceProvider(new GiteaIssue())
->registerServiceProvider(new GiteNotifi())
->registerServiceProvider(new GiteaMisc())
->registerServiceProvider(new GiteaAdmin());
}
}
src/Componentbuilder/Compiler/Field.php000064400000007002151162054130014147
0ustar00<?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;
use VDM\Joomla\Componentbuilder\Compiler\Factory as Compiler;
use VDM\Joomla\Utilities\ArrayHelper;
use VDM\Joomla\Componentbuilder\Compiler\Field\Data;
use VDM\Joomla\Componentbuilder\Compiler\Field\Name;
use VDM\Joomla\Componentbuilder\Compiler\Field\TypeName;
use VDM\Joomla\Componentbuilder\Compiler\Field\UniqueName;
/**
* Compiler Field
*
* @since 3.2.0
*/
class Field
{
/**
* Compiler Field Data
*
* @var Data
* @since 3.2.0
**/
protected Data $data;
/**
* Compiler Field Name
*
* @var Name
* @since 3.2.0
**/
protected Name $name;
/**
* Compiler Field Type Name
*
* @var TypeName
* @since 3.2.0
**/
protected TypeName $typeName;
/**
* Compiler Field Unique Name
*
* @var UniqueName
* @since 3.2.0
**/
protected UniqueName $uniqueName;
/**
* Constructor
*
* @param Data|null $data The compiler field data
object.
* @param Name|null $name The compiler field name
object.
* @param TypeName|null $typeName The compiler field type name
object.
* @param UniqueName|null $uniqueName The compiler field unique name
object.
*
* @since 3.2.0
*/
public function __construct(?Data $data = null, ?Name $name = null,
?TypeName $typeName = null, ?UniqueName $uniqueName = null)
{
$this->data = $data ?: Compiler::_('Field.Data');
$this->name = $name ?: Compiler::_('Field.Name');
$this->typeName = $typeName ?:
Compiler::_('Field.Type.Name');
$this->uniqueName = $uniqueName ?:
Compiler::_('Field.Unique.Name');
}
/**
* set Field details
*
* @param array $field The field array.
* @param string|null $singleViewName The single view name.
* @param string|null $listViewName The list view name.
* @param string $amicably The peaceful resolve.
*
* @return void
* @since 3.2.0
*/
public function set(array &$field, ?string $singleViewName = null,
?string $listViewName = null, string $amicably = '')
{
// set hash
static $hash = 123467890;
// load hash if not found
if (!isset($field['hash']))
{
$field['hash'] = \md5($field['field'] . $hash);
// increment hash
$hash++;
}
// set the settings
if (!isset($field['settings']))
{
$field['settings'] = $this->data->get(
$field['field'], $singleViewName, $listViewName
);
}
// set real field name
if (!isset($field['base_name']))
{
$field['base_name'] = $this->name->get($field);
}
// set code name for field type
if (!isset($field['type_name']))
{
$field['type_name'] = $this->typeName->get($field);
}
// check if value is array
if (isset($field['permission'])
&& !ArrayHelper::check($field['permission'])
&& is_numeric($field['permission']) &&
$field['permission'] > 0)
{
$field['permission'] = array($field['permission']);
}
// set unique name keeper
if ($listViewName)
{
$this->uniqueName->set(
$field['base_name'], $listViewName . $amicably
);
}
}
}
src/Componentbuilder/Compiler/Field/Attributes.php000064400000061340151162054130016302
0ustar00<?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;
use VDM\Joomla\Componentbuilder\Compiler\Config;
use VDM\Joomla\Componentbuilder\Compiler\Registry;
use VDM\Joomla\Componentbuilder\Compiler\Builder\ListFieldClass;
use VDM\Joomla\Componentbuilder\Compiler\Builder\DoNotEscape;
use VDM\Joomla\Componentbuilder\Compiler\Placeholder;
use VDM\Joomla\Componentbuilder\Compiler\Customcode;
use VDM\Joomla\Componentbuilder\Compiler\Language;
use VDM\Joomla\Componentbuilder\Compiler\Field\Groups as FieldGroups;
use VDM\Joomla\Utilities\ArrayHelper;
use VDM\Joomla\Utilities\GetHelper;
use VDM\Joomla\Utilities\StringHelper;
use VDM\Joomla\Utilities\Base64Helper;
use VDM\Joomla\Utilities\String\FieldHelper;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\FieldHelper as
UtilitiesFieldHelper;
/**
* Compiler Field Attributes
*
* @since 3.2.0
*/
final class Attributes
{
/**
* The Config Class.
*
* @var Config
* @since 3.2.0
*/
protected Config $config;
/**
* The Registry Class.
*
* @var Registry
* @since 3.2.0
*/
protected Registry $registry;
/**
* The ListFieldClass Class.
*
* @var ListFieldClass
* @since 3.2.0
*/
protected ListFieldClass $listfieldclass;
/**
* The DoNotEscape Class.
*
* @var DoNotEscape
* @since 3.2.0
*/
protected DoNotEscape $donotescape;
/**
* The Placeholder Class.
*
* @var Placeholder
* @since 3.2.0
*/
protected Placeholder $placeholder;
/**
* The Customcode Class.
*
* @var Customcode
* @since 3.2.0
*/
protected Customcode $customcode;
/**
* The Language Class.
*
* @var Language
* @since 3.2.0
*/
protected Language $language;
/**
* The Groups Class.
*
* @var FieldGroups
* @since 3.2.0
*/
protected FieldGroups $fieldgroups;
/**
* Title Switch
*
* @var int
* @since 3.2.0
*/
private int $title;
/**
* Alias Switch
*
* @var int
* @since 3.2.0
*/
private int $alias;
/**
* Field Properties
*
* @var array
* @since 3.2.0
*/
private array $properties;
/**
* PHP Tracking
*
* @var array
* @since 3.2.0
*/
private array $php;
/**
* Field attributes
*
* @var array
* @since 3.2.0
*/
private array $attributes;
/**
* Field custom switch
*
* @var bool
* @since 3.2.0
*/
private bool $custom;
/**
* Field Custom Label
*
* @var string
* @since 3.2.0
*/
private string $customLabel;
/**
* Field readonly switch
*
* @var bool
* @since 3.2.0
*/
private bool $readonly;
/**
* Field View Type
*
* @var int
* @since 3.2.0
*/
private int $viewType;
/**
* Field Name
*
* @var string
* @since 3.2.0
*/
private string $name;
/**
* Field Type Name
*
* @var string
* @since 3.2.0
*/
private string $typeName;
/**
* Field Multiple Switch
*
* @var bool
* @since 3.2.0
*/
private bool $multiple;
/**
* Field Name Language Label
*
* @var string
* @since 3.2.0
*/
private string $langLabel;
/**
* View Language String
*
* @var string
* @since 3.2.0
*/
private string $langView;
/**
* View List Code
*
* @var string
* @since 3.2.0
*/
private string $nameListCode;
/**
* View Single Code
*
* @var string
* @since 3.2.0
*/
private string $nameSingleCode;
/**
* Field Placeholders
*
* @var array
* @since 3.2.0
*/
private array $placeholders;
/**
* Repeatable Switch
*
* @var bool
* @since 3.2.0
*/
private bool $repeatable;
/**
* Constructor.
*
* @param Config $config The Config Class.
* @param Registry $registry The Registry Class.
* @param ListFieldClass $listfieldclass The ListFieldClass Class.
* @param DoNotEscape $donotescape The DoNotEscape Class.
* @param Placeholder $placeholder The Placeholder Class.
* @param Customcode $customcode The Customcode Class.
* @param Language $language The Language Class.
* @param FieldGroups $fieldgroups The Groups Class.
*
* @since 3.2.0
*/
public function __construct(Config $config, Registry $registry,
ListFieldClass $listfieldclass, DoNotEscape $donotescape, Placeholder
$placeholder,
Customcode $customcode, Language $language, FieldGroups $fieldgroups)
{
$this->config = $config;
$this->registry = $registry;
$this->listfieldclass = $listfieldclass;
$this->donotescape = $donotescape;
$this->placeholder = $placeholder;
$this->customcode = $customcode;
$this->language = $language;
$this->fieldgroups = $fieldgroups;
}
/**
* set field attributes
*
* @param array $field The field data
* @param int $viewType The view type
* @param string $name The field name
* @param string $typeName The field type
* @param bool $multiple The switch to set multiple selection
option
* @param string $langLabel The language string for field label
* @param string $langView The language string of the view
* @param string $nameListCode The list view name
* @param string $nameSingleCode The single view name
* @param array $placeholders The place holder and replace values
* @param bool $repeatable The repeatable field switch
*
* @return array The field attributes
* @since 3.2.0
*/
public function set(
array $field, int $viewType, string $name, string $typeName,
bool &$multiple, string &$langLabel, string $langView, string
$nameListCode,
string $nameSingleCode, array $placeholders, bool $repeatable = false
): array
{
if (!$this->setSettings($field))
{
return [];
}
// initialise the empty attributes and other global values
$this->initialise($viewType, $name, $typeName, $multiple, $langLabel,
$langView, $nameListCode, $nameSingleCode, $placeholders, $repeatable);
if (!$this->setProperties())
{
return $this->attributes;
}
// set the attributes
$this->setAttributes();
// update global ref passed value
$multiple = $this->multiple;
$langLabel = $this->langLabel;
return $this->attributes;
}
/**
* set field settings
*
* @param array $field The field data
*
* @return bool true if settings was set
* @since 3.2.0
*/
private function setSettings(array $field): bool
{
if (isset($field['settings']))
{
$this->settings = $field['settings'];
$this->alias = $field['alias'] ?? 0;
$this->title = $field['title'] ?? 0;
return true;
}
return false;
}
/**
* set field properties
*
* @return bool true if settings was set
* @since 3.2.0
*/
private function setProperties(): bool
{
if (isset($this->settings->properties) &&
ArrayHelper::check($this->settings->properties))
{
$this->properties = $this->settings->properties;
return true;
}
return false;
}
/**
* Set the attributes with properties
*
* @return void
* @since 3.2.0
*/
private function setAttributes(): void
{
foreach ($this->properties as $property)
{
$name = $property['name'] ?? 'error';
$example = $property['example'] ?? 'error';
$translatable = $property['translatable'] ?? 0;
$mandatory = $property['mandatory'] ?? 0;
$this->setValue(
$this->modelValue(
$this->getValue($name),
$name,
(int) $translatable
),
$name,
$example,
(int) $mandatory
);
}
$this->setPHP();
$this->extraAttributes();
}
/**
* Set the extra attributes
*
* @return void
* @since 3.2.0
*/
private function extraAttributes(): void
{
// do some nice twigs beyond the default
if (isset($this->attributes['name']))
{
// check if we have class value for the list view of this field
$listclass = GetHelper::between(
$this->settings->xml, 'listclass="',
'"'
);
if (StringHelper::check($listclass))
{
$this->listfieldclass->set($this->nameListCode . '.'
. $this->attributes['name'], $listclass);
}
// check if we find reason to remove this field from being escaped
$escaped = GetHelper::between(
$this->settings->xml, 'escape="',
'"'
);
if (StringHelper::check($escaped))
{
$this->donotescape->set($this->nameListCode . '.' .
$this->attributes['name'], true);
}
// check if we have display switch for dynamic placement
$display = GetHelper::between(
$this->settings->xml, 'display="',
'"'
);
if (StringHelper::check($display))
{
$this->attributes['display'] = $display;
}
// make sure validation is set if found (even it not part of field
properties)
if (!isset($this->attributes['validate']))
{
// check if we have validate (validation rule set)
$validationRule = GetHelper::between(
$this->settings->xml, 'validate="',
'"'
);
if (StringHelper::check($validationRule))
{
$this->attributes['validate']
= StringHelper::safe(
$validationRule
);
}
}
// make sure ID is always readonly
if ($this->attributes['name'] === 'id' &&
!$this->readonly)
{
$this->attributes['readonly'] = 'true';
}
}
}
/**
* Get XML value
*
* @param string $name The property name
*
* @return string|null The property value
* @since 3.2.0
*/
private function getValue(string $name): ?string
{
if ($name === 'type')
{
return $this->getType();
}
if ($name === 'name')
{
return $this->getName();
}
if ($name === 'validate')
{
return $this->getValidation();
}
if (in_array($name, ['extension', 'directory',
'formsource']))
{
return $this->getXmlValue($name);
}
if (strpos((string) $name, 'type_php') !== false &&
$this->custom)
{
return $this->getTypePHP($name);
}
if ($name === 'prime_php' && $this->custom)
{
return $this->getPrimePHP($name);
}
if ($name === 'extends' && $this->custom)
{
return $this->getExtends();
}
if ($name === 'view' && $this->custom)
{
return $this->getView();
}
if ($name === 'views' && $this->custom)
{
return $this->getViews();
}
if ($name === 'component' && $this->custom)
{
return $this->getComponent();
}
if ($name === 'table' && $this->custom)
{
return $this->getTable();
}
if ($name === 'value_field' && $this->custom)
{
return $this->getValueField();
}
if ($name === 'key_field' && $this->custom)
{
return $this->getKeyField();
}
if ($name === 'button' && $this->repeatable
&& $this->custom)
{
return $this->removeButtonRepeatable();
}
if ($name === 'button' && $this->custom)
{
return $this->getButton();
}
if ($name === 'required' && 'repeatable' ===
$this->typeName)
{
return $this->removeRequired();
}
if ($this->viewType == 2 && in_array($name,
['readonly', 'disabled']))
{
return $this->setReadonly($name);
}
if ($name === 'multiple')
{
return $this->getMultiple($name);
}
if ($name === 'class' && in_array($this->typeName,
['note', 'spacer']))
{
return $this->getClass();
}
// Default action if no condition is met
return $this->getXmlValue($name);
}
/**
* Model the found value
*
* @param string|null $value The property value
* @param string $name The property name
* @param int $translatable Switch to set translation
*
* @return string|null The property value
* @since 3.2.0
*/
private function modelValue(?string $value, string $name, int
$translatable): ?string
{
// check if translatable
if ($value !== null && StringHelper::check($value)
&& $translatable == 1)
{
// update label if field use multiple times
if ($name === 'label')
{
if (isset($this->attributes['name'])
&& $this->registry->get("unique.names." .
$this->nameListCode . ".names." .
$this->attributes['name']) !== null)
{
$value .= ' ('
. StringHelper::safe(
$this->registry->get("unique.names." .
$this->nameListCode . ".names." .
$this->attributes['name'])
) . ')';
}
}
// replace placeholders
$value = $this->placeholder->update(
$value, $this->placeholders
);
// insure custom labels don't get messed up
if ($this->custom)
{
$this->customLabel = $value;
}
// set lang key
$lang_value = $this->langView . '_'
. FieldHelper::safe(
$this->name . ' ' . $name, true
);
// add to lang array
$this->language->set($this->config->lang_target,
$lang_value, $value);
// use lang value
$value = $lang_value;
}
elseif ($this->alias && $translatable == 1)
{
if ($name === 'label')
{
$value = 'JFIELD_ALIAS_LABEL';
}
elseif ($name === 'description')
{
$value = 'JFIELD_ALIAS_DESC';
}
elseif ($name === 'hint')
{
$value = 'JFIELD_ALIAS_PLACEHOLDER';
}
}
elseif ($this->title && $translatable == 1)
{
if ($name === 'label')
{
$value = 'JGLOBAL_TITLE';
}
}
return $value;
}
/**
* set the found value
*
* @param string|null $value The property value
* @param string $name The property name
* @param string $example The example value
* @param int $mandatory The mandatory switch
*
* @return void
* @since 3.2.0
*/
private function setValue(?string $value, string $name, string $example,
int $mandatory): void
{
// only load value if found or is mandatory
if (($value !== null && StringHelper::check($value))
|| ($mandatory == 1 && !$this->custom))
{
// make sure mandatory fields are added
if ($value === null || !StringHelper::check($value))
{
$value = $example;
}
// load to langBuilder down the line
if ($name === 'label')
{
if ($this->custom)
{
$this->attributes['custom']['label'] =
$this->customLabel ?? 'error';
}
$this->langLabel = $value;
}
// now set the value
$this->attributes[$name] = $value;
}
// validate that the default field is set
elseif ($name === 'default'
&& ($xmlValidateValue = GetHelper::between(
$this->settings->xml, 'default="',
'"', 'none-set'
)) !== 'none-set')
{
// we must allow empty defaults
$this->attributes['default'] = $value;
}
}
/**
* Set PHP if needed
*
* @return void
* @since 3.2.0
*/
private function setPHP(): void
{
// check if all php is loaded using the tracker
if (ArrayHelper::check($this->php))
{
// little search validation
$confirmation =
'8qvZHoyuFYQqpj0YQbc6F3o5DhBlmS-_-a8pmCZfOVSfANjkmV5LG8pCdAY2JNYu6cB';
foreach ($this->php as $search_key => $php_key)
{
// we must search for more code in the xml just encase
foreach (range(2, 30) as $php_line)
{
$get_ = $search_key . '_' . $php_line;
if
(!isset($this->attributes['custom'][$php_key][$php_line])
&& ($value = UtilitiesFieldHelper::getValue(
$this->settings->xml, $get_, $confirmation
)) !== $confirmation)
{
$this->attributes['custom'][$php_key][$php_line]
= $this->customcode->update(
Base64Helper::open($value)
);
}
}
}
}
}
/**
* get an xml value (default)
*
* @param string $name The property name
*
* @return string|null
* @since 3.2.0
*/
private function getXmlValue(string $name): ?string
{
// get value & replace the placeholders
return $this->placeholder->update(
GetHelper::between(
$this->settings->xml, $name . '="',
'"'
), $this->placeholders
);
}
/**
* get type value
*
* @return string
* @since 3.2.0
*/
private function getType(): string
{
// add to custom if it is custom
if ($this->custom)
{
// set the type just to make sure.
$this->attributes['custom']['type'] =
$this->typeName;
}
return $this->typeName;
}
/**
* get name value
*
* @return string
* @since 3.2.0
*/
private function getName(): string
{
// get the actual field name
return $this->placeholder->update($this->name,
$this->placeholders);
}
/**
* get validation value
*
* @return string|null
* @since 3.2.0
*/
private function getValidation(): ?string
{
// check if we have validate (validation rule set)
$value = GetHelper::between(
$this->settings->xml, 'validate="',
'"'
);
if (StringHelper::check($value))
{
$value = StringHelper::safe(
$value
);
}
return $value;
}
/**
* get type PHP code
*
* @param string $name The property name
*
* @return string|null
* @since 3.2.0
*/
private function getTypePHP(string $name): ?string
{
// set the line number
$line = (int) preg_replace(
'/[^0-9]/', '', (string) $name
);
// set the type key
$key = (string) trim(
str_replace(
'type_', '',
preg_replace('/[0-9]+/', '', (string) $name)
), '_'
);
// load the php for the custom field file
$this->attributes['custom'][$key][$line]
= $this->customcode->update(
Base64Helper::open(
GetHelper::between(
$this->settings->xml,
$name . '="', '"'
)
)
);
// load tracker
$this->php['type_' . $key] = $key;
return null;
}
/**
* get prime PHP code
*
* @param string $name The property name
*
* @return string|null
* @since 3.2.0
*/
private function getPrimePHP(string $name): ?string
{
// load the php for the custom field file
$this->attributes['custom']['prime_php']
= (int) GetHelper::between(
$this->settings->xml, $name . '="',
'"'
);
return null;
}
/**
* get extends value
*
* @return string|null
* @since 3.2.0
*/
private function getExtends(): ?string
{
// load the class that is being extended
$this->attributes['custom']['extends']
= GetHelper::between(
$this->settings->xml, 'extends="',
'"'
);
return null;
}
/**
* get view value
*
* @return string|null
* @since 3.2.0
*/
private function getView(): ?string
{
// load the view name & replace the placeholders
$this->attributes['custom']['view']
= StringHelper::safe(
$this->placeholder->update(
GetHelper::between(
$this->settings->xml, 'view="',
'"'
), $this->placeholders
)
);
return null;
}
/**
* get views value
*
* @return string|null
* @since 3.2.0
*/
private function getViews(): ?string
{
// load the views name & replace the placeholders
$this->attributes['custom']['views']
= StringHelper::safe(
$this->placeholder->update(
GetHelper::between(
$this->settings->xml, 'views="',
'"'
), $this->placeholders
)
);
return null;
}
/**
* get component value
*
* @return string|null
* @since 3.2.0
*/
private function getComponent(): ?string
{
// load the component name & replace the placeholders
$this->attributes['custom']['component']
= $this->placeholder->update(
GetHelper::between(
$this->settings->xml, 'component="',
'"'
), $this->placeholders
);
return null;
}
/**
* get table value
*
* @return string|null
* @since 3.2.0
*/
private function getTable(): ?string
{
// load the main table that is queried & replace the placeholders
$this->attributes['custom']['table']
= $this->placeholder->update(
GetHelper::between(
$this->settings->xml, 'table="',
'"'
), $this->placeholders
);
return null;
}
/**
* get value field
*
* @return string|null
* @since 3.2.0
*/
private function getValueField(): ?string
{
// load the text key
$this->attributes['custom']['text']
= StringHelper::safe(
GetHelper::between(
$this->settings->xml, 'value_field="',
'"'
)
);
return null;
}
/**
* get key field value
*
* @return string|null
* @since 3.2.0
*/
private function getKeyField(): ?string
{
// load the id key
$this->attributes['custom']['id']
= StringHelper::safe(
GetHelper::between(
$this->settings->xml, 'key_field="',
'"'
)
);
return null;
}
/**
* remove the button on repeatable
*
* @return string
* @since 3.2.0
*/
private function removeButtonRepeatable(): string
{
// do not add button
$this->attributes['custom']['add_button'] =
'false';
// don't load the button to repeatable
return 'false';
}
/**
* get button value
*
* @return string|null
* @since 3.2.0
*/
private function getButton(): ?string
{
// load the button string value if found
$value = (string) StringHelper::safe(
GetHelper::between(
$this->settings->xml, 'button="',
'"'
)
);
// add to custom values
$this->attributes['custom']['add_button']
= (StringHelper::check($value)
|| 1 == $value) ? $value : 'false';
return $value;
}
/**
* remove the required value
*
* @return string
* @since 3.2.0
*/
private function removeRequired(): string
{
// don't load the required to repeatable field type
return 'false';
}
/**
* set the readonly switch
*
* @param string $name The property name
*
* @return string
* @since 3.2.0
*/
private function setReadonly(string $name): string
{
// trip the switch for readonly
if ($name === 'readonly')
{
$this->readonly = true;
}
// set read only
return 'true';
}
/**
* set the multiple switch
*
* @param string $name The property name
*
* @return string
* @since 3.2.0
*/
private function getMultiple(string $name): string
{
$value = (string) GetHelper::between(
$this->settings->xml, $name . '="',
'"'
);
// add the multiple
if ('true' === $value)
{
$this->multiple = true;
}
return $value;
}
/**
* get class value
*
* @return string
* @since 3.2.0
*/
private function getClass(): string
{
$value = GetHelper::between(
$this->settings->xml, 'class="',
'"'
);
// add the type class
if (StringHelper::check($value))
{
if (strpos($value, $this->name) === false)
{
$value = $value . ' ' . $this->name;
}
return $value;
}
return $this->name;
}
/**
* Initialise the attributes and other global values
*
* @param int $viewType The view type
* @param string $name The field name
* @param string $typeName The field type
* @param bool $multiple The switch to set multiple selection
option
* @param string $langLabel The language string for field label
* @param string $langView The language string of the view
* @param string $nameListCode The list view name
* @param string $nameSingleCode The single view name
* @param array $placeholders The place holder and replace values
* @param bool $repeatable The repeatable field switch
*
* @return void
* @since 3.2.0
*/
private function initialise(int $viewType, string $name, string
$typeName,
bool $multiple, string $langLabel, string $langView, string
$nameListCode,
string $nameSingleCode, array $placeholders, bool $repeatable): void
{
$this->attributes = [];
$this->php = [];
$this->custom = false;
$this->readonly = false;
$this->viewType = $viewType;
$this->name = $name;
$this->typeName = $typeName;
$this->multiple = $multiple;
$this->langLabel = $langLabel;
$this->langView = $langView;
$this->nameListCode = $nameListCode;
$this->nameSingleCode = $nameSingleCode;
$this->placeholders = $placeholders;
$this->repeatable = $repeatable;
// setup Joomla default fields
if (!$this->fieldgroups->check($typeName))
{
$this->attributes['custom'] = [];
// is this an own custom field
if (isset($this->settings->own_custom))
{
$this->attributes['custom']['own_custom']
= $this->settings->own_custom;
}
$this->custom = true;
}
}
}
src/Componentbuilder/Compiler/Field/Customcode.php000064400000013334151162054130016261
0ustar00<?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;
use VDM\Joomla\Componentbuilder\Compiler\Factory as Compiler;
use VDM\Joomla\Utilities\StringHelper;
use VDM\Joomla\Componentbuilder\Compiler\Customcode\Dispenser;
/**
* Compiler Field Customcode
*
* @since 3.2.0
*/
class Customcode
{
/**
* Tracking the update of fields per/view
*
* @var array
* @since 3.2.0
*/
protected array $views;
/**
* Compiler Customcode Dispenser
*
* @var Dispenser
* @since 3.2.0
*/
protected Dispenser $dispenser;
/**
* Constructor
*
* @param Dispenser|null $dispenser The compiler customcode
dispenser object.
*
* @since 3.2.0
*/
public function __construct(?Dispenser $dispenser = null)
{
$this->dispenser = $dispenser ?:
Compiler::_('Customcode.Dispenser');
}
/**
* Update field customcode
*
* @param int $id The field id
* @param object $field The field object
* @param string|null $singleViewName The view edit or single name
* @param string|null $listViewName The view list name
*
* @return void
* @since 3.2.0
*/
public function update(int $id, object &$field, $singleViewName =
null, $listViewName = null)
{
// check if we should load scripts for single view
if ($singleViewName && StringHelper::check($singleViewName)
&& !isset($this->views[$singleViewName][$id]))
{
// add_javascript_view_footer
if ($field->add_javascript_view_footer == 1
&& StringHelper::check(
$field->javascript_view_footer
))
{
$convert__ = true;
if (isset($field->javascript_view_footer_decoded)
&& $field->javascript_view_footer_decoded)
{
$convert__ = false;
}
$this->dispenser->set(
$field->javascript_view_footer,
'view_footer',
$singleViewName,
null,
array(
'table' => 'field',
'id' => (int) $id,
'field' => 'javascript_view_footer',
'type' => 'js',
'prefix' => PHP_EOL),
$convert__,
$convert__,
true
);
if (!isset($field->javascript_view_footer_decoded))
{
$field->javascript_view_footer_decoded
= true;
}
if (strpos((string) $field->javascript_view_footer,
"token") !== false
|| strpos((string) $field->javascript_view_footer,
"task=ajax") !== false)
{
if (!isset($this->dispenser->hub['token']))
{
$this->dispenser->hub['token'] = [];
}
if
(!isset($this->dispenser->hub['token'][$singleViewName])
|| !$this->dispenser->hub['token'][$singleViewName])
{
$this->dispenser->hub['token'][$singleViewName]
= true;
}
}
}
// add_css_view
if ($field->add_css_view == 1)
{
$convert__ = true;
if (isset($field->css_view_decoded)
&& $field->css_view_decoded)
{
$convert__ = false;
}
$this->dispenser->set(
$field->css_view,
'css_view',
$singleViewName,
null,
array('prefix' => PHP_EOL),
$convert__,
$convert__,
true
);
if (!isset($field->css_view_decoded))
{
$field->css_view_decoded = true;
}
}
// add this only once to single view.
$this->views[$singleViewName][$id] = true;
}
// check if we should load scripts for list views
if ($listViewName && StringHelper::check($listViewName)
&& !isset($this->views[$listViewName][$id]))
{
// add_javascript_views_footer
if ($field->add_javascript_views_footer == 1
&& StringHelper::check(
$field->javascript_views_footer
))
{
$convert__ = true;
if (isset($field->javascript_views_footer_decoded)
&& $field->javascript_views_footer_decoded)
{
$convert__ = false;
}
$this->dispenser->set(
$field->javascript_views_footer,
'views_footer',
$singleViewName,
null,
array(
'table' => 'field',
'id' => (int) $id,
'field' => 'javascript_views_footer',
'type' => 'js',
'prefix' => PHP_EOL),
$convert__,
$convert__,
true
);
if (!isset($field->javascript_views_footer_decoded))
{
$field->javascript_views_footer_decoded = true;
}
if (strpos((string) $field->javascript_views_footer,
"token") !== false
|| strpos((string) $field->javascript_views_footer,
"task=ajax") !== false)
{
if (!isset($this->dispenser->hub['token']))
{
$this->dispenser->hub['token'] = [];
}
if
(!isset($this->dispenser->hub['token'][$listViewName])
|| !$this->dispenser->hub['token'][$listViewName])
{
$this->dispenser->hub['token'][$listViewName]
= true;
}
}
}
// add_css_views
if ($field->add_css_views == 1)
{
$convert__ = true;
if (isset($field->css_views_decoded)
&& $field->css_views_decoded)
{
$convert__ = false;
}
$this->dispenser->set(
$field->css_views,
'css_views',
$singleViewName,
null,
array('prefix' => PHP_EOL),
$convert__,
$convert__,
true
);
if (!isset($field->css_views_decoded))
{
$field->css_views_decoded = true;
}
}
// add this only once to list view.
$this->views[$listViewName][$id] = true;
}
}
}
src/Componentbuilder/Compiler/Field/Data.php000064400000020432151162054130015022
0ustar00<?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;
use Joomla\CMS\Factory;
use VDM\Joomla\Componentbuilder\Compiler\Config;
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\Rule;
use VDM\Joomla\Utilities\JsonHelper;
use VDM\Joomla\Utilities\ArrayHelper;
use VDM\Joomla\Utilities\StringHelper;
/**
* Compiler Field Data
*
* @since 3.2.0
*/
class Data
{
/**
* Compiler Fields
*
* @var array
* @since 3.2.0
*/
protected array $fields;
/**
* 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 HistoryInterface Class.
*
* @var History
* @since 3.2.0
*/
protected History $history;
/**
* The Placeholder Class.
*
* @var Placeholder
* @since 3.2.0
*/
protected Placeholder $placeholder;
/**
* The Customcode Class.
*
* @var Customcode
* @since 3.2.0
*/
protected Customcode $customcode;
/**
* The Customcode Class.
*
* @var FieldCustomcode
* @since 3.2.0
*/
protected FieldCustomcode $fieldcustomcode;
/**
* The Rule Class.
*
* @var Rule
* @since 3.2.0
*/
protected Rule $rule;
/**
* The database class.
*
* @since 3.2.0
*/
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;
$this->event = $event;
$this->history = $history;
$this->placeholder = $placeholder;
$this->customcode = $customcode;
$this->fieldcustomcode = $fieldcustomcode;
$this->rule = $rule;
$this->db = Factory::getDbo();
}
/**
* Get all Field Data
*
* @param int $id The field ID
* @param string|null $singleViewName The view edit or single name
* @param string|null $listViewName The view list name
*
* @return object|null The field data
* @since 3.2.0
*/
public function get(int $id, ?string $singleViewName = null, ?string
$listViewName = null): ?object
{
if ($id > 0 && !isset($this->fields[$id]))
{
// Create a new query object.
$query = $this->db->getQuery(true);
// Select all the values in the field
$query->select('a.*');
$query->select(
$this->db->quoteName(
array('c.name', 'c.properties'),
array('type_name', 'properties')
)
);
$query->from('#__componentbuilder_field AS a');
$query->join(
'LEFT',
$this->db->quoteName('#__componentbuilder_fieldtype',
'c')
. ' ON (' .
$this->db->quoteName('a.fieldtype') . ' = '
. $this->db->quoteName('c.id') . ')'
);
$query->where(
$this->db->quoteName('a.id') . ' = ' .
$this->db->quote($id)
);
// Trigger Event: jcb_ce_onBeforeQueryFieldData
$this->event->trigger(
'jcb_ce_onBeforeQueryFieldData', [&$id, &$query,
&$this->db]
);
// Reset the query using our newly populated query object.
$this->db->setQuery($query);
$this->db->execute();
if ($this->db->getNumRows())
{
// Load the results as a list of stdClass objects (see later for more
options on retrieving data).
$field = $this->db->loadObject();
// Trigger Event: jcb_ce_onBeforeModelFieldData
$this->event->trigger(
'jcb_ce_onBeforeModelFieldData', [&$field]
);
// adding a fix for the changed name of type to fieldtype
$field->type = $field->fieldtype;
// load the values form params
$field->xml = $this->customcode->update(json_decode((string)
$field->xml));
// check if we have validate (validation rule and set it if found)
$this->rule->set($id, $field->xml);
// load the type values form type params
$field->properties = (isset($field->properties)
&& JsonHelper::check($field->properties))
? json_decode((string) $field->properties, true) : null;
if (ArrayHelper::check($field->properties))
{
$field->properties = array_values($field->properties);
}
// check if we have WHMCS encryption
if (4 == $field->store
&& !$this->config->whmcs_encryption)
{
$this->config->whmcs_encryption = true;
}
// check if we have basic encryption
elseif (3 == $field->store
&& !$this->config->basic_encryption)
{
$this->config->basic_encryption = true;
}
// check if we have better encryption
elseif (5 == $field->store
&& $this->config->medium_encryption)
{
$this->config->medium_encryption = true;
}
// check if we have better encryption
elseif (6 == $field->store
&& StringHelper::check(
$field->on_get_model_field
)
&& StringHelper::check(
$field->on_save_model_field
))
{
// add only if string lenght found
if (StringHelper::check(
$field->initiator_on_save_model
))
{
$field->initiator_save_key = md5(
(string) $field->initiator_on_save_model
);
$field->initiator_save = explode(
PHP_EOL, $this->placeholder->update_(
$this->customcode->update(
base64_decode(
(string) $field->initiator_on_save_model
)
)
)
);
}
if (StringHelper::check(
$field->initiator_on_save_model
))
{
$field->initiator_get_key = md5(
(string) $field->initiator_on_get_model
);
$field->initiator_get = explode(
PHP_EOL, $this->placeholder->update_(
$this->customcode->update(
base64_decode(
(string) $field->initiator_on_get_model
)
)
)
);
}
// set the field modelling
$field->model_field['save'] = explode(
PHP_EOL, $this->placeholder->update_(
$this->customcode->update(
base64_decode((string) $field->on_save_model_field)
)
)
);
$field->model_field['get'] = explode(
PHP_EOL, $this->placeholder->update_(
$this->customcode->update(
base64_decode((string) $field->on_get_model_field)
)
)
);
// remove the original values
unset(
$field->on_save_model_field,
$field->on_get_model_field,
$field->initiator_on_save_model,
$field->initiator_on_get_model
);
}
// get the last used version
$field->history = $this->history->get('field',
$id);
// Trigger Event: jcb_ce_onAfterModelFieldData
$this->event->trigger(
'jcb_ce_onAfterModelFieldData', [&$field]
);
$this->fields[$id] = $field;
}
else
{
return null;
}
}
if ($id > 0 && isset($this->fields[$id]))
{
// update the customcode of the field
$this->fieldcustomcode->update($id, $this->fields[$id],
$singleViewName, $listViewName);
// return the field
return $this->fields[$id];
}
return null;
}
}
src/Componentbuilder/Compiler/Field/DatabaseName.php000064400000004717151162054130016466
0ustar00<?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;
use VDM\Joomla\Componentbuilder\Compiler\Builder\Lists;
use VDM\Joomla\Componentbuilder\Compiler\Registry;
use VDM\Joomla\Utilities\ArrayHelper;
/**
* Compiler Field Database Name
*
* @since 3.2.0
*/
class DatabaseName
{
/**
* The Lists Class.
*
* @var Lists
* @since 3.2.0
*/
protected Lists $lists;
/**
* The Registry Class.
*
* @var Registry
* @since 3.2.0
*/
protected Registry $registry;
/**
* Constructor.
*
* @param Lists $lists The Lists Class.
* @param Registry $registry The Registry Class.
*
* @since 3.2.0
*/
public function __construct(Lists $lists, Registry $registry)
{
$this->lists = $lists;
$this->registry = $registry;
}
/**
* get the field database name and AS prefix
*
* @param string $nameListCode The list view name
* @param int $fieldId The field ID
* @param string $targetArea The area being targeted
*
* @return string|null
* @since 3.2.0
*/
public function get(string $nameListCode, int $fieldId, string $targetArea
= 'builder.list'): ?string
{
if ($targetArea === 'builder.list')
{
if (($fields = $this->lists->get($nameListCode)) === null)
{
return null;
}
}
elseif (($fields =
$this->registry->get("${targetArea}.${nameListCode}")) ===
null)
{
return null;
}
if ($fieldId < 0)
{
switch ($fieldId)
{
case -1:
return 'a.id';
case -2:
return 'a.ordering';
case -3:
return 'a.published';
}
}
foreach ($fields as $field)
{
if ($field['id'] == $fieldId)
{
// now check if this is a category
if ($field['type'] === 'category')
{
return 'c.title';
}
// set the custom code
elseif (ArrayHelper::check(
$field['custom']
))
{
return $field['custom']['db'] . "."
. $field['custom']['text'];
}
else
{
return 'a.' . $field['code'];
}
}
}
return null;
}
}
src/Componentbuilder/Compiler/Field/Groups.php000064400000012755151162054130015441
0ustar00<?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;
use Joomla\CMS\Factory;
use VDM\Joomla\Utilities\ArrayHelper;
use VDM\Joomla\Utilities\GetHelper;
/**
* Compiler Field Groups
*
* @since 3.2.0
*/
final class Groups
{
/**
* Field Grouping https://docs.joomla.org/Form_field
*
* @var array
* @since 3.2.0
**/
protected array $groups = [
'default' => [
'accesslevel', 'cachehandler', 'calendar',
'captcha', 'category', 'checkbox',
'checkboxes', 'chromestyle',
'color', 'combo', 'componentlayout',
'contentlanguage', 'contenttype',
'databaseconnection', 'components',
'editor', 'editors', 'email',
'file', 'file', 'filelist',
'folderlist', 'groupedlist', 'headertag',
'helpsite', 'hidden', 'imagelist',
'integer', 'language', 'list',
'media', 'menu', 'modal_menu',
'menuitem', 'meter', 'modulelayout',
'moduleorder', 'moduleposition',
'moduletag', 'note', 'number',
'password', 'plugins', 'predefinedlist',
'radio', 'range', 'repeatable',
'rules', 'usergrouplist',
'sessionhandler', 'spacer', 'sql',
'subform', 'tag', 'tel',
'templatestyle', 'text', 'textarea',
'timezone', 'url', 'user',
'usergroup'
],
'plain' => [
'cachehandler', 'calendar', 'checkbox',
'chromestyle', 'color', 'componentlayout',
'contenttype', 'editor', 'editors',
'captcha',
'email', 'file', 'headertag',
'helpsite', 'hidden', 'integer',
'language', 'media', 'menu',
'modal_menu', 'menuitem', 'meter',
'modulelayout', 'templatestyle',
'moduleorder', 'moduletag', 'number',
'password', 'range', 'rules',
'tag', 'tel', 'text', 'textarea',
'timezone', 'url', 'user',
'usergroup' , 'usergrouplist'
],
'option' => [
'accesslevel', 'category', 'checkboxes',
'combo', 'contentlanguage',
'databaseconnection', 'components',
'filelist', 'folderlist', 'imagelist',
'list', 'plugins', 'predefinedlist',
'radio', 'sessionhandler', 'sql',
'groupedlist'
],
'text' => [
'calendar', 'color', 'editor',
'email', 'number', 'password',
'range', 'tel', 'text', 'textarea',
'url'
],
'list' => [
'checkbox', 'checkboxes', 'list',
'radio', 'groupedlist', 'combo'
],
'dynamic' => [
'category', 'file', 'filelist',
'folderlist', 'headertag', 'imagelist',
'integer', 'media', 'meter',
'rules', 'tag', 'timezone', 'user'
],
'spacer' => [
'note', 'spacer'
],
'special' => [
'contentlanguage', 'moduleposition',
'plugin', 'repeatable', 'subform'
],
'search' => [
'editor', 'email', 'tel',
'text', 'textarea', 'url',
'subform'
]
];
/**
* Database object to query local DB
*
* @since 3.2.0
*/
protected $db;
/**
* Constructor
*
* @since 3.2.0
*/
public function __construct()
{
$this->db = Factory::getDbo();
}
/**
* Field Checker
*
* @param string $type The field type
* @param string $option The field grouping
*
* @return bool if the field was found
* @since 3.2.0
*/
public function check(string $type, string $option = 'default'):
bool
{
// now check
if (isset($this->groups[$option]) && in_array($type,
$this->groups[$option]))
{
return true;
}
return false;
}
/**
* get the field types id -> name of a group or groups
*
* @param array $groups The groups
*
* @return array|null ids of the spacer field types
* @since 3.2.0
*/
public function types(array $groups = []): ?array
{
// make sure we have a group
if (($ids = $this->typesIds($groups)) !== null)
{
// Create a new query object.
$query = $this->db->getQuery(true);
$query->select($this->db->quoteName(array('id',
'name')));
$query->from($this->db->quoteName('#__componentbuilder_fieldtype'));
$query->where($this->db->quoteName('published') .
' = 1');
$query->where($this->db->quoteName('id') . ' IN
(' . implode(',',$ids) . ')');
// Reset the query using our newly populated query object.
$this->db->setQuery($query);
$this->db->execute();
if ($this->db->getNumRows())
{
return $this->db->loadAssocList('id',
'name');
}
}
return null;
}
/**
* get the field types IDs of a group or groups
*
* @param array $groups The groups
*
* @return array|null ids of the spacer field types
* @since 3.2.0
*/
public function typesIds(array $groups = []): ?array
{
// make sure we have a group
if (ArrayHelper::check($groups))
{
$merge_groups = [];
foreach ($groups as $group)
{
if (isset($this->groups[$group]))
{
$merge_groups[] = $this->groups[$group];
}
}
// make sure we have these types of groups
if (ArrayHelper::check($merge_groups))
{
// get the database object to use quote
return GetHelper::vars(
'fieldtype',
(array) array_map(function($name) {
return $this->db->quote(ucfirst($name));
}, ArrayHelper::merge($merge_groups)),
'name',
'id'
);
}
}
return null;
}
/**
* get the spacer IDs
*
* @return array|null ids of the spacer field types
* @since 3.2.0
*/
public function spacerIds(): ?array
{
return $this->typesIds(['spacer']);
}
}
src/Componentbuilder/Compiler/Field/JoomlaFive/CoreField.php000064400000005356151162054130020050
0ustar00<?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));
}
}
src/Componentbuilder/Compiler/Field/JoomlaFive/CoreRule.php000064400000005201151162054130017721
0ustar00<?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));
}
}
src/Componentbuilder/Compiler/Field/JoomlaFive/InputButton.php000064400000035131151162054130020501
0ustar00<?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 =
Joomla__"."_39403062_84fb_46e0_bac4_0023f766e827___Power::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 = '&ref=' . \$values['view']
. '&refid=' . \$values['id'];";
$addButton[] = Indent::_(4)
. "\$refJ = '&ref=' . \$values['view'] .
'&refid=' . \$values['id'];";
$addButton[] = Indent::_(4) . "//" . Line::_(__Line__,
__Class__)
. " get the return value.";
$addButton[] = Indent::_(4)
. "\$_uri = (string)
Joomla__"."_eecc143e_b5cf_4c33_ba4d_97da1df61422___Power::getInstance();";
$addButton[] = Indent::_(4)
. "\$_return = urlencode(base64_encode(\$_uri));";
$addButton[] = Indent::_(4) . "//" . Line::_(__Line__,
__Class__)
. " load return value.";
$addButton[] = Indent::_(4)
. "\$ref .= '&return=' . \$_return;";
$addButton[] = Indent::_(4)
. "\$refJ .= '&return=' . \$_return;";
$addButton[] = Indent::_(3) . "}";
}
else
{
$addButton[] = Indent::_(3)
. "if (!is_null(\$values['id']) &&
strlen(\$values['view']))";
$addButton[] = Indent::_(3) . "{";
$addButton[] = Indent::_(4) . "//" . Line::_(__Line__,
__Class__)
. " only load field details if not new item.";
$addButton[] = Indent::_(4)
. "\$ref = '&field=' .
\$values['view'] . '&field_id=' .
\$values['id'];";
$addButton[] = Indent::_(4)
. "\$refJ = '&field=' . \$values['view']
. '&field_id=' . \$values['id'];";
$addButton[] = Indent::_(4) . "//" . Line::_(__Line__,
__Class__)
. " get the return value.";
$addButton[] = Indent::_(4)
. "\$_uri = (string)
Joomla__"."_eecc143e_b5cf_4c33_ba4d_97da1df61422___Power::getInstance();";
$addButton[] = Indent::_(4)
. "\$_return = urlencode(base64_encode(\$_uri));";
$addButton[] = Indent::_(4) . "//" . Line::_(__Line__,
__Class__)
. " load return value.";
$addButton[] = Indent::_(4)
. "\$ref = '&return=' . \$_return;";
$addButton[] = Indent::_(4)
. "\$refJ = '&return=' . \$_return;";
$addButton[] = Indent::_(3) . "}";
}
$addButton[] = Indent::_(3) . "//" . Line::_(__Line__,
__Class__)
. " get button label";
$addButton[] = Indent::_(3)
. "\$button_label = trim(\$button_code_name);";
$addButton[] = Indent::_(3)
. "\$button_label = preg_replace('/_+/', ' ',
\$button_label);";
$addButton[] = Indent::_(3)
. "\$button_label = preg_replace('/\s+/', ' ',
\$button_label);";
$addButton[] = Indent::_(3)
. "\$button_label = preg_replace(\"/[^A-Za-z ]/\",
'', \$button_label);";
$addButton[] = Indent::_(3)
. "\$button_label = ucfirst(strtolower(\$button_label));";
$addButton[] = Indent::_(3) . "//" . Line::_(__Line__,
__Class__)
. " get user object";
$addButton[] = Indent::_(3) . "\$user =
Joomla__"."_39403062_84fb_46e0_bac4_0023f766e827___Power::getApplication()->getIdentity();";
$addButton[] = Indent::_(3) . "//" . Line::_(__Line__,
__Class__)
. " only add if user allowed to create " .
$fieldData['view'];
// check if the item has permissions.
$addButton[] = Indent::_(3) . "if
(\$user->authorise('"
. $this->permission->getGlobal($fieldData['view'],
'core.create')
. "', '" . $component . "') &&
\$app->isClient('administrator')) // TODO for now only in
admin area.";
$addButton[] = Indent::_(3) . "{";
$addButton[] = Indent::_(4) . "//" . Line::_(__Line__,
__Class__)
. " build Create button";
$addButton[] = Indent::_(4)
. "\$button[] = '<a
id=\"'.\$button_code_name.'Create\" class=\"btn
btn-small btn-success hasTooltip\" title=\"'.Text:"
. ":sprintf('" . $this->config->lang_prefix
. "_CREATE_NEW_S', \$button_label).'\"
style=\"border-radius: 0px 4px 4px 0px;\"";
$addButton[] = Indent::_(5) . "href=\"index.php?option="
. $fieldData['component'] . "&view=" .
$fieldData['view']
. "&layout=edit'.\$ref.'\" >";
$addButton[] = Indent::_(5)
. "<span class=\"icon-new
icon-white\"></span></a>';";
$addButton[] = Indent::_(3) . "}";
$addButton[] = Indent::_(3) . "//" . Line::_(__Line__,
__Class__)
. " only add if user allowed to edit " .
$fieldData['view'];
// check if the item has permissions.
$addButton[] = Indent::_(3) . "if
(\$user->authorise('"
. $this->permission->getGlobal($fieldData['view'],
'core.edit')
. "', '" . $component . "') &&
\$app->isClient('administrator')) // TODO for now only in
admin area.";
$addButton[] = Indent::_(3) . "{";
$addButton[] = Indent::_(4) . "//" . Line::_(__Line__,
__Class__)
. " build edit button";
$addButton[] = Indent::_(4)
. "\$button[] = '<a
id=\"'.\$button_code_name.'Edit\" class=\"btn
btn-small btn-outline-success button-select hasTooltip\"
title=\"'.Text:"
. ":sprintf('" . $this->config->lang_prefix
. "_EDIT_S', \$button_label).'\"
style=\"display: none; border-radius: 0px 4px 4px 0px;\"
href=\"#\" >";
$addButton[] = Indent::_(5)
. "<span
class=\"icon-edit\"></span></a>';";
$addButton[] = Indent::_(4) . "//" . Line::_(__Line__,
__Class__)
. " build script";
$addButton[] = Indent::_(4) . "\$script[] = \"";
$addButton[] = Indent::_(5) .
"document.addEventListener('DOMContentLoaded', function()
{";
$addButton[] = Indent::_(6)
. "let \".\$button_code_name.\"Field =
document.getElementById('jform_\".\$button_code_name.\"');";
$addButton[] = Indent::_(6)
. "if (!\".\$button_code_name.\"Field) { return;
}";
$addButton[] = Indent::_(6)
.
"\".\$button_code_name.\"Field.addEventListener('change',
function(e) {";
$addButton[] = Indent::_(7) . "e.preventDefault();";
$addButton[] = Indent::_(7)
. "let \".\$button_code_name.\"Value =
this.value;";
$addButton[] = Indent::_(7)
.
"\".\$button_code_name.\"Button(\".\$button_code_name.\"Value);";
$addButton[] = Indent::_(6) . "});";
$addButton[] = Indent::_(6)
. "let \".\$button_code_name.\"Value =
\".\$button_code_name.\"Field.value;";
$addButton[] = Indent::_(6)
.
"\".\$button_code_name.\"Button(\".\$button_code_name.\"Value);";
$addButton[] = Indent::_(5) . "});";
$addButton[] = Indent::_(5)
. "function \".\$button_code_name.\"Button(value)
{";
$addButton[] = Indent::_(6)
. "var createButton =
document.getElementById('\".\$button_code_name.\"Create');";
$addButton[] = Indent::_(6)
. "var editButton =
document.getElementById('\".\$button_code_name.\"Edit');";
$addButton[] = Indent::_(6)
. "if (value > 0) {"; // TODO not ideal since value may
not be an (int)
$addButton[] = Indent::_(7) . "// hide the create button";
$addButton[] = Indent::_(7)
. "createButton.style.display = 'none';";
$addButton[] = Indent::_(7) . "// show edit button";
$addButton[] = Indent::_(7)
. "editButton.style.display = 'block';";
$addButton[] = Indent::_(7) . "let url =
'index.php?option="
. $fieldData['component'] . "&view=" .
$fieldData['views']
. "&task=" . $fieldData['view']
.
".edit&id='+value+'\".\$refJ.\"';";
// TODO this value may not be the ID
$addButton[] = Indent::_(7)
. "editButton.setAttribute('href', url);";
$addButton[] = Indent::_(6) . "} else {";
$addButton[] = Indent::_(7) . "// show the create button";
$addButton[] = Indent::_(7)
. "createButton.style.display = 'block';";
$addButton[] = Indent::_(7) . "// hide edit button";
$addButton[] = Indent::_(7)
. "editButton.style.display = 'none';";
$addButton[] = Indent::_(6) . "}";
$addButton[] = Indent::_(5) . "}\";";
$addButton[] = Indent::_(3) . "}";
$addButton[] = Indent::_(3) . "//" . Line::_(__Line__,
__Class__)
. " check if button was created for " .
$fieldData['view']
. " field.";
$addButton[] = Indent::_(3)
. "if (is_array(\$button) && count(\$button) >
0)";
$addButton[] = Indent::_(3) . "{";
$addButton[] = Indent::_(4) . "//" . Line::_(__Line__,
__Class__)
. " Load the needed script.";
$addButton[] = Indent::_(4)
. "\$document =
Joomla__"."_39403062_84fb_46e0_bac4_0023f766e827___Power::getApplication()->getDocument();";
$addButton[] = Indent::_(4)
. "\$document->addScriptDeclaration(implode('
',\$script));";
$addButton[] = Indent::_(4) . "//" . Line::_(__Line__,
__Class__)
. " return the button attached to input field.";
$addButton[] = Indent::_(4)
. "return '<div class=\"input-group\">'
.\$html . implode('',\$button).'</div>';";
$addButton[] = Indent::_(3) . "}";
$addButton[] = Indent::_(2) . "}";
$addButton[] = Indent::_(2) . "return \$html;";
$addButton[] = Indent::_(1) . "}";
return implode(PHP_EOL, $addButton);
}
return '';
}
}
src/Componentbuilder/Compiler/Field/JoomlaFive/index.html000064400000000054151162054130017466
0ustar00<html><body
bgcolor="#FFFFFF"></body></html>src/Componentbuilder/Compiler/Field/JoomlaFour/CoreField.php000064400000005356151162054130020072
0ustar00<?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));
}
}
src/Componentbuilder/Compiler/Field/JoomlaFour/CoreRule.php000064400000005201151162054130017743
0ustar00<?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));
}
}
src/Componentbuilder/Compiler/Field/JoomlaFour/InputButton.php000064400000035131151162054130020523
0ustar00<?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 =
Joomla__"."_39403062_84fb_46e0_bac4_0023f766e827___Power::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 = '&ref=' . \$values['view']
. '&refid=' . \$values['id'];";
$addButton[] = Indent::_(4)
. "\$refJ = '&ref=' . \$values['view'] .
'&refid=' . \$values['id'];";
$addButton[] = Indent::_(4) . "//" . Line::_(__Line__,
__Class__)
. " get the return value.";
$addButton[] = Indent::_(4)
. "\$_uri = (string)
Joomla__"."_eecc143e_b5cf_4c33_ba4d_97da1df61422___Power::getInstance();";
$addButton[] = Indent::_(4)
. "\$_return = urlencode(base64_encode(\$_uri));";
$addButton[] = Indent::_(4) . "//" . Line::_(__Line__,
__Class__)
. " load return value.";
$addButton[] = Indent::_(4)
. "\$ref .= '&return=' . \$_return;";
$addButton[] = Indent::_(4)
. "\$refJ .= '&return=' . \$_return;";
$addButton[] = Indent::_(3) . "}";
}
else
{
$addButton[] = Indent::_(3)
. "if (!is_null(\$values['id']) &&
strlen(\$values['view']))";
$addButton[] = Indent::_(3) . "{";
$addButton[] = Indent::_(4) . "//" . Line::_(__Line__,
__Class__)
. " only load field details if not new item.";
$addButton[] = Indent::_(4)
. "\$ref = '&field=' .
\$values['view'] . '&field_id=' .
\$values['id'];";
$addButton[] = Indent::_(4)
. "\$refJ = '&field=' . \$values['view']
. '&field_id=' . \$values['id'];";
$addButton[] = Indent::_(4) . "//" . Line::_(__Line__,
__Class__)
. " get the return value.";
$addButton[] = Indent::_(4)
. "\$_uri = (string)
Joomla__"."_eecc143e_b5cf_4c33_ba4d_97da1df61422___Power::getInstance();";
$addButton[] = Indent::_(4)
. "\$_return = urlencode(base64_encode(\$_uri));";
$addButton[] = Indent::_(4) . "//" . Line::_(__Line__,
__Class__)
. " load return value.";
$addButton[] = Indent::_(4)
. "\$ref = '&return=' . \$_return;";
$addButton[] = Indent::_(4)
. "\$refJ = '&return=' . \$_return;";
$addButton[] = Indent::_(3) . "}";
}
$addButton[] = Indent::_(3) . "//" . Line::_(__Line__,
__Class__)
. " get button label";
$addButton[] = Indent::_(3)
. "\$button_label = trim(\$button_code_name);";
$addButton[] = Indent::_(3)
. "\$button_label = preg_replace('/_+/', ' ',
\$button_label);";
$addButton[] = Indent::_(3)
. "\$button_label = preg_replace('/\s+/', ' ',
\$button_label);";
$addButton[] = Indent::_(3)
. "\$button_label = preg_replace(\"/[^A-Za-z ]/\",
'', \$button_label);";
$addButton[] = Indent::_(3)
. "\$button_label = ucfirst(strtolower(\$button_label));";
$addButton[] = Indent::_(3) . "//" . Line::_(__Line__,
__Class__)
. " get user object";
$addButton[] = Indent::_(3) . "\$user =
Joomla__"."_39403062_84fb_46e0_bac4_0023f766e827___Power::getApplication()->getIdentity();";
$addButton[] = Indent::_(3) . "//" . Line::_(__Line__,
__Class__)
. " only add if user allowed to create " .
$fieldData['view'];
// check if the item has permissions.
$addButton[] = Indent::_(3) . "if
(\$user->authorise('"
. $this->permission->getGlobal($fieldData['view'],
'core.create')
. "', '" . $component . "') &&
\$app->isClient('administrator')) // TODO for now only in
admin area.";
$addButton[] = Indent::_(3) . "{";
$addButton[] = Indent::_(4) . "//" . Line::_(__Line__,
__Class__)
. " build Create button";
$addButton[] = Indent::_(4)
. "\$button[] = '<a
id=\"'.\$button_code_name.'Create\" class=\"btn
btn-small btn-success hasTooltip\" title=\"'.Text:"
. ":sprintf('" . $this->config->lang_prefix
. "_CREATE_NEW_S', \$button_label).'\"
style=\"border-radius: 0px 4px 4px 0px;\"";
$addButton[] = Indent::_(5) . "href=\"index.php?option="
. $fieldData['component'] . "&view=" .
$fieldData['view']
. "&layout=edit'.\$ref.'\" >";
$addButton[] = Indent::_(5)
. "<span class=\"icon-new
icon-white\"></span></a>';";
$addButton[] = Indent::_(3) . "}";
$addButton[] = Indent::_(3) . "//" . Line::_(__Line__,
__Class__)
. " only add if user allowed to edit " .
$fieldData['view'];
// check if the item has permissions.
$addButton[] = Indent::_(3) . "if
(\$user->authorise('"
. $this->permission->getGlobal($fieldData['view'],
'core.edit')
. "', '" . $component . "') &&
\$app->isClient('administrator')) // TODO for now only in
admin area.";
$addButton[] = Indent::_(3) . "{";
$addButton[] = Indent::_(4) . "//" . Line::_(__Line__,
__Class__)
. " build edit button";
$addButton[] = Indent::_(4)
. "\$button[] = '<a
id=\"'.\$button_code_name.'Edit\" class=\"btn
btn-small btn-outline-success button-select hasTooltip\"
title=\"'.Text:"
. ":sprintf('" . $this->config->lang_prefix
. "_EDIT_S', \$button_label).'\"
style=\"display: none; border-radius: 0px 4px 4px 0px;\"
href=\"#\" >";
$addButton[] = Indent::_(5)
. "<span
class=\"icon-edit\"></span></a>';";
$addButton[] = Indent::_(4) . "//" . Line::_(__Line__,
__Class__)
. " build script";
$addButton[] = Indent::_(4) . "\$script[] = \"";
$addButton[] = Indent::_(5) .
"document.addEventListener('DOMContentLoaded', function()
{";
$addButton[] = Indent::_(6)
. "let \".\$button_code_name.\"Field =
document.getElementById('jform_\".\$button_code_name.\"');";
$addButton[] = Indent::_(6)
. "if (!\".\$button_code_name.\"Field) { return;
}";
$addButton[] = Indent::_(6)
.
"\".\$button_code_name.\"Field.addEventListener('change',
function(e) {";
$addButton[] = Indent::_(7) . "e.preventDefault();";
$addButton[] = Indent::_(7)
. "let \".\$button_code_name.\"Value =
this.value;";
$addButton[] = Indent::_(7)
.
"\".\$button_code_name.\"Button(\".\$button_code_name.\"Value);";
$addButton[] = Indent::_(6) . "});";
$addButton[] = Indent::_(6)
. "let \".\$button_code_name.\"Value =
\".\$button_code_name.\"Field.value;";
$addButton[] = Indent::_(6)
.
"\".\$button_code_name.\"Button(\".\$button_code_name.\"Value);";
$addButton[] = Indent::_(5) . "});";
$addButton[] = Indent::_(5)
. "function \".\$button_code_name.\"Button(value)
{";
$addButton[] = Indent::_(6)
. "var createButton =
document.getElementById('\".\$button_code_name.\"Create');";
$addButton[] = Indent::_(6)
. "var editButton =
document.getElementById('\".\$button_code_name.\"Edit');";
$addButton[] = Indent::_(6)
. "if (value > 0) {"; // TODO not ideal since value may
not be an (int)
$addButton[] = Indent::_(7) . "// hide the create button";
$addButton[] = Indent::_(7)
. "createButton.style.display = 'none';";
$addButton[] = Indent::_(7) . "// show edit button";
$addButton[] = Indent::_(7)
. "editButton.style.display = 'block';";
$addButton[] = Indent::_(7) . "let url =
'index.php?option="
. $fieldData['component'] . "&view=" .
$fieldData['views']
. "&task=" . $fieldData['view']
.
".edit&id='+value+'\".\$refJ.\"';";
// TODO this value may not be the ID
$addButton[] = Indent::_(7)
. "editButton.setAttribute('href', url);";
$addButton[] = Indent::_(6) . "} else {";
$addButton[] = Indent::_(7) . "// show the create button";
$addButton[] = Indent::_(7)
. "createButton.style.display = 'block';";
$addButton[] = Indent::_(7) . "// hide edit button";
$addButton[] = Indent::_(7)
. "editButton.style.display = 'none';";
$addButton[] = Indent::_(6) . "}";
$addButton[] = Indent::_(5) . "}\";";
$addButton[] = Indent::_(3) . "}";
$addButton[] = Indent::_(3) . "//" . Line::_(__Line__,
__Class__)
. " check if button was created for " .
$fieldData['view']
. " field.";
$addButton[] = Indent::_(3)
. "if (is_array(\$button) && count(\$button) >
0)";
$addButton[] = Indent::_(3) . "{";
$addButton[] = Indent::_(4) . "//" . Line::_(__Line__,
__Class__)
. " Load the needed script.";
$addButton[] = Indent::_(4)
. "\$document =
Joomla__"."_39403062_84fb_46e0_bac4_0023f766e827___Power::getApplication()->getDocument();";
$addButton[] = Indent::_(4)
. "\$document->addScriptDeclaration(implode('
',\$script));";
$addButton[] = Indent::_(4) . "//" . Line::_(__Line__,
__Class__)
. " return the button attached to input field.";
$addButton[] = Indent::_(4)
. "return '<div class=\"input-group\">'
.\$html . implode('',\$button).'</div>';";
$addButton[] = Indent::_(3) . "}";
$addButton[] = Indent::_(2) . "}";
$addButton[] = Indent::_(2) . "return \$html;";
$addButton[] = Indent::_(1) . "}";
return implode(PHP_EOL, $addButton);
}
return '';
}
}
src/Componentbuilder/Compiler/Field/JoomlaFour/index.html000064400000000054151162054130017510
0ustar00<html><body
bgcolor="#FFFFFF"></body></html>src/Componentbuilder/Compiler/Field/JoomlaThree/CoreField.php000064400000005454151162054130020225
0ustar00<?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\JoomlaThree;
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';
$this->paths[] = JPATH_LIBRARIES . '/joomla/form/fields';
}
/**
* 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));
}
}
src/Componentbuilder/Compiler/Field/JoomlaThree/CoreRule.php000064400000005202151162054130020100
0ustar00<?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\JoomlaThree;
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));
}
}
src/Componentbuilder/Compiler/Field/JoomlaThree/InputButton.php000064400000033744151162054130020667
0ustar00<?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\JoomlaThree;
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 = '&ref=' . \$values['view']
. '&refid=' . \$values['id'];";
$addButton[] = Indent::_(4)
. "\$refJ = '&ref=' . \$values['view'] .
'&refid=' . \$values['id'];";
$addButton[] = Indent::_(4) . "//" . Line::_(__Line__,
__Class__)
. " get the return value.";
$addButton[] = Indent::_(4)
. "\$_uri = (string) \Joomla\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 .= '&return=' . \$_return;";
$addButton[] = Indent::_(4)
. "\$refJ .= '&return=' . \$_return;";
$addButton[] = Indent::_(3) . "}";
}
else
{
$addButton[] = Indent::_(3)
. "if (!is_null(\$values['id']) &&
strlen(\$values['view']))";
$addButton[] = Indent::_(3) . "{";
$addButton[] = Indent::_(4) . "//" . Line::_(__Line__,
__Class__)
. " only load field details if not new item.";
$addButton[] = Indent::_(4)
. "\$ref = '&field=' .
\$values['view'] . '&field_id=' .
\$values['id'];";
$addButton[] = Indent::_(4)
. "\$refJ = '&field=' . \$values['view']
. '&field_id=' . \$values['id'];";
$addButton[] = Indent::_(4) . "//" . Line::_(__Line__,
__Class__)
. " get the return value.";
$addButton[] = Indent::_(4)
. "\$_uri = (string) \Joomla\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 = '&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::getUser();";
$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; padding: 4px 4px 4px
7px;\"";
$addButton[] = Indent::_(5) . "href=\"index.php?option="
. $fieldData['component'] . "&view=" .
$fieldData['view']
. "&layout=edit'.\$ref.'\" >";
$addButton[] = Indent::_(5)
. "<span class=\"icon-new
icon-white\"></span></a>';";
$addButton[] = Indent::_(3) . "}";
$addButton[] = Indent::_(3) . "//" . Line::_(__Line__,
__Class__)
. " only add if user allowed to edit " .
$fieldData['view'];
// check if the item has permissions.
$addButton[] = Indent::_(3) . "if
(\$user->authorise('"
. $this->permission->getGlobal($fieldData['view'],
'core.edit')
. "', '" . $component . "') &&
\$app->isClient('administrator')) // TODO for now only in
admin area.";
$addButton[] = Indent::_(3) . "{";
$addButton[] = Indent::_(4) . "//" . Line::_(__Line__,
__Class__)
. " build edit button";
$addButton[] = Indent::_(4)
. "\$button[] = '<a
id=\"'.\$button_code_name.'Edit\" class=\"btn
btn-small hasTooltip\" title=\"'.Text:"
. ":sprintf('" . $this->config->lang_prefix
. "_EDIT_S', \$button_label).'\"
style=\"display: none; padding: 3px 4px 4px 7px;\"
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) . "jQuery(document).ready(function()
{";
$addButton[] = Indent::_(6)
. "jQuery('#adminForm').on('change',
'#jform_\".\$button_code_name.\"',function (e)
{";
$addButton[] = Indent::_(7) . "e.preventDefault();";
$addButton[] = Indent::_(7)
. "var \".\$button_code_name.\"Value =
jQuery('#jform_\".\$button_code_name.\"').val();";
$addButton[] = Indent::_(7)
.
"\".\$button_code_name.\"Button(\".\$button_code_name.\"Value);";
$addButton[] = Indent::_(6) . "});";
$addButton[] = Indent::_(6)
. "var \".\$button_code_name.\"Value =
jQuery('#jform_\".\$button_code_name.\"').val();";
$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)
. "if (value > 0) {"; // TODO not ideal since value may
not be an (int)
$addButton[] = Indent::_(7) . "// hide the create button";
$addButton[] = Indent::_(7)
.
"jQuery('#\".\$button_code_name.\"Create').hide();";
$addButton[] = Indent::_(7) . "// show edit button";
$addButton[] = Indent::_(7)
.
"jQuery('#\".\$button_code_name.\"Edit').show();";
$addButton[] = Indent::_(7) . "var 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)
.
"jQuery('#\".\$button_code_name.\"Edit').attr('href',
url);";
$addButton[] = Indent::_(6) . "} else {";
$addButton[] = Indent::_(7) . "// show the create button";
$addButton[] = Indent::_(7)
.
"jQuery('#\".\$button_code_name.\"Create').show();";
$addButton[] = Indent::_(7) . "// hide edit button";
$addButton[] = Indent::_(7)
.
"jQuery('#\".\$button_code_name.\"Edit').hide();";
$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::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-append\">'
.\$html . implode('',\$button).'</div>';";
$addButton[] = Indent::_(3) . "}";
$addButton[] = Indent::_(2) . "}";
$addButton[] = Indent::_(2) . "return \$html;";
$addButton[] = Indent::_(1) . "}";
return implode(PHP_EOL, $addButton);
}
return '';
}
}
src/Componentbuilder/Compiler/Field/JoomlaThree/index.html000064400000000054151162054130017644
0ustar00<html><body
bgcolor="#FFFFFF"></body></html>src/Componentbuilder/Compiler/Field/Name.php000064400000014042151162054130015031
0ustar00<?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;
use VDM\Joomla\Utilities\StringHelper;
use VDM\Joomla\Utilities\ArrayHelper;
use VDM\Joomla\Utilities\String\TypeHelper;
use VDM\Joomla\Utilities\String\FieldHelper;
use VDM\Joomla\Utilities\GetHelper;
use VDM\Joomla\Componentbuilder\Compiler\Placeholder;
use VDM\Joomla\Componentbuilder\Compiler\Field\UniqueName;
use VDM\Joomla\Componentbuilder\Compiler\Builder\CategoryOtherName;
/**
* Compiler Field Name
*
* @since 3.2.0
*/
class Name
{
/**
* Unique Field Names
*
* @var array
* @since 3.2.0
*/
protected array $unique;
/**
* The Placeholder Class.
*
* @var Placeholder
* @since 3.2.0
*/
protected Placeholder $placeholder;
/**
* The UniqueName Class.
*
* @var UniqueName
* @since 3.2.0
*/
protected UniqueName $uniquename;
/**
* The CategoryOtherName Class.
*
* @var CategoryOtherName
* @since 3.2.0
*/
protected CategoryOtherName $categoryothername;
/**
* Constructor.
*
* @param Placeholder $placeholder The Placeholder Class.
* @param UniqueName $uniquename The UniqueName Class.
* @param CategoryOtherName $categoryothername The CategoryOtherName
Class.
*
* @since 3.2.0
*/
public function __construct(Placeholder $placeholder, UniqueName
$uniquename,
CategoryOtherName $categoryothername)
{
$this->placeholder = $placeholder;
$this->uniquename = $uniquename;
$this->categoryothername = $categoryothername;
}
/**
* Get the field's actual name
*
* @param array $field The field array
* @param string|null $listViewName The list view name
* @param string $amicably The peaceful resolve (for fields
in subforms in same view :)
*
* @return string Success returns field name
* @since 3.2.0
*/
public function get(array &$field, ?string $listViewName = null,
string $amicably = ''): string
{
// return the unique name if already set
if ($listViewName && StringHelper::check($listViewName)
&& isset($field['hash'])
&& isset($this->unique[$listViewName . $amicably .
$field['hash']]))
{
return $this->unique[$listViewName . $amicably .
$field['hash']];
}
// always make sure we have a field name and type
if (!isset($field['settings']) ||
!isset($field['settings']->type_name)
|| !isset($field['settings']->name))
{
return 'error';
}
// set the type name
$type_name = TypeHelper::safe(
$field['settings']->type_name
);
// set the name of the field
$name = FieldHelper::safe($field['settings']->name);
// check that we have the properties
if (ArrayHelper::check($field['settings']->properties))
{
foreach ($field['settings']->properties as $property)
{
if ($property['name'] === 'name')
{
// if category then name must be catid (only one per view)
if ($type_name === 'category')
{
// quick check if this is a category linked to view page
$requeSt_id = GetHelper::between(
$field['settings']->xml, 'name="',
'"'
);
if (strpos($requeSt_id, '_request_id') !== false
|| strpos($requeSt_id, '_request_catid') !== false)
{
// keep it then, don't change
$name = $this->placeholder->update_(
$requeSt_id
);
}
else
{
$name = 'catid';
}
// if list view name is set
if (StringHelper::check($listViewName))
{
// check if we should use another Text Name as this views name
$otherName = $this->placeholder->update_(
GetHelper::between(
$field['settings']->xml,
'othername="', '"'
)
);
$otherViews = $this->placeholder->update_(
GetHelper::between(
$field['settings']->xml, 'views="',
'"'
)
);
$otherView = $this->placeholder->update_(
GetHelper::between(
$field['settings']->xml, 'view="',
'"'
)
);
// This is to link other view category
if (StringHelper::check($otherName)
&& StringHelper::check($otherViews)
&& StringHelper::check($otherView))
{
// set other category details
$this->categoryothername->set($listViewName, [
'name' => FieldHelper::safe(
$otherName
),
'views' => StringHelper::safe(
$otherViews
),
'view' => StringHelper::safe(
$otherView
)
]);
}
}
}
// if tag is set then enable all tag options for this view (only one
per view)
elseif ($type_name === 'tag')
{
$name = 'tags';
}
// if the field is set as alias it must be called alias
elseif (isset($field['alias']) &&
$field['alias'])
{
$name = 'alias';
}
else
{
// get value from xml
$xml = FieldHelper::safe(
$this->placeholder->update_(
GetHelper::between(
$field['settings']->xml, 'name="',
'"'
)
)
);
// check if a value was found
if (StringHelper::check($xml))
{
$name = $xml;
}
}
// exit foreach loop
break;
}
}
}
// return the value unique
if (StringHelper::check($listViewName) &&
isset($field['hash']))
{
$this->unique[$listViewName . $amicably . $field['hash']]
= $this->uniquename->get($name, $listViewName . $amicably);
// now return the unique name
return $this->unique[$listViewName . $amicably .
$field['hash']];
}
// fall back to global
return $name;
}
}
src/Componentbuilder/Compiler/Field/Rule.php000064400000010203151162054130015053
0ustar00<?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;
use VDM\Joomla\Componentbuilder\Compiler\Registry;
use VDM\Joomla\Componentbuilder\Compiler\Customcode;
use VDM\Joomla\Componentbuilder\Compiler\Customcode\Gui;
use VDM\Joomla\Componentbuilder\Compiler\Placeholder;
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\Field\CoreRuleInterface
as CoreRule;
use VDM\Joomla\Utilities\StringHelper;
use VDM\Joomla\Utilities\GetHelper;
/**
* Compiler Field Rules
*
* @since 3.2.0
*/
class Rule
{
/**
* The Registry Class.
*
* @var Registry
* @since 3.2.0
*/
protected Registry $registry;
/**
* The Customcode Class.
*
* @var Customcode
* @since 3.2.0
*/
protected Customcode $customcode;
/**
* The Gui Class.
*
* @var Gui
* @since 3.2.0
*/
protected Gui $gui;
/**
* The Placeholder Class.
*
* @var Placeholder
* @since 3.2.0
*/
protected Placeholder $placeholder;
/**
* The CoreRuleInterface Class.
*
* @var CoreRule
* @since 3.2.0
*/
protected CoreRule $corerule;
/**
* Constructor.
*
* @param Registry $registry The Registry Class.
* @param Customcode $customcode The Customcode Class.
* @param Gui $gui The Gui Class.
* @param Placeholder $placeholder The Placeholder Class.
* @param CoreRule $corerule The CoreRuleInterface Class.
*
* @since 3.2.0
*/
public function __construct(Registry $registry, Customcode $customcode,
Gui $gui,
Placeholder $placeholder, CoreRule $corerule)
{
$this->registry = $registry;
$this->customcode = $customcode;
$this->gui = $gui;
$this->placeholder = $placeholder;
$this->corerule = $corerule;
}
/**
* Set the validation rule
*
* @param int $id The field id
* @param string $field The field string
*
* @return void
* @since 3.2.0
*/
public function set(int $id, string $field)
{
// check if we have validate (validation rule set)
$validation_rule = GetHelper::between(
$field, 'validate="', '"'
);
if (StringHelper::check($validation_rule))
{
// make sure it is lowercase
$validation_rule = StringHelper::safe(
$validation_rule
);
// link this field to this validation (don't move this down)
$this->registry->set("validation.linked.${id}",
$validation_rule);
// make sure it is not already set
if
($this->registry->get("validation.rules.${validation_rule}")
=== null)
{
// get joomla core validation names and make sure this rule is not a
core validation rule
if (!in_array($validation_rule, (array)
$this->corerule->get(true)))
{
// get the class methods for this rule if it exists
if (($php_code = GetHelper::var(
'validation_rule', $validation_rule, 'name',
'php'
)) !== false)
{
// open and set the validation rule
$this->registry->set("validation.rules.${validation_rule}",
$this->gui->set(
$this->placeholder->update_(
$this->customcode->update(
base64_decode(
(string) $php_code
)
)
),
array(
'table' => 'validation_rule',
'field' => 'php',
'id' => GetHelper::var(
'validation_rule',
$validation_rule, 'name', 'id'
),
'type' => 'php'
)
)
);
}
else
{
// TODO set the notice that this validation rule is custom and was
not found
$this->registry->remove("validation.linked.${id}");
}
}
else
{
// remove link (we only want custom validations linked)
$this->registry->remove("validation.linked.${id}");
}
}
}
}
}
src/Componentbuilder/Compiler/Field/TypeName.php000064400000005666151162054130015707
0ustar00<?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;
use VDM\Joomla\Utilities\StringHelper;
use VDM\Joomla\Utilities\ArrayHelper;
use VDM\Joomla\Utilities\ObjectHelper;
use VDM\Joomla\Utilities\GetHelper;
use VDM\Joomla\Utilities\String\TypeHelper;
/**
* Compiler Field Type Name
*
* @since 3.2.0
*/
class TypeName
{
/**
* Get the field's actual type
*
* @param array $field The field object
*
* @return string Success returns field type
* @since 3.2.0
*/
public function get(array &$field): string
{
// check if we have done this already
if (isset($field['type_name']))
{
return $field['type_name'];
}
// check that we have the properties
if (isset($field['settings'])
&& ObjectHelper::check($field['settings'])
&& isset($field['settings']->properties)
&&
ArrayHelper::check($field['settings']->properties))
{
// search for own custom fields
if (strpos((string) $field['settings']->type_name,
'@') !== false)
{
// set own custom field
$field['settings']->own_custom =
$field['settings']->type_name;
$field['settings']->type_name = 'Custom';
}
// set the type name
$type_name = TypeHelper::safe(
$field['settings']->type_name
);
// if custom (we must use the xml value)
if (strtolower((string) $type_name) === 'custom'
|| strtolower((string) $type_name) === 'customuser')
{
$type = TypeHelper::safe(
GetHelper::between(
$field['settings']->xml, 'type="',
'"'
)
);
}
else
{
// loop over properties looking for the type value
foreach ($field['settings']->properties as $property)
{
if ($property['name']
=== 'type') // type field is never adjustable (unless
custom)
{
// force the default value
if (isset($property['example'])
&& StringHelper::check(
$property['example']
))
{
$type = TypeHelper::safe(
$property['example']
);
}
// fall back on the xml settings (not ideal)
else
{
$type = TypeHelper::safe(
GetHelper::between(
$field['settings']->xml, 'type="',
'"'
)
);
}
// exit foreach loop
break;
}
}
}
// check if the value is set
if (isset($type) && StringHelper::check($type))
{
return $type;
}
// fallback on type name set in name field (not ideal)
else
{
return $type_name;
}
}
// fall back to text
return 'text';
}
}
src/Componentbuilder/Compiler/Field/UniqueName.php000064400000005135151162054130016223
0ustar00<?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;
use VDM\Joomla\Componentbuilder\Compiler\Factory as Compiler;
use VDM\Joomla\Utilities\String\FieldHelper;
use VDM\Joomla\Componentbuilder\Compiler\Registry;
/**
* Compiler Field Unique Name
*
* @since 3.2.0
*/
class UniqueName
{
/**
* The compiler registry
*
* @var Registry
* @since 3.2.0
*/
protected Registry $registry;
/**
* Constructor
*
* @param Registry|null $registry The compiler registry object.
*
* @since 3.2.0
*/
public function __construct(?Registry $registry = null)
{
$this->registry = $registry ?: Compiler::_('Registry');
}
/**
* Count how many times the same field is used per view
*
* @param string $name The name of the field
* @param string $view The name of the view
*
* @return void
* @since 3.2.0
*/
public function set(string $name, string $view)
{
if (($number =
$this->registry->get("unique.names.${view}.counter.${name}"))
=== null)
{
$this->registry->set("unique.names.${view}.counter.${name}",
1);
return;
}
// count how many times the field is used
$this->registry->set("unique.names.${view}.counter.${name}",
++$number);
return;
}
/**
* Naming each field with an unique name
*
* @param string $name The name of the field
* @param string $view The name of the view
*
* @return string the name
* @since 3.2.0
*/
public function get(string $name, string $view): string
{
// only increment if the field name is used multiple times
if
($this->registry->get("unique.names.${view}.counter.${name}")
> 1)
{
$counter = 1;
// set the unique name
$unique_name = FieldHelper::safe(
$name . '_' . $counter
);
while
($this->registry->get("unique.names.${view}.names.${unique_name}")
!== null)
{
// increment the number
$counter++;
// try again
$unique_name = FieldHelper::safe(
$name . '_' . $counter
);
}
// set the new name number
$this->registry->set("unique.names.${view}.names.${unique_name}",
$counter);
// return the unique name
return $unique_name;
}
return $name;
}
}
src/Componentbuilder/Compiler/Field/index.html000064400000000054151162054130015433
0ustar00<html><body
bgcolor="#FFFFFF"></body></html>src/Componentbuilder/Compiler/Helper/Compiler.php000064400000153707151162054130016133
0ustar00<?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\Helper;
use Joomla\CMS\Factory;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Filesystem\File;
use Joomla\CMS\Filesystem\Folder;
// use
VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper;
(for Joomla 4 and above)
use VDM\Joomla\Utilities\StringHelper;
use VDM\Joomla\Utilities\ArrayHelper;
use VDM\Joomla\Utilities\ObjectHelper;
use VDM\Joomla\Utilities\FileHelper;
use VDM\Joomla\Utilities\GetHelper;
use VDM\Joomla\Utilities\MathHelper;
use VDM\Joomla\Componentbuilder\Compiler\Factory as CFactory;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Placefix;
use VDM\Joomla\Componentbuilder\Compiler\Helper\Infusion;
/**
* Compiler class
*
* @deprecated 3.3
*/
class Compiler extends Infusion
{
/**
* The Temp path
*
* @var string
*/
public $tempPath;
/**
* The timer
*
* @var string
*/
private $time_start;
private $time_end;
public $secondsCompiled;
/**
* The file path array
*
* @var string
*/
public $filepath
= array(
'component' => '',
'component-folder' => '',
'package' => '',
'plugins' => array(),
'plugins-folders' => array(),
'modules' => array()
);
// fixed pathes
protected $dynamicIntegration = false;
protected $backupPath = false;
protected $repoPath = false;
protected $addCustomCodeAt = array();
/**
* Constructor
*/
public function __construct($config = array())
{
// to check the compiler speed
$this->time_start = microtime(true);
CFactory::_('Utilities.Counter')->start();
// first we run the parent constructors
if (parent::__construct())
{
// set temp directory
$comConfig = Factory::getConfig();
$this->tempPath = $comConfig->get('tmp_path');
// set some folder paths in relation to distribution
if (CFactory::_('Config')->backup)
{
$this->backupPath = $this->params->get(
'backup_folder_path', $this->tempPath
);
// see if component has overriding options set
if
(CFactory::_('Component')->get('add_backup_folder_path',
0) == 1)
{
$this->backupPath =
CFactory::_('Component')->get('backup_folder_path',
$this->backupPath);
}
$this->dynamicIntegration = true;
}
// set local repos switch
if (CFactory::_('Config')->repository)
{
$this->repoPath =
$this->params->get('git_folder_path', null);
// see if component has overriding options set
if
(CFactory::_('Component')->get('add_git_folder_path',
0) == 1)
{
$this->repoPath =
CFactory::_('Component')->get('git_folder_path',
$this->repoPath);
}
}
// remove site folder if not needed (TODO add check if custom script was
moved to site folder then we must do a more complex cleanup here)
if (CFactory::_('Config')->remove_site_folder &&
CFactory::_('Config')->remove_site_edit_folder)
{
// first remove the files and folders
CFactory::_('Utilities.Folder')->remove(CFactory::_('Utilities.Paths')->component_path
. '/site');
// clear form component xml
$xmlPath =
CFactory::_('Utilities.Paths')->component_path .
'/'
.
CFactory::_('Compiler.Builder.Content.One')->get('component')
. '.xml';
$componentXML = FileHelper::getContent($xmlPath);
$textToSite = GetHelper::between(
$componentXML, '<files folder="site">',
'</files>'
);
$textToSiteLang = GetHelper::between(
$componentXML, '<languages folder="site">',
'</languages>'
);
$componentXML = str_replace(
array('<files folder="site">' . $textToSite
. "</files>",
'<languages folder="site">' .
$textToSiteLang
. "</languages>"), array('',
''), (string) $componentXML
);
CFactory::_('Utilities.File')->write($xmlPath,
$componentXML);
}
// remove API
if (CFactory::_('Config')->get('add_api') ===
null)
{
// first remove the files and folders
CFactory::_('Utilities.Folder')->remove(CFactory::_('Utilities.Paths')->component_path
. '/api');
}
// Trigger Event: jcb_ce_onBeforeUpdateFiles
CFactory::_('Event')->trigger(
'jcb_ce_onBeforeUpdateFiles', [$this] // TODO move
setGetItemsModelMethod to its own class
);
// now update the files
if (!$this->updateFiles())
{
return false;
}
// Trigger Event: jcb_ce_onBeforeGetCustomCode
CFactory::_('Event')->trigger(
'jcb_ce_onBeforeGetCustomCode'
);
// now insert into the new files
if (CFactory::_('Customcode')->get())
{
// Trigger Event: jcb_ce_onBeforeAddCustomCode
CFactory::_('Event')->trigger(
'jcb_ce_onBeforeAddCustomCode'
);
$this->addCustomCode();
}
// Trigger Event: jcb_ce_onBeforeSetLangFileData
CFactory::_('Event')->trigger(
'jcb_ce_onBeforeSetLangFileData'
);
// set the lang data now
$this->setLangFileData();
// set the language notice if it was set
if
(CFactory::_('Compiler.Builder.Language.Messages')->isActive())
{
if
(CFactory::_('Compiler.Builder.Language.Messages')->isArray('exclude'))
{
$this->app->enqueueMessage(
Text::_('COM_COMPONENTBUILDER_HR_HTHREELANGUAGE_WARNINGHTHREE'),
'Warning'
);
foreach
(CFactory::_('Compiler.Builder.Language.Messages')->get('exclude')
as $tag => $targets)
{
foreach ($targets as $extention => $files)
{
foreach ($files as $file => $percentage)
{
$this->app->enqueueMessage(
Text::sprintf(
'The [%s].%s <b>%s</b> language has %s%
translated, you will need to translate %s% of the language strings
before it will be added.',
$extention, $file, $tag, $percentage,
CFactory::_('Config')->percentage_language_add
), 'Warning'
);
}
}
}
$this->app->enqueueMessage(
Text::_('COM_COMPONENTBUILDER_HR_HTHREELANGUAGE_NOTICEHTHREE'),
'Notice'
);
$this->app->enqueueMessage(
Text::sprintf(
'<b>You can change this percentage of translated strings
required in the global options of JCB.</b><br />Please watch
this <a href=%s>tutorial for more help surrounding the JCB
translations manager</a>.',
'"https://youtu.be/zzAcVkn_cWU?list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE"
target="_blank" title="JCB Tutorial surrounding Translation
Manager"'
), 'Notice'
);
}
// set why the strings were added
$whyAddedLang = Text::sprintf(
'because more then %s% of the strings have been
translated.',
CFactory::_('Config')->percentage_language_add
);
if (CFactory::_('Config')->get('debug_line_nr',
false))
{
$whyAddedLang = Text::_(
'because the debugging mode is on. (debug line numbers)'
);
}
// show languages that were added
if
(CFactory::_('Compiler.Builder.Language.Messages')->isArray('include'))
{
$this->app->enqueueMessage(
Text::_('COM_COMPONENTBUILDER_HR_HTHREELANGUAGE_NOTICEHTHREE'),
'Notice'
);
foreach
(CFactory::_('Compiler.Builder.Language.Messages')->get('include')
as $tag => $targets)
{
foreach ($targets as $extention => $files)
{
foreach ($files as $file => $percentage)
{
$this->app->enqueueMessage(
Text::sprintf(
'The [%s].%s <b>%s</b> language has %s%
translated. Was added %s',
$extention, $file, $tag, $percentage, $whyAddedLang
), 'Notice'
);
}
}
}
}
}
// set assets table column fix type messages
$message_fix['intelligent'] = Text::_(
'The <b>intelligent</b> fix only updates the #__assets
table\'s column when it detects that it is too small for the worse
case. The intelligent fix also only reverse the #__assets table\'s
update on uninstall of the component if it detects that no other component
needs the rules column to be larger any longer. This options also shows a
notice to the end user of all that it does to the #__assets table on
installation and uninstalling of the component.'
);
$message_fix['sql'] = Text::_(
'The <b>SQL</b> fix updates the #__assets
table\'s column size on installation of the component and reverses it
back to the Joomla default on uninstall of the component.'
);
// get the asset table fix switch
$add_assets_table_fix =
CFactory::_('Config')->get('add_assets_table_fix',
0);
// set assets table rules column notice
if ($add_assets_table_fix)
{
$this->app->enqueueMessage(
Text::_('COM_COMPONENTBUILDER_HR_HTHREEASSETS_TABLE_NOTICEHTHREE'),
'Notice'
);
$asset_table_fix_type = ($add_assets_table_fix == 2)
? 'intelligent' : 'sql';
$this->app->enqueueMessage(
Text::sprintf(
'The #__assets table <b>%s</b> fix has been added to
this component. %s',
$asset_table_fix_type,
$message_fix[$asset_table_fix_type]
), 'Notice'
);
}
// set assets table rules column Warning
elseif (CFactory::_('Utilities.Counter')->accessSize >=
30)
{
$this->app->enqueueMessage(
Text::_('COM_COMPONENTBUILDER_HR_HTHREEASSETS_TABLE_WARNINGHTHREE'),
'Warning'
);
$this->app->enqueueMessage(
Text::sprintf(
'The Joomla #__assets table\'s rules column has to be fixed
for this component to work coherently. JCB has detected that in worse case
the rules column in the #__assets table may require <b>%s</b>
characters, and yet the Joomla default is only
<b>varchar(5120)</b>. JCB has three option to resolve this
issue, first <b>use less permissions</b> in your component,
second use the <b>SQL</b> fix, or the
<b>intelligent</b> fix. %s %s',
CFactory::_('Config')->access_worse_case,
$message_fix['intelligent'],
$message_fix['sql']
), 'Warning'
);
}
// set assets table name column warning if not set
if (!$add_assets_table_fix &&
CFactory::_('Config')->add_assets_table_name_fix)
{
// only add if not already added
if (CFactory::_('Utilities.Counter')->accessSize < 30)
{
$this->app->enqueueMessage(
Text::_('COM_COMPONENTBUILDER_HR_HTHREEASSETS_TABLE_WARNINGHTHREE'),
'Warning'
);
}
$this->app->enqueueMessage(
Text::sprintf(
'The Joomla #__assets table\'s name column has to be fixed
for this component to work correctly. JCB has detected that the #__assets
table name column will need to be enlarged because this component\'s
own naming convention is larger than varchar(50) which is the Joomla
default. JCB has three option to resolve this issue, first <b>shorter
names</b> for your component and/or its admin views, second use the
<b>SQL</b> fix, or the <b>intelligent</b> fix. %s
%s',
$message_fix['intelligent'],
$message_fix['sql']
), 'Warning'
);
}
// move the update server into place
$this->setUpdateServer();
// build read me
$this->buildReadMe();
// set local repos
$this->setLocalRepos();
// zip the component
if (!$this->zipComponent())
{
// done with error
return false;
}
// if there are modules zip them
$this->zipModules();
// if there are plugins zip them
$this->zipPlugins();
// do lang mismatch check
if
(ArrayHelper::check(CFactory::_('Language.Extractor')->langMismatch))
{
if
(ArrayHelper::check(CFactory::_('Language.Extractor')->langMatch))
{
$mismatch = array_diff(
array_unique(CFactory::_('Language.Extractor')->langMismatch),
array_unique(CFactory::_('Language.Extractor')->langMatch)
);
}
else
{
$mismatch =
array_unique(CFactory::_('Language.Extractor')->langMismatch);
}
// set a notice if we have a mismatch
if (isset($mismatch)
&& ArrayHelper::check(
$mismatch
))
{
$this->app->enqueueMessage(
Text::_('COM_COMPONENTBUILDER_HR_HTHREELANGUAGE_WARNINGHTHREE'),
'Warning'
);
if (count((array) $mismatch) > 1)
{
$this->app->enqueueMessage(
Text::_(
'<h3>Please check the following mismatching Joomla.JText
language constants.</h3>'
), 'Warning'
);
}
else
{
$this->app->enqueueMessage(
Text::_(
'<h3>Please check the following mismatch Joomla.JText
language constant.</h3>'
), 'Warning'
);
}
// add the mismatching issues
foreach ($mismatch as $string)
{
$constant = CFactory::_('Config')->lang_prefix .
'_'
. StringHelper::safe($string, 'U');
$this->app->enqueueMessage(
Text::sprintf(
'The <b>Joomla.JText._('%s')</b>
language constant for <b>%s</b> does not have a corresponding
<code>Text::script('%s')</code> decalaration,
please add it.',
$constant, $string, $string
), 'Warning'
);
}
}
}
// check if we should add a EXTERNALCODE notice
if (ArrayHelper::check($this->externalCodeString))
{
// number of external code strings
$externalCount = count($this->externalCodeString);
// the correct string
$externalCodeString = ($externalCount == 1) ? Text::_(
'code/string'
) : Text::_('COM_COMPONENTBUILDER_CODESTRINGS');
// the notice
$this->app->enqueueMessage(
Text::_('COM_COMPONENTBUILDER_HR_HTHREEEXTERNAL_CODE_NOTICEHTHREE'),
'Notice'
);
$this->app->enqueueMessage(
Text::sprintf(
'There has been <b>%s - %s</b> added to this
component as EXTERNALCODE. To avoid shipping your component with malicious
%s always make sure that the correct <b>code/string values</b>
were used.',
$externalCount, $externalCodeString, $externalCodeString
), 'Notice'
);
}
// end the timer here
$this->time_end = microtime(true);
$this->secondsCompiled = $this->time_end - $this->time_start;
CFactory::_('Utilities.Counter')->end();
// completed the compilation
return true;
}
return false;
}
/**
* Set the dynamic data to the created files
*
* @return bool true on success
*
*/
protected function updateFiles()
{
if
(CFactory::_('Utilities.Files')->exists('static')
&&
CFactory::_('Utilities.Files')->exists('dynamic'))
{
// load any other super powers that was already found
if (($super_powers =
CFactory::_('Power.Extractor')->get_()) !== null)
{
CFactory::_('Power')->load($super_powers);
}
// set the autoloader for Powers
CFactory::_('Power.Autoloader')->set();
// get the bom file
$bom =
FileHelper::getContent(CFactory::_('Config')->bom_path);
// first we do the static files
foreach
(CFactory::_('Utilities.Files')->get('static') as
$static)
{
if (File::exists($static['path']))
{
$this->setFileContent(
$static['name'], $static['path'], $bom
);
}
}
// now we do the dynamic files
foreach
(CFactory::_('Utilities.Files')->get('dynamic') as
$view => $files)
{
if
(CFactory::_('Compiler.Builder.Content.Multi')->isArray($view))
{
foreach ($files as $file)
{
if ($file['view'] == $view)
{
if (File::exists($file['path']))
{
$this->setFileContent(
$file['name'], $file['path'], $bom,
$file['view']
);
}
}
}
}
// free up some memory
CFactory::_('Compiler.Builder.Content.Multi')->remove($view);
}
// free up some memory
CFactory::_('Utilities.Files')->remove('dynamic');
// do modules if found
if (CFactory::_('Joomlamodule.Data')->exists())
{
foreach (CFactory::_('Joomlamodule.Data')->get() as
$module)
{
if (ObjectHelper::check($module)
&&
CFactory::_('Utilities.Files')->exists($module->key))
{
// move field or rule if needed
if (isset($module->fields_rules_paths)
&& $module->fields_rules_paths == 2)
{
// check the config fields
if (isset($module->config_fields)
&& ArrayHelper::check(
$module->config_fields
))
{
foreach (
$module->config_fields as $field_name =>
$fieldsets
)
{
foreach ($fieldsets as $fieldset => $fields)
{
foreach ($fields as $field)
{
$this->moveFieldsRules(
$field, $module->folder_path
);
}
}
}
}
// check the fieldsets
if (isset($module->form_files)
&& ArrayHelper::check(
$module->form_files
))
{
foreach ($module->form_files as $file => $files)
{
foreach (
$files as $field_name => $fieldsets
)
{
foreach (
$fieldsets as $fieldset => $fields
)
{
foreach ($fields as $field)
{
$this->moveFieldsRules(
$field, $module->folder_path
);
}
}
}
}
}
}
// update the module files
foreach
(CFactory::_('Utilities.Files')->get($module->key) as
$module_file)
{
if (File::exists($module_file['path']))
{
$this->setFileContent(
$module_file['name'], $module_file['path'],
$bom, $module->key
);
}
}
// free up some memory
CFactory::_('Utilities.Files')->remove($module->key);
CFactory::_('Compiler.Builder.Content.Multi')->remove($module->key);
}
}
}
// do plugins if found
if (CFactory::_('Joomlaplugin.Data')->exists())
{
foreach (CFactory::_('Joomlaplugin.Data')->get() as
$plugin)
{
if (ObjectHelper::check($plugin)
&&
CFactory::_('Utilities.Files')->exists($plugin->key))
{
// move field or rule if needed
if (isset($plugin->fields_rules_paths)
&& $plugin->fields_rules_paths == 2)
{
// check the config fields
if (isset($plugin->config_fields)
&& ArrayHelper::check(
$plugin->config_fields
))
{
foreach (
$plugin->config_fields as $field_name =>
$fieldsets
)
{
foreach ($fieldsets as $fieldset => $fields)
{
foreach ($fields as $field)
{
$this->moveFieldsRules(
$field, $plugin->folder_path
);
}
}
}
}
// check the fieldsets
if (isset($plugin->form_files)
&& ArrayHelper::check(
$plugin->form_files
))
{
foreach ($plugin->form_files as $file => $files)
{
foreach (
$files as $field_name => $fieldsets
)
{
foreach (
$fieldsets as $fieldset => $fields
)
{
foreach ($fields as $field)
{
$this->moveFieldsRules(
$field, $plugin->folder_path
);
}
}
}
}
}
}
// update the plugin files
foreach
(CFactory::_('Utilities.Files')->get($plugin->key) as
$plugin_file)
{
if (File::exists($plugin_file['path']))
{
$this->setFileContent(
$plugin_file['name'], $plugin_file['path'],
$bom, $plugin->key
);
}
}
// free up some memory
CFactory::_('Utilities.Files')->remove($plugin->key);
CFactory::_('Compiler.Builder.Content.Multi')->remove($plugin->key);
}
}
}
// load any other super powers that was found
if (($super_powers =
CFactory::_('Power.Extractor')->get_()) !== null)
{
CFactory::_('Power')->load($super_powers);
}
// load the powers files/folders
CFactory::_('Power.Structure')->build();
// Infuse POWERS
CFactory::_('Power.Infusion')->set();
// do powers if found
if (ArrayHelper::check(CFactory::_('Power')->active))
{
foreach (CFactory::_('Power')->active as $power)
{
if (ObjectHelper::check($power)
&&
CFactory::_('Utilities.Files')->exists($power->key))
{
// update the power files
foreach
(CFactory::_('Utilities.Files')->get($power->key) as
$power_file)
{
if (File::exists($power_file['path']))
{
$this->setFileContent(
$power_file['name'], $power_file['path'],
$bom, $power->key
);
}
}
// free up some memory
CFactory::_('Utilities.Files')->remove($power->key);
CFactory::_('Compiler.Builder.Content.Multi')->remove($power->key);
}
}
}
// do super powers details if found
if (ArrayHelper::check(CFactory::_('Power')->superpowers))
{
foreach (CFactory::_('Power')->superpowers as $path =>
$powers)
{
$key = StringHelper::safe($path);
if (CFactory::_('Utilities.Files')->exists($key))
{
// update the power files
foreach (CFactory::_('Utilities.Files')->get($key) as
$power_file)
{
if (File::exists($power_file['path']))
{
$this->setFileContent(
$power_file['name'], $power_file['path'],
$bom, $key
);
}
}
// free up some memory
CFactory::_('Utilities.Files')->remove($key);
CFactory::_('Compiler.Builder.Content.Multi')->remove($key);
}
}
}
return true;
}
return false;
}
/**
* set the file content
*
* @return void
*
*/
protected function setFileContent(&$name, &$path, &$bom, $view
= null)
{
// Trigger Event: jcb_ce_onBeforeSetFileContent
CFactory::_('Event')->trigger(
'jcb_ce_onBeforeSetFileContent', [&$name, &$path,
&$bom, &$view]
);
// set the file name
CFactory::_('Compiler.Builder.Content.One')->set('FILENAME',
$name);
// check if the file should get PHP opening
$php = '';
if (\ComponentbuilderHelper::checkFileType($name, 'php'))
{
$php = "<?php\n";
}
// get content of the file
$string = FileHelper::getContent($path);
// Trigger Event: jcb_ce_onGetFileContents
CFactory::_('Event')->trigger(
'jcb_ce_onGetFileContents', [&$string, &$name,
&$path, &$bom, &$view]
);
// see if we should add a BOM
if (strpos((string) $string, (string) Placefix::_h('BOM')) !==
false)
{
list($wast, $code) = explode(
Placefix::_h('BOM'), (string) $string
);
$string = $php . $bom . $code;
}
// set the answer
$answer = CFactory::_('Placeholder')->update($string,
CFactory::_('Compiler.Builder.Content.One')->allActive(), 3);
// set the dynamic answer
if ($view)
{
$placeholders =
CFactory::_('Compiler.Builder.Content.Multi')->get($view,
[]);
if (is_array($placeholders))
{
$answer = CFactory::_('Placeholder')->update(
$answer, $placeholders, 3
);
}
else
{
echo '<pre>';
var_dump($view, $placeholders);
exit;
}
unset($placeholders);
}
// check if this file needs extra care :)
if
(CFactory::_('Registry')->exists('update.file.content.'
. $path))
{
$answer = CFactory::_('Customcode')->update($answer);
}
// Trigger Event: jcb_ce_onBeforeSetFileContent
CFactory::_('Event')->trigger(
'jcb_ce_onBeforeWriteFileContent', [&$answer, &$name,
&$path, &$bom, &$view]
);
// inject any super powers found
$answer = CFactory::_('Joomla.Power.Injector')->power(
CFactory::_('Power.Injector')->power(
$answer
)
);
// add answer back to file
CFactory::_('Utilities.File')->write($path, $answer);
// count the file lines
CFactory::_('Utilities.Counter')->line +=
substr_count((string) $answer, PHP_EOL);
}
/**
* move the local update server xml file to a remote ftp server
*
* @return void
*
*/
protected function setUpdateServer()
{
// move the component update server to host
if
(CFactory::_('Component')->get('add_update_server',
0) == 1
&&
CFactory::_('Component')->get('update_server_target',
0) == 1
&& isset($this->updateServerFileName)
&& $this->dynamicIntegration)
{
$update_server_xml_path =
CFactory::_('Utilities.Paths')->component_path .
'/'
. $this->updateServerFileName . '.xml';
// make sure we have the correct file
if (File::exists($update_server_xml_path)
&& ($update_server =
CFactory::_('Component')->get('update_server')) !==
null)
{
// move to server
if (!CFactory::_('Server')->legacyMove(
$update_server_xml_path,
$this->updateServerFileName . '.xml',
(int) $update_server,
CFactory::_('Component')->get('update_server_protocol')
))
{
$this->app->enqueueMessage(
Text::sprintf(
'Upload of component (%s) update server XML failed.',
CFactory::_('Component')->get('system_name')
), 'Error'
);
}
// remove the local file
File::delete($update_server_xml_path);
}
}
// move the modules update server to host
if (CFactory::_('Joomlamodule.Data')->exists())
{
foreach (CFactory::_('Joomlamodule.Data')->get() as
$module)
{
if (ObjectHelper::check($module)
&& isset($module->add_update_server)
&& $module->add_update_server == 1
&& isset($module->update_server_target)
&& $module->update_server_target == 1
&& isset($module->update_server)
&& is_numeric($module->update_server)
&& $module->update_server > 0
&& isset($module->update_server_xml_path)
&& File::exists($module->update_server_xml_path)
&& isset($module->update_server_xml_file_name)
&& StringHelper::check(
$module->update_server_xml_file_name
))
{
// move to server
if (!CFactory::_('Server')->legacyMove(
$module->update_server_xml_path,
$module->update_server_xml_file_name,
(int) $module->update_server,
$module->update_server_protocol
))
{
$this->app->enqueueMessage(
Text::sprintf(
'Upload of module (%s) update server XML failed.',
$module->name
), 'Error'
);
}
// remove the local file
File::delete($module->update_server_xml_path);
}
// var_dump($module->update_server_xml_path);exit;
}
}
// move the plugins update server to host
if (CFactory::_('Joomlaplugin.Data')->exists())
{
foreach (CFactory::_('Joomlaplugin.Data')->get() as
$plugin)
{
if (ObjectHelper::check($plugin)
&& isset($plugin->add_update_server)
&& $plugin->add_update_server == 1
&& isset($plugin->update_server_target)
&& $plugin->update_server_target == 1
&& isset($plugin->update_server)
&& is_numeric($plugin->update_server)
&& $plugin->update_server > 0
&& isset($plugin->update_server_xml_path)
&& File::exists($plugin->update_server_xml_path)
&& isset($plugin->update_server_xml_file_name)
&& StringHelper::check(
$plugin->update_server_xml_file_name
))
{
// move to server
if (!CFactory::_('Server')->legacyMove(
$plugin->update_server_xml_path,
$plugin->update_server_xml_file_name,
(int) $plugin->update_server,
$plugin->update_server_protocol
))
{
$this->app->enqueueMessage(
Text::sprintf(
'Upload of plugin (%s) update server XML failed.',
$plugin->name
), 'Error'
);
}
// remove the local file
File::delete($plugin->update_server_xml_path);
}
}
}
}
// link changes made to views into the file license
protected function fixLicenseValues($data)
{
// check if these files have its own config data)
if (isset($data['config'])
&& ArrayHelper::check(
$data['config']
)
&&
CFactory::_('Component')->get('mvc_versiondate', 0)
== 1)
{
foreach ($data['config'] as $key => $value)
{
if (Placefix::_h('VERSION') === $key)
{
// hmm we sould in some way make it known that this version number
// is not in relation the the project but to the file only... any
ideas?
// this is the best for now...
if (1 == $value)
{
$value = '@first version of this MVC';
}
else
{
$value = '@update number ' . $value . ' of this
MVC';
}
}
CFactory::_('Compiler.Builder.Content.One')->set($key,
$value);
}
return true;
}
// else insure to reset to global
CFactory::_('Compiler.Builder.Content.One')->set('CREATIONDATE',
CFactory::_('Compiler.Builder.Content.One')->get('GLOBALCREATIONDATE'));
CFactory::_('Compiler.Builder.Content.One')->set('BUILDDATE',
CFactory::_('Compiler.Builder.Content.One')->get('GLOBALBUILDDATE'));
CFactory::_('Compiler.Builder.Content.One')->set('VERSION',
CFactory::_('Compiler.Builder.Content.One')->get('GLOBALVERSION'));
}
/**
* Set all global numbers
*
* @return void
* @deprecated 3.3
*/
protected function setCountingStuff()
{
// set notice that we could not get a valid string from the target
$this->app->enqueueMessage(
Text::sprintf('COM_COMPONENTBUILDER_HR_HTHREES_WARNINGHTHREE',
__CLASS__), 'Error'
);
$this->app->enqueueMessage(
Text::sprintf(
'Use of a deprecated method (%s)!', __METHOD__
), 'Error'
);
}
private function buildReadMe()
{
// do a final run to update the readme file
$two = 0;
// counter data if not set already
if
(!CFactory::_('Compiler.Builder.Content.One')->exists('LINE_COUNT')
||
CFactory::_('Compiler.Builder.Content.One')->get('LINE_COUNT')
!= CFactory::_('Utilities.Counter')->line)
{
CFactory::_('Utilities.Counter')->set();
}
// search for the readme
foreach
(CFactory::_('Utilities.Files')->get('static') as
$static)
{
if (('README.md' === $static['name']
|| 'README.txt' === $static['name'])
&&
CFactory::_('Component')->get('addreadme')
&& File::exists($static['path']))
{
$this->setReadMe($static['path']);
$two++;
}
if ($two == 2)
{
break;
}
}
CFactory::_('Utilities.Files')->remove('static');
}
private function setReadMe($path)
{
// get the file
$string = FileHelper::getContent($path);
// update the file
$answer = CFactory::_('Placeholder')->update($string,
CFactory::_('Compiler.Builder.Content.One')->allActive());
// add to zip array
CFactory::_('Utilities.File')->write($path, $answer);
}
/**
* Build README data
*
* @return void
* @deprecated 3.3
*/
private function buildReadMeData()
{
// set notice that we could not get a valid string from the target
$this->app->enqueueMessage(
Text::sprintf('COM_COMPONENTBUILDER_HR_HTHREES_WARNINGHTHREE',
__CLASS__), 'Error'
);
$this->app->enqueueMessage(
Text::sprintf(
'Use of a deprecated method (%s)!', __METHOD__
), 'Error'
);
}
private function setLocalRepos()
{
// move it to the repo folder if set
if (isset($this->repoPath)
&& StringHelper::check(
$this->repoPath
))
{
// set the repo path
$repoFullPath = $this->repoPath . '/com_'
. CFactory::_('Component')->get('sales_name') .
'__joomla_'
. CFactory::_('Config')->get('joomla_version',
3);
// for plugin event TODO change event api signatures
$component_context =
CFactory::_('Config')->component_context;
$component_path =
CFactory::_('Utilities.Paths')->component_path;
// Trigger Event: jcb_ce_onBeforeUpdateRepo
CFactory::_('Event')->trigger(
'jcb_ce_onBeforeUpdateRepo',
array(&$component_context, &$component_path,
&$repoFullPath, &$this->componentData)
);
// remove old data
CFactory::_('Utilities.Folder')->remove($repoFullPath,
CFactory::_('Component')->get('toignore'));
// set the new data
try {
Folder::copy(CFactory::_('Utilities.Paths')->component_path,
$repoFullPath, '', true);
} catch (\RuntimeException $e) {
$this->app->enqueueMessage(
Text::_('COM_COMPONENTBUILDER_WE_WHERE_WAS_UNABLE_TO_TRANSFER_THE_COMPONENT_TO_THE_GIT_REPOSITORY')
. ' ' . $e->getMessage()
, 'Error'
);
}
// Trigger Event: jcb_ce_onAfterUpdateRepo
CFactory::_('Event')->trigger(
'jcb_ce_onAfterUpdateRepo',
array(&$component_context, &$component_path,
&$repoFullPath, &$this->componentData)
);
// move the modules to local folder repos
if (CFactory::_('Joomlamodule.Data')->exists())
{
foreach (CFactory::_('Joomlamodule.Data')->get() as
$module)
{
if (ObjectHelper::check($module)
&& isset($module->file_name))
{
$module_context = 'module.' . $module->file_name .
'.'
. $module->id;
// set the repo path
$repoFullPath = $this->repoPath . '/'
. $module->folder_name . '__joomla_'
.
CFactory::_('Config')->get('joomla_version', 3);
// Trigger Event: jcb_ce_onBeforeUpdateRepo
CFactory::_('Event')->trigger(
'jcb_ce_onBeforeUpdateRepo',
array(&$module_context, &$module->folder_path,
&$repoFullPath, &$module)
);
// remove old data
CFactory::_('Utilities.Folder')->remove(
$repoFullPath,
CFactory::_('Component')->get('toignore')
);
// set the new data
try {
Folder::copy(
$module->folder_path, $repoFullPath, '', true
);
} catch (\RuntimeException $e) {
$this->app->enqueueMessage(
Text::sprintf('COM_COMPONENTBUILDER_WE_WHERE_WAS_UNABLE_TO_TRANSFER_THE_S_MODULE_TO_THE_GIT_REPOSITORY',
$module->name) . ' ' . $e->getMessage()
, 'Error'
);
}
// Trigger Event: jcb_ce_onAfterUpdateRepo
CFactory::_('Event')->trigger(
'jcb_ce_onAfterUpdateRepo',
array(&$module_context, &$module->folder_path,
&$repoFullPath, &$module)
);
}
}
}
// move the plugins to local folder repos
if (CFactory::_('Joomlaplugin.Data')->exists())
{
foreach (CFactory::_('Joomlaplugin.Data')->get() as
$plugin)
{
if (ObjectHelper::check($plugin)
&& isset($plugin->file_name))
{
$plugin_context = 'plugin.' . $plugin->file_name .
'.'
. $plugin->id;
// set the repo path
$repoFullPath = $this->repoPath . '/'
. $plugin->folder_name . '__joomla_'
.
CFactory::_('Config')->get('joomla_version', 3);
// Trigger Event: jcb_ce_onBeforeUpdateRepo
CFactory::_('Event')->trigger(
'jcb_ce_onBeforeUpdateRepo',
array(&$plugin_context, &$plugin->folder_path,
&$repoFullPath, &$plugin)
);
// remove old data
CFactory::_('Utilities.Folder')->remove(
$repoFullPath,
CFactory::_('Component')->get('toignore')
);
// set the new data
try {
Folder::copy(
$plugin->folder_path, $repoFullPath, '', true
);
} catch (\RuntimeException $e) {
$this->app->enqueueMessage(
Text::sprintf('COM_COMPONENTBUILDER_WE_WHERE_WAS_UNABLE_TO_TRANSFER_THE_S_PLUGIN_TO_THE_GIT_REPOSITORY',
$plugin->name) . ' ' . $e->getMessage()
, 'Error'
);
}
// Trigger Event: jcb_ce_onAfterUpdateRepo
CFactory::_('Event')->trigger(
'jcb_ce_onAfterUpdateRepo',
array(&$plugin_context, &$plugin->folder_path,
&$repoFullPath, &$plugin)
);
}
}
}
}
}
private function zipComponent()
{
// Component Folder Name
$this->filepath['component-folder'] =
CFactory::_('Utilities.Paths')->component_folder_name;
// the name of the zip file to create
$this->filepath['component'] = $this->tempPath .
'/'
. $this->filepath['component-folder'] . '.zip';
// for plugin event TODO change event api signatures
$component_context =
CFactory::_('Config')->component_context;
$component_path =
CFactory::_('Utilities.Paths')->component_path;
$component_sales_name =
CFactory::_('Utilities.Paths')->component_sales_name;
$component_folder_name =
CFactory::_('Utilities.Paths')->component_folder_name;
// Trigger Event: jcb_ce_onBeforeZipComponent
CFactory::_('Event')->trigger(
'jcb_ce_onBeforeZipComponent', [&$component_path,
&$this->filepath['component'],
&$this->tempPath, &$component_folder_name]
);
//create the zip file
if (FileHelper::zip(
CFactory::_('Utilities.Paths')->component_path,
$this->filepath['component']
))
{
// now move to backup if zip was made and backup is required
if ($this->backupPath && $this->dynamicIntegration)
{
// Trigger Event: jcb_ce_onBeforeBackupZip
CFactory::_('Event')->trigger(
'jcb_ce_onBeforeBackupZip',
[&$this->filepath['component'], &$this->tempPath,
&$this->backupPath]
);
// copy the zip to backup path
try {
File::copy(
$this->filepath['component'],
$this->backupPath . '/' .
CFactory::_('Utilities.Paths')->component_backup_name
. '.zip'
);
} catch (\RuntimeException $e) {
$this->app->enqueueMessage(
Text::_('COM_COMPONENTBUILDER_WE_WHERE_WAS_UNABLE_TO_TRANSFER_THE_COMPONENT_ZIP_FILE_TO_THE_BACKUP_FOLDER')
. ' ' . $e->getMessage()
, 'Error'
);
}
}
// move to sales server host
if
(CFactory::_('Component')->get('add_sales_server',
0) == 1
&& $this->dynamicIntegration)
{
// make sure we have the correct file
if
(CFactory::_('Component')->get('sales_server'))
{
// Trigger Event: jcb_ce_onBeforeMoveToServer
CFactory::_('Event')->trigger(
'jcb_ce_onBeforeMoveToServer',
[&$this->filepath['component'], &$this->tempPath,
&$component_sales_name]
);
// move to server
if (!CFactory::_('Server')->legacyMove(
$this->filepath['component'],
$component_sales_name . '.zip',
(int)
CFactory::_('Component')->get('sales_server'),
CFactory::_('Component')->get('sales_server_protocol')
))
{
$this->app->enqueueMessage(
Text::sprintf(
'Upload of component (%s) zip file failed.',
CFactory::_('Component')->get('system_name')
), 'Error'
);
}
}
}
// Trigger Event: jcb_ce_onAfterZipComponent
CFactory::_('Event')->trigger(
'jcb_ce_onAfterZipComponent',
[&$this->filepath['component'], &$this->tempPath,
&$component_folder_name]
);
// remove the component folder since we are done
if
(CFactory::_('Utilities.Folder')->remove(CFactory::_('Utilities.Paths')->component_path))
{
return true;
}
}
return false;
}
private function zipModules()
{
if (CFactory::_('Joomlamodule.Data')->exists())
{
foreach (CFactory::_('Joomlamodule.Data')->get() as
$module)
{
if (ObjectHelper::check($module)
&& isset($module->zip_name)
&& StringHelper::check($module->zip_name)
&& isset($module->folder_path)
&& StringHelper::check(
$module->folder_path
))
{
// set module context
$module_context = $module->file_name . '.' .
$module->id;
// Component Folder Name
$this->filepath['modules-folder'][$module->id]
= $module->zip_name;
// the name of the zip file to create
$this->filepath['modules'][$module->id] =
$this->tempPath
. '/' . $module->zip_name . '.zip';
// Trigger Event: jcb_ce_onBeforeZipModule
CFactory::_('Event')->trigger(
'jcb_ce_onBeforeZipModule',
array(&$module_context, &$module->folder_path,
&$this->filepath['modules'][$module->id],
&$this->tempPath, &$module->zip_name,
&$module)
);
//create the zip file
if (FileHelper::zip(
$module->folder_path,
$this->filepath['modules'][$module->id]
))
{
// now move to backup if zip was made and backup is required
if ($this->backupPath)
{
$__module_context = 'module.' . $module_context;
// Trigger Event: jcb_ce_onBeforeBackupZip
CFactory::_('Event')->trigger(
'jcb_ce_onBeforeBackupZip',
array(&$__module_context,
&$this->filepath['modules'][$module->id],
&$this->tempPath, &$this->backupPath,
&$module)
);
// copy the zip to backup path
try {
File::copy(
$this->filepath['modules'][$module->id],
$this->backupPath . '/' . $module->zip_name
. '.zip'
);
} catch (\RuntimeException $e) {
$this->app->enqueueMessage(
Text::sprintf('COM_COMPONENTBUILDER_WE_WHERE_WAS_UNABLE_TO_TRANSFER_THE_S_MODULE_ZIP_FILE_TO_THE_BACKUP_FOLDER',
$module->name) . ' ' . $e->getMessage()
, 'Error'
);
}
}
// move to sales server host
if ($module->add_sales_server == 1)
{
// make sure we have the correct file
if (isset($module->sales_server))
{
// Trigger Event: jcb_ce_onBeforeMoveToServer
CFactory::_('Event')->trigger(
'jcb_ce_onBeforeMoveToServer',
array(&$__module_context,
&$this->filepath['modules'][$module->id],
&$this->tempPath, &$module->zip_name,
&$module)
);
// move to server
if (!CFactory::_('Server')->legacyMove(
$this->filepath['modules'][$module->id],
$module->zip_name . '.zip',
(int) $module->sales_server,
$module->sales_server_protocol
))
{
$this->app->enqueueMessage(
Text::sprintf(
'Upload of module (%s) zip file failed.',
$module->name
), 'Error'
);
}
}
}
// Trigger Event: jcb_ce_onAfterZipModule
CFactory::_('Event')->trigger(
'jcb_ce_onAfterZipModule', array(&$module_context,
&$this->filepath['modules'][$module->id],
&$this->tempPath,
&$module->zip_name,
&$module)
);
// remove the module folder since we are done
CFactory::_('Utilities.Folder')->remove($module->folder_path);
}
}
}
}
}
private function zipPlugins()
{
if (CFactory::_('Joomlaplugin.Data')->exists())
{
foreach (CFactory::_('Joomlaplugin.Data')->get() as
$plugin)
{
if (ObjectHelper::check($plugin)
&& isset($plugin->zip_name)
&& StringHelper::check($plugin->zip_name)
&& isset($plugin->folder_path)
&& StringHelper::check(
$plugin->folder_path
))
{
// set plugin context
$plugin_context = $plugin->file_name . '.' .
$plugin->id;
// Component Folder Name
$this->filepath['plugins-folder'][$plugin->id]
= $plugin->zip_name;
// the name of the zip file to create
$this->filepath['plugins'][$plugin->id] =
$this->tempPath
. '/' . $plugin->zip_name . '.zip';
// Trigger Event: jcb_ce_onBeforeZipPlugin
CFactory::_('Event')->trigger(
'jcb_ce_onBeforeZipPlugin',
array(&$plugin_context, &$plugin->folder_path,
&$this->filepath['plugins'][$plugin->id],
&$this->tempPath, &$plugin->zip_name,
&$plugin)
);
//create the zip file
if (FileHelper::zip(
$plugin->folder_path,
$this->filepath['plugins'][$plugin->id]
))
{
// now move to backup if zip was made and backup is required
if ($this->backupPath)
{
$__plugin_context = 'plugin.' . $plugin_context;
// Trigger Event: jcb_ce_onBeforeBackupZip
CFactory::_('Event')->trigger(
'jcb_ce_onBeforeBackupZip',
array(&$__plugin_context,
&$this->filepath['plugins'][$plugin->id],
&$this->tempPath, &$this->backupPath,
&$plugin)
);
// copy the zip to backup path
try {
File::copy(
$this->filepath['plugins'][$plugin->id],
$this->backupPath . '/' . $plugin->zip_name
. '.zip'
);
} catch (\RuntimeException $e) {
$this->app->enqueueMessage(
Text::sprintf('COM_COMPONENTBUILDER_WE_WHERE_WAS_UNABLE_TO_TRANSFER_THE_S_PLUGIN_ZIP_FILE_TO_THE_BACKUP_FOLDER',
$plugin->name) . ' ' . $e->getMessage()
, 'Error'
);
}
}
// move to sales server host
if ($plugin->add_sales_server == 1)
{
// make sure we have the correct file
if (isset($plugin->sales_server))
{
// Trigger Event: jcb_ce_onBeforeMoveToServer
CFactory::_('Event')->trigger(
'jcb_ce_onBeforeMoveToServer',
array(&$__plugin_context,
&$this->filepath['plugins'][$plugin->id],
&$this->tempPath, &$plugin->zip_name,
&$plugin)
);
// move to server
if (!CFactory::_('Server')->legacyMove(
$this->filepath['plugins'][$plugin->id],
$plugin->zip_name . '.zip',
(int) $plugin->sales_server,
$plugin->sales_server_protocol
))
{
$this->app->enqueueMessage(
Text::sprintf(
'Upload of plugin (%s) zip file failed.',
$plugin->name
), 'Error'
);
}
}
}
// Trigger Event: jcb_ce_onAfterZipPlugin
CFactory::_('Event')->trigger(
'jcb_ce_onAfterZipPlugin', array(&$plugin_context,
&$this->filepath['plugins'][$plugin->id],
&$this->tempPath,
&$plugin->zip_name,
&$plugin)
);
// remove the plugin folder since we are done
CFactory::_('Utilities.Folder')->remove($plugin->folder_path);
}
}
}
}
}
protected function addCustomCode()
{
// reset all these
CFactory::_('Placeholder')->clearType('view');
CFactory::_('Placeholder')->clearType('arg');
foreach (CFactory::_('Customcode')->active as $nr =>
$target)
{
// reset each time per custom code
$fingerPrint = array();
if (isset($target['hashtarget'][0]) &&
$target['hashtarget'][0] > 3
&& isset($target['path'])
&& StringHelper::check($target['path'])
&& isset($target['hashtarget'][1])
&& StringHelper::check(
$target['hashtarget'][1]
))
{
$file =
CFactory::_('Utilities.Paths')->component_path . '/'
. $target['path'];
$size = (int) $target['hashtarget'][0];
$hash = $target['hashtarget'][1];
$cut = $size - 1;
$found = false;
$bites = 0;
$lineBites = array();
$replace = array();
if ($target['type'] == 1 &&
isset($target['hashendtarget'][0])
&& $target['hashendtarget'][0] > 0)
{
$foundEnd = false;
$sizeEnd = (int) $target['hashendtarget'][0];
$hashEnd = $target['hashendtarget'][1];
$cutEnd = $sizeEnd - 1;
}
else
{
// replace to the end of the file
$foundEnd = true;
}
$counter = 0;
// check if file exist
if (File::exists($file))
{
foreach (
new \SplFileObject($file) as $lineNumber => $lineContent
)
{
// if not found we need to load line bites per line
$lineBites[$lineNumber] = (int) mb_strlen(
$lineContent, '8bit'
);
if (!$found)
{
$bites = (int) MathHelper::bc(
'add', $lineBites[$lineNumber], $bites
);
}
if ($found && !$foundEnd)
{
$replace[] = (int) $lineBites[$lineNumber];
// we must keep last three lines to dynamic find target entry
$fingerPrint[$lineNumber] = trim($lineContent);
// check lines each time if it fits our target
if (count((array) $fingerPrint) === $sizeEnd
&& !$foundEnd)
{
$fingerTest = md5(implode('', $fingerPrint));
if ($fingerTest === $hashEnd)
{
// we are done here
$foundEnd = true;
$replace = array_slice(
$replace, 0, count($replace) - $sizeEnd
);
break;
}
else
{
$fingerPrint = array_slice(
$fingerPrint, -$cutEnd, $cutEnd, true
);
}
}
continue;
}
if ($found && $foundEnd)
{
$replace[] = (int) $lineBites[$lineNumber];
}
// we must keep last three lines to dynamic find target entry
$fingerPrint[$lineNumber] = trim($lineContent);
// check lines each time if it fits our target
if (count((array) $fingerPrint) === $size && !$found)
{
$fingerTest = md5(implode('', $fingerPrint));
if ($fingerTest === $hash)
{
// we are done here
$found = true;
// reset in case
$fingerPrint = array();
// break if it is insertion
if ($target['type'] == 2)
{
break;
}
}
else
{
$fingerPrint = array_slice(
$fingerPrint, -$cut, $cut, true
);
}
}
}
if ($found)
{
$placeholder = CFactory::_('Placeholder')->keys(
(int) $target['comment_type'] .
$target['type'],
$target['id']
);
$data = $placeholder['start'] . PHP_EOL
. CFactory::_('Placeholder')->update_(
$target['code']
) . $placeholder['end'] . PHP_EOL;
if ($target['type'] == 2)
{
// found it now add code from the next line
CFactory::_('Utilities.FileInjector')->add($file,
$data, $bites);
}
elseif ($target['type'] == 1 && $foundEnd)
{
// found it now add code from the next line
CFactory::_('Utilities.FileInjector')->add(
$file, $data, $bites, (int) array_sum($replace)
);
}
else
{
// Load escaped code since the target endhash has changed
$this->loadEscapedCode($file, $target, $lineBites);
$this->app->enqueueMessage(
Text::_('COM_COMPONENTBUILDER_HR_HTHREECUSTOM_CODE_WARNINGHTHREE'),
'Warning'
);
$this->app->enqueueMessage(
Text::sprintf(
'Custom code %s could not be added to <b>%s</b>
please review the file after install at <b>line %s</b> and
reposition the code, remove the comments and recompile to fix the issue.
The issue could be due to a change to <b>lines below</b> the
custom code.',
'<a
href="index.php?option=com_componentbuilder&view=custom_codes&task=custom_code.edit&id='
. $target['id'] . '"
target="_blank">#'
. $target['id'] . '</a>',
$target['path'],
$target['from_line']
), 'Warning'
);
}
}
else
{
// Load escaped code since the target hash has changed
$this->loadEscapedCode($file, $target, $lineBites);
$this->app->enqueueMessage(
Text::_('COM_COMPONENTBUILDER_HR_HTHREECUSTOM_CODE_WARNINGHTHREE'),
'Warning'
);
$this->app->enqueueMessage(
Text::sprintf(
'Custom code %s could not be added to <b>%s</b>
please review the file after install at <b>line %s</b> and
reposition the code, remove the comments and recompile to fix the issue.
The issue could be due to a change to <b>lines above</b> the
custom code.',
'<a
href="index.php?option=com_componentbuilder&view=custom_codes&task=custom_code.edit&id='
. $target['id'] . '"
target="_blank">#'
. $target['id'] . '</a>',
$target['path'],
$target['from_line']
), 'Warning'
);
}
}
else
{
// Give developer a notice that file is not found.
$this->app->enqueueMessage(
Text::_('COM_COMPONENTBUILDER_HR_HTHREECUSTOM_CODE_WARNINGHTHREE'),
'Warning'
);
$this->app->enqueueMessage(
Text::sprintf(
'File <b>%s</b> could not be found, so the custom
code for this file could not be addded.',
$target['path']
), 'Warning'
);
}
}
}
}
protected function loadEscapedCode($file, $target, $lineBites)
{
// get comment type
if ($target['comment_type'] == 1)
{
$commentType = "// ";
$_commentType = "";
}
else
{
$commentType = "<!--";
$_commentType = " -->";
}
// escape the code
$code = explode(PHP_EOL, (string) $target['code']);
$code = PHP_EOL . $commentType . implode(
$_commentType . PHP_EOL . $commentType, $code
) . $_commentType . PHP_EOL;
// get placeholders
$placeholder = CFactory::_('Placeholder')->keys(
(int) $target['comment_type'] . $target['type'],
$target['id']
);
// build the data
$data = $placeholder['start'] . $code .
$placeholder['end'] . PHP_EOL;
// get the bites before insertion
$bitBucket = array();
foreach ($lineBites as $line => $value)
{
if ($line < $target['from_line'])
{
$bitBucket[] = $value;
}
}
// add to the file
CFactory::_('Utilities.FileInjector')->add($file, $data,
(int) array_sum($bitBucket));
}
/**
* Inserts or replaces data in a file at a specific position.
* Thanks to http://stackoverflow.com/a/16813550/1429677
*
* @param string $file The path of the file to modify
* @param string $data The data to insert or replace
* @param int $position The position in the file where the data
should be inserted or replaced
* @param int|null $replace The number of bytes to replace; if null,
data will be inserted
*
* @return void
* @throws RuntimeException if unable to open the file
* @deprecated 3.3 Use
CFactory::_('Utilities.FileInjector')->add($file, $data,
$position, $replace);
*/
protected function addDataToFile(string $file, string $data, int
$position, ?int $replace = null)
{
CFactory::_('Utilities.FileInjector')->add($file, $data,
$position, $replace);
}
}
src/Componentbuilder/Compiler/Helper/Fields.php000064400000152412151162054130015557
0ustar00<?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\Helper;
use Joomla\CMS\Language\Text;
// use
VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper;
(for Joomla 4 and above)
use VDM\Joomla\Utilities\ArrayHelper;
use VDM\Joomla\Utilities\StringHelper;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Indent;
use VDM\Joomla\Componentbuilder\Compiler\Factory as CFactory;
use VDM\Joomla\Componentbuilder\Compiler\Helper\Structure;
/**
* Fields class
*
* @deprecated 3.3
*/
class Fields extends Structure
{
/**
* Metadate Switch
*
* @var array
* @deprecated 3.3 Use
CFactory::_('Compiler.Builder.Meta.Data')->get($key);
*/
public $metadataBuilder = [];
/**
* View access Switch
*
* @var array
* @deprecated 3.3 Use
CFactory::_('Compiler.Builder.Access.Switch')->get($key);
*/
public $accessBuilder = [];
/**
* edit view tabs counter
*
* @var array
* @deprecated 3.3 Use
CFactory::_('Compiler.Builder.Tab.Counter')->get($key);
*/
public $tabCounter = [];
/**
* layout builder
*
* @var array
* @deprecated 3.3 Use
CFactory::_('Compiler.Builder.Layout')->get($key);
*/
public $layoutBuilder = [];
/**
* permissions builder
*
* @var array
* @deprecated 3.3 Use
CFactory::_('Compiler.Builder.Has.Permissions')->get($key);
*/
public $hasPermissions = [];
/**
* used to fix the zero order
*
* @var array
* @deprecated 3.3 Use
CFactory::_('Compiler.Builder.Order.Zero')->get($key);
*/
private $zeroOrderFix = [];
/**
* Site field data
*
* @var array
* @deprecated 3.3 Use
CFactory::_('Compiler.Builder.Site.Field.Data')->get($key);
*/
public $siteFieldData = [];
/**
* list of fields that are not being escaped
*
* @var array
* @deprecated 3.3 Use
CFactory::_('Compiler.Builder.Do.Not.Escape')->get($key);
*/
public $doNotEscape = [];
/**
* list of classes used in the list view for the fields
*
* @var array
* @deprecated 3.3 Use
CFactory::_('Compiler.Builder.List.Field.Class')->set($key,
true);
*/
public $listFieldClass = [];
/**
* tags builder
*
* @var array
* @deprecated 3.3 Use
CFactory::_('Compiler.Builder.Tags')->get($key);
*/
public $tagsBuilder = [];
/**
* query builder
*
* @var array
* @deprecated 3.3 Use
CFactory::_('Compiler.Builder.Database.Tables')->get($key);
*/
public $queryBuilder = [];
/**
* unique keys for database field
*
* @var array
* @deprecated 3.3 Use
CFactory::_('Compiler.Builder.Database.Unique.Keys')->get($key);
*/
public $dbUniqueKeys = [];
/**
* unique guid swtich
*
* @var array
* @deprecated 3.3 Use
CFactory::_('Compiler.Builder.Database.Unique.Guid')->get($key);
*/
public $dbUniqueGuid = [];
/**
* keys for database field
*
* @var array
* @deprecated 3.3 Use
CFactory::_('Compiler.Builder.Database.Keys')->get($key);
*/
public $dbKeys = [];
/**
* history builder
*
* @var array
* @deprecated 3.3 Use
CFactory::_('Compiler.Builder.History')->get($key);
*/
public $historyBuilder = [];
/**
* alias builder
*
* @var array
* @deprecated 3.3
CFactory::_('Compiler.Builder.Alias')->get($key);
*/
public $aliasBuilder = [];
/**
* title builder
*
* @var array
* @deprecated 3.3
CFactory::_('Compiler.Builder.Title')->get($key);
*/
public $titleBuilder = [];
/**
* list builder
*
* @var array
* @deprecated 3.3 Use
CFactory::_('Compiler.Builder.Lists')->get($key);
*/
public $listBuilder = [];
/**
* custom Builder List
*
* @var array
* @deprecated 3.3 Use
CFactory::_('Compiler.Builder.Custom.List')->get($key);
*/
public $customBuilderList = [];
/**
* Hidden Fields Builder
*
* @var array
* @deprecated 3.3 Use
CFactory::_('Compiler.Builder.Hidden.Fields')->get($key);
*/
public $hiddenFieldsBuilder = [];
/**
* INT Field Builder
*
* @var array
* @deprecated 3.3 Use
CFactory::_('Compiler.Builder.Integer.Fields')->get($key);
*/
public $intFieldsBuilder = [];
/**
* Dynamic Fields Builder
*
* @var array
* @deprecated 3.3 Use
CFactory::_('Compiler.Builder.Dynamic.Fields')->get($key);
*/
public $dynamicfieldsBuilder = [];
/**
* Main text Builder
*
* @var array
* @deprecated 3.3 Use
CFactory::_('Compiler.Builder.Main.Text.Field')->get($key);
*/
public $maintextBuilder = [];
/**
* Custom Builder
*
* @var array
* @deprecated 3.3 Use
CFactory::_('Compiler.Builder.Custom.Field')->get($key);
*/
public $customBuilder = [];
/**
* Custom Field Links Builder
*
* @var array
* @deprecated 3.3 Use
CFactory::_('Compiler.Builder.Custom.Field.Links')->get($key);
*/
public $customFieldLinksBuilder = [];
/**
* Set Script for User Switch
*
* @var array
* @deprecated 3.3 Use
CFactory::_('Compiler.Builder.Script.User.Switch')->get($key);
*/
public $setScriptUserSwitch = [];
/**
* Set Script for Media Switch
*
* @var array
* @deprecated 3.3 Use
CFactory::_('Compiler.Builder.Script.Media.Switch')->get($key);
*/
public $setScriptMediaSwitch = [];
/**
* Category builder
*
* @var array
* @deprecated 3.3 Use
CFactory::_('Compiler.Builder.Category')->get($key);
*/
public $categoryBuilder = [];
/**
* Category Code builder
*
* @var array
* @deprecated 3.3 Use
CFactory::_('Compiler.Builder.Category.Code')->get($key);
*/
public $catCodeBuilder = [];
/**
* Check Box builder
*
* @var array
* @deprecated 3.3 Use
CFactory::_('Compiler.Builder.Check.Box')->get($key);
*/
public $checkboxBuilder = [];
/**
* Json String Builder
*
* @var array
* @deprecated 3.3 Use
CFactory::_('Compiler.Builder.Json.String')->get($key);
*/
public $jsonStringBuilder = [];
/**
* Json String Builder for return values to array
*
* @var array
* @deprecated 3.3 Use
CFactory::_('Compiler.Builder.Json.Item.Array')->get($key);
*/
public $jsonItemBuilderArray = [];
/**
* Json Item Builder
*
* @var array
* @deprecated 3.3 Use
CFactory::_('Compiler.Builder.Json.Item')->get($key);
*/
public $jsonItemBuilder = [];
/**
* Base 64 Builder
*
* @var array
* @deprecated 3.3 Use
CFactory::_('Compiler.Builder.Base.Six.Four')->get($key);
*/
public $base64Builder = [];
/**
* Basic Encryption Field Modeling
*
* @var array
* @deprecated 3.3 Use
CFactory::_('Compiler.Builder.Model.Basic.Field')->get($key);
*/
public $basicFieldModeling = [];
/**
* WHMCS Encryption Field Modeling
*
* @var array
* @deprecated 3.3 Use
CFactory::_('Compiler.Builder.Model.Whmcs.Field')->get($key);
*/
public $whmcsFieldModeling = [];
/**
* Medium Encryption Field Modeling
*
* @var array
* @deprecated 3.3 Use
CFactory::_('Compiler.Builder.Model.Medium.Field')->get($key);
*/
public $mediumFieldModeling = [];
/**
* Expert Field Modeling
*
* @var array
* @deprecated 3.3 Use
CFactory::_('Compiler.Builder.Model.Expert.Field')->get($key);
*/
public $expertFieldModeling = [];
/**
* Expert Mode Initiator
*
* @var array
* @deprecated 3.3 Use
CFactory::_('Compiler.Builder.Model.Expert.Field.Initiator')->get($key);
*/
public $expertFieldModelInitiator = [];
/**
* Get Items Method List String Fix Builder
*
* @var array
* @deprecated 3.3 Use
CFactory::_('Compiler.Builder.Items.Method.List.String')->get($key);
*/
public $getItemsMethodListStringFixBuilder = [];
/**
* Get Items Method Eximport String Fix Builder
*
* @var array
* @deprecated 3.3 Use
CFactory::_('Compiler.Builder.Items.Method.Eximport.String')->get($key);
*/
public $getItemsMethodEximportStringFixBuilder = [];
/**
* Selection Translation Fix Builder
*
* @var array
* @deprecated 3.3 Use
CFactory::_('Compiler.Builder.Selection.Translation')->get($key);
*/
public $selectionTranslationFixBuilder = [];
/**
* Sort Builder
*
* @var array
* @deprecated 3.3 Use
CFactory::_('Compiler.Builder.Sort')->get($key);
*/
public $sortBuilder = [];
/**
* Search Builder
*
* @var array
* @deprecated 3.3 Use
CFactory::_('Compiler.Builder.Search')->get($key);
*/
public $searchBuilder = [];
/**
* Filter Builder
*
* @var array
* @deprecated 3.3 Use
CFactory::_('Compiler.Builder.Filter')->get($key);
*/
public $filterBuilder = [];
/**
* Set Group Control
*
* @var array
* @deprecated 3.3 Use
CFactory::_('Compiler.Builder.Field.Group.Control')->get($key);
*/
public $setGroupControl = [];
/**
* Set Field Names
*
* @var array
* @deprecated 3.3 Use
CFactory::_('Compiler.Builder.Field.Names')->get($key);
*/
public $fieldsNames = [];
/**
* Default Fields set to publishing
*
* @var array
* @deprecated 3.3 Use
CFactory::_('Compiler.Builder.New.Publishing.Fields')->set($key);
*/
public $newPublishingFields = [];
/**
* Default Fields set to publishing
*
* @var array
* @deprecated 3.3 Use
CFactory::_('Compiler.Builder.Moved.Publishing.Fields')->set($key);
*/
public $movedPublishingFields = [];
/**
* set the Field set of a view
*
* @param array $view The view data
* @param string $component The component name
* @param string $nameSingleCode The single view name
* @param string $nameListCode The list view name
*
* @return string The fields set in xml
* @deprecated 3.3 Use
CFactory::_('Compiler.Creator.Fieldset')->get(...);
*/
public function setFieldSet(array $view, string $component, string
$nameSingleCode, string $nameListCode)
{
return CFactory::_('Compiler.Creator.Fieldset')->
get($view, $component, $nameSingleCode, $nameListCode);
}
/**
* build field set using string manipulation
*
* @param array $view The view data
* @param string $component The component name
* @param string $nameSingleCode The single view name
* @param string $nameListCode The list view name
* @param string $langView The language string of the view
* @param string $langViews The language string of the views
*
* @return string The fields set in xml
* @deprecated 3.3 Use
CFactory::_('Compiler.Creator.Fieldset.String')->get(...);
*/
protected function stringFieldSet(array $view, string $component, string
$nameSingleCode, string $nameListCode,
string $langView, string $langViews): string
{
return
CFactory::_('Compiler.Creator.Fieldset.String')->get(
$view,
$component,
$nameSingleCode,
$nameListCode,
$langView,
$langViews
);
}
/**
* build field set with simpleXMLElement class
*
* @param array $view The view data
* @param string $component The component name
* @param string $nameSingleCode The single view name
* @param string $nameListCode The list view name
* @param string $langView The language string of the view
* @param string $langViews The language string of the views
*
* @return string The fields set in string xml
* @deprecated 3.3 Use
CFactory::_('Compiler.Creator.Fieldset.XML')->get(...);
*/
protected function simpleXMLFieldSet(array $view, string $component,
string $nameSingleCode,
string $nameListCode, string $langView, string $langViews): string
{
return CFactory::_('Compiler.Creator.Fieldset.XML')->get(
$view,
$component,
$nameSingleCode,
$nameListCode,
$langView,
$langViews
);
}
/**
* Check to see if a view has permissions
*
* @param array $view View details
* @param string $nameSingleCode View Single Code Name
*
* @return boolean true if it has permisssions
* @deprecated 3.3 Use
CFactory::_('Adminview.Permission')->check($view,
$nameSingleCode);
*/
protected function hasPermissionsSet(&$view, &$nameSingleCode)
{
return CFactory::_('Adminview.Permission')->check($view,
$nameSingleCode);
}
/**
* set Field Names
*
* @param string $view View the field belongs to
* @param string $name The name of the field
*
* @deprecated 3.3 Use
CFactory::_('Compiler.Builder.Field.Names')->set($view .
'.' . $name, $name);
*/
public function setFieldsNames(&$view, &$name)
{
CFactory::_('Compiler.Builder.Field.Names')->set($view .
'.' . $name, $name);
}
/**
* set Dynamic field
*
* @param array $field The field data
* @param array $view The view data
* @param int $viewType The view type
* @param string $langView The language string of the view
* @param string $nameSingleCode The single view name
* @param string $nameListCode The list view name
* @param array $placeholders The place holder and replace values
* @param string $dbkey The the custom table key
* @param boolean $build The switch to set the build option
*
* @return mixed The complete field
* @deprecated 3.3 Use
CFactory::_('Compiler.Builder.Field.Names')->get(...);
*/
public function setDynamicField(&$field, &$view, &$viewType,
&$langView,
&$nameSingleCode, &$nameListCode, &$placeholders,
&$dbkey, $build)
{
CFactory::_('Compiler.Creator.Field.Dynamic')->get($field,
$view, $viewType, $langView,
$nameSingleCode, $nameListCode, $placeholders, $dbkey, $build);
}
/**
* build field set
*
* @param array $fields The fields data
* @param string $langView The language string of the view
* @param string $nameSingleCode The single view name
* @param string $nameListCode The list view name
* @param array $placeholders The place holder and replace values
* @param string $dbkey The the custom table key
* @param boolean $build The switch to set the build option
* @param int $return_type The return type 1 = string, 2 =
array
*
* @return mixed The complete field in string or array
* @deprecated 3.3 Use
CFactory::_('Compiler.Builder.Fieldset.Dynamic')->get(...);
*/
public function getFieldsetXML(array &$fields, string &$langView,
string &$nameSingleCode,
string &$nameListCode, array &$placeholders, string &$dbkey,
bool $build = false,
int $returnType = 1)
{
return
CFactory::_('Compiler.Creator.Fieldset.Dynamic')->get(
$fields, $langView, $nameSingleCode,
$nameListCode, $placeholders, $dbkey, $build, $returnType
);
}
/**
* build field string
*
* @param array $field The field data
* @param array $view The view data
* @param int $viewType The view type
* @param string $langView The language string of the view
* @param string $nameSingleCode The single view name
* @param string $nameListCode The list view name
* @param array $placeholders The place holder and replace values
* @param string $dbkey The the custom table key
* @param boolean $build The switch to set the build option
*
* @return string The complete field in xml-string
* @deprecated 3.3 Use
CFactory::_('Compiler.Creator.Field.As.String')->get(...);
*/
public function getFieldXMLString(array &$field, array &$view, int
&$viewType, string &$langView,
string &$nameSingleCode, string &$nameListCode, array
&$placeholders, string &$dbkey,
bool $build = false): string
{
// get field
return
CFactory::_('Compiler.Creator.Field.As.String')->get(
$field, $view, $viewType, $langView,
$nameSingleCode, $nameListCode, $placeholders, $dbkey, $build
);
}
/**
* set a field
*
* @param string $setType The set of fields type
* @param array $fieldAttributes The field values
* @param string $name The field name
* @param string $typeName The field type
* @param string $langView The language string of the view
* @param string $nameSingleCode The single view name
* @param string $nameListCode The list view name
* @param array $placeholders The place holder and replace values
* @param array|null $optionArray The option bucket array used to
set the field options if needed.
* @param array $custom Used when field is from config
* @param string $taber The tabs to add in layout (only in
string manipulation)
*
* @return SimpleXMLElement The field in xml
* @deprecated 3.3 Use
CFactory::_('Compiler.Creator.Field.Type')->get(...);
*/
private function setField($setType, &$fieldAttributes, &$name,
&$typeName,
&$langView, &$nameSingleCode,
&$nameListCode, $placeholders,
&$optionArray, $custom = null, $taber =
''
) {
return CFactory::_('Compiler.Creator.Field.Type')->get(
$setType, $fieldAttributes, $name, $typeName,
$langView, $nameSingleCode, $nameListCode, $placeholders,
$optionArray, $custom, $taber
);
}
/**
* set a field using string manipulation
*
* @param string $setType The set of fields type
* @param array $fieldAttributes The field values
* @param string $name The field name
* @param string $typeName The field type
* @param string $langView The language string of the view
* @param string $nameSingleCode The single view name
* @param string $nameListCode The list view name
* @param array $placeholders The place holder and replace values
* @param array|null $optionArray The option bucket array used to
set the field options if needed.
* @param array $custom Used when field is from config
* @param string $taber The tabs to add in layout
*
* @return SimpleXMLElement The field in xml
* @deprecated 3.3 Use
CFactory::_('Compiler.Creator.Field.String')->get(...);
*/
protected function stringSetField($setType, &$fieldAttributes,
&$name,
&$typeName, &$langView, &$nameSingleCode,
&$nameListCode,
$placeholders, &$optionArray, $custom = null, $taber = '')
{
return CFactory::_('Compiler.Creator.Field.String')->get(
$setType, $fieldAttributes, $name,
$typeName, $langView, $nameSingleCode, $nameListCode,
$placeholders, $optionArray, $custom, $taber
);
}
/**
* set a field with simpleXMLElement class
*
* @param string $setType The set of fields type
* @param array $fieldAttributes The field values
* @param string $name The field name
* @param string $typeName The field type
* @param string $langView The language string of the view
* @param string $nameSingleCode The single view name
* @param string $nameListCode The list view name
* @param array $placeholders The place holder and replace values
* @param string $optionArray The option bucket array used to set
the field options if needed.
* @param array $custom Used when field is from config
*
* @return SimpleXMLElement The field in xml
* @deprecated 3.3 Use
CFactory::_('Compiler.Creator.Field.XML')->get(...);
*/
protected function simpleXMLSetField($setType, &$fieldAttributes,
&$name,
&$typeName, &$langView, &$nameSingleCode,
&$nameListCode,
$placeholders, &$optionArray, $custom = null)
{
return CFactory::_('Compiler.Creator.Field.XML')->get(
$setType, $fieldAttributes, $name,
$typeName, $langView, $nameSingleCode, $nameListCode,
$placeholders, $optionArray, $custom
);
}
/**
* set the layout builder
*
* @param string $nameSingleCode The single edit view code name
* @param string $tabName The tab code name
* @param string $name The field code name
* @param array $field The field details
*
* @return void
* @deprecated 3.3 Use
CFactory::_('Compiler.Creator.Layout')->set(...);
*/
public function setLayoutBuilder($nameSingleCode, $tabName, $name,
&$field)
{
CFactory::_('Compiler.Creator.Layout')->set($nameSingleCode,
$tabName, $name, $field);
}
/**
* build the site field data needed
*
* @param string $view The single edit view code name
* @param string $field The field name
* @param string $set The decoding set this field belongs to
* @param string $type The field type
*
* @return void
* @deprecated 3.3 Use
CFactory::_('Compiler.Creator.Site.Field.Data')->set(...);
*/
public function buildSiteFieldData($view, $field, $set, $type)
{
CFactory::_('Compiler.Creator.Site.Field.Data')->set($view,
$field, $set, $type);
}
/**
* set field attributes
*
* @param array $field The field data
* @param int $viewType The view type
* @param string $name The field name
* @param string $typeName The field type
* @param boolean $multiple The switch to set multiple selection
option
* @param string $langLabel The language string for field label
* @param string $langView The language string of the view
* @param string $nameListCode The list view name
* @param string $nameSingleCode The single view name
* @param array $placeholders The place holder and replace values
* @param boolean $repeatable The repeatable field switch
*
* @return array The field attributes
* @deprecated 3.3 Use
CFactory::_('Field.Attributes')->set(...);
*/
private function setFieldAttributes(&$field, &$viewType,
&$name, &$typeName,
&$multiple, &$langLabel, $langView, $nameListCode,
$nameSingleCode,
$placeholders, $repeatable = false
)
{
// set notice that we could not get a valid string from the target
$this->app->enqueueMessage(
Text::sprintf('COM_COMPONENTBUILDER_HR_HTHREES_WARNINGHTHREE',
__CLASS__), 'Error'
);
$this->app->enqueueMessage(
Text::sprintf(
'Use of a deprecated method (%s)!', __METHOD__
), 'Error'
);
return false;
}
/**
* set Builders
*
* @param string $langLabel The language string for field
label
* @param string $langView The language string of the view
* @param string $nameSingleCode The single view name
* @param string $nameListCode The list view name
* @param string $name The field name
* @param array $view The view data
* @param array $field The field data
* @param string $typeName The field type
* @param bool $multiple The switch to set multiple
selection option
* @param array|null $custom The custom field switch
* @param array|null $options The options switch
*
* @return void
* @deprecated 3.3 Use
CFactory::_('Compiler.Creator.Builders')->set(...);
*/
public function setBuilders($langLabel, $langView, $nameSingleCode,
$nameListCode, $name, $view, $field, $typeName, $multiple,
$custom = null, $options = null
): void
{
CFactory::_('Compiler.Creator.Builders')->set($langLabel,
$langView, $nameSingleCode,
$nameListCode, $name, $view, $field, $typeName, $multiple, $custom,
$options);
}
/**
* set Custom Field Type File
*
* @param array $data The field complete data set
* @param string $nameListCode The list view code name
* @param string $nameSingleCode The single view code name
*
* @return void
* @deprecated 3.3 Use
CFactory::_('Compiler.Creator.Custom.Field.Type.File')->set(...);
*/
public function setCustomFieldTypeFile($data,
$nameListCode,$nameSingleCode)
{
CFactory::_('Compiler.Creator.Custom.Field.Type.File')->set($data,
$nameListCode,$nameSingleCode);
}
/**
* This is just to get the code.
* Don't use this to build the field
*
* @param array $custom The field complete data set
*
* @return array with the code
*
*/
public function getCustomFieldCode($custom)
{
// the code bucket
$code_bucket = array(
'JFORM_TYPE_HEADER' => '',
'JFORM_TYPE_PHP' => ''
);
// set tab and break replacements
$tabBreak = array(
'\t' => Indent::_(1),
'\n' => PHP_EOL
);
// load the other PHP options
foreach (\ComponentbuilderHelper::$phpFieldArray as $x)
{
// reset the php bucket
$phpBucket = '';
// only set if available
if (isset($custom['php' . $x])
&& ArrayHelper::check(
$custom['php' . $x]
))
{
foreach ($custom['php' . $x] as $line => $code)
{
if (StringHelper::check($code))
{
$phpBucket .= PHP_EOL .
CFactory::_('Placeholder')->update(
$code, $tabBreak
);
}
}
// check if this is header text
if ('HEADER' === $x)
{
$code_bucket['JFORM_TYPE_HEADER']
.= PHP_EOL . $phpBucket;
}
else
{
// JFORM_TYPE_PHP <<<DYNAMIC>>>
$code_bucket['JFORM_TYPE_PHP']
.= PHP_EOL . $phpBucket;
}
}
}
return $code_bucket;
}
/**
* set the Filter Field set of a view
*
* @param string $nameSingleCode The single view name
* @param string $nameListCode The list view name
*
* @return string The fields set in xml
*
*/
public function setFieldFilterSet(&$nameSingleCode,
&$nameListCode)
{
if (CFactory::_('Config')->get('joomla_version',
3) == 3)
{
return $this->setFieldFilterSetJ3($nameSingleCode, $nameListCode);
}
return $this->setFieldFilterSetJ4($nameSingleCode, $nameListCode);
}
/**
* set the Filter List set of a view
*
* @param string $nameSingleCode The single view name
* @param string $nameListCode The list view name
*
* @return string The fields set in xml
*
*/
public function setFieldFilterListSet(&$nameSingleCode,
&$nameListCode)
{
if (CFactory::_('Config')->get('joomla_version',
3) == 3)
{
return $this->setFieldFilterListSetJ3($nameSingleCode,
$nameListCode);
}
return $this->setFieldFilterListSetJ4($nameSingleCode,
$nameListCode);
}
/**
* set the Filter Field set of a view
*
* @param string $nameSingleCode The single view name
* @param string $nameListCode The list view name
*
* @return string The fields set in xml
*
*/
public function setFieldFilterSetJ3(&$nameSingleCode,
&$nameListCode)
{
// check if this is the above/new filter option
if
(CFactory::_('Compiler.Builder.Admin.Filter.Type')->get($nameListCode,
1) == 2)
{
// we first create the file
$target = array('admin' => 'filter_' .
$nameListCode);
CFactory::_('Utilities.Structure')->build(
$target, 'filter'
);
// the search language string
$lang_search = CFactory::_('Config')->lang_prefix .
'_FILTER_SEARCH';
// and to translation
CFactory::_('Language')->set(
CFactory::_('Config')->lang_target, $lang_search,
'Search'
. StringHelper::safe($nameListCode, 'w')
);
// the search description language string
$lang_search_desc = CFactory::_('Config')->lang_prefix .
'_FILTER_SEARCH_'
. strtoupper($nameListCode);
// and to translation
CFactory::_('Language')->set(
CFactory::_('Config')->lang_target, $lang_search_desc,
'Search the '
. StringHelper::safe($nameSingleCode, 'w')
. ' items. Prefix with ID: to search for an item by ID.'
);
// now build the XML
$field_filter_sets = [];
$field_filter_sets[] = Indent::_(1) . '<fields
name="filter">';
// we first add the search
$field_filter_sets[] = Indent::_(2) . '<field';
$field_filter_sets[] = Indent::_(3) .
'type="text"';
$field_filter_sets[] = Indent::_(3) .
'name="search"';
$field_filter_sets[] = Indent::_(3) .
'inputmode="search"';
$field_filter_sets[] = Indent::_(3)
. 'label="' . $lang_search . '"';
$field_filter_sets[] = Indent::_(3)
. 'description="' . $lang_search_desc .
'"';
$field_filter_sets[] = Indent::_(3) .
'hint="JSEARCH_FILTER"';
$field_filter_sets[] = Indent::_(2) . '/>';
// add the published filter if published is not set
if
(!CFactory::_('Compiler.Builder.Field.Names')->isString($nameSingleCode
. '.published'))
{
// the published language string
$lang_published = CFactory::_('Config')->lang_prefix .
'_FILTER_PUBLISHED';
// and to translation
CFactory::_('Language')->set(
CFactory::_('Config')->lang_target, $lang_published,
'Status'
);
// the published description language string
$lang_published_desc = CFactory::_('Config')->lang_prefix
. '_FILTER_PUBLISHED_'
. strtoupper($nameListCode);
// and to translation
CFactory::_('Language')->set(
CFactory::_('Config')->lang_target, $lang_published_desc,
'Status options for '
. StringHelper::safe($nameListCode, 'w')
);
$field_filter_sets[] = Indent::_(2) . '<field';
$field_filter_sets[] = Indent::_(3) .
'type="status"';
$field_filter_sets[] = Indent::_(3) .
'name="published"';
$field_filter_sets[] = Indent::_(3)
. 'label="' . $lang_published . '"';
$field_filter_sets[] = Indent::_(3)
. 'description="' . $lang_published_desc .
'"';
$field_filter_sets[] = Indent::_(3)
. 'onchange="this.form.submit();"';
$field_filter_sets[] = Indent::_(2) . '>';
$field_filter_sets[] = Indent::_(3)
. '<option
value="">JOPTION_SELECT_PUBLISHED</option>';
$field_filter_sets[] = Indent::_(2) . '</field>';
}
// add the category if found
if
(CFactory::_('Compiler.Builder.Category')->exists("{$nameListCode}.extension")
&&
CFactory::_('Compiler.Builder.Category')->get("{$nameListCode}.filter",
0) >= 1)
{
$field_filter_sets[] = Indent::_(2) . '<field';
$field_filter_sets[] = Indent::_(3) .
'type="category"';
$field_filter_sets[] = Indent::_(3) .
'name="category_id"';
$field_filter_sets[] = Indent::_(3)
. 'label="' .
CFactory::_('Compiler.Builder.Category')->get("{$nameListCode}.name",
'error')
. '"';
$field_filter_sets[] = Indent::_(3)
. 'description="JOPTION_FILTER_CATEGORY_DESC"';
$field_filter_sets[] = Indent::_(3) .
'multiple="true"';
$field_filter_sets[] = Indent::_(3)
. 'class="multipleCategories"';
$field_filter_sets[] = Indent::_(3) . 'extension="'
.
CFactory::_('Compiler.Builder.Category')->get("{$nameListCode}.extension")
. '"';
$field_filter_sets[] = Indent::_(3)
. 'onchange="this.form.submit();"';
// TODO NOT SURE IF THIS SHOULD BE STATIC
$field_filter_sets[] = Indent::_(3) .
'published="0,1,2"';
$field_filter_sets[] = Indent::_(2) . '/>';
}
// add the access filter if this view has access
// and if access manually is not set
if
(CFactory::_('Compiler.Builder.Access.Switch')->exists($nameSingleCode)
&&
!CFactory::_('Compiler.Builder.Field.Names')->isString($nameSingleCode
. '.access'))
{
$field_filter_sets[] = Indent::_(2) . '<field';
$field_filter_sets[] = Indent::_(3) .
'type="accesslevel"';
$field_filter_sets[] = Indent::_(3) .
'name="access"';
$field_filter_sets[] = Indent::_(3)
. 'label="JFIELD_ACCESS_LABEL"';
$field_filter_sets[] = Indent::_(3)
. 'description="JFIELD_ACCESS_DESC"';
$field_filter_sets[] = Indent::_(3) .
'multiple="true"';
$field_filter_sets[] = Indent::_(3)
. 'class="multipleAccessLevels"';
$field_filter_sets[] = Indent::_(3)
. 'onchange="this.form.submit();"';
$field_filter_sets[] = Indent::_(2) . '/>';
}
// now add the dynamic fields
if
(CFactory::_('Compiler.Builder.Filter')->exists($nameListCode))
{
foreach
(CFactory::_('Compiler.Builder.Filter')->get($nameListCode) as
$n => $filter)
{
if ($filter['type'] != 'category')
{
$field_filter_sets[] = Indent::_(2) . '<field';
// if this is a custom field
if (ArrayHelper::check($filter['custom']))
{
// we use the field type from the custom field
$field_filter_sets[] = Indent::_(3) . 'type="'
. $filter['type'] . '"';
// set css classname of this field
$filter_class = ucfirst((string) $filter['type']);
}
else
{
// we use the filter field type that was build
$field_filter_sets[] = Indent::_(3) . 'type="'
. $filter['filter_type'] . '"';
// set css classname of this field
$filter_class = ucfirst((string) $filter['filter_type']);
}
// update global data set
CFactory::_('Compiler.Builder.Filter')->set("{$nameListCode}.{$n}.class",
$filter_class);
$field_filter_sets[] = Indent::_(3) . 'name="'
. $filter['code'] . '"';
$field_filter_sets[] = Indent::_(3) . 'label="'
. $filter['label'] . '"';
// if this is a multi field
if ($filter['multi'] == 2)
{
$field_filter_sets[] = Indent::_(3) .
'class="multiple' . $filter_class . '"';
$field_filter_sets[] = Indent::_(3) .
'multiple="true"';
}
else
{
$field_filter_sets[] = Indent::_(3) .
'multiple="false"';
}
$field_filter_sets[] = Indent::_(3)
. 'onchange="this.form.submit();"';
$field_filter_sets[] = Indent::_(2) . '/>';
}
}
}
$field_filter_sets[] = Indent::_(2)
. '<input type="hidden"
name="form_submited" value="1"/>';
$field_filter_sets[] = Indent::_(1) . '</fields>';
// now update the file
return implode(PHP_EOL, $field_filter_sets);
}
return '';
}
/**
* set the Filter List set of a view
*
* @param string $nameSingleCode The single view name
* @param string $nameListCode The list view name
*
* @return string The fields set in xml
*
*/
public function setFieldFilterListSetJ3(&$nameSingleCode,
&$nameListCode)
{
// check if this is the above/new filter option
if
(CFactory::_('Compiler.Builder.Admin.Filter.Type')->get($nameListCode,
1) == 2)
{
// keep track of all fields already added
$donelist = array('ordering' => true, 'id' =>
true);
// now build the XML
$list_sets = [];
$list_sets[] = Indent::_(1) . '<fields
name="list">';
$list_sets[] = Indent::_(2) . '<field';
$list_sets[] = Indent::_(3) .
'name="fullordering"';
$list_sets[] = Indent::_(3) . 'type="list"';
$list_sets[] = Indent::_(3)
. 'label="COM_CONTENT_LIST_FULL_ORDERING"';
$list_sets[] = Indent::_(3)
.
'description="COM_CONTENT_LIST_FULL_ORDERING_DESC"';
$list_sets[] = Indent::_(3) .
'onchange="this.form.submit();"';
// add dynamic ordering (Admin view)
$default_ordering = $this->getListViewDefaultOrdering(
$nameListCode
);
// set the default ordering
$list_sets[] = Indent::_(3) . 'default="'
. $default_ordering['name'] . ' '
. $default_ordering['direction'] . '"';
$list_sets[] = Indent::_(3) . 'validate="options"';
$list_sets[] = Indent::_(2) . '>';
$list_sets[] = Indent::_(3)
. '<option
value="">JGLOBAL_SORT_BY</option>';
$list_sets[] = Indent::_(3)
. '<option value="a.ordering
ASC">JGRID_HEADING_ORDERING_ASC</option>';
$list_sets[] = Indent::_(3)
. '<option value="a.ordering
DESC">JGRID_HEADING_ORDERING_DESC</option>';
// add the published filter if published is not set
if
(!CFactory::_('Compiler.Builder.Field.Names')->isString($nameSingleCode
. '.published'))
{
// add to done list
$donelist['published'] = true;
// add to xml :)
$list_sets[] = Indent::_(3)
. '<option value="a.published
ASC">JSTATUS_ASC</option>';
$list_sets[] = Indent::_(3)
. '<option value="a.published
DESC">JSTATUS_DESC</option>';
}
// add the rest of the set filters
if
(CFactory::_('Compiler.Builder.Sort')->exists($nameListCode))
{
foreach
(CFactory::_('Compiler.Builder.Sort')->get($nameListCode) as
$filter)
{
if (!isset($donelist[$filter['code']]))
{
if ($filter['type'] === 'category')
{
$list_sets[] = Indent::_(3)
. '<option value="category_title ASC">'
. $filter['lang_asc'] . '</option>';
$list_sets[] = Indent::_(3)
. '<option value="category_title DESC">'
. $filter['lang_desc'] . '</option>';
}
elseif (ArrayHelper::check(
$filter['custom']
))
{
$list_sets[] = Indent::_(3) . '<option value="'
. $filter['custom']['db'] . '.'
. $filter['custom']['text'] . '
ASC">'
. $filter['lang_asc'] . '</option>';
$list_sets[] = Indent::_(3) . '<option value="'
. $filter['custom']['db'] . '.'
. $filter['custom']['text'] . '
DESC">'
. $filter['lang_desc'] . '</option>';
}
else
{
$list_sets[] = Indent::_(3) . '<option value="a.'
. $filter['code'] . ' ASC">'
. $filter['lang_asc'] . '</option>';
$list_sets[] = Indent::_(3) . '<option value="a.'
. $filter['code'] . ' DESC">'
. $filter['lang_desc'] . '</option>';
}
// do not add again
$donelist[$filter['code']] = true;
}
}
}
$list_sets[] = Indent::_(3)
. '<option value="a.id
ASC">JGRID_HEADING_ID_ASC</option>';
$list_sets[] = Indent::_(3)
. '<option value="a.id
DESC">JGRID_HEADING_ID_DESC</option>';
$list_sets[] = Indent::_(2) . '</field>' . PHP_EOL;
$list_sets[] = Indent::_(2) . '<field';
$list_sets[] = Indent::_(3) . 'name="limit"';
$list_sets[] = Indent::_(3) . 'type="limitbox"';
$list_sets[] = Indent::_(3) .
'label="COM_CONTENT_LIST_LIMIT"';
$list_sets[] = Indent::_(3)
. 'description="COM_CONTENT_LIST_LIMIT_DESC"';
$list_sets[] = Indent::_(3) . 'class="input-mini"';
$list_sets[] = Indent::_(3) . 'default="25"';
$list_sets[] = Indent::_(3) .
'onchange="this.form.submit();"';
$list_sets[] = Indent::_(2) . '/>';
$list_sets[] = Indent::_(1) . '</fields>';
return implode(PHP_EOL, $list_sets);
}
return '';
}
/**
* set the Filter Field set of a view
*
* @param string $nameSingleCode The single view name
* @param string $nameListCode The list view name
*
* @return string The fields set in xml
*
*/
public function setFieldFilterSetJ4(&$nameSingleCode,
&$nameListCode)
{
// check if this is the above/new filter option
if
(CFactory::_('Compiler.Builder.Admin.Filter.Type')->get($nameListCode,
1) == 2)
{
// we first create the file
$target = ['admin' => 'filter_' .
$nameListCode];
CFactory::_('Utilities.Structure')->build(
$target, 'filter'
);
// the search language string
$lang_search = CFactory::_('Config')->lang_prefix .
'_FILTER_SEARCH';
// and to translation
CFactory::_('Language')->set(
CFactory::_('Config')->lang_target, $lang_search,
'Search'
. StringHelper::safe($nameListCode, 'w')
);
// the search description language string
$lang_search_desc = CFactory::_('Config')->lang_prefix .
'_FILTER_SEARCH_'
. strtoupper($nameListCode);
// and to translation
CFactory::_('Language')->set(
CFactory::_('Config')->lang_target, $lang_search_desc,
'Search the '
. StringHelper::safe($nameSingleCode, 'w')
. ' items. Prefix with ID: to search for an item by ID.'
);
// now build the XML
$field_filter_sets = [];
$field_filter_sets[] = Indent::_(1) . '<fields
name="filter">';
// we first add the search
$field_filter_sets[] = Indent::_(2) . '<field';
$field_filter_sets[] = Indent::_(3) .
'type="text"';
$field_filter_sets[] = Indent::_(3) .
'name="search"';
$field_filter_sets[] = Indent::_(3) .
'inputmode="search"';
$field_filter_sets[] = Indent::_(3)
. 'label="' . $lang_search . '"';
$field_filter_sets[] = Indent::_(3)
. 'description="' . $lang_search_desc .
'"';
$field_filter_sets[] = Indent::_(3) .
'hint="JSEARCH_FILTER"';
$field_filter_sets[] = Indent::_(2) . '/>';
// add the published filter if published is not set
if
(!CFactory::_('Compiler.Builder.Field.Names')->isString($nameSingleCode
. '.published'))
{
// the published language string
$lang_published = CFactory::_('Config')->lang_prefix .
'_FILTER_PUBLISHED';
// and to translation
CFactory::_('Language')->set(
CFactory::_('Config')->lang_target, $lang_published,
'Status'
);
// the published description language string
$lang_published_desc = CFactory::_('Config')->lang_prefix
. '_FILTER_PUBLISHED_'
. strtoupper($nameListCode);
// and to translation
CFactory::_('Language')->set(
CFactory::_('Config')->lang_target, $lang_published_desc,
'Status options for '
. StringHelper::safe($nameListCode, 'w')
);
$field_filter_sets[] = Indent::_(2) . '<field';
$field_filter_sets[] = Indent::_(3) .
'type="status"';
$field_filter_sets[] = Indent::_(3) .
'name="published"';
$field_filter_sets[] = Indent::_(3)
. 'label="' . $lang_published . '"';
$field_filter_sets[] = Indent::_(3)
. 'description="' . $lang_published_desc .
'"';
$field_filter_sets[] = Indent::_(3)
. 'class="js-select-submit-on-change"';
$field_filter_sets[] = Indent::_(2) . '>';
$field_filter_sets[] = Indent::_(3)
. '<option
value="">JOPTION_SELECT_PUBLISHED</option>';
$field_filter_sets[] = Indent::_(2) . '</field>';
}
// add the category if found
if
(CFactory::_('Compiler.Builder.Category')->exists("{$nameListCode}.extension")
&&
CFactory::_('Compiler.Builder.Category')->get("{$nameListCode}.filter",
0) >= 1)
{
$field_filter_sets[] = Indent::_(2) . '<field';
$field_filter_sets[] = Indent::_(3) .
'type="category"';
$field_filter_sets[] = Indent::_(3) .
'name="category_id"';
$field_filter_sets[] = Indent::_(3)
. 'label="' .
CFactory::_('Compiler.Builder.Category')->get("{$nameListCode}.name",
'error')
. '"';
$field_filter_sets[] = Indent::_(3)
. 'description="JOPTION_FILTER_CATEGORY_DESC"';
$field_filter_sets[] = Indent::_(3) .
'multiple="true"';
$field_filter_sets[] = Indent::_(3)
. 'class="js-select-submit-on-change"';
$field_filter_sets[] = Indent::_(3) . 'extension="'
.
CFactory::_('Compiler.Builder.Category')->get("{$nameListCode}.extension")
. '"';
$field_filter_sets[] = Indent::_(3)
. 'layout="joomla.form.field.list-fancy-select"';
// TODO NOT SURE IF THIS SHOULD BE STATIC
$field_filter_sets[] = Indent::_(3) .
'published="0,1,2"';
$field_filter_sets[] = Indent::_(2) . '/>';
}
// add the access filter if this view has access
// and if access manually is not set
if
(CFactory::_('Compiler.Builder.Access.Switch')->exists($nameSingleCode)
&&
!CFactory::_('Compiler.Builder.Field.Names')->isString($nameSingleCode
. '.access'))
{
$field_filter_sets[] = Indent::_(2) . '<field';
$field_filter_sets[] = Indent::_(3) .
'type="accesslevel"';
$field_filter_sets[] = Indent::_(3) .
'name="access"';
$field_filter_sets[] = Indent::_(3)
. 'label="JGRID_HEADING_ACCESS"';
$field_filter_sets[] = Indent::_(3)
. 'hint="JOPTION_SELECT_ACCESS"';
$field_filter_sets[] = Indent::_(3) .
'multiple="true"';
$field_filter_sets[] = Indent::_(3)
. 'class="js-select-submit-on-change"';
$field_filter_sets[] = Indent::_(3)
. 'layout="joomla.form.field.list-fancy-select"';
$field_filter_sets[] = Indent::_(2) . '/>';
}
// now add the dynamic fields
if
(CFactory::_('Compiler.Builder.Filter')->exists($nameListCode))
{
foreach
(CFactory::_('Compiler.Builder.Filter')->get($nameListCode) as
$n => $filter)
{
if ($filter['type'] != 'category')
{
$field_filter_sets[] = Indent::_(2) . '<field';
// if this is a custom field
if (ArrayHelper::check($filter['custom']))
{
// we use the field type from the custom field
$field_filter_sets[] = Indent::_(3) . 'type="'
. $filter['type'] . '"';
// set css classname of this field
$filter_class = ucfirst((string) $filter['type']);
}
else
{
// we use the filter field type that was build
$field_filter_sets[] = Indent::_(3) . 'type="'
. $filter['filter_type'] . '"';
// set css classname of this field
$filter_class = ucfirst((string) $filter['filter_type']);
}
$field_filter_sets[] = Indent::_(3) . 'name="'
. $filter['code'] . '"';
$field_filter_sets[] = Indent::_(3) . 'label="'
. $filter['label'] . '"';
// if this is a multi field
if ($filter['multi'] == 2)
{
$field_filter_sets[] = Indent::_(3) .
'layout="joomla.form.field.list-fancy-select"';
$field_filter_sets[] = Indent::_(3) .
'multiple="true"';
if (isset($filter['lang_select']))
{
$field_filter_sets[] = Indent::_(3) . 'hint="' .
$filter['lang_select'] . '"';
}
}
else
{
$field_filter_sets[] = Indent::_(3) .
'multiple="false"';
}
// we add the on change css class
$field_filter_sets[] = Indent::_(3) .
'class="js-select-submit-on-change"';
$field_filter_sets[] = Indent::_(2) . '/>';
}
}
}
$field_filter_sets[] = Indent::_(2)
. '<input type="hidden"
name="form_submited" value="1"/>';
$field_filter_sets[] = Indent::_(1) . '</fields>';
// now update the file
return implode(PHP_EOL, $field_filter_sets);
}
return '';
}
/**
* set the Filter List set of a view
*
* @param string $nameSingleCode The single view name
* @param string $nameListCode The list view name
*
* @return string The fields set in xml
*
*/
public function setFieldFilterListSetJ4(&$nameSingleCode,
&$nameListCode)
{
// check if this is the above/new filter option
if
(CFactory::_('Compiler.Builder.Admin.Filter.Type')->get($nameListCode,
1) == 2)
{
// keep track of all fields already added
$donelist = ['ordering' => true, 'id' =>
true];
// now build the XML
$list_sets = [];
$list_sets[] = Indent::_(1) . '<fields
name="list">';
$list_sets[] = Indent::_(2) . '<field';
$list_sets[] = Indent::_(3) .
'name="fullordering"';
$list_sets[] = Indent::_(3) . 'type="list"';
$list_sets[] = Indent::_(3)
. 'label="JGLOBAL_SORT_BY"';
$list_sets[] = Indent::_(3) .
'class="js-select-submit-on-change"';
// add dynamic ordering (Admin view)
$default_ordering = $this->getListViewDefaultOrdering(
$nameListCode
);
// set the default ordering
$list_sets[] = Indent::_(3) . 'default="'
. $default_ordering['name'] . ' '
. $default_ordering['direction'] . '"';
$list_sets[] = Indent::_(3) . 'validate="options"';
$list_sets[] = Indent::_(2) . '>';
$list_sets[] = Indent::_(3)
. '<option
value="">JGLOBAL_SORT_BY</option>';
$list_sets[] = Indent::_(3)
. '<option value="a.ordering
ASC">JGRID_HEADING_ORDERING_ASC</option>';
$list_sets[] = Indent::_(3)
. '<option value="a.ordering
DESC">JGRID_HEADING_ORDERING_DESC</option>';
// add the published filter if published is not set
if
(!CFactory::_('Compiler.Builder.Field.Names')->isString($nameSingleCode
. '.published'))
{
// add to done list
$donelist['published'] = true;
// add to xml :)
$list_sets[] = Indent::_(3)
. '<option value="a.published
ASC">JSTATUS_ASC</option>';
$list_sets[] = Indent::_(3)
. '<option value="a.published
DESC">JSTATUS_DESC</option>';
}
// add the rest of the set filters
if
(CFactory::_('Compiler.Builder.Sort')->exists($nameListCode))
{
foreach
(CFactory::_('Compiler.Builder.Sort')->get($nameListCode) as
$filter)
{
if (!isset($donelist[$filter['code']]))
{
if ($filter['type'] === 'category')
{
$list_sets[] = Indent::_(3)
. '<option value="category_title ASC">'
. $filter['lang_asc'] . '</option>';
$list_sets[] = Indent::_(3)
. '<option value="category_title DESC">'
. $filter['lang_desc'] . '</option>';
}
elseif (ArrayHelper::check(
$filter['custom']
))
{
$list_sets[] = Indent::_(3) . '<option value="'
. $filter['custom']['db'] . '.'
. $filter['custom']['text'] . '
ASC">'
. $filter['lang_asc'] . '</option>';
$list_sets[] = Indent::_(3) . '<option value="'
. $filter['custom']['db'] . '.'
. $filter['custom']['text'] . '
DESC">'
. $filter['lang_desc'] . '</option>';
}
else
{
$list_sets[] = Indent::_(3) . '<option value="a.'
. $filter['code'] . ' ASC">'
. $filter['lang_asc'] . '</option>';
$list_sets[] = Indent::_(3) . '<option value="a.'
. $filter['code'] . ' DESC">'
. $filter['lang_desc'] . '</option>';
}
// do not add again
$donelist[$filter['code']] = true;
}
}
}
$list_sets[] = Indent::_(3)
. '<option value="a.id
ASC">JGRID_HEADING_ID_ASC</option>';
$list_sets[] = Indent::_(3)
. '<option value="a.id
DESC">JGRID_HEADING_ID_DESC</option>';
$list_sets[] = Indent::_(2) . '</field>' . PHP_EOL;
$list_sets[] = Indent::_(2) . '<field';
$list_sets[] = Indent::_(3) . 'name="limit"';
$list_sets[] = Indent::_(3) . 'type="limitbox"';
$list_sets[] = Indent::_(3) .
'label="JGLOBAL_LIST_LIMIT"';
$list_sets[] = Indent::_(3) . 'default="25"';
$list_sets[] = Indent::_(3) .
'class="js-select-submit-on-change"';
$list_sets[] = Indent::_(2) . '/>';
$list_sets[] = Indent::_(1) . '</fields>';
return implode(PHP_EOL, $list_sets);
}
return '';
}
/**
* set Custom Field for Filter
*
* @param string $getOptions The get options php string/code
* @param array $filter The filter details
*
* @return void
*
*/
public function setFilterFieldFile($getOptions, $filter)
{
// make sure it is not already been build
if (!CFactory::_('Compiler.Builder.Content.Multi')->
isArray('customfilterfield_' .
$filter['filter_type']))
{
// start loading the field type
// $this->fileContentDynamic['customfilterfield_'
// . $filter['filter_type']]
// = [];
// JPREFIX <<DYNAMIC>>>
CFactory::_('Compiler.Builder.Content.Multi')->set('customfilterfield_'
. $filter['filter_type'] . '|JPREFIX', 'J');
// Type <<<DYNAMIC>>>
CFactory::_('Compiler.Builder.Content.Multi')->set('customfilterfield_'
. $filter['filter_type'] . '|Type',
StringHelper::safe(
$filter['filter_type'], 'F'
)
);
// type <<<DYNAMIC>>>
CFactory::_('Compiler.Builder.Content.Multi')->set('customfilterfield_'
. $filter['filter_type'] . '|type',
StringHelper::safe($filter['filter_type'])
);
// JFORM_GETOPTIONS_PHP <<<DYNAMIC>>>
CFactory::_('Compiler.Builder.Content.Multi')->set('customfilterfield_'
. $filter['filter_type'] . '|JFORM_GETOPTIONS_PHP',
$getOptions
);
// ADD_BUTTON <<<DYNAMIC>>>
CFactory::_('Compiler.Builder.Content.Multi')->set('customfilterfield_'
. $filter['filter_type'] . '|ADD_BUTTON',
'');
// now build the custom filter field type file
$target = array('admin' => 'customfilterfield');
CFactory::_('Utilities.Structure')->build(
$target, 'fieldlist',
$filter['filter_type']
);
}
}
/**
* set Add Button To List Field (getInput tweak)
*
* @param array $fieldData The field custom data
*
* @return string of getInput class on success empty string otherwise
* @deprecated 3.3 Use
CFactory::_('Field.Input.Button')->get($fieldData);
*/
protected function setAddButtonToListField($fieldData)
{
return CFactory::_('Field.Input.Button')->get($fieldData);
}
/**
* xmlPrettyPrint
*
* @param SimpleXMLElement $xml The XML element containing a node
to be output
* @param string $nodename node name of the input xml
element to print out. this is done to omit the <?xml... tag
*
* @return string XML output
* @deprecated 3.3 Use
CFactory::_('Utilities.Xml')->pretty($xml, $nodename);
*/
public function xmlPrettyPrint($xml, $nodename)
{
return CFactory::_('Utilities.Xml')->pretty($xml,
$nodename);
}
/**
* xmlIndent
*
* @param string $string The XML input
* @param string $char Character or characters to use as the
repeated indent
* @param integer $depth number of times to repeat the indent
character
* @param boolean $skipfirst Skip the first line of the input.
* @param boolean $skiplast Skip the last line of the input;
*
* @return string XML output
* @deprecated 3.3 Use
CFactory::_('Utilities.Xml')->indent(...);
*/
public function xmlIndent($string, $char = ' ', $depth = 0,
$skipfirst = false, $skiplast = false
) {
return CFactory::_('Utilities.Xml')->indent($string, $char,
$depth, $skipfirst, $skiplast);
}
}
src/Componentbuilder/Compiler/Helper/Get.php000064400000217236151162054130015076
0ustar00<?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\Helper;
use Joomla\CMS\Factory;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Component\ComponentHelper;
// use
VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper;
(for Joomla 4 and above)
use VDM\Joomla\Utilities\StringHelper;
use VDM\Joomla\Utilities\JsonHelper;
use VDM\Joomla\Utilities\ArrayHelper;
use VDM\Joomla\Componentbuilder\Compiler\Factory as CFactory;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Placefix;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Indent;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Unique;
/**
* Get class as the main compilers class
*
* @deprecated 3.3
*/
class Get
{
/**
* The Joomla Version
*
* @var string
* @deprecated 3.3 Use
CFactory::_('Config')->joomla_version;
*/
public $joomlaVersion;
/**
* The Joomla Versions
*
* @var array
* @deprecated 3.3 Use
CFactory::_('Config')->joomla_versions;
*/
public $joomlaVersions = array(
3 => array('folder_key' => 3, 'xml_version'
=> 3.9), // only joomla 3
3.10 => array('folder_key' => 3, 'xml_version'
=> 4.0) // legacy joomla 4
);
/**
* The hash placeholder
*
* @var string
* @deprecated 3.3 Use Placefix::h();
*/
public $hhh = '#' . '#' . '#';
/**
* The open bracket placeholder
*
* @var string
* @deprecated 3.3 Use Placefix::b();
*/
public $bbb = '[' . '[' . '[';
/**
* The close bracket placeholder
*
* @var string
* @deprecated 3.3 Use Placefix::d();
*/
public $ddd = ']' . ']' . ']';
/**
* The app
*
* @var object
*/
public $app;
/**
* The Params
*
* @var object
*/
public $params;
/**
* Add strict field export permissions
*
* @var boolean
*/
public $strictFieldExportPermissions = false;
/**
* Add text only export options
*
* @var boolean
*/
public $exportTextOnly = false;
/**
* The global placeholders
*
* @var array
* @deprecated 3.3 Use
CFactory::_('Component.Placeholder')->get();
*/
public $globalPlaceholders = [];
/**
* The placeholders
*
* @var array
* @deprecated 3.3 Use CFactory::_('Placeholder')->active[];
*/
public $placeholders = [];
/**
* The Compiler Path
*
* @var object
* @deprecated 3.3 Use CFactory::_('Config')->compiler_path;
*/
public $compilerPath;
/**
* The JCB Powers Path
*
* @var object
* @deprecated 3.3 Use
CFactory::_('Config')->jcb_powers_path;
*/
public $jcbPowersPath;
/**
* Switch to add assets table fix
*
* @var int
* @deprecated 3.3 Use
CFactory::_('Config')->add_assets_table_fix;
*/
public $addAssetsTableFix = 1;
/**
* Assets table worse case
*
* @var int
* @deprecated 3.3 Use
CFactory::_('Config')->access_worse_case;
*/
public $accessWorseCase;
/**
* Switch to add assets table name fix
*
* @var bool
* @deprecated 3.3 Use
CFactory::_('Config')->add_assets_table_name_fix;
*/
public $addAssetsTableNameFix = false;
/**
* Switch to add custom code placeholders
*
* @var bool
* @deprecated 3.3 Use
CFactory::_('Config')->add_placeholders;
*/
public $addPlaceholders = false;
/**
* Switch to remove line breaks from language strings
*
* @var bool
* @deprecated 3.3 Use
CFactory::_('Config')->remove_line_breaks;
*/
public $removeLineBreaks = true;
/**
* The placeholders for custom code keys
*
* @var array
* @deprecated 3.3
*/
protected $customCodeKeyPlacholders
= array(
'[' => '[',
']' => ']',
',' => ',',
'+' => '+',
'=' => '='
);
/**
* The Component data
*
* @var object
* @deprecated 3.3 Use CFactory::_('Component');
*/
public $componentData;
/**
* The Switch to add Powers data
*
* @var boolean
* @deprecated 3.3 Use CFactory::_('Config')->add_power;
*/
public $addPower;
/**
* The Powers data
*
* @var array
* @deprecated 3.3 Use CFactory::_('Power')->active;
*/
public $powers = [];
/**
* The state of all Powers
*
* @var array
* @deprecated 3.3
*/
public $statePowers = [];
/**
* The linked Powers
*
* @var array
*/
public $linkedPowers = [];
/**
* The Plugins data
*
* @var array
* @deprecated 3.3 Use
CFactory::_('Joomlaplugin.Data')->get();
*/
public $joomlaPlugins = [];
/**
* The Modules data
*
* @var array
* @deprecated 3.3 Use
CFactory::_('Joomlamodule.Data')->get();
*/
public $joomlaModules = [];
/**
* The custom script placeholders - we use the (xxx) to avoid detection
it should be (***)
* ##################################---> PHP/JS
<---####################################
*
* New Insert Code = /xxx[INSERT<>$$$$]xxx/
/xxx[/INSERT<>$$$$]xxx/
* New Replace Code = /xxx[REPLACE<>$$$$]xxx/
/xxx[/REPLACE<>$$$$]xxx/
*
* //////////////////////////////// when JCB adds it back
//////////////////////////////////
* JCB Add Inserted Code = /xxx[INSERTED$$$$]xxx//xx23xx/
/xxx[/INSERTED$$$$]xxx/
* JCB Add Replaced Code = /xxx[REPLACED$$$$]xxx//xx25xx/
/xxx[/REPLACED$$$$]xxx/
*
* /////////////////////////////// changeing existing custom code
/////////////////////////
* Update Inserted Code = /xxx[INSERTED<>$$$$]xxx//xx23xx/
/xxx[/INSERTED<>$$$$]xxx/
* Update Replaced Code = /xxx[REPLACED<>$$$$]xxx//xx25xx/
/xxx[/REPLACED<>$$$$]xxx/
*
* The custom script placeholders - we use the (==) to avoid detection
it should be (--)
* ###################################---> HTML
<---#####################################
*
* New Insert Code = <!==[INSERT<>$$$$]==>
<!==[/INSERT<>$$$$]==>
* New Replace Code = <!==[REPLACE<>$$$$]==>
<!==[/REPLACE<>$$$$]==>
*
* ///////////////////////////////// when JCB adds it back
///////////////////////////////
* JCB Add Inserted Code =
<!==[INSERTED$$$$]==><!==23==>
<!==[/INSERTED$$$$]==>
* JCB Add Replaced Code =
<!==[REPLACED$$$$]==><!==25==>
<!==[/REPLACED$$$$]==>
*
* //////////////////////////// changeing existing custom code
///////////////////////////
* Update Inserted Code =
<!==[INSERTED<>$$$$]==><!==23==>
<!==[/INSERTED<>$$$$]==>
* Update Replaced Code =
<!==[REPLACED<>$$$$]==><!==25==>
<!==[/REPLACED<>$$$$]==>
*
* ////////23 is the ID of the code in the system don't change
it!!!!!!!!!!!!!!!!!!!!!!!!!!
*
* @var array
* @deprecated 3.3
*/
protected $customCodePlaceholders
= array(
1 => 'REPLACE<>$$$$]',
2 => 'INSERT<>$$$$]',
3 => 'REPLACED<>$$$$]',
4 => 'INSERTED<>$$$$]'
);
/**
* The custom code to be added
*
* @var array
* @deprecated 3.3 Use CFactory::_('Customcode')->active
*/
public $customCode;
/**
* The custom code to be added
*
* @var array
* @deprecated 3.3
*/
protected $customCodeData = [];
/**
* The function name memory ids
*
* @var array
* @deprecated 3.3 Use
CFactory::_('Customcode')->functionNameMemory
*/
public $functionNameMemory = [];
/**
* The custom code for local memory
*
* @var array
* @deprecated 3.3 Use CFactory::_('Customcode')->memory
*/
public $customCodeMemory = [];
/**
* The custom code in local files that already exist in system
*
* @var array
* @deprecated 3.3
*/
protected $existingCustomCode = [];
/**
* The custom code in local files this are new
*
* @var array
* @deprecated 3.3
*/
protected $newCustomCode = [];
/**
* The index of code already loaded
*
* @var array
* @deprecated 3.3
*/
protected $codeAreadyDone = [];
/**
* The external code/string to be added
*
* @var array
* @deprecated 3.3
*/
protected $externalCodeString = [];
/**
* The external code/string cutter
*
* @var array
* @deprecated 3.3
*/
protected $externalCodeCutter = [];
/*
* The line numbers Switch
*
* @var boolean
* @deprecated 3.3 Use CFactory::_('Config')->debug_line_nr;
*/
public $debugLinenr = false;
/*
* The percentage when a language should be added
*
* @var int
* @deprecated 3.3 Use
CFactory::_('Config')->percentage_language_add
*/
public $percentageLanguageAdd = 0;
/**
* The Placholder Language prefix
*
* @var string
* @deprecated 3.3 Use CFactory::_('Config')->lang_prefix;
*/
public $langPrefix;
/**
* The Language content
*
* @var array
* @deprecated 3.3
*/
public $langContent = [];
/**
* The Languages bucket
*
* @var array
*/
public $languages
= array('components' => array(), 'modules' =>
array(),
'plugins' => array());
/**
* The Main Languages
*
* @var string
* @deprecated 3.3 Use CFactory::_('Config')->lang_tag;
*/
public $langTag = 'en-GB';
/**
* The Multi Languages bucket
*
* @var array
*/
public $multiLangString = [];
/**
* The new lang to add
*
* @var array
*/
protected $newLangStrings = [];
/**
* The existing lang to update
*
* @var array
*/
protected $existingLangStrings = [];
/**
* The Language JS matching check
*
* @var array
* @deprecated 3.3 Use
CFactory::_('Language.Extractor')->langMismatch;
*/
public $langMismatch = [];
/**
* The Language SC matching check
*
* @var array
* @deprecated 3.3 Use
CFactory::_('Language.Extractor')->langMatch;
*/
public $langMatch = [];
/**
* The Language string targets
*
* @var array
* @deprecated 3.3 Use
CFactory::_('Config')->lang_string_targets;
*/
public $langStringTargets
= array(
'Joomla' . '.JText._(',
'JText:' . ':script(',
'Text:' . ':_(', // namespace and J version
will be found
'Text:' . ':sprintf(', // namespace and J version
will be found
'JustTEXT:' . ':_('
);
/**
* The Component Code Name
*
* @var string
* @deprecated 3.3 Use
CFactory::_('Config')->component_code_name;
*/
public $componentCodeName;
/**
* The Component Context
*
* @var string
* @deprecated 3.3 Use
CFactory::_('Config')->component_context;
*/
public $componentContext;
/**
* The Component Code Name Length
*
* @var int
* @deprecated 3.3 Use
CFactory::_('Config')->component_code_name_length;
*/
public $componentCodeNameLength;
/**
* The Component ID
*
* @var int
* @deprecated 3.3 Use CFactory::_('Config')->component_id;
*/
public $componentID;
/**
* The current user
*
* @var array
*/
public $user;
/**
* The database object
*
* @var array
*/
public $db;
/**
* The Component version
*
* @var string
* @deprecated 3.3 Use
CFactory::_('Config')->component_version;
*/
public $component_version;
/**
* The UIKIT Switch
*
* @var boolean
* @deprecated 3.3 Use CFactory::_('Config')->uikit;
*/
public $uikit = 0;
/**
* The UIKIT component checker
*
* @var array
* @deprecated 3.3 Use
CFactory::_('Compiler.Builder.Uikit.Comp')->get($key);
*/
public $uikitComp = [];
/**
* The FOOTABLE Switch
*
* @var boolean
* @deprecated 3.3 Use CFactory::_('Config')->footable;
*/
public $footable = false;
/**
* The FOOTABLE Version
*
* @var int
* @deprecated 3.3 Use
CFactory::_('Config')->footable_version;
*/
public $footableVersion;
/**
* The Google Chart Switch per view
*
* @var array
* @deprecated 3.3 Use
CFactory::_('Compiler.Builder.Google.Chart')->get($key);
*/
public $googleChart = [];
/**
* The Google Chart Switch
*
* @var boolean
* @deprecated 3.3 Use CFactory::_('Config')->google_chart;
*/
public $googlechart = false;
/**
* The Import & Export Switch
*
* @var boolean
* @deprecated 3.3 Use CFactory::_('Config')->add_eximport;
*/
public $addEximport = false;
/**
* The Import & Export View
*
* @var array
*/
public $eximportView = [];
/**
* The Import & Export Custom Script
*
* @var array
*/
public $importCustomScripts = [];
/**
* The Tag & History Switch
*
* @var boolean
* @deprecated 3.3 Use
CFactory::_('Config')->set_tag_history;
*/
public $setTagHistory = false;
/**
* The Joomla Fields Switch
*
* @var boolean
* @deprecated 3.3 Use
CFactory::_('Config')->set_joomla_fields;
*/
public $setJoomlaFields = false;
/**
* The site edit views
*
* @var array
* @deprecated 3.3 Use
CFactory::_('Compiler.Builder.Site.Edit.View')->get($key);
*/
public $siteEditView = [];
/**
* The admin list view filter type
*
* @var array
* @deprecated 3.3 Use
CFactory::_('Compiler.Builder.Admin.Filter.Type')->get($key);
*/
public $adminFilterType = [];
/**
* The Language target
*
* @var string
* @deprecated 3.3 Use CFactory::_('Config')->lang_target;
*/
public $lang = 'admin';
/**
* The lang keys for extentions
*
* @var array
* @deprecated 3.3 Use
CFactory::_('Language.Extractor')->langKeys;
*/
public $langKeys = [];
/**
* The Build target Switch
*
* @var string
* @deprecated 3.3 Use CFactory::_('Config')->build_target;
*/
public $target;
/**
* The unique codes
*
* @var array
* @deprecated 3.3
*/
public $uniquecodes = [];
/**
* The unique keys
*
* @var array
* @deprecated 3.3
*/
public $uniquekeys = [];
/**
* The Add contributors Switch
*
* @var boolean
* @deprecated 3.3 Use
CFactory::_('Config')->add_contributors;
*/
public $addContributors = false;
/**
* The Custom Script Builder
*
* @var array
* @deprecated 3.3 Use
CFactory::_('Customcode.Dispenser')->hub;
*/
public $customScriptBuilder = [];
/**
* The Footable Script Builder
*
* @var array
* @deprecated 3.3 Use
CFactory::_('Compiler.Builder.Footable.Scripts')->get($key);
*/
public $footableScripts = [];
/**
* The pathe to the bom file to be used
*
* @var string
* @deprecated 3.3 Use CFactory::_('Config')->bom_path;
*/
public $bomPath;
/**
* The SQL Tweak of admin views
*
* @var array
* @deprecated 3.3 Use
CFactory::_('Registry')->get('builder.sql_tweak');
*/
public $sqlTweak = [];
/**
* The validation rules that should be added
*
* @var array
* @deprecated 3.3 Use
CFactory::_('Registry')->get('validation.rules');
*/
public $validationRules = [];
/**
* The validation linked to fields
*
* @var array
* @deprecated 3.3 Use
CFactory::_('Registry')->get('validation.linked');
*/
public $validationLinkedFields = [];
/**
* The admin views data array
*
* @var array
* @deprecated 3.3
*/
private $_adminViewData = [];
/**
* The field data array
*
* @var array
* @deprecated 3.3
*/
private $_fieldData = [];
/**
* The custom alias builder
*
* @var array
* @deprecated 3.3 Use
CFactory::_('Compiler.Builder.Custom.Alias')->get($key);
*/
public $customAliasBuilder = [];
/**
* The field builder type
*
* 1 = StringManipulation
* 2 = SimpleXMLElement
*
* @var int
* @deprecated 3.3 Use
CFactory::_('Config')->field_builder_type;
*/
public $fieldBuilderType;
/**
* Set unique Names
*
* @var array
* @deprecated 3.3 Use
CFactory::_('Registry')->get('unique.names');
*/
public $uniqueNames = [];
/**
* Set unique Names
*
* @var array
* @deprecated
*/
protected $uniqueFieldNames = [];
/**
* Category other name bucket
*
* @var array
* @deprecated 3.3 Use
CFactory::_('Compiler.Builder.Category.Other.Name')->get($key);
*/
public $catOtherName = [];
/**
* The field relations values
*
* @var array
* @deprecate 3.3 Use
CFactory::_('Compiler.Builder.Field.Relations')->get($key);
*/
public $fieldRelations = [];
/**
* The views default ordering
*
* @var array
* @deprecate 3.3 Use
CFactory::_('Compiler.Builder.Views.Default.Ordering')->get($key);
*/
public $viewsDefaultOrdering = [];
/**
* Default Fields
*
* @var array
* @deprecated 3.3 Use
CFactory::_('Config')->default_fields;
*/
public $defaultFields
= array('created', 'created_by',
'modified', 'modified_by', 'published',
'ordering', 'access', 'version',
'hits', 'id');
/**
* The list join fields
*
* @var array
* @deprecate 3.3 Use
CFactory::_('Compiler.Builder.List.Join')->get($key);
*/
public $listJoinBuilder = [];
/**
* The list head over ride
*
* @var array
* @deprecate 3.3 Use
CFactory::_('Compiler.Builder.List.Head.Override')->get($key);
*/
public $listHeadOverRide = [];
/**
* The linked admin view tabs
*
* @var array
* @deprecate 3.3 Use
CFactory::_('Registry')->get('builder.linked_admin_views');
*/
public $linkedAdminViews = [];
/**
* The custom admin view tabs
*
* @var array
* @deprecate 3.3 Use
CFactory::_('Compiler.Builder.Custom.Tabs')->get($key);
*/
public $customTabs = [];
/**
* The Add Ajax Switch
*
* @var boolean
* @deprecate 3.3 Use CFactory::_('Config')->add_ajax
*/
public $addAjax = false;
/**
* The Add Site Ajax Switch
*
* @var boolean
* @deprecate 3.3 Use CFactory::_('Config')->add_site_ajax;
*/
public $addSiteAjax = false;
/**
* The get Module Script Switch
*
* @var array
* @deprecate 3.3 Use
CFactory::_('Compiler.Builder.Get.Module')->get($key);
*/
public $getModule = [];
/**
* The template data
*
* @var array
* @deprecate 3.3 Use
CFactory::_('Compiler.Builder.Template.Data')->get($key);
*/
public $templateData = [];
/**
* The layout data
*
* @var array
* @deprecate 3.3 Use
CFactory::_('Compiler.Builder.Layout.Data')->get($key);
*/
public $layoutData = [];
/**
* The Encryption Types
*
* @var array
* @deprecated 3.3 Use
CFactory::_('Config')->cryption_types;
*/
public $cryptionTypes = array('basic', 'medium',
'whmcs', 'expert');
/**
* The WHMCS Encryption Switch
*
* @var boolean
* @deprecated 3.3 Use
CFactory::_('Config')->whmcs_encryption;
*/
public $whmcsEncryption = false;
/**
* The Basic Encryption Switch
*
* @var boolean
* @deprecated 3.3 Use
CFactory::_('Config')->basic_encryption;
*/
public $basicEncryption = false;
/**
* The Medium Encryption Switch
*
* @var boolean
* @deprecated 3.3 Use
CFactory::_('Config')->medium_encryption;
*/
public $mediumEncryption = false;
/**
* The Custom field Switch per view
*
* @var array
* @deprecated 3.3
*/
public $customFieldScript = [];
/**
* The site main get
*
* @var array
* @deprecate 3.3 Use
CFactory::_('Compiler.Builder.Site.Main.Get')->get($key);
*/
public $siteMainGet = [];
/**
* The site dynamic get
*
* @var array
* @deprecate 3.3 Use
CFactory::_('Compiler.Builder.Site.Dynamic.Get')->get($key);
*/
public $siteDynamicGet = [];
/**
* The get AS lookup
*
* @var array
* @deprecate 3.3 Use
CFactory::_('Compiler.Builder.Get.As.Lookup')->get($key);
*/
public $getAsLookup = [];
/**
* The site fields
*
* @var array
* @deprecate 3.3 Use
CFactory::_('Compiler.Builder.Site.Fields')->get($key);
*/
public $siteFields = [];
/**
* The add SQL
*
* @var array
* @deprecate 3.3 Use
CFactory::_('Registry')->get('builder.add_sql');
*/
public $addSQL = [];
/**
* The update SQL
*
* @var array
* @deprecate 3.3 Use
CFactory::_('Registry')->get('builder.update_sql');
*/
public $updateSQL = [];
/**
* The data by alias keys
*
* @var array
* @deprecate 3.3 Use
CFactory::_('Registry')->get('builder.data_with_alias_keys');
*/
protected $dataWithAliasKeys = [];
/**
* The Library Manager
*
* @var array
* @deprecate 3.3 Use
CFactory::_('Compiler.Builder.Library.Manager')->get($key);
*/
public $libManager = [];
/**
* The Libraries
*
* @var array
* @deprecated 3.3 Use
CFactory::_('Registry')->get('builder.libraries');
*/
public $libraries = [];
/**
* Is minify Enabled
*
* @var int
* @deprecated 3.3 Use CFactory::_('Config')->minify;
*/
public $minify = 0;
/**
* Is Tidy Enabled
*
* @var bool
* @deprecated 3.3 Use CFactory::_('Config')->tidy;
*/
public $tidy = false;
/**
* Set Tidy warning once switch
*
* @var bool
* @deprecated 3.3 Use
CFactory::_('Config')->set_tidy_warning;
*/
public $setTidyWarning = false;
/**
* mysql table setting keys
*
* @var array
* @deprecated 3.3 Use
CFactory::_('Config')->mysql_table_keys;
*/
public $mysqlTableKeys
= array(
'engine' => array('default' =>
'MyISAM'),
'charset' => array('default' =>
'utf8'),
'collate' => array('default' =>
'utf8_general_ci'),
'row_format' => array('default' =>
'')
);
/**
* mysql table settings
*
* @var array
* @deprecated 3.3 Use
CFactory::_('Compiler.Builder.Mysql.Table.Setting')->get($key);
*/
public $mysqlTableSetting = [];
/**
* Constructor
*/
public function __construct()
{
// we do not yet have this set as an option
$config['remove_line_breaks']
= 2; // 2 is global (use the components value)
// load application
$this->app = Factory::getApplication();
// Set the params
$this->params =
ComponentHelper::getParams('com_componentbuilder');
// Trigger Event: jcb_ce_onBeforeGet
CFactory::_('Event')->trigger('jcb_ce_onBeforeGet',
array(&$config, &$this));
// set the Joomla version @deprecated
$this->joomlaVersion =
CFactory::_('Config')->joomla_version;
// set the minfy switch of the JavaScript @deprecated
$this->minify =
CFactory::_('Config')->get('minify', 0);
// set the global language @deprecated
$this->langTag =
CFactory::_('Config')->get('lang_tag',
'en-GB');
// also set the helper class langTag (for safeStrings)
\ComponentbuilderHelper::$langTag =
CFactory::_('Config')->get('lang_tag',
'en-GB');
// check if we have Tidy enabled @deprecated
$this->tidy =
CFactory::_('Config')->get('tidy', false);
// set the field type builder @deprecated
$this->fieldBuilderType =
CFactory::_('Config')->get('field_builder_type',
2);
// check the field builder type logic
if (!CFactory::_('Config')->get('tidy', false)
&&
CFactory::_('Config')->get('field_builder_type', 2)
== 2)
{
// we do not have the tidy extension set fall back to
StringManipulation
$this->fieldBuilderType = 1;
// load the sugestion to use string manipulation
$this->app->enqueueMessage(
Text::_('COM_COMPONENTBUILDER_HR_HTHREEFIELD_NOTICEHTHREE'),
'Notice'
);
$this->app->enqueueMessage(
Text::_(
'Since you do not have <b>Tidy</b> extentsion setup
on your system, we could not use the SimpleXMLElement class. We instead
used <b>string manipulation</b> to build all your fields, this
is a faster method, you must inspect the xml files in your component
package to see if you are satisfied with the result.<br />You can
make this method your default by opening the global options of JCB and
under the <b>Global</b> tab set the <b>Field Builder
Type</b> to string manipulation.'
), 'Notice'
);
}
CFactory::_('Config')->set('field_builder_type',
$this->fieldBuilderType);
// load the compiler path @deprecated
$this->compilerPath =
CFactory::_('Config')->get('compiler_path',
JPATH_COMPONENT_ADMINISTRATOR . '/compiler');
// load the jcb powers path @deprecated
$this->jcbPowersPath =
CFactory::_('Config')->get('jcb_powers_path',
'libraries/jcb_powers');
// set the component ID @deprecated
$this->componentID =
CFactory::_('Config')->component_id;
// set lang prefix @deprecated
$this->langPrefix = CFactory::_('Config')->lang_prefix;
// set component code name @deprecated
$this->componentCodeName =
CFactory::_('Config')->component_code_name;
// set component context @deprecated
$this->componentContext =
CFactory::_('Config')->component_context;
// set the component name length @deprecated
$this->componentCodeNameLength =
CFactory::_('Config')->component_code_name_length;
// set if language strings line breaks should be removed @deprecated
$this->removeLineBreaks =
CFactory::_('Config')->remove_line_breaks;
// set if placeholders should be added to customcode @deprecated
$this->addPlaceholders =
CFactory::_('Config')->get('add_placeholders',
false);
// set if line numbers should be added to comments @deprecated
$this->debugLinenr =
CFactory::_('Config')->get('debug_line_nr', false);
// set if powers should be added to component (default is true)
@deprecated
$this->addPower =
CFactory::_('Config')->get('add_power', true);
// set the current user
$this->user = Factory::getUser();
// Get a db connection.
$this->db = Factory::getDbo();
// get global placeholders @deprecated
$this->globalPlaceholders =
CFactory::_('Component.Placeholder')->get();
// get the custom code from installed files
CFactory::_('Customcode.Extractor')->run();
// Trigger Event: jcb_ce_onBeforeGetComponentData
CFactory::_('Event')->trigger(
'jcb_ce_onBeforeGetComponentData'
);
// get the component data @deprecated
$this->componentData = CFactory::_('Component');
// Trigger Event: jcb_ce_onAfterGetComponentData
CFactory::_('Event')->trigger(
'jcb_ce_onAfterGetComponentData'
);
// make sure we have a version
if (strpos((string)
CFactory::_('Component')->component_version, '.')
=== false)
{
CFactory::_('Component')->set('component_version
', '1.0.0');
}
// update the version
if
(!CFactory::_('Component')->exists('old_component_version')
&&
(CFactory::_('Registry')->get('builder.add_sql',
null)
||
CFactory::_('Registry')->get('builder.update_sql',
null)))
{
// set the new version
$version = (array) explode(
'.', (string)
CFactory::_('Component')->component_version
);
// get last key
end($version);
$key = key($version);
// just increment the last
$version[$key]++;
// set the old version
CFactory::_('Component')->set('old_component_version',
CFactory::_('Component')->component_version);
// set the new version, and set update switch
CFactory::_('Component')->set('component_version',
implode(
'.', $version
));
}
// FOR THE HELPER CLASS POWERS
// Utilities String Helper
CFactory::_('Power')->get('1f28cb53-60d9-4db1-b517-3c7dc6b429ef',
1);
// Utilities Array Helper
CFactory::_('Power')->get('0a59c65c-9daf-4bc9-baf4-e063ff9e6a8a',
1);
// Utilities Component Helper
CFactory::_('Power')->get('640b5352-fb09-425f-a26e-cd44eda03f15',
1);
// Utilities Object Helper
CFactory::_('Power')->get('91004529-94a9-4590-b842-e7c6b624ecf5',
1);
// Utilities GetHelper
CFactory::_('Power')->get('db87c339-5bb6-4291-a7ef-2c48ea1b06bc',
1);
// Utilities Json Helper
CFactory::_('Power')->get('4b225c51-d293-48e4-b3f6-5136cf5c3f18',
1);
// Utilities FormHelper
CFactory::_('Power')->get('1198aecf-84c6-45d2-aea8-d531aa4afdfa',
1);
// load powers *+*+*+*+*+*+*+*
CFactory::_('Power')->load($this->linkedPowers);
// set the percentage when a language can be added
$this->percentageLanguageAdd = (int)
CFactory::_('Config')->get('percentage_language_add',
50);
// Trigger Event: jcb_ce_onBeforeGet
CFactory::_('Event')->trigger(
'jcb_ce_onAfterGet'
);
return true;
}
/**
* Set the tab/space
*
* @param int $nr The number of tag/space
*
* @return string
* @deprecated 3.3 Use Indent::_($nr);
*/
public function _t($nr)
{
// use global method for conformity
return Indent::_($nr);
}
/**
* Trigger events
*
* @param string $event The event to trigger
* @param mix $data The values to pass to the event/plugin
*
* @return void
* @deprecated 3.3 Use CFactory::_('Event')->trigger($event,
$data);
*/
public function triggerEvent($event, $data = null)
{
return CFactory::_('Event')->trigger($event, $data);
}
/**
* get all System Placeholders
*
* @return array The global placeholders
* @deprecated 3.3 Use
CFactory::_('Component.Placeholder')->get();
*/
public function getGlobalPlaceholders()
{
return CFactory::_('Component.Placeholder')->get();
}
/**
* get all Component Data
*
* @return oject The component data
* @deprecated 3.3 Use CFactory::_('Component');
*/
public function getComponentData()
{
return CFactory::_('Component');
}
/**
* set the language content values to language content array
*
* @param string $target The target area for the language string
* @param string $language The language key string
* @param string $string The language string
* @param boolean $addPrefix The switch to add langPrefix
*
* @return void
* @deprecated 3.3 Use CFactory::_('Language')->set($target,
$language, $string, $addPrefix);
*/
public function setLangContent($target, $language, $string, $addPrefix =
false)
{
CFactory::_('Language')->set($target, $language, $string,
$addPrefix);
}
/**
* We need to remove all text breaks from all language strings
*
* @param string $string The language string
*
* @return string
* @deprecated 3.3
*/
public function fixLangString(&$string)
{
if (CFactory::_('Config')->remove_line_breaks)
{
return trim(str_replace(array(PHP_EOL, "\r", "\n"),
'', $string));
}
return trim($string);
}
/**
* Get all Admin View Data
*
* @param int $id The view ID
*
* @return oject The view data
* @deprecated 3.3 Use
CFactory::_('Adminview.Data')->get($id);
*/
public function getAdminViewData($id)
{
return CFactory::_('Adminview.Data')->get($id);
}
/**
* Get all Custom View Data
*
* @param int $id The view ID
* @param string $table The view table
*
* @return oject The view data
* @deprecated 3.3 Use
CFactory::_('Customview.Data')->get($id, $table);
*/
public function getCustomViewData($id, $table = 'site_view')
{
return CFactory::_('Customview.Data')->get($id, $table);
}
/**
* Get all Field Data
*
* @param int $id The field ID
* @param string $name_single The view edit or single name
* @param string $name_list The view list name
*
* @return oject The field data
* @deprecated 3.3 Use CFactory::_('Field.Data')->get($id,
$name_single, $name_list);
*/
public function getFieldData($id, $name_single = null, $name_list = null)
{
return CFactory::_('Field.Data')->get($id, $name_single,
$name_list);
}
/**
* set Field details
*
* @param object $field The field object
* @param string $singleViewName The single view name
* @param string $listViewName The list view name
* @param string $amicably The peaceful resolve
*
* @return void
* @deprecated 3.3 Use CFactory::_('Field')->set($field,
$singleViewName, $listViewName, $amicably);
*/
public function setFieldDetails(&$field, $singleViewName = null,
$listViewName = null, $amicably = '')
{
CFactory::_('Field')->set($field, $singleViewName,
$listViewName, $amicably);
}
/**
* get the list default ordering values
*
* @param string $nameListCode The list view name
*
* @return array
*
*/
public function getListViewDefaultOrdering(&$nameListCode)
{
if
(CFactory::_('Compiler.Builder.Views.Default.Ordering')->
get("$nameListCode.add_admin_ordering", 0) == 1)
{
foreach
(CFactory::_('Compiler.Builder.Views.Default.Ordering')->
get("$nameListCode.admin_ordering_fields", []) as
$order_field)
{
if (($order_field_name =
CFactory::_('Field.Database.Name')->get(
$nameListCode, $order_field['field']
)) !== false)
{
// just the first field is the based ordering state
return array(
'name' => $order_field_name,
'direction' => $order_field['direction']
);
}
}
}
// the default
return array(
'name' => 'a.id',
'direction' => 'DESC'
);
}
/**
* get the field database name and AS prefix
*
* @param string $nameListCode The list view name
* @param int $fieldId The field ID
* @param string $targetArea The area being targeted
*
* @return string
* @deprecated 3.3 Use
CFactory::_('Field.Database.Name')->get($nameListCode,
$fieldId, $targetArea);
*/
public function getFieldDatabaseName($nameListCode, int $fieldId,
$targetArea = 'builder.list')
{
return
CFactory::_('Field.Database.Name')->get($nameListCode,
$fieldId, $targetArea);
}
/**
* Get the field's actual type
*
* @param object $field The field object
*
* @return string Success returns field type
* @deprecated 3.3 Use
CFactory::_('Field.Type.Name')->get($field);
*/
public function getFieldType(&$field)
{
return CFactory::_('Field.Type.Name')->get($field);
}
/**
* Get the field's actual name
*
* @param object $field The field object
* @param string $listViewName The list view name
* @param string $amicably The peaceful resolve (for fields in
subforms in same view :)
*
* @return string Success returns field name
* @deprecated 3.3 Use CFactory::_('Field.Name')->get($field,
$listViewName, $amicably);
*/
public function getFieldName(&$field, $listViewName = null, $amicably
= '')
{
return CFactory::_('Field.Name')->get($field, $listViewName,
$amicably);
}
/**
* Count how many times the same field is used per view
*
* @param string $name The name of the field
* @param string $view The name of the view
*
* @return void
* @deprecated Use
CFactory::_('Field.Unique.Name')->set($name, $view);
*/
protected function setUniqueNameCounter($name, $view)
{
CFactory::_('Field.Unique.Name')->set($name, $view);
}
/**
* Naming each field with an unique name
*
* @param string $name The name of the field
* @param string $view The name of the view
*
* @return string the name
* @deprecated
*/
protected function uniqueName($name, $view)
{
// set notice that we could not get a valid string from the target
$this->app->enqueueMessage(
Text::sprintf('COM_COMPONENTBUILDER_HR_HTHREES_WARNINGHTHREE',
__CLASS__), 'Error'
);
$this->app->enqueueMessage(
Text::sprintf(
'Use of a deprecated method (%s)!', __METHOD__
), 'Error'
);
}
/**
* Set get Data
*
* @param array $ids The ids of the dynamic get
* @param string $view_code The view code name
* @param string $context The context for events
*
* @return oject the get dynamicGet data
* @deprecated Use CFactory::_('Dynamicget.Data')->get($ids,
$view_code, $context);
*/
public function setGetData($ids, $view_code, $context)
{
return CFactory::_('Dynamicget.Data')->get($ids, $view_code,
$context);
}
/**
* Set the script for the customcode dispenser
*
* @param string $script The script
* @param string $first The first key
* @param string|null $second The second key (if not set we use only
first key)
* @param string|null $third The third key (if not set we use only
first and second key)
* @param array $config The config options
* @param bool $base64 The switch to decode base64 the script
* default: true
* @param bool $dynamic The switch to dynamic update the
script
* default: true
* @param bool $add The switch to add to exiting instead of
replace
* default: false
*
* @return bool true on success
* @deprecated 3.3 Use
CFactory::_('Customcode.Dispenser')->set($script, $first,
$second, $third, $config, $base64, $dynamic, $add);
*/
public function setCustomScriptBuilder(
&$script,
string $first,
?string $second = null,
?string $third = null,
array $config = array(),
bool $base64 = true,
bool $dynamic = true,
bool $add = false
): bool
{
return CFactory::_('Customcode.Dispenser')->set($script,
$first, $second, $third, $config, $base64, $dynamic, $add);
}
/**
* get the a script from the custom script builder
*
* @param string $first The first key
* @param string $second The second key
* @param string $prefix The prefix to add in front of the script if
found
* @param string $note The switch/note to add to the script
* @param bool $unset The switch to unset the value if found
* @param string $default The switch/string to use as default return
if script not found
* @param string $sufix The sufix to add after the script if found
*
* @return mix The string/script if found or the default value if not
found
* @deprecated 3.3 Use
CFactory::_('Customcode.Dispenser')->get($first, $second,
$prefix, $note, $unset, $default, $sufix);
*/
public function getCustomScriptBuilder($first, $second, $prefix =
'',
$note = null, $unset = null, $default = null, $sufix = ''
)
{
return CFactory::_('Customcode.Dispenser')->get($first,
$second, $prefix, $note, $unset, $default, $sufix);
}
/**
* To limit the SQL Demo date build in the views
*
* @param array $settings Tweaking array.
*
* @return void
* @deprecated 3.3
*/
public function setSqlTweaking($settings)
{
// set notice that we could not get a valid string from the target
$this->app->enqueueMessage(
Text::sprintf('COM_COMPONENTBUILDER_HR_HTHREES_WARNINGHTHREE',
__CLASS__), 'Error'
);
$this->app->enqueueMessage(
Text::sprintf(
'Use of a deprecated method (%s)!', __METHOD__
), 'Error'
);
}
/**
* check if an update SQL is needed
*
* @param mix $old The old values
* @param mix $new The new values
* @param string $type The type of values
* @param int $key The id/key where values changed
* @param array $ignore The ids to ignore
*
* @return void
* @deprecated 3.3 Use
CFactory::_('Model.Updatesql')->set($old, $new, $type, $key,
$ignore);
*/
protected function setUpdateSQL($old, $new, $type, $key = null,
$ignore = null
)
{
CFactory::_('Model.Updatesql')->set($old, $new, $type, $key,
$ignore);
}
/**
* Set the add sql
*
* @param string $type The type of values
* @param int $item The item id to add
* @param int|null $key The id/key where values changed
*
* @return void
* @deprecated 3.3
*/
protected function setAddSQL(string $type, int $item, ?int $key = null)
{
// add key if found
if ($key)
{
CFactory::_('Registry')->set('builder.add_sql.' .
$type . '.' . $key . '.' . $item, $item);
}
else
{
// convert adminview id to name
if ('adminview' === $type)
{
CFactory::_('Registry')->set('builder.add_sql.'
. $type, StringHelper::safe(
$this->getAdminViewData($item)->name_single
));
}
else
{
CFactory::_('Registry')->set('builder.add_sql.'
. $type, $item);
}
}
}
/**
* Get Item History values
*
* @param string $type The type of item
* @param int $id The item ID
*
* @return object The history
* @deprecated 3.3 Use CFactory::_('History')->get($type,
$id);
*/
protected function getHistoryWatch($type, $id)
{
return CFactory::_('History')->get($type, $id);
}
/**
* Set Item History Watch
*
* @param Object $object The history object
* @param int $action The action to take
* 0 = remove watch
* 1 = add watch
* @param string $type The type of item
*
* @return bool
* @deprecated 3.3
*/
protected function setHistoryWatch($object, $action)
{
// set notice that we could not get a valid string from the target
$this->app->enqueueMessage(
Text::sprintf('COM_COMPONENTBUILDER_HR_HTHREES_WARNINGHTHREE',
__CLASS__), 'Error'
);
$this->app->enqueueMessage(
Text::sprintf(
'Use of a deprecated method (%s)!', __METHOD__
), 'Error'
);
}
/**
* Set Template and Layout Data
*
* @param string $default The content to check
* @param string $view The view code name
* @param boolean $found The proof that something was found
* @param array $templates The option to pass templates keys (to
avoid search)
* @param array $layouts The option to pass layout keys (to avoid
search)
*
* @return boolean if something was found true
* @deprecated 3.3 Use
CFactory::_('Templatelayout.Data')->set($default, $view,
$found, $templates, $layouts);
*/
public function setTemplateAndLayoutData($default, $view, $found = false,
$templates = array(), $layouts =
array()
)
{
return CFactory::_('Templatelayout.Data')->set($default,
$view, $found, $templates, $layouts);
}
/**
* Get Data With Alias
*
* @param string $n_ame The alias name
* @param string $table The table where to find the alias
* @param string $view The view code name
*
* @return array The data found with the alias
* @deprecated 3.3 Use CFactory::_('Alias.Data')->get($n_ame,
$table, $view);
*/
protected function getDataWithAlias($n_ame, $table, $view)
{
return CFactory::_('Alias.Data')->get($n_ame, $table,
$view);
}
/**
* set Data With Alias Keys
*
* @param string $table The table where to find the alias
*
* @return void
* @deprecated 3.3
*/
protected function setDataWithAliasKeys($table)
{
// set notice that we could not get a valid string from the target
$this->app->enqueueMessage(
Text::sprintf('COM_COMPONENTBUILDER_HR_HTHREES_WARNINGHTHREE',
__CLASS__), 'Error'
);
$this->app->enqueueMessage(
Text::sprintf(
'Use of a deprecated method (%s)!', __METHOD__
), 'Error'
);
}
/**
* Get Media Library Data and store globally
*
* @param string $id the library id
*
* @return bool true on success
* @deprecated 3.3 Use
CFactory::_('Library.Data')->get($id);
*/
protected function getMediaLibrary($id)
{
return CFactory::_('Library.Data')->get($id);
}
/**
* Set Language Place Holders
*
* @param string $content The content
*
* @return string The content with the updated Language place holder
* @deprecated 3.3 Use
CFactory::_('Language.Extractor')->engine($content)
*/
public function setLangStrings($content)
{
return CFactory::_('Language.Extractor')->engine($content);
}
/**
* Set the language String
*
* @param string $string The plan text string (English)
*
* @return string The key language string (all uppercase)
* @deprecated 3.3 Use
CFactory::_('Language')->key($string);
*/
public function setLang($string)
{
return CFactory::_('Language')->key($string);
}
/**
* Set Data Selection of the dynamic get
*
* @param string $method_key The method unique key
* @param string $view_code The code name of the view
* @param string $string The data string
* @param string $asset The asset in question
* @param string $as The as string
* @param int $row_type The row type
* @param string $type The target type (db||view)
*
* @return array the select query
* @deprecated 3.3 Use
CFactory::_('Dynamicget.Selection')->get($method_key,
$view_code, $string, $asset, $as, $type, $row_type);
*/
public function setDataSelection($method_key, $view_code, $string,
$asset,
$as, $row_type, $type
)
{
return CFactory::_('Dynamicget.Selection')->get(
$method_key, $view_code, $string, $asset,
$as, $type, $row_type);
}
/**
* Get the View Table Name
*
* @param int $id The admin view in
*
* @return string view code name
* @deprecated 3.3
*/
public function getViewTableName($id)
{
// Create a new query object.
$query = $this->db->getQuery(true);
$query->select($this->db->quoteName(array('a.name_single')));
$query->from(
$this->db->quoteName('#__componentbuilder_admin_view',
'a')
);
$query->where($this->db->quoteName('a.id') . ' =
' . (int) $id);
$this->db->setQuery($query);
return StringHelper::safe($this->db->loadResult());
}
/**
* Build the SQL dump String for a view
*
* @param string $tables The tables to use in build
* @param string $view The target view/table to dump in
* @param int $view_id The id of the target view
*
* @return string on success with the Dump SQL
* @deprecated 3.3 Use
CFactory::_('Model.Sqldump')->key($tables, $view, $view_id);
*/
public function buildSqlDump($tables, $view, $view_id)
{
return CFactory::_('Model.Sqldump')->key($tables, $view,
$view_id);
}
/**
* Escape the values for a SQL dump
*
* @param string $value the value to escape
*
* @return string on success with escaped string
* @deprecated 3.3
*/
public function mysql_escape($value)
{
// set notice that we could not get a valid string from the target
$this->app->enqueueMessage(
Text::sprintf('COM_COMPONENTBUILDER_HR_HTHREES_WARNINGHTHREE',
__CLASS__), 'Error'
);
$this->app->enqueueMessage(
Text::sprintf(
'Use of a deprecated method (%s)!', __METHOD__
), 'Error'
);
}
/**
* Creating an uniqueCode
*
* @param string $code The planed code
*
* @return string The unique code
* @deprecated 3.3 use Unique::code($code);
*/
public function uniqueCode($code)
{
return Unique::code($code);
}
/**
* Creating an unique local key
*
* @param int $size The key size
*
* @return string The unique localkey
* @deprecated 3.3 use Unique::get($size);
*/
public function uniquekey($size, $random = false,
$newBag = "vvvvvvvvvvvvvvvvvvv"
)
{
return Unique::get($size);
}
/**
* Check for footable scripts
*
* @param string $content The content to check
*
* @return boolean True if found
* @deprecated 3.3
*/
public function getFootableScripts($content)
{
if (strpos($content, 'footable') !== false)
{
return true;
}
return false;
}
/**
* Check for getModules script
*
* @param string $content The content to check
*
* @return boolean True if found
* @deprecated 3.3
*/
public function getGetModule($content)
{
if (strpos($content, 'this->getModules(') !== false)
{
return true;
}
return false;
}
/**
* Check for get Google Chart script
*
* @param string $content The content to check
*
* @return boolean True if found
* @deprecated 3.3
*/
public function getGoogleChart($content)
{
if (strpos($content, 'Chartbuilder(') !== false)
{
return true;
}
return false;
}
/**
* Set the dynamic values in strings here
*
* @param string $string The content to check
* @param int $debug The switch to debug the update
* We can now at any time debug the
* dynamic build values if it gets broken
*
* @return string
* @deprecated 3.3 Use
CFactory::_('Customcode')->update($string, $debug);
*/
public function setDynamicValues($string, $debug = 0)
{
return CFactory::_('Customcode')->update($string, $debug);
}
/**
* Set the external code string & load it in to string
*
* @param string $string The content to check
* @param int $debug The switch to debug the update
*
* @return string
* @deprecated 3.3 Use
CFactory::_('Customcode.External')->set($string, $debug);
*/
public function setExternalCodeString($string, $debug = 0)
{
return CFactory::_('Customcode.External')->set($string,
$debug);
}
/**
* Get the External Code/String
*
* @param string $string The content to check
* @param array $bucket The Placeholders bucket
*
* @return void
* @deprecated 3.3
*/
protected function getExternalCodeString($target, &$bucket)
{
// set notice that we could not get a valid string from the target
$this->app->enqueueMessage(
Text::sprintf('COM_COMPONENTBUILDER_HR_HTHREES_WARNINGHTHREE',
__CLASS__), 'Error'
);
$this->app->enqueueMessage(
Text::sprintf(
'Use of a deprecated method (%s)!', __METHOD__
), 'Error'
);
}
/**
* Cut the External Code/String
*
* @param string $string The content to cut
* @param string $sequence The cutting sequence
* @param string $key The content key
*
* @return string
* @deprecated 3.3
*/
protected function cutExternalCodeString($string, $sequence, $key)
{
// set notice that we could not get a valid string from the target
$this->app->enqueueMessage(
Text::sprintf('COM_COMPONENTBUILDER_HR_HTHREES_WARNINGHTHREE',
__CLASS__), 'Error'
);
$this->app->enqueueMessage(
Text::sprintf(
'Use of a deprecated method (%s)!', __METHOD__
), 'Error'
);
return '';
}
/**
* We start set the custom code data & can load it in to string
*
* @param string $string The content to check
* @param int $debug The switch to debug the update
*
* @return string
* @deprecated 3.3 Use
CFactory::_('Customcode')->set($string, $debug, $not);
*/
public function setCustomCodeData($string, $debug = 0, $not = null)
{
return CFactory::_('Customcode')->set($string, $debug,
$not);
}
/**
* Insert the custom code into the string
*
* @param string $string The content to check
* @param int $debug The switch to debug the update
*
* @return string on success
* @deprecated 3.3
*/
protected function insertCustomCode($ids, $string, $debug = 0)
{
// set notice that we could not get a valid string from the target
$this->app->enqueueMessage(
Text::sprintf('COM_COMPONENTBUILDER_HR_HTHREES_WARNINGHTHREE',
__CLASS__), 'Error'
);
$this->app->enqueueMessage(
Text::sprintf(
'Use of a deprecated method (%s)!', __METHOD__
), 'Error'
);
return '';
}
/**
* Insert the custom code into the string
*
* @param string $string The content to check
* @param int $debug The switch to debug the update
*
* @return string on success
* @deprecated 3.3
*/
protected function buildCustomCodePlaceholders($item, &$code, $debug =
0)
{
// set notice that we could not get a valid string from the target
$this->app->enqueueMessage(
Text::sprintf('COM_COMPONENTBUILDER_HR_HTHREES_WARNINGHTHREE',
__CLASS__), 'Error'
);
$this->app->enqueueMessage(
Text::sprintf(
'Use of a deprecated method (%s)!', __METHOD__
), 'Error'
);
return '';
}
/**
* Set a type of placeholder with set of values
*
* @param string $key The main string for placeholder key
* @param array $values The values to add
*
* @return void
* @deprecated 3.3 Use
CFactory::_('Placeholder')->setType($key, $values);
*/
public function setThesePlaceHolders($key, $values)
{
// use the new container class
CFactory::_('Placeholder')->setType($key, $values);
}
/**
* Remove a type of placeholder by main string
*
* @param string $like The main string for placeholder key
*
* @return void
* @deprecated 3.3 Use
CFactory::_('Placeholder')->clearType($key);
*/
public function clearFromPlaceHolders($like)
{
// use the new container class
CFactory::_('Placeholder')->clearType($like);
}
/**
* to unset stuff that are private or protected
*
*/
public function unsetNow($remove)
{
unset($this->$remove);
}
/**
* Get the other languages
*
* @param array $values The lang strings to get
*
* @return array|null
* @deprecated 3.4 Use
CFactory::_('Language.Multilingual')->get($values);
*/
public function getMultiLangStrings($values)
{
return CFactory::_('Language.Multilingual')->get($values);
}
/**
* Set the Current language values to DB
*
* @return void
* @deprecated 3.4 Use
CFactory::_('Language.Set')->execute(...);
*/
public function setLangPlaceholders($strings, int $target_id,
$target = 'components'
)
{
CFactory::_('Language.Set')->execute($strings, $target_id,
$target);
}
/**
* store the language placeholders
*
* @param string $target The target extention type
* @param int $when To set when to update
*
* @return void
* @deprecated 3.4
*/
protected function setNewLangStrings($target, $when = 1)
{
// set notice that we could not get a valid string from the target
$this->app->enqueueMessage(
Text::sprintf('COM_COMPONENTBUILDER_HR_HTHREES_WARNINGHTHREE',
__CLASS__), 'Error'
);
$this->app->enqueueMessage(
Text::sprintf(
'Use of a deprecated method (%s)!', __METHOD__
), 'Error'
);
}
/**
* update the language placeholders
*
* @param int $when To set when to update
*
* @return void
* @deprecated 3.4
*/
protected function setExistingLangStrings($when = 1)
{
// set notice that we could not get a valid string from the target
$this->app->enqueueMessage(
Text::sprintf('COM_COMPONENTBUILDER_HR_HTHREES_WARNINGHTHREE',
__CLASS__), 'Error'
);
$this->app->enqueueMessage(
Text::sprintf(
'Use of a deprecated method (%s)!', __METHOD__
), 'Error'
);
}
/**
* Remove exiting language translation stings
*
* @param int $id To string ID to remove
*
* @return void
* @deprecated 3.4
*/
protected function removeExitingLangString($id)
{
// set notice that we could not get a valid string from the target
$this->app->enqueueMessage(
Text::sprintf('COM_COMPONENTBUILDER_HR_HTHREES_WARNINGHTHREE',
__CLASS__), 'Error'
);
$this->app->enqueueMessage(
Text::sprintf(
'Use of a deprecated method (%s)!', __METHOD__
), 'Error'
);
}
/**
* Function to purge the unused languge strings
*
* @param string $values the active strings
*
* @return void
* @deprecated 3.4 Use
CFactory::_('Language.Purge')->execute(...);
*/
public function purgeLanuageStrings($values, $target_id, $target =
'components')
{
CFactory::_('Language.Purge')->execute($values, $target_id,
$target);
}
/**
* just to add lang string to the existing Lang Strings array
*
* @return void
* @deprecated 3.4
*/
protected function setUpdateExistingLangStrings($id, $target, $targets,
$published, $today,
$counterUpdate
)
{
// set notice that we could not get a valid string from the target
$this->app->enqueueMessage(
Text::sprintf('COM_COMPONENTBUILDER_HR_HTHREES_WARNINGHTHREE',
__CLASS__), 'Error'
);
$this->app->enqueueMessage(
Text::sprintf(
'Use of a deprecated method (%s)!', __METHOD__
), 'Error'
);
}
/**
* get the custom code from the system
*
* @param array|null $ids The custom code ides if known
* @param int|null $setLang The set lang switch
* @param int $debug The switch to debug the update
*
* @return void
* @deprecated 3.3 Use CFactory::_('Customcode')->get($ids,
$setLang, $debug);
*/
public function getCustomCode(?array $ids = null, bool $setLang = true,
int $debug = 0)
{
CFactory::_('Customcode')->get($ids, $setLang, $debug);
}
/**
* check if we already have these ids in local memory
*
* @return void
* @deprecated 3.3
*/
protected function checkCustomCodeMemory($ids)
{
// set notice that we could not get a valid string from the target
$this->app->enqueueMessage(
Text::sprintf('COM_COMPONENTBUILDER_HR_HTHREES_WARNINGHTHREE',
__CLASS__), 'Error'
);
$this->app->enqueueMessage(
Text::sprintf(
'Use of a deprecated method (%s)!', __METHOD__
), 'Error'
);
}
/**
* get all the powers linkd to this component
*
* @return void
* @deprecated 3.3 Use CFactory::_('Power')->load($guids);
*/
protected function getPowers($guids)
{
CFactory::_('Power')->load($guids);
}
/**
* get a power linkd to this component
*
* @return mixed
* @deprecated 3.3 Use CFactory::_('Power')->get($guid,
$build);
*/
public function getPower($guid, $build = 0)
{
CFactory::_('Power')->get($guid, $build);
}
/**
* set a power linkd to this component
*
* @return bool
* @deprecated 3.3
*/
protected function setPower($guid)
{
// set notice that we could not get a valid string from the target
$this->app->enqueueMessage(
Text::sprintf('COM_COMPONENTBUILDER_HR_HTHREES_WARNINGHTHREE',
__CLASS__), 'Error'
);
$this->app->enqueueMessage(
Text::sprintf(
'Use of a deprecated method (%s)!', __METHOD__
), 'Error'
);
return false;
}
/**
* get the Joomla module path
*
* @return string of module path and target site area on success
* @deprecated 3.3
*/
protected function getModulePath($id)
{
// set notice that we could not get a valid string from the target
$this->app->enqueueMessage(
Text::sprintf('COM_COMPONENTBUILDER_HR_HTHREES_WARNINGHTHREE',
__CLASS__), 'Error'
);
$this->app->enqueueMessage(
Text::sprintf(
'Use of a deprecated method (%s)!', __METHOD__
), 'Error'
);
return '';
}
/**
* get the Joomla Modules IDs
*
* @return array of IDs on success
* @deprecated 3.3
*/
protected function getModuleIDs()
{
// set notice that we could not get a valid string from the target
$this->app->enqueueMessage(
Text::sprintf('COM_COMPONENTBUILDER_HR_HTHREES_WARNINGHTHREE',
__CLASS__), 'Error'
);
$this->app->enqueueMessage(
Text::sprintf(
'Use of a deprecated method (%s)!', __METHOD__
), 'Error'
);
return [];
}
/**
* set the Joomla modules
*
* @return true
* @deprecated 3.3 Use
CFactory::_('Joomlamodule.Data')->set($id);
*/
public function setJoomlaModule($id, &$component)
{
return CFactory::_('Joomlamodule.Data')->set($id);
}
/**
* get the module xml template
*
* @return string
* @deprecated 3.3
*/
public function getModuleXMLTemplate(&$module)
{
// set notice that we could not get a valid string from the target
$this->app->enqueueMessage(
Text::sprintf('COM_COMPONENTBUILDER_HR_HTHREES_WARNINGHTHREE',
__CLASS__), 'Error'
);
$this->app->enqueueMessage(
Text::sprintf(
'Use of a deprecated method (%s)!', __METHOD__
), 'Error'
);
}
/**
* get the module admin custom script field
*
* @return string
* @deprecated 3.3
*/
public function getModAdminVvvvvvvdm($fieldScriptBucket)
{
// set notice that we could not get a valid string from the target
$this->app->enqueueMessage(
Text::sprintf('COM_COMPONENTBUILDER_HR_HTHREES_WARNINGHTHREE',
__CLASS__), 'Error'
);
$this->app->enqueueMessage(
Text::sprintf(
'Use of a deprecated method (%s)!', __METHOD__
), 'Error'
);
}
/**
* get the Joomla plugins IDs
*
* @return array of IDs on success
* @deprecated 3.3
*/
protected function getPluginIDs()
{
// set notice that we could not get a valid string from the target
$this->app->enqueueMessage(
Text::sprintf('COM_COMPONENTBUILDER_HR_HTHREES_WARNINGHTHREE',
__CLASS__), 'Error'
);
$this->app->enqueueMessage(
Text::sprintf(
'Use of a deprecated method (%s)!', __METHOD__
), 'Error'
);
return [];
}
/**
* get the Joomla plugin path
*
* @return string of plugin path on success
* @deprecated 3.3
*/
protected function getPluginPath($id)
{
// set notice that we could not get a valid string from the target
$this->app->enqueueMessage(
Text::sprintf('COM_COMPONENTBUILDER_HR_HTHREES_WARNINGHTHREE',
__CLASS__), 'Error'
);
$this->app->enqueueMessage(
Text::sprintf(
'Use of a deprecated method (%s)!', __METHOD__
), 'Error'
);
return '';
}
/**
* set the Joomla plugins
*
* @return true
* @deprecated 3.3 Use
CFactory::_('Joomlamodule.Data')->set($id);
*/
public function setJoomlaPlugin($id, &$component)
{
return CFactory::_('Joomlaplugin.Data')->set($id);
}
/**
* get the plugin xml template
*
* @return string
* @deprecated 3.3
*/
public function getPluginXMLTemplate(&$plugin)
{
// set notice that we could not get a valid string from the target
$this->app->enqueueMessage(
Text::sprintf('COM_COMPONENTBUILDER_HR_HTHREES_WARNINGHTHREE',
__CLASS__), 'Error'
);
$this->app->enqueueMessage(
Text::sprintf(
'Use of a deprecated method (%s)!', __METHOD__
), 'Error'
);
}
/**
* store the code
*
* @param int $when To set when to update
*
* @return void
* @deprecated 3.3
*/
protected function setNewCustomCode($when = 1)
{
// set notice that we could not get a valid string from the target
$this->app->enqueueMessage(
Text::sprintf('COM_COMPONENTBUILDER_HR_HTHREES_WARNINGHTHREE',
__CLASS__), 'Error'
);
$this->app->enqueueMessage(
Text::sprintf(
'Use of a deprecated method (%s)!', __METHOD__
), 'Error'
);
}
/**
* store the code
*
* @param int $when To set when to update
*
* @return void
* @deprecated 3.3
*/
protected function setExistingCustomCode($when = 1)
{
// set notice that we could not get a valid string from the target
$this->app->enqueueMessage(
Text::sprintf('COM_COMPONENTBUILDER_HR_HTHREES_WARNINGHTHREE',
__CLASS__), 'Error'
);
$this->app->enqueueMessage(
Text::sprintf(
'Use of a deprecated method (%s)!', __METHOD__
), 'Error'
);
}
/**
* get the custom code from the local files
*
* @param array $paths The local paths to parse
* @param string $today The date for today
*
* @return void
* @deprecated 3.3 Use
CFactory::_('Customcode.Extractor')->run();
*/
protected function customCodeFactory(&$paths, &$today)
{
CFactory::_('Customcode.Extractor')->run();
}
/**
* search a file for placeholders and store result
*
* @param array $counter The counter for the arrays
* @param string $file The file path to search
* @param array $searchArray The values to search for
* @param array $placeholders The values to replace in the code being
stored
* @param string $today The date for today
*
* @return array on success
*
* @deprecated 3.3
*/
protected function searchFileContent(&$counter, &$file,
&$target,
&$searchArray,
&$placeholders, &$today
)
{
// set notice that we could not get a valid string from the target
$this->app->enqueueMessage(
Text::sprintf('COM_COMPONENTBUILDER_HR_HTHREES_WARNINGHTHREE',
__CLASS__), 'Error'
);
$this->app->enqueueMessage(
Text::sprintf(
'Use of a deprecated method (%s)!', __METHOD__
), 'Error'
);
return [];
}
/**
* Set a hash of a file and/or string
*
* @param string $string The code string
*
* @return string
* @deprecated 3.3 Use
CFactory::_('Customcode.Hash')->set($script);
*/
protected function setDynamicHASHING($script)
{
return CFactory::_('Customcode.Hash')->set($script);
}
/**
* Lock a string with bsae64 (basic)
*
* @param string $string The code string
*
* @return string
* @deprecated 3.3 Use
CFactory::_('Customcode.LockBase')->set($script);
*/
protected function setBase64LOCK($script)
{
return CFactory::_('Customcode.LockBase')->set($script);
}
/**
* Set the JCB GUI code placeholder
*
* @param string $string The code string
* @param array $config The placeholder config values
*
* @return string
* @deprecated 3.3 Use
CFactory::_('Customcode.Gui')->set($string, $config);
*/
public function setGuiCodePlaceholder($string, $config)
{
return CFactory::_('Customcode.Gui')->set($string,
$config);
}
/**
* search a code to see if there is already any custom
* code or other reasons not to add the GUI code placeholders
*
* @param string $code The code to check
*
* @return boolean true if GUI code placeholders can be added
* @deprecated 3.3
*/
protected function canAddGuiCodePlaceholder(&$code)
{
// set notice that we could not get a valid string from the target
$this->app->enqueueMessage(
Text::sprintf('COM_COMPONENTBUILDER_HR_HTHREES_WARNINGHTHREE',
__CLASS__), 'Error'
);
$this->app->enqueueMessage(
Text::sprintf(
'Use of a deprecated method (%s)!', __METHOD__
), 'Error'
);
return false;
}
/**
* search a file for gui code blocks that were updated in the IDE
*
* @param string $file The file path to search
* @param array $placeholders The values to replace in the code being
stored
* @param string $today The date for today
* @param string $target The target path type
*
* @return void
* @deprecated 3.3 Use
CFactory::_('Customcode.Gui')->search($file, $placeholders,
$today, $target);
*/
protected function guiCodeSearch(&$file, &$placeholders,
&$today, &$target)
{
CFactory::_('Customcode.Gui')->search($file, $placeholders,
$today, $target);
}
/**
* Check if this line should be added
*
* @param string $replaceKey The key to remove from line
* @param int $type The line type
* @param string $lineContent The line to check
*
* @return bool true on success
*
* @deprecated 3.3
*/
protected function addLineChecker($replaceKey, $type, $lineContent)
{
// set notice that we could not get a valid string from the target
$this->app->enqueueMessage(
Text::sprintf('COM_COMPONENTBUILDER_HR_HTHREES_WARNINGHTHREE',
__CLASS__), 'Error'
);
$this->app->enqueueMessage(
Text::sprintf(
'Use of a deprecated method (%s)!', __METHOD__
), 'Error'
);
return false;
}
/**
* set the start replace placeholder
*
* @param int $id The comment id
* @param int $commentType The comment type
* @param string $startReplace The main replace string
*
* @return array on success
*
* @deprecated 3.3
*/
protected function setStartReplace($id, $commentType, $startReplace)
{
// set notice that we could not get a valid string from the target
$this->app->enqueueMessage(
Text::sprintf('COM_COMPONENTBUILDER_HR_HTHREES_WARNINGHTHREE',
__CLASS__), 'Error'
);
$this->app->enqueueMessage(
Text::sprintf(
'Use of a deprecated method (%s)!', __METHOD__
), 'Error'
);
return [];
}
/**
* search for the system id in the line given
*
* @param string $lineContent The file path to search
* @param string $placeholders The values to search for
* @param int $commentType The comment type
*
* @return int on success
*
* @deprecated 3.3
*/
protected function getSystemID(&$lineContent, $placeholders,
$commentType)
{
// set notice that we could not get a valid string from the target
$this->app->enqueueMessage(
Text::sprintf('COM_COMPONENTBUILDER_HR_HTHREES_WARNINGHTHREE',
__CLASS__), 'Error'
);
$this->app->enqueueMessage(
Text::sprintf(
'Use of a deprecated method (%s)!', __METHOD__
), 'Error'
);
return null;
}
/**
* Reverse Engineer the dynamic placeholders (TODO hmmmm this is not
ideal)
*
* @param string $string The string to revers
* @param array $placeholders The values to search for
* @param string $target The target path type
* @param int $id The custom code id
* @param string $field The field name
* @param string $table The table name
*
* @return string
* @deprecated 3.3 Use
CFactory::_('Placeholder.Reverse')->engine($string,
$placeholders, $target, $id, $field, $table);
*/
protected function reversePlaceholders($string, &$placeholders,
&$target,
$id = null, $field =
'code', $table = 'custom_code'
)
{
// use the new container class
CFactory::_('Placeholder.Reverse')->engine($string,
$placeholders, $target, $id, $field, $table);
}
/**
* Set the langs strings for the reveres process
*
* @param string $updateString The string to update
* @param string $string The string to use lang update
* @param string $target The target path type
*
* @return string
* @deprecated 3.3 See $this->reversePlaceholders();
*/
protected function setReverseLangPlaceholders($updateString, $string,
&$target
)
{
// set notice that we could not get a valid string from the target
$this->app->enqueueMessage(
Text::sprintf('COM_COMPONENTBUILDER_HR_HTHREES_WARNINGHTHREE',
__CLASS__), 'Error'
);
$this->app->enqueueMessage(
Text::sprintf(
'Use of a deprecated method (%s)!', __METHOD__
), 'Error'
);
return '';
}
/**
* Update the data with the placeholders
*
* @param string $data The actual data
* @param array $placeholder The placeholders
* @param int $action The action to use
*
* THE ACTION OPTIONS ARE
* 1 -> Just replace (default)
* 2 -> Check if data string has placeholders
* 3 -> Remove placeholders not in data string
*
* @return string
* @deprecated 3.3 Use
CFactory::_('Placeholder')->update($data, $placeholder,
$action);
*/
public function setPlaceholders($data, &$placeholder, $action = 1)
{
// use the new container class
CFactory::_('Placeholder')->update($data, $placeholder,
$action);
}
/**
* return the placeholders for inserted and replaced code
*
* @param int $type The type of placement
* @param int $id The code id in the system
*
* @return array on success
* @deprecated 3.3 Use
CFactory::_('Placeholder')->keys($type, $id);
*/
public function getPlaceHolder($type, $id)
{
return CFactory::_('Placeholder')->keys($type, $id);
}
/**
* get the local installed path of this component
*
* @return array of paths on success
* @deprecated 3.3
*/
protected function getLocalInstallPaths()
{
// set notice that we could not get a valid string from the target
$this->app->enqueueMessage(
Text::sprintf('COM_COMPONENTBUILDER_HR_HTHREES_WARNINGHTHREE',
__CLASS__), 'Error'
);
$this->app->enqueueMessage(
Text::sprintf(
'Use of a deprecated method (%s)!', __METHOD__
), 'Error'
);
return [];
}
}
src/Componentbuilder/Compiler/Helper/Infusion.php000064400000270671151162054130016153
0ustar00<?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\Helper;
use Joomla\CMS\Factory;
use Joomla\CMS\Filesystem\File;
use Joomla\CMS\Filesystem\Folder;
use Joomla\Filter\OutputFilter;
// use
VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper;
(for Joomla 4 and above)
use VDM\Joomla\Utilities\StringHelper;
use VDM\Joomla\Utilities\ArrayHelper;
use VDM\Joomla\Utilities\ObjectHelper;
use VDM\Joomla\Utilities\FileHelper;
use VDM\Joomla\Utilities\String\NamespaceHelper;
use VDM\Joomla\Componentbuilder\Compiler\Factory as CFactory;
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\Utilities\Minify;
use VDM\Joomla\Componentbuilder\Compiler\Helper\Interpretation;
/**
* Infusion class
*
* @deprecated 3.3
*/
class Infusion extends Interpretation
{
public $langFiles = [];
/**
* Switch to remove site folder
*
* @var bool
* @deprecated 3.3 Use
CFactory::_('Config')->remove_site_folder;
*/
public $removeSiteFolder = false;
/**
* Switch to remove site edit folder
*
* @var bool
* @deprecated 3.3 Use
CFactory::_('Config')->remove_site_edit_folder;
*/
public $removeSiteEditFolder = true;
/**
* Constructor
*/
public function __construct()
{
// first we run the perent constructor
if (parent::__construct())
{
// infuse the data into the structure
return $this->buildFileContent();
}
return false;
}
/**
* Build the content for the structure
*
*
* @return boolean on success
*
*/
protected function buildFileContent()
{
if
(CFactory::_('Component')->isArray('admin_views'))
{
// Trigger Event: jcb_ce_onBeforeBuildFilesContent
CFactory::_('Event')->trigger(
'jcb_ce_onBeforeBuildFilesContent'
);
// COMPONENT
CFactory::_('Compiler.Builder.Content.One')->set('COMPONENT',
CFactory::_('Placeholder')->get('COMPONENT')
);
// Component
CFactory::_('Compiler.Builder.Content.One')->set('Component',
CFactory::_('Placeholder')->get('Component')
);
// component
CFactory::_('Compiler.Builder.Content.One')->set('component',
CFactory::_('Placeholder')->get('component')
);
// ComponentNamespace
CFactory::_('Compiler.Builder.Content.One')->set('ComponentNamespace',
CFactory::_('Placeholder')->get('ComponentNamespace')
);
// COMPANYNAME
$companyname =
CFactory::_('Component')->get('companyname');
CFactory::_('Compiler.Builder.Content.One')->set('COMPANYNAME',
trim(
(string) \JFilterOutput::cleanText($companyname)
));
// POWER_LIBRARY_FOLDER
CFactory::_('Compiler.Builder.Content.One')->set('POWER_LIBRARY_FOLDER',
CFactory::_('Config')->power_library_folder
);
// CREATIONDATE
CFactory::_('Compiler.Builder.Content.One')->set('CREATIONDATE',
Factory::getDate(CFactory::_('Component')->get('created'))->format(
'jS F, Y'
));
CFactory::_('Compiler.Builder.Content.One')->set('GLOBALCREATIONDATE',
CFactory::_('Compiler.Builder.Content.One')->get('CREATIONDATE'));
// BUILDDATE
CFactory::_('Compiler.Builder.Content.One')->set('BUILDDATE',
Factory::getDate(
CFactory::_('Config')->get('build_date',
'now'))->format('jS F, Y'));
CFactory::_('Compiler.Builder.Content.One')->set('GLOBALBUILDDATE',
CFactory::_('Compiler.Builder.Content.One')->get('BUILDDATE'));
// AUTHOR
$author =
CFactory::_('Component')->get('author');
CFactory::_('Compiler.Builder.Content.One')->set('AUTHOR',
trim(
(string) OutputFilter::cleanText($author)
));
// AUTHOREMAIL
CFactory::_('Compiler.Builder.Content.One')->set('AUTHOREMAIL',
trim((string)
CFactory::_('Component')->get('email',
''))
);
// AUTHORWEBSITE
CFactory::_('Compiler.Builder.Content.One')->set('AUTHORWEBSITE',
trim((string)
CFactory::_('Component')->get('website',
''))
);
// COPYRIGHT
CFactory::_('Compiler.Builder.Content.One')->set('COPYRIGHT',
trim((string)
CFactory::_('Component')->get('copyright',
''))
);
// LICENSE
CFactory::_('Compiler.Builder.Content.One')->set('LICENSE',
trim((string)
CFactory::_('Component')->get('license',
''))
);
// VERSION
CFactory::_('Compiler.Builder.Content.One')->set('VERSION',
trim((string)
CFactory::_('Component')->get('component_version',
''))
);
// set the actual global version
CFactory::_('Compiler.Builder.Content.One')->set('ACTUALVERSION',
CFactory::_('Compiler.Builder.Content.One')->get('VERSION')
);
// do some Tweaks to the version based on selected options
if (strpos((string)
CFactory::_('Compiler.Builder.Content.One')->get('VERSION'),
'.') !== false)
{
$versionArray = explode(
'.', (string)
CFactory::_('Compiler.Builder.Content.One')->get('VERSION')
);
}
// load only first two values
if (isset($versionArray)
&& ArrayHelper::check(
$versionArray
) &&
CFactory::_('Component')->get('mvc_versiondate', 0)
== 2)
{
CFactory::_('Compiler.Builder.Content.One')->set('VERSION',
$versionArray[0] . '.' . $versionArray[1] . '.x'
);
}
// load only the first value
elseif (isset($versionArray)
&& ArrayHelper::check(
$versionArray
) &&
CFactory::_('Component')->get('mvc_versiondate', 0)
== 3)
{
CFactory::_('Compiler.Builder.Content.One')->set('VERSION',
$versionArray[0] . '.x.x'
);
}
unset($versionArray);
// set the namespace prefix
CFactory::_('Compiler.Builder.Content.One')->set('NAMESPACEPREFIX',
CFactory::_('Placeholder')->get('NAMESPACEPREFIX')
);
// set the global version in case
CFactory::_('Compiler.Builder.Content.One')->set('GLOBALVERSION',
CFactory::_('Compiler.Builder.Content.One')->get('VERSION')
);
// set the joomla target xml version
CFactory::_('Compiler.Builder.Content.One')->set('XMLVERSION',
CFactory::_('Config')->joomla_versions[CFactory::_('Config')->joomla_version]['xml_version']
);
// Component_name
$name = CFactory::_('Component')->get('name');
CFactory::_('Compiler.Builder.Content.One')->set('Component_name',
OutputFilter::cleanText($name)
);
// SHORT_DISCRIPTION
$short_description =
CFactory::_('Component')->get('short_description');
CFactory::_('Compiler.Builder.Content.One')->set('SHORT_DESCRIPTION',
trim(
(string) OutputFilter::cleanText(
$short_description
)
));
// DESCRIPTION
CFactory::_('Compiler.Builder.Content.One')->set('DESCRIPTION',
trim((string)
CFactory::_('Component')->get('description'))
);
// COMP_IMAGE_TYPE
CFactory::_('Compiler.Builder.Content.One')->set('COMP_IMAGE_TYPE',
$this->setComponentImageType(CFactory::_('Component')->get('image'))
);
// ACCESS_SECTIONS
CFactory::_('Compiler.Builder.Content.One')->set('ACCESS_SECTIONS',
CFactory::_('Compiler.Creator.Access.Sections')->get()
);
// CONFIG_FIELDSETS
$keepLang = CFactory::_('Config')->lang_target;
CFactory::_('Config')->lang_target = 'admin';
// start loading the category tree scripts
CFactory::_('Compiler.Builder.Content.One')->set('CATEGORY_CLASS_TREES',
'');
// run the field sets for first time
CFactory::_('Compiler.Creator.Config.Fieldsets')->set(1);
CFactory::_('Config')->lang_target = $keepLang;
// ADMINJS
CFactory::_('Compiler.Builder.Content.One')->set('ADMINJS',
CFactory::_('Placeholder')->update_(
CFactory::_('Customcode.Dispenser')->hub['component_js']
));
// SITEJS
CFactory::_('Compiler.Builder.Content.One')->set('SITEJS',
CFactory::_('Placeholder')->update_(
CFactory::_('Customcode.Dispenser')->hub['component_js']
));
// ADMINCSS
CFactory::_('Compiler.Builder.Content.One')->set('ADMINCSS',
CFactory::_('Placeholder')->update_(
CFactory::_('Customcode.Dispenser')->hub['component_css_admin']
));
// SITECSS
CFactory::_('Compiler.Builder.Content.One')->set('SITECSS',
CFactory::_('Placeholder')->update_(
CFactory::_('Customcode.Dispenser')->hub['component_css_site']
));
// CUSTOM_HELPER_SCRIPT
CFactory::_('Compiler.Builder.Content.One')->set('CUSTOM_HELPER_SCRIPT',
CFactory::_('Placeholder')->update_(
CFactory::_('Customcode.Dispenser')->hub['component_php_helper_admin']
));
// BOTH_CUSTOM_HELPER_SCRIPT
CFactory::_('Compiler.Builder.Content.One')->set('BOTH_CUSTOM_HELPER_SCRIPT',
CFactory::_('Placeholder')->update_(
CFactory::_('Customcode.Dispenser')->hub['component_php_helper_both']
));
// ADMIN_GLOBAL_EVENT_HELPER
if
(!CFactory::_('Compiler.Builder.Content.One')->exists('ADMIN_GLOBAL_EVENT'))
{
CFactory::_('Compiler.Builder.Content.One')->set('ADMIN_GLOBAL_EVENT',
'');
}
if
(!CFactory::_('Compiler.Builder.Content.One')->exists('ADMIN_GLOBAL_EVENT_HELPER'))
{
CFactory::_('Compiler.Builder.Content.One')->set('ADMIN_GLOBAL_EVENT_HELPER',
'');
}
// now load the data for the global event if needed
if
(CFactory::_('Component')->get('add_admin_event', 0)
== 1)
{
// ADMIN_GLOBAL_EVENT
CFactory::_('Compiler.Builder.Content.One')->add('ADMIN_GLOBAL_EVENT',
PHP_EOL . PHP_EOL . '// Trigger the Global Admin Event'
);
CFactory::_('Compiler.Builder.Content.One')->add('ADMIN_GLOBAL_EVENT',
PHP_EOL .
CFactory::_('Compiler.Builder.Content.One')->get('Component')
. 'Helper::globalEvent(Factory::getDocument());');
// ADMIN_GLOBAL_EVENT_HELPER
CFactory::_('Compiler.Builder.Content.One')->add('ADMIN_GLOBAL_EVENT_HELPER',
PHP_EOL . PHP_EOL . Indent::_(1) . '/**'
);
CFactory::_('Compiler.Builder.Content.One')->add('ADMIN_GLOBAL_EVENT_HELPER',
PHP_EOL . Indent::_(1)
. '* The Global Admin Event Method.');
CFactory::_('Compiler.Builder.Content.One')->add('ADMIN_GLOBAL_EVENT_HELPER',
PHP_EOL . Indent::_(1) . '**/'
);
CFactory::_('Compiler.Builder.Content.One')->add('ADMIN_GLOBAL_EVENT_HELPER',
PHP_EOL . Indent::_(1)
. 'public static function globalEvent($document)');
CFactory::_('Compiler.Builder.Content.One')->add('ADMIN_GLOBAL_EVENT_HELPER',
PHP_EOL . Indent::_(1) . '{'
);
CFactory::_('Compiler.Builder.Content.One')->add('ADMIN_GLOBAL_EVENT_HELPER',
PHP_EOL . CFactory::_('Placeholder')->update_(
CFactory::_('Customcode.Dispenser')->hub['component_php_admin_event']
));
CFactory::_('Compiler.Builder.Content.One')->add('ADMIN_GLOBAL_EVENT_HELPER',
PHP_EOL . Indent::_(1) . '}'
);
}
// now load the readme file if needed
if (CFactory::_('Component')->get('addreadme', 0)
== 1)
{
CFactory::_('Compiler.Builder.Content.One')->add('EXSTRA_ADMIN_FILES',
PHP_EOL . Indent::_(3)
. "<filename>README.txt</filename>");
}
// HELPER_CREATEUSER
CFactory::_('Compiler.Builder.Content.One')->add('HELPER_CREATEUSER',
CFactory::_('Architecture.ComHelperClass.CreateUser')->get(
CFactory::_('Component')->get('creatuserhelper',
0)
)
);
// HELP
CFactory::_('Compiler.Builder.Content.One')->set('HELP',
$this->noHelp());
// HELP_SITE
CFactory::_('Compiler.Builder.Content.One')->set('HELP_SITE',
$this->noHelp());
// build route parse switch
CFactory::_('Compiler.Builder.Content.One')->set('ROUTER_PARSE_SWITCH',
'');
// build route views
CFactory::_('Compiler.Builder.Content.One')->set('ROUTER_BUILD_VIEWS',
'');
// add the helper emailer if set
CFactory::_('Compiler.Builder.Content.One')->set('HELPER_EMAIL',
$this->addEmailHelper());
// load the global placeholders
foreach (CFactory::_('Component.Placeholder')->get() as
$globalPlaceholder =>
$gloabalValue
)
{
CFactory::_('Compiler.Builder.Content.One')->set($globalPlaceholder,
$gloabalValue);
}
// reset view array
$viewarray = [];
$site_edit_view_array = [];
// start dynamic build
foreach
(CFactory::_('Component')->get('admin_views') as
$view)
{
// set the target
CFactory::_('Config')->build_target = 'admin';
CFactory::_('Config')->lang_target = 'admin';
// set local names
$nameSingleCode = $view['settings']->name_single_code;
$nameListCode = $view['settings']->name_list_code;
// set the view placeholders
$this->setViewPlaceholders($view['settings']);
// set site edit view array
if (isset($view['edit_create_site_view'])
&& is_numeric(
$view['edit_create_site_view']
)
&& $view['edit_create_site_view'] > 0)
{
$site_edit_view_array[$nameSingleCode] = $nameListCode;
CFactory::_('Config')->lang_target = 'both';
// insure site view does not get removed
CFactory::_('Config')->remove_site_edit_folder = false;
}
// check if help is being loaded
$this->checkHelp($nameSingleCode);
// set custom admin view list links
$this->setCustomAdminViewListLink(
$view, $nameListCode
);
// set view array
$viewarray[] = Indent::_(4) . "'"
. $nameSingleCode . "' => '"
. $nameListCode . "'";
// set the view names
if (isset($view['settings']->name_single)
&& $view['settings']->name_single !=
'null')
{
// set license per view if needed
$this->setLockLicensePer(
$nameSingleCode, CFactory::_('Config')->build_target
);
$this->setLockLicensePer(
$nameListCode, CFactory::_('Config')->build_target
);
// Trigger Event: jcb_ce_onBeforeBuildAdminEditViewContent
CFactory::_('Event')->trigger(
'jcb_ce_onBeforeBuildAdminEditViewContent', [&$view,
&$nameSingleCode, &$nameListCode]
);
// FIELDSETS <<<DYNAMIC>>>
CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode
. '|FIELDSETS',
CFactory::_('Compiler.Creator.Fieldset')->get(
$view,
CFactory::_('Config')->component_code_name,
$nameSingleCode,
$nameListCode
)
);
// ACCESSCONTROL <<<DYNAMIC>>>
CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode
. '|ACCESSCONTROL',
$this->setFieldSetAccessControl(
$nameSingleCode
)
);
// LINKEDVIEWITEMS <<<DYNAMIC>>>
CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode
. '|LINKEDVIEWITEMS', '');
// ADDTOOLBAR <<<DYNAMIC>>>
CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode
. '|ADDTOOLBAR',
$this->setAddToolBar($view)
);
// set the script for this view
$this->buildTheViewScript($view);
// VIEW_SCRIPT
CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode
. '|VIEW_SCRIPT',
$this->setViewScript(
$nameSingleCode, 'fileScript'
)
);
// EDITBODYSCRIPT
CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode
. '|EDITBODYSCRIPT',
$this->setViewScript(
$nameSingleCode, 'footerScript'
)
);
// AJAXTOKE <<<DYNAMIC>>>
CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode
. '|AJAXTOKE',
$this->setAjaxToke(
$nameSingleCode
)
);
// DOCUMENT_CUSTOM_PHP <<<DYNAMIC>>>
if ($phpDocument =
CFactory::_('Customcode.Dispenser')->get(
'php_document', $nameSingleCode,
PHP_EOL, null, true,
false
))
{
CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode
. '|DOCUMENT_CUSTOM_PHP',
str_replace(
'$document->', '$this->document->',
(string) $phpDocument
)
);
// clear some memory
unset($phpDocument);
}
else
{
CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode
. '|DOCUMENT_CUSTOM_PHP', '');
}
// LINKEDVIEWTABLESCRIPTS <<<DYNAMIC>>>
CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode
. '|LINKEDVIEWTABLESCRIPTS', '');
// VALIDATEFIX <<<DYNAMIC>>>
CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode
. '|VALIDATIONFIX',
$this->setValidationFix(
$nameSingleCode,
CFactory::_('Compiler.Builder.Content.One')->get('Component')
)
);
// EDITBODY <<<DYNAMIC>>>
CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode
. '|EDITBODY',
$this->setEditBody($view)
);
// EDITBODYFADEIN <<<DYNAMIC>>>
CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode
. '|EDITBODYFADEIN',
$this->setFadeInEfect($view)
);
// JTABLECONSTRUCTOR <<<DYNAMIC>>>
CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode
. '|JTABLECONSTRUCTOR',
$this->setJtableConstructor(
$nameSingleCode
)
);
// JTABLEALIASCATEGORY <<<DYNAMIC>>>
CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode
. '|JTABLEALIASCATEGORY',
$this->setJtableAliasCategory(
$nameSingleCode
)
);
// METHOD_GET_ITEM <<<DYNAMIC>>>
CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode
. '|METHOD_GET_ITEM',
$this->setMethodGetItem(
$nameSingleCode
)
);
// LINKEDVIEWGLOBAL <<<DYNAMIC>>>
CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode
. '|LINKEDVIEWGLOBAL', '');
// LINKEDVIEWMETHODS <<<DYNAMIC>>>
CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode
. '|LINKEDVIEWMETHODS', '');
// JMODELADMIN_BEFORE_DELETE <<<DYNAMIC>>>
CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode
. '|JMODELADMIN_BEFORE_DELETE',
CFactory::_('Customcode.Dispenser')->get(
'php_before_delete',
$nameSingleCode, PHP_EOL
)
);
// JMODELADMIN_AFTER_DELETE <<<DYNAMIC>>>
CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode
. '|JMODELADMIN_AFTER_DELETE',
CFactory::_('Customcode.Dispenser')->get(
'php_after_delete', $nameSingleCode,
PHP_EOL . PHP_EOL
)
);
// JMODELADMIN_BEFORE_DELETE <<<DYNAMIC>>>
CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode
. '|JMODELADMIN_BEFORE_PUBLISH',
CFactory::_('Customcode.Dispenser')->get(
'php_before_publish',
$nameSingleCode, PHP_EOL
)
);
// JMODELADMIN_AFTER_DELETE <<<DYNAMIC>>>
CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode
. '|JMODELADMIN_AFTER_PUBLISH',
CFactory::_('Customcode.Dispenser')->get(
'php_after_publish',
$nameSingleCode, PHP_EOL . PHP_EOL
)
);
// CHECKBOX_SAVE <<<DYNAMIC>>>
CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode
. '|CHECKBOX_SAVE',
$this->setCheckboxSave(
$nameSingleCode
)
);
// METHOD_ITEM_SAVE <<<DYNAMIC>>>
CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode
. '|METHOD_ITEM_SAVE',
$this->setMethodItemSave(
$nameSingleCode
)
);
// POSTSAVEHOOK <<<DYNAMIC>>>
CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode
. '|POSTSAVEHOOK',
CFactory::_('Customcode.Dispenser')->get(
'php_postsavehook', $nameSingleCode,
PHP_EOL, null,
true, PHP_EOL . Indent::_(2) . "return;",
PHP_EOL . PHP_EOL . Indent::_(2) . "return;"
)
);
// VIEWCSS <<<DYNAMIC>>>
CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode
. '|VIEWCSS',
CFactory::_('Customcode.Dispenser')->get(
'css_view', $nameSingleCode, '',
null, true
)
);
// AJAXTOKE <<<DYNAMIC>>>
CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode
. '|AJAXTOKE',
$this->setAjaxToke(
$nameSingleCode
)
);
// add css to front end
if (isset($view['edit_create_site_view'])
&& is_numeric($view['edit_create_site_view'])
&& $view['edit_create_site_view'] > 0)
{
CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode
. '|SITE_VIEWCSS',
CFactory::_('Compiler.Builder.Content.Multi')->get($nameSingleCode
. '|VIEWCSS', '')
);
// check if we should add a create menu
if ($view['edit_create_site_view'] == 2)
{
// SITE_MENU_XML <<<DYNAMIC>>>
CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode
. '|SITE_MENU_XML',
$this->setAdminViewMenu(
$nameSingleCode, $view
)
);
}
// SITE_ADMIN_VIEW_CONTROLLER_HEADER <<<DYNAMIC>>>
add the header details for the controller
CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode
. '|SITE_ADMIN_VIEW_CONTROLLER_HEADER',
CFactory::_('Header')->get(
'site.admin.view.controller',
$nameSingleCode
)
);
// SITE_ADMIN_VIEW_MODEL_HEADER <<<DYNAMIC>>> add
the header details for the model
CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode
. '|SITE_ADMIN_VIEW_MODEL_HEADER',
CFactory::_('Header')->get(
'site.admin.view.model',
$nameSingleCode
)
);
// SITE_ADMIN_VIEW_HTML_HEADER <<<DYNAMIC>>> add
the header details for the view
CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode
. '|SITE_ADMIN_VIEW_HTML_HEADER',
CFactory::_('Header')->get(
'site.admin.view.html',
$nameSingleCode
)
);
// SITE_ADMIN_VIEW_HEADER <<<DYNAMIC>>> add the
header details for the view
CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode
. '|SITE_ADMIN_VIEW_HEADER',
CFactory::_('Header')->get(
'site.admin.view',
$nameSingleCode
)
);
}
// TABLAYOUTFIELDSARRAY <<<DYNAMIC>>> add the tab
layout fields array to the model
CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode
. '|TABLAYOUTFIELDSARRAY',
$this->getTabLayoutFieldsArray(
$nameSingleCode
)
);
// ADMIN_VIEW_CONTROLLER_HEADER <<<DYNAMIC>>> add
the header details for the controller
CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode
. '|ADMIN_VIEW_CONTROLLER_HEADER',
CFactory::_('Header')->get(
'admin.view.controller',
$nameSingleCode
)
);
// ADMIN_VIEW_MODEL_HEADER <<<DYNAMIC>>> add the
header details for the model
CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode
. '|ADMIN_VIEW_MODEL_HEADER',
CFactory::_('Header')->get(
'admin.view.model', $nameSingleCode
)
);
// ADMIN_VIEW_HTML_HEADER <<<DYNAMIC>>> add the
header details for the view
CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode
. '|ADMIN_VIEW_HTML_HEADER',
CFactory::_('Header')->get(
'admin.view.html', $nameSingleCode
)
);
// ADMIN_VIEW_HEADER <<<DYNAMIC>>> add the header
details for the view
CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode
. '|ADMIN_VIEW_HEADER',
CFactory::_('Header')->get(
'admin.view', $nameSingleCode
)
);
// API_VIEW_CONTROLLER_HEADER <<<DYNAMIC>>> add the
header details for the controller
CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode
. '|API_VIEW_CONTROLLER_HEADER',
CFactory::_('Header')->get(
'api.view.controller',
$nameSingleCode
)
);
// API_VIEW_JSON_HEADER <<<DYNAMIC>>> add the header
details for the controller
CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode
. '|API_VIEW_JSON_HEADER',
CFactory::_('Header')->get(
'api.view.json',
$nameSingleCode
)
);
// JQUERY <<<DYNAMIC>>>
CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode
. '|JQUERY',
$this->setJquery(
$nameSingleCode
)
);
// Trigger Event: jcb_ce_onAfterBuildAdminEditViewContent
CFactory::_('Event')->trigger(
'jcb_ce_onAfterBuildAdminEditViewContent',[&$view,
&$nameSingleCode, &$nameListCode]
);
}
// set the views names
if (isset($view['settings']->name_list)
&& $view['settings']->name_list !=
'null')
{
CFactory::_('Config')->lang_target = 'admin';
// ICOMOON <<<DYNAMIC>>>
CFactory::_('Compiler.Builder.Content.Multi')->set($nameListCode
. '|ICOMOON', $view['icomoon']);
// Trigger Event: jcb_ce_onBeforeBuildAdminListViewContent
CFactory::_('Event')->trigger(
'jcb_ce_onBeforeBuildAdminListViewContent', [&$view,
&$nameSingleCode, &$nameListCode]
);
// set the export/import option
if (isset($view['port']) && $view['port']
|| 1 == $view['settings']->add_custom_import)
{
$this->eximportView[$nameListCode] = true;
if (1 == $view['settings']->add_custom_import)
{
// this view has custom import scripting
$this->importCustomScripts[$nameListCode]
= true;
// set all custom scripts
$this->setImportCustomScripts(
$nameListCode
);
}
}
else
{
$this->eximportView[$nameListCode]
= false;
}
// set Auto check in function
if (isset($view['checkin']) &&
$view['checkin'] == 1)
{
// AUTOCHECKIN <<<DYNAMIC>>>
CFactory::_('Compiler.Builder.Content.Multi')->set($nameListCode
. '|AUTOCHECKIN',
$this->setAutoCheckin(
$nameSingleCode,
CFactory::_('Config')->component_code_name
)
);
// CHECKINCALL <<<DYNAMIC>>>
CFactory::_('Compiler.Builder.Content.Multi')->set($nameListCode
. '|CHECKINCALL',
$this->setCheckinCall()
);
}
else
{
// AUTOCHECKIN <<<DYNAMIC>>>
CFactory::_('Compiler.Builder.Content.Multi')->set($nameListCode
. '|AUTOCHECKIN', '');
// CHECKINCALL <<<DYNAMIC>>>
CFactory::_('Compiler.Builder.Content.Multi')->set($nameListCode
. '|CHECKINCALL', '');
}
// admin list file contnet
CFactory::_('Compiler.Builder.Content.Multi')->set($nameListCode
. '|ADMIN_JAVASCRIPT_FILE',
$this->setViewScript(
$nameListCode, 'list_fileScript'
)
);
// ADMIN_CUSTOM_BUTTONS_LIST
CFactory::_('Compiler.Builder.Content.Multi')->set($nameListCode
. '|ADMIN_CUSTOM_BUTTONS_LIST',
$this->setCustomButtons($view, 3, Indent::_(1)));
CFactory::_('Compiler.Builder.Content.Multi')->set($nameListCode
. '|ADMIN_CUSTOM_FUNCTION_ONLY_BUTTONS_LIST',
$this->setFunctionOnlyButtons(
$nameListCode
)
);
// GET_ITEMS_METHOD_STRING_FIX <<<DYNAMIC>>>
CFactory::_('Compiler.Builder.Content.Multi')->set($nameListCode
. '|GET_ITEMS_METHOD_STRING_FIX',
$this->setGetItemsMethodStringFix(
$nameSingleCode,
$nameListCode,
CFactory::_('Compiler.Builder.Content.One')->get('Component')
)
);
// GET_ITEMS_METHOD_AFTER_ALL <<<DYNAMIC>>>
CFactory::_('Compiler.Builder.Content.Multi')->set($nameListCode
. '|GET_ITEMS_METHOD_AFTER_ALL',
CFactory::_('Customcode.Dispenser')->get(
'php_getitems_after_all',
$nameSingleCode, PHP_EOL
)
);
// SELECTIONTRANSLATIONFIX <<<DYNAMIC>>>
CFactory::_('Compiler.Builder.Content.Multi')->set($nameListCode
. '|SELECTIONTRANSLATIONFIX',
$this->setSelectionTranslationFix(
$nameListCode,
CFactory::_('Compiler.Builder.Content.One')->get('Component')
)
);
// SELECTIONTRANSLATIONFIXFUNC <<<DYNAMIC>>>
CFactory::_('Compiler.Builder.Content.Multi')->set($nameListCode
. '|SELECTIONTRANSLATIONFIXFUNC',
$this->setSelectionTranslationFixFunc(
$nameListCode,
CFactory::_('Compiler.Builder.Content.One')->get('Component')
)
);
// FILTER_FIELDS <<<DYNAMIC>>>
CFactory::_('Compiler.Builder.Content.Multi')->set($nameListCode
. '|FILTER_FIELDS',
$this->setFilterFieldsArray(
$nameSingleCode,
$nameListCode
)
);
// STOREDID <<<DYNAMIC>>>
CFactory::_('Compiler.Builder.Content.Multi')->set($nameListCode
. '|STOREDID',
$this->setStoredId(
$nameSingleCode, $nameListCode
)
);
// POPULATESTATE <<<DYNAMIC>>>
CFactory::_('Compiler.Builder.Content.Multi')->set($nameListCode
. '|POPULATESTATE',
$this->setPopulateState(
$nameSingleCode, $nameListCode
)
);
// SORTFIELDS <<<DYNAMIC>>>
CFactory::_('Compiler.Builder.Content.Multi')->set($nameListCode
. '|SORTFIELDS',
$this->setSortFields(
$nameListCode
)
);
// CATEGORY_VIEWS
CFactory::_('Compiler.Builder.Content.One')->add('ROUTER_CATEGORY_VIEWS',
$this->setRouterCategoryViews(
$nameSingleCode,
$nameListCode
));
// FILTERFIELDDISPLAYHELPER <<<DYNAMIC>>>
CFactory::_('Compiler.Builder.Content.Multi')->set($nameListCode
. '|FILTERFIELDDISPLAYHELPER',
$this->setFilterFieldSidebarDisplayHelper(
$nameSingleCode,
$nameListCode
)
);
// BATCHDISPLAYHELPER <<<DYNAMIC>>>
CFactory::_('Compiler.Builder.Content.Multi')->set($nameListCode
. '|BATCHDISPLAYHELPER',
$this->setBatchDisplayHelper(
$nameSingleCode,
$nameListCode
)
);
// FILTERFUNCTIONS <<<DYNAMIC>>>
CFactory::_('Compiler.Builder.Content.Multi')->set($nameListCode
. '|FILTERFUNCTIONS',
$this->setFilterFieldHelper(
$nameSingleCode,
$nameListCode
)
);
// FIELDFILTERSETS <<<DYNAMIC>>>
CFactory::_('Compiler.Builder.Content.Multi')->set('filter_'
. $nameListCode . '|FIELDFILTERSETS',
$this->setFieldFilterSet(
$nameSingleCode,
$nameListCode
));
// FIELDLISTSETS <<<DYNAMIC>>>
CFactory::_('Compiler.Builder.Content.Multi')->set('filter_'
. $nameListCode . '|FIELDLISTSETS',
$this->setFieldFilterListSet(
$nameSingleCode,
$nameListCode
));
// LISTQUERY <<<DYNAMIC>>>
CFactory::_('Compiler.Builder.Content.Multi')->set($nameListCode
. '|LISTQUERY',
$this->setListQuery(
$nameSingleCode,
$nameListCode
)
);
// MODELEXPORTMETHOD <<<DYNAMIC>>>
CFactory::_('Compiler.Builder.Content.Multi')->set($nameListCode
. '|MODELEXPORTMETHOD',
$this->setGetItemsModelMethod(
$nameSingleCode,
$nameListCode
)
);
// MODELEXIMPORTMETHOD <<<DYNAMIC>>>
CFactory::_('Compiler.Builder.Content.Multi')->set($nameListCode
. '|CONTROLLEREXIMPORTMETHOD',
$this->setControllerEximportMethod(
$nameSingleCode,
$nameListCode
)
);
// EXPORTBUTTON <<<DYNAMIC>>>
CFactory::_('Compiler.Builder.Content.Multi')->set($nameListCode
. '|EXPORTBUTTON',
$this->setExportButton(
$nameSingleCode,
$nameListCode
)
);
// IMPORTBUTTON <<<DYNAMIC>>>
CFactory::_('Compiler.Builder.Content.Multi')->set($nameListCode
. '|IMPORTBUTTON',
$this->setImportButton(
$nameSingleCode,
$nameListCode
)
);
// VIEWS_DEFAULT_BODY <<<DYNAMIC>>>
CFactory::_('Compiler.Builder.Content.Multi')->set($nameListCode
. '|VIEWS_DEFAULT_BODY',
$this->setDefaultViewsBody(
$nameSingleCode,
$nameListCode
)
);
// LISTHEAD <<<DYNAMIC>>>
CFactory::_('Compiler.Builder.Content.Multi')->set($nameListCode
. '|LISTHEAD',
$this->setListHead(
$nameSingleCode,
$nameListCode
)
);
// LISTBODY <<<DYNAMIC>>>
CFactory::_('Compiler.Builder.Content.Multi')->set($nameListCode
. '|LISTBODY',
$this->setListBody(
$nameSingleCode,
$nameListCode
)
);
// LISTCOLNR <<<DYNAMIC>>>
CFactory::_('Compiler.Builder.Content.Multi')->set($nameListCode
. '|LISTCOLNR',
$this->setListColnr(
$nameListCode
)
);
// JVIEWLISTCANDO <<<DYNAMIC>>>
CFactory::_('Compiler.Builder.Content.Multi')->set($nameListCode
. '|JVIEWLISTCANDO',
$this->setJviewListCanDo(
$nameSingleCode,
$nameListCode
)
);
// VIEWSCSS <<<DYNAMIC>>>
CFactory::_('Compiler.Builder.Content.Multi')->set($nameListCode
. '|VIEWSCSS',
CFactory::_('Customcode.Dispenser')->get(
'css_views', $nameSingleCode, '',
null, true
)
);
// ADMIN_DIPLAY_METHOD <<<DYNAMIC>>>
CFactory::_('Compiler.Builder.Content.Multi')->set($nameListCode
. '|ADMIN_DIPLAY_METHOD',
$this->setAdminViewDisplayMethod(
$nameListCode
)
);
// VIEWS_FOOTER_SCRIPT <<<DYNAMIC>>>
$scriptNote = PHP_EOL . '//' . Line::_(__Line__, __Class__)
. ' ' . $nameListCode
. ' footer script';
if (($footerScript =
CFactory::_('Customcode.Dispenser')->get(
'views_footer', $nameSingleCode, '',
$scriptNote, true,
false, PHP_EOL
)) !== false
&& StringHelper::check($footerScript))
{
// only minfy if no php is added to the footer script
if (CFactory::_('Config')->get('minify', 0)
&& strpos((string) $footerScript, '<?php') ===
false)
{
// minify the script
$footerScript = Minify::js($footerScript);
}
CFactory::_('Compiler.Builder.Content.Multi')->set($nameListCode
. '|VIEWS_FOOTER_SCRIPT',
PHP_EOL . '<script
type="text/javascript">'
. $footerScript . "</script>");
// clear some memory
unset($footerScript);
}
else
{
CFactory::_('Compiler.Builder.Content.Multi')->set($nameListCode
. '|VIEWS_FOOTER_SCRIPT', '');
}
// ADMIN_VIEWS_CONTROLLER_HEADER <<<DYNAMIC>>> add
the header details for the controller
CFactory::_('Compiler.Builder.Content.Multi')->set($nameListCode
. '|ADMIN_VIEWS_CONTROLLER_HEADER',
CFactory::_('Header')->get(
'admin.views.controller',
$nameListCode
)
);
// ADMIN_VIEWS_MODEL_HEADER <<<DYNAMIC>>> add the
header details for the model
CFactory::_('Compiler.Builder.Content.Multi')->set($nameListCode
. '|ADMIN_VIEWS_MODEL_HEADER',
CFactory::_('Header')->get(
'admin.views.model', $nameListCode
)
);
// ADMIN_VIEWS_HTML_HEADER <<<DYNAMIC>>> add the
header details for the views
CFactory::_('Compiler.Builder.Content.Multi')->set($nameListCode
. '|ADMIN_VIEWS_HTML_HEADER',
CFactory::_('Header')->get(
'admin.views.html', $nameListCode
)
);
// ADMIN_VIEWS_HEADER <<<DYNAMIC>>> add the header
details for the views
CFactory::_('Compiler.Builder.Content.Multi')->set($nameListCode
. '|ADMIN_VIEWS_HEADER',
CFactory::_('Header')->get(
'admin.views', $nameListCode
)
);
// API_VIEWS_CONTROLLER_HEADER <<<DYNAMIC>>> add the
header details for the controller
CFactory::_('Compiler.Builder.Content.Multi')->set($nameListCode
. '|API_VIEWS_CONTROLLER_HEADER',
CFactory::_('Header')->get(
'api.views.controller', $nameListCode
)
);
// API_VIEWS_JSON_HEADER <<<DYNAMIC>>> add the
header details for the controller
CFactory::_('Compiler.Builder.Content.Multi')->set($nameListCode
. '|API_VIEWS_JSON_HEADER',
CFactory::_('Header')->get(
'api.views.json', $nameListCode
)
);
// JQUERY <<<DYNAMIC>>>
CFactory::_('Compiler.Builder.Content.Multi')->set($nameListCode
. '|JQUERY',
$this->setJquery(
$nameSingleCode
)
);
// Trigger Event: jcb_ce_onAfterBuildAdminListViewContent
CFactory::_('Event')->trigger(
'jcb_ce_onAfterBuildAdminListViewContent', [&$view,
&$nameSingleCode, &$nameListCode]
);
}
// set u fields used in batch
CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode
. '|UNIQUEFIELDS',
$this->setUniqueFields(
$nameSingleCode
)
);
// TITLEALIASFIX <<<DYNAMIC>>>
CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode
. '|TITLEALIASFIX',
$this->setAliasTitleFix(
$nameSingleCode
)
);
// GENERATENEWTITLE <<<DYNAMIC>>>
CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode
. '|GENERATENEWTITLE',
$this->setGenerateNewTitle(
$nameSingleCode
)
);
// GENERATENEWALIAS <<<DYNAMIC>>>
CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode
. '|GENERATENEWALIAS',
$this->setGenerateNewAlias(
$nameSingleCode
)
);
// MODEL_BATCH_COPY <<<DYNAMIC>>>
CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode
. '|MODEL_BATCH_COPY',
$this->setBatchCopy($nameSingleCode)
);
// MODEL_BATCH_MOVE <<<DYNAMIC>>>
CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode
. '|MODEL_BATCH_MOVE',
$this->setBatchMove($nameSingleCode)
);
// BATCH_ONCLICK_CANCEL_SCRIPT <<<DYNAMIC>>>
CFactory::_('Compiler.Builder.Content.Multi')->set($nameListCode
. '|BATCH_ONCLICK_CANCEL_SCRIPT', ''); // TODO <--
must still be build
// JCONTROLLERFORM_ALLOWADD <<<DYNAMIC>>>
CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode
. '|JCONTROLLERFORM_ALLOWADD',
CFactory::_('Architecture.Controller.AllowAdd')->get(
$nameSingleCode,
)
);
// JCONTROLLERFORM_BEFORECANCEL <<<DYNAMIC>>>
CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode
. '|JCONTROLLERFORM_BEFORECANCEL',
CFactory::_('Customcode.Dispenser')->get(
'php_before_cancel', $nameSingleCode,
PHP_EOL, null, false,
''
)
);
// JCONTROLLERFORM_AFTERCANCEL <<<DYNAMIC>>>
CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode
. '|JCONTROLLERFORM_AFTERCANCEL',
CFactory::_('Customcode.Dispenser')->get(
'php_after_cancel', $nameSingleCode,
PHP_EOL, null, false,
''
)
);
// JCONTROLLERFORM_ALLOWEDIT <<<DYNAMIC>>>
CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode
. '|JCONTROLLERFORM_ALLOWEDIT',
CFactory::_('Architecture.Controller.AllowEdit')->get(
$nameSingleCode,
$nameListCode
)
);
// JMODELADMIN_GETFORM <<<DYNAMIC>>>
CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode
. '|JMODELADMIN_GETFORM',
$this->setJmodelAdminGetForm(
$nameSingleCode,
$nameListCode
)
);
// JMODELADMIN_ALLOWEDIT <<<DYNAMIC>>>
CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode
. '|JMODELADMIN_ALLOWEDIT',
$this->setJmodelAdminAllowEdit(
$nameSingleCode,
$nameListCode
)
);
// JMODELADMIN_CANDELETE <<<DYNAMIC>>>
CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode
. '|JMODELADMIN_CANDELETE',
CFactory::_('Architecture.Model.CanDelete')->get(
$nameSingleCode
)
);
// JMODELADMIN_CANEDITSTATE <<<DYNAMIC>>>
CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode
. '|JMODELADMIN_CANEDITSTATE',
CFactory::_('Architecture.Model.CanEditState')->get(
$nameSingleCode
)
);
// set custom admin view Toolbare buttons
// CUSTOM_ADMIN_DYNAMIC_BUTTONS <<<DYNAMIC>>>
CFactory::_('Compiler.Builder.Content.Multi')->set($nameListCode
. '|CUSTOM_ADMIN_DYNAMIC_BUTTONS',
$this->setCustomAdminDynamicButton(
$nameListCode
)
);
// CUSTOM_ADMIN_DYNAMIC_BUTTONS_CONTROLLER
<<<DYNAMIC>>>
CFactory::_('Compiler.Builder.Content.Multi')->set($nameListCode
. '|CUSTOM_ADMIN_DYNAMIC_BUTTONS_CONTROLLER',
$this->setCustomAdminDynamicButtonController(
$nameListCode
)
);
// set helper router
CFactory::_('Compiler.Builder.Content.One')->add('ROUTEHELPER',
$this->setRouterHelp(
$nameSingleCode,
$nameListCode
));
if (isset($view['edit_create_site_view'])
&& is_numeric(
$view['edit_create_site_view']
)
&& $view['edit_create_site_view'] > 0)
{
// add needed router stuff for front edit views
CFactory::_('Compiler.Builder.Content.One')->add('ROUTER_PARSE_SWITCH',
$this->routerParseSwitch(
$nameSingleCode, null, false
));
CFactory::_('Compiler.Builder.Content.One')->add('ROUTER_BUILD_VIEWS',
$this->routerBuildViews(
$nameSingleCode
));
}
// ACCESS_SECTIONS
CFactory::_('Compiler.Builder.Content.One')->add('ACCESS_SECTIONS',
CFactory::_('Compiler.Creator.Access.Sections.Category')->get(
$nameSingleCode,
$nameListCode
)
);
// set the Joomla Fields ACCESS section if needed
if (isset($view['joomla_fields'])
&& $view['joomla_fields'] == 1)
{
CFactory::_('Compiler.Builder.Content.One')->add('ACCESS_SECTIONS',
CFactory::_('Compiler.Creator.Access.Sections.Joomla.Fields')->get()
);
}
// Trigger Event: jcb_ce_onAfterBuildAdminViewContent
CFactory::_('Event')->trigger(
'jcb_ce_onAfterBuildAdminViewContent', [&$view,
&$nameSingleCode, &$nameListCode]
);
}
// setup the layouts
$this->setCustomViewLayouts();
// setup custom_admin_views and all needed stuff for the site
if
(CFactory::_('Component')->isArray('custom_admin_views'))
{
CFactory::_('Config')->build_target =
'custom_admin';
CFactory::_('Config')->lang_target = 'admin';
// start dynamic build
foreach
(CFactory::_('Component')->get('custom_admin_views')
as $view)
{
// for single views
CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code
. '|SView', $view['settings']->Code);
CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code
. '|sview', $view['settings']->code);
CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code
. '|SVIEW', $view['settings']->CODE);
// for list views
CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code
. '|SViews', $view['settings']->Code);
CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code
. '|sviews', $view['settings']->code);
CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code
. '|SVIEWS', $view['settings']->CODE);
// add to lang array
CFactory::_('Language')->set(
CFactory::_('Config')->lang_target,
CFactory::_('Config')->lang_prefix . '_' .
$view['settings']->CODE,
$view['settings']->name
);
CFactory::_('Language')->set(
CFactory::_('Config')->lang_target,
CFactory::_('Config')->lang_prefix . '_' .
$view['settings']->CODE
. '_DESC', $view['settings']->description
);
// ICOMOON <<<DYNAMIC>>>
CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code
. '|ICOMOON', $view['icomoon']);
// set placeholders
CFactory::_('Placeholder')->set('SView',
$view['settings']->Code);
CFactory::_('Placeholder')->set('sview',
$view['settings']->code);
CFactory::_('Placeholder')->set('SVIEW',
$view['settings']->CODE);
CFactory::_('Placeholder')->set('SViews',
$view['settings']->Code);
CFactory::_('Placeholder')->set('sviews',
$view['settings']->code);
CFactory::_('Placeholder')->set('SVIEWS',
$view['settings']->CODE);
// Trigger Event: jcb_ce_onBeforeBuildCustomAdminViewContent
CFactory::_('Event')->trigger(
'jcb_ce_onBeforeBuildCustomAdminViewContent', [&$view,
&$view['settings']->code]
);
// set license per view if needed
$this->setLockLicensePer(
$view['settings']->code,
CFactory::_('Config')->build_target
);
// check if this custom admin view is the default view
if
(CFactory::_('Registry')->get('build.dashboard.type',
'') === 'custom_admin_views'
&&
CFactory::_('Registry')->get('build.dashboard',
'') === $view['settings']->code)
{
// HIDEMAINMENU <<<DYNAMIC>>>
CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code
. '|HIDEMAINMENU', '');
}
else
{
// HIDEMAINMENU <<<DYNAMIC>>>
CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code
. '|HIDEMAINMENU',
PHP_EOL . Indent::_(2) . '//' . Line::_(
__LINE__,__CLASS__
) . " hide the main menu"
. PHP_EOL . Indent::_(2)
. "\$this->app->input->set('hidemainmenu',
true);"
);
}
if ($view['settings']->main_get->gettype == 1)
{
// CUSTOM_ADMIN_BEFORE_GET_ITEM <<<DYNAMIC>>>
CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code
. '|CUSTOM_ADMIN_BEFORE_GET_ITEM',
CFactory::_('Customcode.Dispenser')->get(
CFactory::_('Config')->build_target .
'_php_before_getitem',
$view['settings']->code, '', null, true
)
);
// CUSTOM_ADMIN_GET_ITEM <<<DYNAMIC>>>
CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code
. '|CUSTOM_ADMIN_GET_ITEM',
$this->setCustomViewGetItem(
$view['settings']->main_get,
$view['settings']->code, Indent::_(2)
)
);
// CUSTOM_ADMIN_AFTER_GET_ITEM <<<DYNAMIC>>>
CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code
. '|CUSTOM_ADMIN_AFTER_GET_ITEM',
CFactory::_('Customcode.Dispenser')->get(
CFactory::_('Config')->build_target .
'_php_after_getitem',
$view['settings']->code, '', null, true
)
);
}
elseif ($view['settings']->main_get->gettype == 2)
{
// CUSTOM_ADMIN_GET_LIST_QUERY <<<DYNAMIC>>>
CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code
. '|CUSTOM_ADMIN_GET_LIST_QUERY',
$this->setCustomViewListQuery(
$view['settings']->main_get,
$view['settings']->code
)
);
// CUSTOM_ADMIN_CUSTOM_BEFORE_LIST_QUERY
<<<DYNAMIC>>>
CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code
. '|CUSTOM_ADMIN_CUSTOM_BEFORE_LIST_QUERY',
CFactory::_('Customcode.Dispenser')->get(
CFactory::_('Config')->build_target .
'_php_getlistquery',
$view['settings']->code, PHP_EOL, null, true
)
);
// CUSTOM_ADMIN_BEFORE_GET_ITEMS <<<DYNAMIC>>>
CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code
. '|CUSTOM_ADMIN_BEFORE_GET_ITEMS',
CFactory::_('Customcode.Dispenser')->get(
CFactory::_('Config')->build_target .
'_php_before_getitems',
$view['settings']->code, PHP_EOL, null, true
)
);
// CUSTOM_ADMIN_GET_ITEMS <<<DYNAMIC>>>
CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code
. '|CUSTOM_ADMIN_GET_ITEMS',
$this->setCustomViewGetItems(
$view['settings']->main_get,
$view['settings']->code
)
);
// CUSTOM_ADMIN_AFTER_GET_ITEMS <<<DYNAMIC>>>
CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code
. '|CUSTOM_ADMIN_AFTER_GET_ITEMS',
CFactory::_('Customcode.Dispenser')->get(
CFactory::_('Config')->build_target .
'_php_after_getitems',
$view['settings']->code, PHP_EOL, null, true
)
);
}
// CUSTOM_ADMIN_CUSTOM_METHODS <<<DYNAMIC>>>
CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code
. '|CUSTOM_ADMIN_CUSTOM_METHODS',
$this->setCustomViewCustomItemMethods(
$view['settings']->main_get,
$view['settings']->code
)
);
CFactory::_('Compiler.Builder.Content.Multi')->add($view['settings']->code
. '|CUSTOM_ADMIN_CUSTOM_METHODS',
$this->setCustomViewCustomMethods(
$view, $view['settings']->code
). false
);
// CUSTOM_ADMIN_DIPLAY_METHOD <<<DYNAMIC>>>
CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code
. '|CUSTOM_ADMIN_DIPLAY_METHOD',
$this->setCustomViewDisplayMethod($view)
);
// set document details
$this->setPrepareDocument($view);
// CUSTOM_ADMIN_EXTRA_DIPLAY_METHODS <<<DYNAMIC>>>
CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code
. '|CUSTOM_ADMIN_EXTRA_DIPLAY_METHODS',
$this->setCustomViewExtraDisplayMethods($view)
);
// CUSTOM_ADMIN_CODE_BODY <<<DYNAMIC>>>
CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code
. '|CUSTOM_ADMIN_CODE_BODY',
$this->setCustomViewCodeBody($view)
);
// CUSTOM_ADMIN_BODY <<<DYNAMIC>>>
CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code
. '|CUSTOM_ADMIN_BODY',
$this->setCustomViewBody($view)
);
// CUSTOM_ADMIN_SUBMITBUTTON_SCRIPT <<<DYNAMIC>>>
CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code
. '|CUSTOM_ADMIN_SUBMITBUTTON_SCRIPT',
$this->setCustomViewSubmitButtonScript($view)
);
// setup the templates
$this->setCustomViewTemplateBody($view);
// set the site form if needed
CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code
. '|CUSTOM_ADMIN_TOP_FORM',
$this->setCustomViewForm(
$view['settings']->code,
$view['settings']->main_get->gettype, 1
)
);
CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code
. '|CUSTOM_ADMIN_BOTTOM_FORM',
$this->setCustomViewForm(
$view['settings']->code,
$view['settings']->main_get->gettype, 2
)
);
// set headers based on the main get type
if ($view['settings']->main_get->gettype == 1)
{
// CUSTOM_ADMIN_VIEW_CONTROLLER_HEADER
<<<DYNAMIC>>> add the header details for the controller
CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code
. '|CUSTOM_ADMIN_VIEW_CONTROLLER_HEADER',
CFactory::_('Header')->get(
'custom.admin.view.controller',
$view['settings']->code
)
);
// CUSTOM_ADMIN_VIEW_MODEL_HEADER <<<DYNAMIC>>> add
the header details for the model
CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code
. '|CUSTOM_ADMIN_VIEW_MODEL_HEADER',
CFactory::_('Header')->get(
'custom.admin.view.model',
$view['settings']->code
)
);
// CUSTOM_ADMIN_VIEW_HTML_HEADER <<<DYNAMIC>>> add
the header details for the view
CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code
. '|CUSTOM_ADMIN_VIEW_HTML_HEADER',
CFactory::_('Header')->get(
'custom.admin.view.html',
$view['settings']->code
)
);
// CUSTOM_ADMIN_VIEW_HEADER <<<DYNAMIC>>> add the
header details for the view
CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code
. '|CUSTOM_ADMIN_VIEW_HEADER',
CFactory::_('Header')->get(
'custom.admin.view',
$view['settings']->code
)
);
}
elseif ($view['settings']->main_get->gettype == 2)
{
// CUSTOM_ADMIN_VIEWS_CONTROLLER_HEADER
<<<DYNAMIC>>> add the header details for the controller
CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code
. '|CUSTOM_ADMIN_VIEWS_CONTROLLER_HEADER',
CFactory::_('Header')->get(
'custom.admin.views.controller',
$view['settings']->code
)
);
// CUSTOM_ADMIN_VIEWS_MODEL_HEADER <<<DYNAMIC>>>
add the header details for the model
CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code
. '|CUSTOM_ADMIN_VIEWS_MODEL_HEADER',
CFactory::_('Header')->get(
'custom.admin.views.model',
$view['settings']->code
)
);
// CUSTOM_ADMIN_VIEWS_HTML_HEADER <<<DYNAMIC>>> add
the header details for the view
CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code
. '|CUSTOM_ADMIN_VIEWS_HTML_HEADER',
CFactory::_('Header')->get(
'custom.admin.views.html',
$view['settings']->code
)
);
// CUSTOM_ADMIN_VIEWS_HEADER <<<DYNAMIC>>> add the
header details for the view
CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code
. '|CUSTOM_ADMIN_VIEWS_HEADER',
CFactory::_('Header')->get(
'custom.admin.views',
$view['settings']->code
)
);
}
// Trigger Event: jcb_ce_onAfterBuildCustomAdminViewContent
CFactory::_('Event')->trigger(
'jcb_ce_onAfterBuildCustomAdminViewContent', [&$view,
&$view['settings']->code]
);
}
// setup the layouts
$this->setCustomViewLayouts();
}
// ADMIN_HELPER_CLASS_HEADER
CFactory::_('Compiler.Builder.Content.One')->set('ADMIN_HELPER_CLASS_HEADER',
CFactory::_('Header')->get(
'admin.helper', 'admin'
));
// ADMIN_COMPONENT_HEADER
CFactory::_('Compiler.Builder.Content.One')->set('ADMIN_COMPONENT_HEADER',
CFactory::_('Header')->get(
'admin.component', 'admin'
));
// SITE_HELPER_CLASS_HEADER
CFactory::_('Compiler.Builder.Content.One')->set('SITE_HELPER_CLASS_HEADER',
CFactory::_('Header')->get(
'site.helper', 'site'
));
// SITE_COMPONENT_HEADER
CFactory::_('Compiler.Builder.Content.One')->set('SITE_COMPONENT_HEADER',
CFactory::_('Header')->get(
'site.component', 'site'
));
// SITE_ROUTER_HEADER (Joomla 4 and above)
CFactory::_('Compiler.Builder.Content.One')->set('SITE_ROUTER_HEADER',
CFactory::_('Header')->get(
'site.router', 'site'
));
// HELPER_EXEL
CFactory::_('Compiler.Builder.Content.One')->set('HELPER_EXEL',
$this->setHelperExelMethods());
// VIEWARRAY
CFactory::_('Compiler.Builder.Content.One')->set('VIEWARRAY',
PHP_EOL . implode("," . PHP_EOL, $viewarray)
);
// SITE_EDIT_VIEW_ARRAY (Joomla3 only)
CFactory::_('Compiler.Builder.Content.One')->set('SITE_EDIT_VIEW_ARRAY',
PHP_EOL . Indent::_(4) . "'" .
implode("'," . PHP_EOL . Indent::_(4) . "'",
array_keys($site_edit_view_array)) . "'"
);
// SITE_ALLOW_EDIT_VIEWS_ARRAY
CFactory::_('Compiler.Builder.Content.One')->set('SITE_ALLOW_EDIT_VIEWS_ARRAY',
CFactory::_('Architecture.Controller.AllowEditViews')->getArray($site_edit_view_array)
);
// SITE_ALLOW_EDIT_VIEWS_FUNCTIONS
CFactory::_('Compiler.Builder.Content.One')->set('SITE_ALLOW_EDIT_VIEWS_FUNCTIONS',
CFactory::_('Architecture.Controller.AllowEditViews')->getFunctions($site_edit_view_array)
);
// MAINMENUS
CFactory::_('Compiler.Builder.Content.One')->set('MAINMENUS',
$this->setMainMenus());
// SUBMENU
CFactory::_('Compiler.Builder.Content.One')->set('SUBMENU',
$this->setSubMenus());
// GET_CRYPT_KEY
CFactory::_('Compiler.Builder.Content.One')->set('GET_CRYPT_KEY',
$this->setGetCryptKey());
// set the license locker
$this->setLockLicense();
// CONTRIBUTORS
CFactory::_('Compiler.Builder.Content.One')->set('CONTRIBUTORS',
CFactory::_('Compiler.Builder.Contributors')->get('bom',
'')
);
// INSTALL
CFactory::_('Compiler.Builder.Content.One')->set('INSTALL',
$this->setInstall());
// UNINSTALL
CFactory::_('Compiler.Builder.Content.One')->set('UNINSTALL',
$this->setUninstall());
// UPDATE_VERSION_MYSQL
$this->setVersionController();
// only set these if default dashboard it used
if
(!CFactory::_('Registry')->get('build.dashboard'))
{
// DASHBOARDVIEW
CFactory::_('Compiler.Builder.Content.One')->set('DASHBOARDVIEW',
CFactory::_('Config')->component_code_name
);
// DASHBOARDICONS
CFactory::_('Compiler.Builder.Content.Multi')->set(CFactory::_('Config')->component_code_name
. '|DASHBOARDICONS',
$this->setDashboardIcons()
);
// DASHBOARDICONACCESS
CFactory::_('Compiler.Builder.Content.Multi')->set(CFactory::_('Config')->component_code_name
. '|DASHBOARDICONACCESS',
CFactory::_('Compiler.Builder.Permission.Dashboard')->build()
);
// DASH_MODEL_METHODS
CFactory::_('Compiler.Builder.Content.Multi')->set(CFactory::_('Config')->component_code_name
. '|DASH_MODEL_METHODS',
$this->setDashboardModelMethods()
);
// DASH_GET_CUSTOM_DATA
CFactory::_('Compiler.Builder.Content.Multi')->set(CFactory::_('Config')->component_code_name
. '|DASH_GET_CUSTOM_DATA',
$this->setDashboardGetCustomData()
);
// DASH_DISPLAY_DATA
CFactory::_('Compiler.Builder.Content.Multi')->set(CFactory::_('Config')->component_code_name
. '|DASH_DISPLAY_DATA',
$this->setDashboardDisplayData()
);
// DASH_VIEW_HEADER
CFactory::_('Compiler.Builder.Content.Multi')->set(CFactory::_('Config')->component_code_name
. '|DASH_VIEW_HEADER',
CFactory::_('Header')->get('dashboard.view',
'dashboard')
);
// DASH_VIEW_HTML_HEADER
CFactory::_('Compiler.Builder.Content.Multi')->set(CFactory::_('Config')->component_code_name
. '|DASH_VIEW_HTML_HEADER',
CFactory::_('Header')->get('dashboard.view.html',
'dashboard')
);
// DASH_MODEL_HEADER
CFactory::_('Compiler.Builder.Content.Multi')->set(CFactory::_('Config')->component_code_name
. '|DASH_MODEL_HEADER',
CFactory::_('Header')->get('dashboard.model',
'dashboard')
);
// DASH_CONTROLLER_HEADER
CFactory::_('Compiler.Builder.Content.Multi')->set(CFactory::_('Config')->component_code_name
. '|DASH_CONTROLLER_HEADER',
CFactory::_('Header')->get('dashboard.controller',
'dashboard')
);
}
else
{
// DASHBOARDVIEW
CFactory::_('Compiler.Builder.Content.One')->set('DASHBOARDVIEW',
CFactory::_('Registry')->get('build.dashboard')
);
}
// add import
if (CFactory::_('Config')->get('add_eximport',
false))
{
// setup import files
$target = array('admin' => 'import');
CFactory::_('Utilities.Structure')->build($target,
'import');
// IMPORT_EXT_METHOD <<<DYNAMIC>>>
CFactory::_('Compiler.Builder.Content.Multi')->set('import'
. '|IMPORT_EXT_METHOD',
PHP_EOL . PHP_EOL . CFactory::_('Placeholder')->update_(
\ComponentbuilderHelper::getDynamicScripts('ext')
)
);
// IMPORT_SETDATA_METHOD <<<DYNAMIC>>>
CFactory::_('Compiler.Builder.Content.Multi')->set('import'
. '|IMPORT_SETDATA_METHOD',
PHP_EOL . PHP_EOL . CFactory::_('Placeholder')->update_(
\ComponentbuilderHelper::getDynamicScripts('setdata')
)
);
// IMPORT_SAVE_METHOD <<<DYNAMIC>>>
CFactory::_('Compiler.Builder.Content.Multi')->set('import'
. '|IMPORT_SAVE_METHOD',
PHP_EOL . PHP_EOL . CFactory::_('Placeholder')->update_(
\ComponentbuilderHelper::getDynamicScripts('save')
)
);
// IMPORT_CONTROLLER_HEADER <<<DYNAMIC>>> add the
header details for the controller
CFactory::_('Compiler.Builder.Content.Multi')->set('import'
. '|IMPORT_CONTROLLER_HEADER',
CFactory::_('Header')->get(
'import.controller', 'import'
)
);
// IMPORT_MODEL_HEADER <<<DYNAMIC>>> add the header
details for the model
CFactory::_('Compiler.Builder.Content.Multi')->set('import'
. '|IMPORT_MODEL_HEADER',
CFactory::_('Header')->get(
'import.model', 'import'
)
);
}
// ensure that the ajax model and controller is set if needed
if (CFactory::_('Config')->get('add_ajax',
false))
{
// setup Ajax files
$target = array('admin' => 'ajax');
CFactory::_('Utilities.Structure')->build($target,
'ajax');
// set the controller
CFactory::_('Compiler.Builder.Content.Multi')->set('ajax'
. '|REGISTER_AJAX_TASK',
$this->setRegisterAjaxTask('admin')
);
CFactory::_('Compiler.Builder.Content.Multi')->set('ajax'
. '|AJAX_INPUT_RETURN',
$this->setAjaxInputReturn('admin')
);
// set the model header
CFactory::_('Compiler.Builder.Content.Multi')->set('ajax'
. '|AJAX_ADMIN_MODEL_HEADER',
CFactory::_('Header')->get('ajax.admin.model',
'ajax')
);
// set the module
CFactory::_('Compiler.Builder.Content.Multi')->set('ajax'
. '|AJAX_MODEL_METHODS',
$this->setAjaxModelMethods('admin')
);
}
// ensure that the site ajax model and controller is set if needed
if (CFactory::_('Config')->get('add_site_ajax',
false))
{
// setup Ajax files
$target = array('site' => 'ajax');
CFactory::_('Utilities.Structure')->build($target,
'ajax');
// set the controller
CFactory::_('Compiler.Builder.Content.Multi')->set('ajax'
. '|REGISTER_SITE_AJAX_TASK',
$this->setRegisterAjaxTask('site')
);
CFactory::_('Compiler.Builder.Content.Multi')->set('ajax'
. '|AJAX_SITE_INPUT_RETURN',
$this->setAjaxInputReturn('site')
);
// set the model header
CFactory::_('Compiler.Builder.Content.Multi')->set('ajax'
. '|AJAX_SITE_MODEL_HEADER',
CFactory::_('Header')->get('ajax.site.model',
'ajax')
);
// set the module
CFactory::_('Compiler.Builder.Content.Multi')->set('ajax'
. '|AJAX_SITE_MODEL_METHODS',
$this->setAjaxModelMethods('site')
);
}
// build the validation rules
if (($validationRules =
CFactory::_('Registry')->_('validation.rules')) !==
null)
{
foreach ($validationRules as $rule => $_php)
{
// setup rule file
$target = array('admin' => 'a_rule_zi');
CFactory::_('Utilities.Structure')->build($target,
'rule', $rule);
// set the JFormRule Name
CFactory::_('Compiler.Builder.Content.Multi')->set('a_rule_zi_'
. $rule . '|Name',
ucfirst((string) $rule)
);
// set the JFormRule PHP
CFactory::_('Compiler.Builder.Content.Multi')->set('a_rule_zi_'
. $rule . '|VALIDATION_RULE_METHODS',
PHP_EOL . $_php
);
}
}
// run the second run if needed
if (isset($this->secondRunAdmin)
&& ArrayHelper::check($this->secondRunAdmin))
{
// start dynamic build
foreach ($this->secondRunAdmin as $function => $arrays)
{
if (ArrayHelper::check($arrays)
&& StringHelper::check($function))
{
foreach ($arrays as $array)
{
$this->{$function}($array);
}
}
}
}
// CONFIG_FIELDSETS
$keepLang = CFactory::_('Config')->lang_target;
CFactory::_('Config')->lang_target = 'admin';
// run field sets for second time
CFactory::_('Compiler.Creator.Config.Fieldsets')->set(2);
CFactory::_('Config')->lang_target = $keepLang;
// setup front-views and all needed stuff for the site
if
(CFactory::_('Component')->isArray('site_views'))
{
CFactory::_('Config')->build_target = 'site';
// start dynamic build
foreach
(CFactory::_('Component')->get('site_views') as
$view)
{
// for list views
CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code
. '|SViews',
$view['settings']->Code
);
CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code
. '|sviews',
$view['settings']->code
);
// for single views
CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code
. '|SView',
$view['settings']->Code
);
CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code
. '|sview',
$view['settings']->code
);
// set placeholders
CFactory::_('Placeholder')->set('SView',
$view['settings']->Code);
CFactory::_('Placeholder')->set('sview',
$view['settings']->code);
CFactory::_('Placeholder')->set('SVIEW',
$view['settings']->CODE);
CFactory::_('Placeholder')->set('SViews',
$view['settings']->Code);
CFactory::_('Placeholder')->set('sviews',
$view['settings']->code);
CFactory::_('Placeholder')->set('SVIEWS',
$view['settings']->CODE);
// Trigger Event: jcb_ce_onBeforeBuildSiteViewContent
CFactory::_('Event')->trigger(
'jcb_ce_onBeforeBuildSiteViewContent', [&$view,
&$view['settings']->code]
);
// set license per view if needed
$this->setLockLicensePer(
$view['settings']->code,
CFactory::_('Config')->build_target
);
// set the site default view
if (isset($view['default_view'])
&& $view['default_view'] == 1)
{
CFactory::_('Compiler.Builder.Content.One')->set('SITE_DEFAULT_VIEW',
$view['settings']->code
);
}
// add site menu
if (isset($view['menu']) && $view['menu']
== 1)
{
// SITE_MENU_XML <<<DYNAMIC>>>
CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code
. '|SITE_MENU_XML',
$this->setCustomViewMenu($view)
);
}
// insure the needed route helper is loaded
CFactory::_('Compiler.Builder.Content.One')->add('ROUTEHELPER',
$this->setRouterHelp(
$view['settings']->code,
$view['settings']->code, true
));
// build route details
CFactory::_('Compiler.Builder.Content.One')->add('ROUTER_PARSE_SWITCH',
$this->routerParseSwitch(
$view['settings']->code, $view
));
CFactory::_('Compiler.Builder.Content.One')->add('ROUTER_BUILD_VIEWS',
$this->routerBuildViews($view['settings']->code)
);
if ($view['settings']->main_get->gettype == 1)
{
// set user permission access check USER_PERMISSION_CHECK_ACCESS
<<<DYNAMIC>>>
CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code
. '|USER_PERMISSION_CHECK_ACCESS',
$this->setUserPermissionCheckAccess($view, 1)
);
// SITE_BEFORE_GET_ITEM <<<DYNAMIC>>>
CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code
. '|SITE_BEFORE_GET_ITEM',
CFactory::_('Customcode.Dispenser')->get(
CFactory::_('Config')->build_target .
'_php_before_getitem',
$view['settings']->code, '', null, true
)
);
// SITE_GET_ITEM <<<DYNAMIC>>>
CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code
. '|SITE_GET_ITEM',
$this->setCustomViewGetItem(
$view['settings']->main_get,
$view['settings']->code, Indent::_(2)
)
);
// SITE_AFTER_GET_ITEM <<<DYNAMIC>>>
CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code
. '|SITE_AFTER_GET_ITEM',
CFactory::_('Customcode.Dispenser')->get(
CFactory::_('Config')->build_target .
'_php_after_getitem',
$view['settings']->code, '', null, true
)
);
}
elseif ($view['settings']->main_get->gettype == 2)
{
// set user permission access check USER_PERMISSION_CHECK_ACCESS
<<<DYNAMIC>>>
CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code
. '|USER_PERMISSION_CHECK_ACCESS',
$this->setUserPermissionCheckAccess($view, 2)
);
// SITE_GET_LIST_QUERY <<<DYNAMIC>>>
CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code
. '|SITE_GET_LIST_QUERY',
$this->setCustomViewListQuery(
$view['settings']->main_get,
$view['settings']->code
)
);
// SITE_BEFORE_GET_ITEMS <<<DYNAMIC>>>
CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code
. '|SITE_BEFORE_GET_ITEMS',
CFactory::_('Customcode.Dispenser')->get(
CFactory::_('Config')->build_target .
'_php_before_getitems',
$view['settings']->code, PHP_EOL, null, true
));
// SITE_GET_ITEMS <<<DYNAMIC>>>
CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code
. '|SITE_GET_ITEMS',
$this->setCustomViewGetItems(
$view['settings']->main_get,
$view['settings']->code
)
);
// SITE_AFTER_GET_ITEMS <<<DYNAMIC>>>
CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code
. '|SITE_AFTER_GET_ITEMS',
CFactory::_('Customcode.Dispenser')->get(
CFactory::_('Config')->build_target .
'_php_after_getitems',
$view['settings']->code, PHP_EOL, null, true
)
);
}
// add to lang array
CFactory::_('Language')->set(
'site',
CFactory::_('Config')->lang_prefix . '_' .
$view['settings']->CODE,
$view['settings']->name
);
CFactory::_('Language')->set(
'site',
CFactory::_('Config')->lang_prefix . '_' .
$view['settings']->CODE
. '_DESC', $view['settings']->description
);
// SITE_CUSTOM_METHODS <<<DYNAMIC>>>
CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code
. '|SITE_CUSTOM_METHODS',
$this->setCustomViewCustomItemMethods(
$view['settings']->main_get,
$view['settings']->code
)
);
CFactory::_('Compiler.Builder.Content.Multi')->add($view['settings']->code
. '|SITE_CUSTOM_METHODS',
$this->setCustomViewCustomMethods(
$view, $view['settings']->code
), false
);
// SITE_DIPLAY_METHOD <<<DYNAMIC>>>
CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code
. '|SITE_DIPLAY_METHOD',
$this->setCustomViewDisplayMethod($view)
);
// set document details
$this->setPrepareDocument($view);
// SITE_EXTRA_DIPLAY_METHODS <<<DYNAMIC>>>
CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code
. '|SITE_EXTRA_DIPLAY_METHODS',
$this->setCustomViewExtraDisplayMethods($view)
);
// SITE_CODE_BODY <<<DYNAMIC>>>
CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code
. '|SITE_CODE_BODY',
$this->setCustomViewCodeBody($view)
);
// SITE_BODY <<<DYNAMIC>>>
CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code
. '|SITE_BODY',
$this->setCustomViewBody($view)
);
// setup the templates
$this->setCustomViewTemplateBody($view);
// set the site form if needed
CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code
. '|SITE_TOP_FORM',
$this->setCustomViewForm(
$view['settings']->code,
$view['settings']->main_get->gettype, 1
)
);
CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code
. '|SITE_BOTTOM_FORM',
$this->setCustomViewForm(
$view['settings']->code,
$view['settings']->main_get->gettype, 2
)
);
// set headers based on the main get type
if ($view['settings']->main_get->gettype == 1)
{
// insure the controller headers are added
if (StringHelper::check(
$view['settings']->php_controller
)
&& $view['settings']->php_controller !=
'//')
{
// SITE_VIEW_CONTROLLER_HEADER <<<DYNAMIC>>> add
the header details for the model
CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code
. '|SITE_VIEW_CONTROLLER_HEADER',
CFactory::_('Header')->get(
'site.view.controller',
$view['settings']->code
)
);
}
// SITE_VIEW_MODEL_HEADER <<<DYNAMIC>>> add the
header details for the model
CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code
. '|SITE_VIEW_MODEL_HEADER',
CFactory::_('Header')->get(
'site.view.model', $view['settings']->code
)
);
// SITE_VIEW_HTML_HEADER <<<DYNAMIC>>> add the
header details for the view
CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code
. '|SITE_VIEW_HTML_HEADER',
CFactory::_('Header')->get(
'site.view.html', $view['settings']->code
)
);
// SITE_VIEW_HEADER <<<DYNAMIC>>> add the header
details for the view
CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code
. '|SITE_VIEW_HEADER',
CFactory::_('Header')->get(
'site.view', $view['settings']->code
)
);
}
elseif ($view['settings']->main_get->gettype == 2)
{
// insure the controller headers are added
if (StringHelper::check(
$view['settings']->php_controller
)
&& $view['settings']->php_controller !=
'//')
{
// SITE_VIEW_CONTROLLER_HEADER <<<DYNAMIC>>> add
the header details for the model
CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code
. '|SITE_VIEW_CONTROLLER_HEADER',
CFactory::_('Header')->get(
'site.views.controller',
$view['settings']->code
)
);
}
// SITE_VIEWS_MODEL_HEADER <<<DYNAMIC>>> add the
header details for the model
CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code
. '|SITE_VIEWS_MODEL_HEADER',
CFactory::_('Header')->get(
'site.views.model', $view['settings']->code
)
);
// SITE_VIEWS_HTML_HEADER <<<DYNAMIC>>> add the
header details for the view
CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code
. '|SITE_VIEWS_HTML_HEADER',
CFactory::_('Header')->get(
'site.views.html', $view['settings']->code
)
);
// SITE_VIEWS_HEADER <<<DYNAMIC>>> add the header
details for the view
CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code
. '|SITE_VIEWS_HEADER',
CFactory::_('Header')->get(
'site.views', $view['settings']->code
)
);
}
// Trigger Event: jcb_ce_onAfterBuildSiteViewContent
CFactory::_('Event')->trigger(
'jcb_ce_onAfterBuildSiteViewContent', [&$view,
&$view['settings']->code]
);
}
// setup the layouts
$this->setCustomViewLayouts();
}
else
{
// clear all site folder since none is needed
CFactory::_('Config')->remove_site_folder = true;
}
// load the site statics
if (!CFactory::_('Config')->remove_site_folder ||
!CFactory::_('Config')->remove_site_edit_folder)
{
CFactory::_('Config')->build_target = 'site';
// if no default site view was set, the redirect to root
if
(!CFactory::_('Compiler.Builder.Content.One')->exists('SITE_DEFAULT_VIEW'))
{
CFactory::_('Compiler.Builder.Content.One')->set('SITE_DEFAULT_VIEW',
'');
}
// set site custom script to helper class
// SITE_CUSTOM_HELPER_SCRIPT
CFactory::_('Compiler.Builder.Content.One')->set('SITE_CUSTOM_HELPER_SCRIPT',
CFactory::_('Placeholder')->update_(
CFactory::_('Customcode.Dispenser')->hub['component_php_helper_site']
));
// SITE_GLOBAL_EVENT_HELPER
if
(!CFactory::_('Compiler.Builder.Content.One')->exists('SITE_GLOBAL_EVENT'))
{
CFactory::_('Compiler.Builder.Content.One')->set('SITE_GLOBAL_EVENT',
'');
}
if
(!CFactory::_('Compiler.Builder.Content.One')->exists('SITE_GLOBAL_EVENT_HELPER'))
{
CFactory::_('Compiler.Builder.Content.One')->set('SITE_GLOBAL_EVENT_HELPER',
'');
}
// now load the data for the global event if needed
if
(CFactory::_('Component')->get('add_site_event', 0)
== 1)
{
CFactory::_('Compiler.Builder.Content.One')->add('SITE_GLOBAL_EVENT',
PHP_EOL . PHP_EOL . "//" . Line::_(
__LINE__,__CLASS__
) . "Trigger the Global Site Event");
CFactory::_('Compiler.Builder.Content.One')->add('SITE_GLOBAL_EVENT',
PHP_EOL .
CFactory::_('Compiler.Builder.Content.One')->get('Component')
. 'Helper::globalEvent(Factory::getDocument());');
// SITE_GLOBAL_EVENT_HELPER
CFactory::_('Compiler.Builder.Content.One')->add('SITE_GLOBAL_EVENT_HELPER',
PHP_EOL . PHP_EOL . Indent::_(1) . '/**'
);
CFactory::_('Compiler.Builder.Content.One')->add('SITE_GLOBAL_EVENT_HELPER',
PHP_EOL . Indent::_(1)
. '* The Global Site Event Method.');
CFactory::_('Compiler.Builder.Content.One')->add('SITE_GLOBAL_EVENT_HELPER',
PHP_EOL . Indent::_(1) . '**/'
);
CFactory::_('Compiler.Builder.Content.One')->add('SITE_GLOBAL_EVENT_HELPER',
PHP_EOL . Indent::_(1)
. 'public static function globalEvent($document)');
CFactory::_('Compiler.Builder.Content.One')->add('SITE_GLOBAL_EVENT_HELPER',
PHP_EOL . Indent::_(1) . '{'
);
CFactory::_('Compiler.Builder.Content.One')->add('SITE_GLOBAL_EVENT_HELPER',
PHP_EOL . CFactory::_('Placeholder')->update_(
CFactory::_('Customcode.Dispenser')->hub['component_php_site_event']
));
CFactory::_('Compiler.Builder.Content.One')->add('SITE_GLOBAL_EVENT_HELPER',
PHP_EOL . Indent::_(1) . '}'
);
}
}
// PREINSTALLSCRIPT
CFactory::_('Compiler.Builder.Content.One')->add('PREINSTALLSCRIPT',
CFactory::_('Customcode.Dispenser')->get(
'php_preflight', 'install', PHP_EOL, null, true
));
// PREUPDATESCRIPT
CFactory::_('Compiler.Builder.Content.One')->add('PREUPDATESCRIPT',
CFactory::_('Customcode.Dispenser')->get(
'php_preflight', 'update', PHP_EOL, null, true
));
// POSTINSTALLSCRIPT
CFactory::_('Compiler.Builder.Content.One')->add('POSTINSTALLSCRIPT',
$this->setPostInstallScript());
// POSTUPDATESCRIPT
CFactory::_('Compiler.Builder.Content.One')->add('POSTUPDATESCRIPT',
$this->setPostUpdateScript());
// UNINSTALLSCRIPT
CFactory::_('Compiler.Builder.Content.One')->add('UNINSTALLSCRIPT',
$this->setUninstallScript());
// INSTALLERMETHODS
CFactory::_('Compiler.Builder.Content.One')->add('INSTALLERMETHODS',
CFactory::_('Customcode.Dispenser')->get(
'php_method', 'install', PHP_EOL
));
// MOVEFOLDERSSCRIPT
CFactory::_('Compiler.Builder.Content.One')->set('MOVEFOLDERSSCRIPT',
$this->setMoveFolderScript());
// INSTALLERMETHODS2
CFactory::_('Compiler.Builder.Content.One')->add('INSTALLERMETHODS',
$this->setMoveFolderMethod());
// HELPER_UIKIT
CFactory::_('Compiler.Builder.Content.One')->set('HELPER_UIKIT',
$this->setUikitHelperMethods());
// CONFIG_FIELDSETS
CFactory::_('Compiler.Builder.Content.One')->set('CONFIG_FIELDSETS',
implode(PHP_EOL,
CFactory::_('Compiler.Builder.Config.Fieldsets')->get('component',
[])
)
);
// check if this has been set
if
(!CFactory::_('Compiler.Builder.Content.One')->exists('ROUTER_BUILD_VIEWS')
|| !StringHelper::check(
CFactory::_('Compiler.Builder.Content.One')->get('ROUTER_BUILD_VIEWS')
))
{
CFactory::_('Compiler.Builder.Content.One')->set('ROUTER_BUILD_VIEWS',
0);
}
else
{
CFactory::_('Compiler.Builder.Content.One')->set('ROUTER_BUILD_VIEWS',
'(' .
CFactory::_('Compiler.Builder.Content.One')->get('ROUTER_BUILD_VIEWS')
. ')'
);
}
// README
if (CFactory::_('Component')->get('addreadme'))
{
CFactory::_('Compiler.Builder.Content.One')->set('README',
CFactory::_('Component')->get('readme')
);
}
// CHANGELOG
if (($changelog =
CFactory::_('Component')->get('changelog')) !==
null)
{
CFactory::_('Compiler.Builder.Content.One')->set('CHANGELOG',
$changelog);
}
// ROUTER
if (CFactory::_('Config')->get('joomla_version',
3) != 3)
{
// build route constructor before parent call
CFactory::_('Compiler.Builder.Content.One')->set('SITE_ROUTER_CONSTRUCTOR_BEFORE_PARENT',
CFactory::_('Compiler.Creator.Router')->getConstructor()
);
// build route constructor after parent call
CFactory::_('Compiler.Builder.Content.One')->set('SITE_ROUTER_CONSTRUCTOR_AFTER_PARENT',
CFactory::_('Compiler.Creator.Router')->getConstructorAfterParent()
);
// build route methods
CFactory::_('Compiler.Builder.Content.One')->set('SITE_ROUTER_METHODS',
CFactory::_('Compiler.Creator.Router')->getMethods()
);
}
// all fields stored in database
CFactory::_('Compiler.Builder.Content.One')->set('ALL_COMPONENT_FIELDS',
CFactory::_('Compiler.Builder.Component.Fields')->varExport(null,
1)
);
// set the autoloader for Powers
CFactory::_('Power.Autoloader')->setFiles();
// tweak system to set stuff to the module domain
$_backup_target = CFactory::_('Config')->build_target;
$_backup_lang = CFactory::_('Config')->lang_target;
$_backup_langPrefix = CFactory::_('Config')->lang_prefix;
// infuse module data if set
if (CFactory::_('Joomlamodule.Data')->exists())
{
foreach (CFactory::_('Joomlamodule.Data')->get() as
$module)
{
if (ObjectHelper::check($module))
{
// Trigger Event: jcb_ce_onBeforeInfuseModuleData
CFactory::_('Event')->trigger(
'jcb_ce_onBeforeInfuseModuleData', [&$module]
);
CFactory::_('Config')->build_target = $module->key;
CFactory::_('Config')->lang_target = $module->key;
$this->langPrefix = $module->lang_prefix;
CFactory::_('Config')->set('lang_prefix',
$module->lang_prefix);
// MODCODE
CFactory::_('Compiler.Builder.Content.Multi')->set($module->key
. '|MODCODE',
$this->getModCode($module)
);
// DYNAMICGET
CFactory::_('Compiler.Builder.Content.Multi')->set($module->key
. '|DYNAMICGETS',
$this->setCustomViewCustomMethods(
$module, $module->key
)
);
// HELPERCODE
if ($module->add_class_helper >= 1)
{
CFactory::_('Compiler.Builder.Content.Multi')->set($module->key
. '|HELPERCODE',
$this->getModHelperCode($module)
);
}
// MODDEFAULT
CFactory::_('Compiler.Builder.Content.Multi')->set($module->key
. '|MODDEFAULT',
$this->getModDefault($module, $module->key)
);
// MODDEFAULT_XXX
$this->setModTemplates($module);
// only add install script if needed
if ($module->add_install_script)
{
// INSTALLCLASS
CFactory::_('Compiler.Builder.Content.Multi')->set($module->key
. '|INSTALLCLASS',
CFactory::_('Extension.InstallScript')->get($module)
);
}
// FIELDSET
if (isset($module->form_files)
&& ArrayHelper::check(
$module->form_files
))
{
foreach ($module->form_files as $file => $files)
{
foreach ($files as $field_name => $fieldsets)
{
foreach ($fieldsets as $fieldset => $fields)
{
// FIELDSET_ . $file.$field_name.$fieldset
CFactory::_('Compiler.Builder.Content.Multi')->set($module->key
.
'|FIELDSET_' . $file . $field_name . $fieldset,
CFactory::_('Compiler.Creator.Fieldset.Extension')->get(
$module, $fields
)
);
}
}
}
}
// MAINXML
CFactory::_('Compiler.Builder.Content.Multi')->set($module->key
. '|MAINXML',
$this->getModuleMainXML($module)
);
// Trigger Event: jcb_ce_onAfterInfuseModuleData
CFactory::_('Event')->trigger(
'jcb_ce_onAfterInfuseModuleData', [&$module]
);
}
}
}
// infuse plugin data if set
CFactory::_('Joomlaplugin.Infusion')->set();
// rest globals
CFactory::_('Config')->build_target = $_backup_target;
CFactory::_('Config')->lang_target = $_backup_lang;
$this->langPrefix = $_backup_langPrefix;
CFactory::_('Config')->set('lang_prefix',
$_backup_langPrefix);
// Trigger Event: jcb_ce_onAfterBuildFilesContent
CFactory::_('Event')->trigger(
'jcb_ce_onAfterBuildFilesContent'
);
return true;
}
return false;
}
/**
* Set the view place holders to global scope
*
* @param object $view The view settings
*
* @ return void
*/
protected function setViewPlaceholders(&$view)
{
// just to be safe, lets clear previous view placeholders
CFactory::_('Placeholder')->clearType('view');
CFactory::_('Placeholder')->clearType('views');
// VIEW <<<DYNAMIC>>>
if (isset($view->name_single) && $view->name_single !=
'null')
{
// set main keys
$nameSingleCode = $view->name_single_code;
$name_single_uppercase = StringHelper::safe(
$view->name_single, 'U'
);
$name_single_first_uppercase = StringHelper::safe(
$view->name_single, 'F'
);
// set some place holder for the views
CFactory::_('Placeholder')->set('view',
$nameSingleCode);
CFactory::_('Placeholder')->set('View',
$name_single_first_uppercase);
CFactory::_('Placeholder')->set('VIEW',
$name_single_uppercase);
}
// VIEWS <<<DYNAMIC>>>
if (isset($view->name_list) && $view->name_list !=
'null')
{
$nameListCode = $view->name_list_code;
$name_list_uppercase = StringHelper::safe(
$view->name_list, 'U'
);
$name_list_first_uppercase = StringHelper::safe(
$view->name_list, 'F'
);
// set some place holder for the views
CFactory::_('Placeholder')->set('views',
$nameListCode);
CFactory::_('Placeholder')->set('Views',
$name_list_first_uppercase);
CFactory::_('Placeholder')->set('VIEWS',
$name_list_uppercase);
}
// view <<<DYNAMIC>>>
if (isset($nameSingleCode))
{
CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode
. '|view', $nameSingleCode);
CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode
. '|VIEW', $name_single_uppercase);
CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode
. '|View', $name_single_first_uppercase);
if (isset($nameListCode))
{
CFactory::_('Compiler.Builder.Content.Multi')->set($nameListCode
. '|view', $nameSingleCode);
CFactory::_('Compiler.Builder.Content.Multi')->set($nameListCode
. '|VIEW', $name_single_uppercase);
CFactory::_('Compiler.Builder.Content.Multi')->set($nameListCode
. '|View', $name_single_first_uppercase);
}
}
// views <<<DYNAMIC>>>
if (isset($nameListCode))
{
CFactory::_('Compiler.Builder.Content.Multi')->set($nameListCode
. '|views', $nameListCode);
CFactory::_('Compiler.Builder.Content.Multi')->set($nameListCode
. '|VIEWS', $name_list_uppercase);
CFactory::_('Compiler.Builder.Content.Multi')->set($nameListCode
. '|Views', $name_list_first_uppercase);
if (isset($nameSingleCode))
{
CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode
. '|views', $nameListCode);
CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode
. '|VIEWS', $name_list_uppercase);
CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode
. '|Views', $name_list_first_uppercase);
}
}
}
/**
* Build the language values and insert into file
*
* @return void
*/
public function setLangFileData(): void
{
// add final list of needed lang strings
$componentName =
CFactory::_('Component')->get('name');
$componentName = OutputFilter::cleanText($componentName);
$langTag = CFactory::_('Config')->get('lang_tag',
'en-GB');
// Trigger Event: jcb_ce_onBeforeLoadingAllLangStrings
CFactory::_('Event')->trigger(
'jcb_ce_onBeforeLoadingAllLangStrings', [&$componentName]
);
// reset values
$values = [];
$mainLangLoader = [];
// check the admin lang is set
if ($this->setLangAdmin($componentName))
{
$values[] = array_values(
CFactory::_('Compiler.Builder.Languages')->get("components.{$langTag}.admin")
);
$mainLangLoader['admin'] = count(
CFactory::_('Compiler.Builder.Languages')->get("components.{$langTag}.admin")
);
}
// check the admin system lang is set
if ($this->setLangAdminSys())
{
$values[] = array_values(
CFactory::_('Compiler.Builder.Languages')->get("components.{$langTag}.adminsys")
);
$mainLangLoader['adminsys'] = count(
CFactory::_('Compiler.Builder.Languages')->get("components.{$langTag}.adminsys")
);
}
// check the site lang is set
if ((!CFactory::_('Config')->remove_site_folder ||
!CFactory::_('Config')->remove_site_edit_folder)
&& $this->setLangSite($componentName))
{
$values[] = array_values(
CFactory::_('Compiler.Builder.Languages')->get("components.{$langTag}.site")
);
$mainLangLoader['site'] = count(
CFactory::_('Compiler.Builder.Languages')->get("components.{$langTag}.site")
);
}
// check the site system lang is set
if ((!CFactory::_('Config')->remove_site_folder ||
!CFactory::_('Config')->remove_site_edit_folder)
&& $this->setLangSiteSys($componentName))
{
$values[] = array_values(
CFactory::_('Compiler.Builder.Languages')->get("components.{$langTag}.sitesys")
);
$mainLangLoader['sitesys'] = count(
CFactory::_('Compiler.Builder.Languages')->get("components.{$langTag}.sitesys")
);
}
$values = array_unique(ArrayHelper::merge($values));
// get the other lang strings if there is any
CFactory::_('Compiler.Builder.Multilingual')->set('components',
CFactory::_('Language.Multilingual')->get($values)
);
// update insert the current lang in to DB
CFactory::_('Language.Set')->execute($values,
CFactory::_('Config')->component_id);
// remove old unused language strings
CFactory::_('Language.Purge')->execute($values,
CFactory::_('Config')->component_id);
// path to INI file
$getPAth = CFactory::_('Utilities.Paths')->template_path .
'/en-GB.com_admin.ini';
// Trigger Event: jcb_ce_onBeforeBuildAllLangFiles
CFactory::_('Event')->trigger(
'jcb_ce_onBeforeBuildAllLangFiles', ['components']
);
// now we insert the values into the files
if
(CFactory::_('Compiler.Builder.Languages')->IsArray("components"))
{
// rest xml array
$langXML = [];
foreach
(CFactory::_('Compiler.Builder.Languages')->get("components")
as $tag => $areas)
{
// trim the tag
$tag = trim((string) $tag);
foreach ($areas as $area => $languageStrings)
{
// set naming convention
$p = 'admin';
$t = '';
if (strpos((string) $area, 'site') !== false)
{
if (CFactory::_('Config')->remove_site_folder
&&
CFactory::_('Config')->remove_site_edit_folder)
{
continue;
}
$p = 'site';
}
if (strpos((string) $area, 'sys') !== false)
{
$t = '.sys';
}
// build the file name
$file_name = $tag . '.com_' .
CFactory::_('Config')->component_code_name . $t
. '.ini';
// check if language should be added
if (CFactory::_('Language.Translation')->check(
$tag, $languageStrings, $mainLangLoader[$area],
$file_name
))
{
// build the path to place the lang file
$path = CFactory::_('Utilities.Paths')->component_path .
'/' . $p . '/language/'
. $tag . '/';
if (!Folder::exists($path))
{
Folder::create($path);
// count the folder created
CFactory::_('Utilities.Counter')->folder++;
}
// move the file to its place
File::copy($getPAth, $path . $file_name);
// count the file created
CFactory::_('Utilities.Counter')->file++;
// add content to it
$lang = array_map(
fn($langstring, $placeholder) => $placeholder .
'="' . $langstring . '"',
array_values($languageStrings),
array_keys($languageStrings)
);
// add to language file
CFactory::_('Utilities.File')->write(
$path . $file_name, implode(PHP_EOL, $lang)
);
// set the line counter
CFactory::_('Utilities.Counter')->line += count(
(array) $lang
);
unset($lang);
// build xml strings
if (!isset($langXML[$p]))
{
$langXML[$p] = [];
}
$langXML[$p][] = '<language tag="' . $tag
. '">language/'
. $tag . '/' . $file_name .
'</language>';
}
}
}
// load the lang xml
if (ArrayHelper::check($langXML))
{
$replace = [];
if (isset($langXML['admin'])
&& ArrayHelper::check($langXML['admin']))
{
$replace[Placefix::_h('ADMIN_LANGUAGES')]
= implode(PHP_EOL . Indent::_(3), $langXML['admin']);
}
if ((!CFactory::_('Config')->remove_site_folder ||
!CFactory::_('Config')->remove_site_edit_folder)
&& isset($langXML['site'])
&& ArrayHelper::check($langXML['site']))
{
$replace[Placefix::_h('SITE_LANGUAGES')]
= implode(PHP_EOL . Indent::_(2), $langXML['site']);
}
// build xml path
$xmlPath = CFactory::_('Utilities.Paths')->component_path
. '/' . CFactory::_('Config')->component_code_name
. '.xml';
// get the content in xml
$componentXML = FileHelper::getContent(
$xmlPath
);
// update the xml content
$componentXML =
CFactory::_('Placeholder')->update($componentXML, $replace);
// store the values back to xml
CFactory::_('Utilities.File')->write($xmlPath,
$componentXML);
}
}
}
}
src/Componentbuilder/Compiler/Helper/Interpretation.php000064400003212466151162054130017371
0ustar00<?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\Helper;
use Joomla\CMS\Filesystem\File;
use Joomla\CMS\Filesystem\Folder;
use Joomla\CMS\Language\Text;
// use
VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper;
(for Joomla 4 and above)
use VDM\Joomla\FOF\Encrypt\AES;
use VDM\Joomla\Utilities\StringHelper;
use VDM\Joomla\Utilities\ArrayHelper;
use VDM\Joomla\Utilities\ObjectHelper;
use VDM\Joomla\Utilities\GetHelper;
use VDM\Joomla\Utilities\FileHelper;
use VDM\Joomla\Utilities\MathHelper;
use VDM\Joomla\Componentbuilder\Compiler\Factory as CFactory;
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\Utilities\Minify;
use VDM\Joomla\Componentbuilder\Compiler\Helper\Fields;
/**
* Interpretation class
*
* @deprecated 3.3
*/
class Interpretation extends Fields
{
/**
* The global config Field Sets
*
* @var array
* @deprecated 3.3 Use
CFactory::_('Compiler.Builder.Config.Fieldsets')->add($key,
$value);
*/
public $configFieldSets = [];
/**
* The global config Field Sets Custom Fields
*
* @var array
* @deprecated 3.3 Use
CFactory::_('Compiler.Builder.Config.Fieldsets.Customfield')->add($key,
$value);
*/
public $configFieldSetsCustomField = [];
/**
* The contributors
*
* @var string
*/
public $theContributors = '';
/**
* The unistall builder
*
* @var array
* @deprecated 3.3 Use
CFactory::_('Builder.Database.Uninstall')->set(...);
*/
public $uninstallBuilder = [];
/**
* The update SQL builder
*
* @var array
* @deprecated 3.3 Use
CFactory::_('Model.Updatesql')->set($old, $new, string $type,
$key = null, ?array $ignore = null);
*/
public $updateSQLBuilder = [];
/**
* The List Column Builder
*
* @var array
*/
public $listColnrBuilder = [];
/**
* The permissions Builder
*
* @var array
* @deprecated 3.3 Use
CFactory::_('Compiler.Builder.Permission.Action')->set($action,
$nameView, $nameView);
* @deprecated 3.3 or Use
CFactory::_('Compiler.Builder.Permission.Global')->set($action,
$nameView, $nameView);
*/
public $permissionBuilder = [];
/**
* The dashboard permissions builder
*
* @var array
* @deprecated 3.3 Use
CFactory::_('Compiler.Builder.Permission.Dashboard')->add('icon',
$key, $value)
*/
public $permissionDashboard = [];
/**
* The permissions core
*
* @var array
* @deprecated 3.3 Use
CFactory::_('Compiler.Builder.Permission.Core')->set($nameView,
$coreTarget, $action);
*/
public $permissionCore = [];
/**
* The customs field builder
*
* @var array
*/
public $customFieldBuilder = [];
/**
* The category builder
*
* @var array
*/
public $buildCategories = [];
/**
* The icon builder
*
* @var array
*/
public $iconBuilder = [];
/**
* The validation fix builder
*
* @var array
*/
public $validationFixBuilder = [];
/**
* The view script builder
*
* @var array
*/
public $viewScriptBuilder = [];
/**
* The target relation control
*
* @var array
*/
public $targetRelationControl = [];
/**
* The target control script checker
*
* @var array
*/
public $targetControlsScriptChecker = [];
/**
* The router helper
*
* @var array
*/
public $setRouterHelpDone = [];
/**
* The other where
*
* @var array
*/
public $otherWhere = [];
/**
* The dashboard get custom data
*
* @var array
*/
public $DashboardGetCustomData = [];
/**
* The custom admin added
*
* @var array
*/
public $customAdminAdded = [];
/**
* Switch to add form to views
*
* @var array
*/
public $addCustomForm = [];
/**
* The extensions params
*
* @var array
* @deprecated 3.3 Use
CFactory::_('Compiler.Builder.Extensions.Params')
*/
protected $extensionsParams = [];
/**
* The asset rules
*
* @var array
* @deprecated 3.3 Use
CFactory::_('Compiler.Builder.Assets.Rules')
*/
public $assetsRules = [];
/**
* View Has Category Request
*
* @var array
* @deprecated 3.3 Use
CFactory::_('Compiler.Builder.Request')->get("catid.$key")
*/
protected $hasCatIdRequest = [];
/**
* All fields with permissions
*
* @var array
* @deprecated 3.3 Use
CFactory::_('Compiler.Builder.Permission.Fields')
*/
public $permissionFields = [];
/**
* Custom Admin View List Link
*
* @var array
*/
protected $customAdminViewListLink = [];
/**
* load Tracker of fields to fix
*
* @var array
*/
protected $loadTracker = [];
/**
* View Has Id Request
*
* @var array
* @deprecated 3.3 Use
CFactory::_('Compiler.Builder.Request')->get("id.$key")
*/
protected $hasIdRequest = [];
/**
* Library warning
*
* @var array
* @deprecated 3.3 Use
CFactory::_('Compiler.Builder.Library.Warning')
*/
protected $libwarning = [];
/**
* Language message bucket
*
* @var array
* @deprecated 3.3 Use
CFactory::_('Compiler.Builder.Language.Messages')
*/
public $langNot = [];
/**
* Language message bucket
*
* @var array
* @deprecated 3.3 Use
CFactory::_('Compiler.Builder.Language.Messages')
*/
public $langSet = [];
/**
* alignment names
*
* @var array
*/
protected $alignmentOptions
= array(1 => 'left', 2 => 'right', 3 =>
'fullwidth', 4 => 'above',
5 => 'under', 6 => 'leftside', 7 =>
'rightside');
/**
* Constructor
*/
public function __construct()
{
// first we run the parent constructor
if (parent::__construct())
{
return true;
}
return false;
}
/**
* add email helper
*/
public function addEmailHelper()
{
if
(CFactory::_('Component')->get('add_email_helper'))
{
// set email helper in place with component name
$component = CFactory::_('Config')->component_code_name;
$Component =
CFactory::_('Compiler.Builder.Content.One')->get('Component');
$target = array('admin' => 'emailer');
$done =
CFactory::_('Utilities.Structure')->build($target,
'emailer', $component);
if ($done)
{
// the text for the file BAKING
CFactory::_('Compiler.Builder.Content.Multi')->set('emailer_'
. $component . '|BAKING', ''); // <<-- to insure
it gets updated
// return the code need to load the abstract class
return PHP_EOL . "\JLoader::register('" . $Component
. "Email', JPATH_COMPONENT_ADMINISTRATOR .
'/helpers/"
. $component . "email.php'); ";
}
}
return '';
}
/**
* set the lock license (NOT OKAY)
*/
public function setLockLicense()
{
if (CFactory::_('Component')->get('add_license',
0) == 3)
{
if
(!CFactory::_('Compiler.Builder.Content.One')->exists('HELPER_SITE_LICENSE_LOCK'))
{
$_WHMCS = '_' . StringHelper::safe(
$this->uniquekey(10), 'U'
);
// add it to the system
CFactory::_('Compiler.Builder.Content.One')->set('HELPER_SITE_LICENSE_LOCK',
$this->setHelperLicenseLock($_WHMCS, 'site'));
CFactory::_('Compiler.Builder.Content.One')->set('HELPER_LICENSE_LOCK',
$this->setHelperLicenseLock($_WHMCS, 'admin'));
CFactory::_('Compiler.Builder.Content.One')->set('LICENSE_LOCKED_INT',
$this->setInitLicenseLock($_WHMCS));
CFactory::_('Compiler.Builder.Content.One')->set('LICENSE_LOCKED_DEFINED',
PHP_EOL . PHP_EOL . 'defined(\'' . $_WHMCS
. '\') or die(Text:' .
':_(\'NIE_REG_NIE\'));');
}
}
else
{
// don't add it to the system
CFactory::_('Compiler.Builder.Content.One')->set('HELPER_SITE_LICENSE_LOCK',
'');
CFactory::_('Compiler.Builder.Content.One')->set('HELPER_LICENSE_LOCK',
'');
CFactory::_('Compiler.Builder.Content.One')->set('LICENSE_LOCKED_INT',
'');
CFactory::_('Compiler.Builder.Content.One')->set('LICENSE_LOCKED_DEFINED',
'');
}
}
/**
* set Lock License Per
*
* @param string $view
* @param string $target
*/
public function setLockLicensePer(&$view, $target)
{
if (CFactory::_('Component')->get('add_license',
0) == 3)
{
if
(!CFactory::_('Compiler.Builder.Content.Multi')->exists($view
. '|BOOLMETHOD'))
{
$boolMethod = 'get' . StringHelper::safe(
$this->uniquekey(3, false, 'ddd'), 'W'
);
$globalbool = 'set' . StringHelper::safe(
$this->uniquekey(3), 'W'
);
// add it to the system
CFactory::_('Compiler.Builder.Content.Multi')->set($view .
'|LICENSE_LOCKED_SET_BOOL',
$this->setBoolLicenseLock($boolMethod, $globalbool));
CFactory::_('Compiler.Builder.Content.Multi')->set($view .
'|LICENSE_LOCKED_CHECK',
$this->checkStatmentLicenseLocked($boolMethod));
CFactory::_('Compiler.Builder.Content.Multi')->set($view .
'|LICENSE_TABLE_LOCKED_CHECK',
$this->checkStatmentLicenseLocked($boolMethod,
'$table'));
CFactory::_('Compiler.Builder.Content.Multi')->set($view .
'|BOOLMETHOD', $boolMethod);
}
}
else
{
// don't add it to the system
CFactory::_('Compiler.Builder.Content.Multi')->set($view .
'|LICENSE_LOCKED_SET_BOOL', '');
CFactory::_('Compiler.Builder.Content.Multi')->set($view .
'|LICENSE_LOCKED_CHECK', '');
CFactory::_('Compiler.Builder.Content.Multi')->set($view .
'|LICENSE_TABLE_LOCKED_CHECK', '');
}
}
/**
* Check statment license locked
*
* @param type $boolMethod
* @param type $thIIS
*
* @return string
*/
public function checkStatmentLicenseLocked($boolMethod, $thIIS =
'$this')
{
$statment[] = PHP_EOL . Indent::_(2) . "if (!" . $thIIS .
"->"
. $boolMethod . "())";
$statment[] = Indent::_(2) . "{";
$statment[] = Indent::_(3) . "\$app =
Factory::getApplication();";
$statment[] = Indent::_(3) . "\$app->enqueueMessage(Text:"
. ":_('NIE_REG_NIE'), 'error');";
$statment[] = Indent::_(3) .
"\$app->redirect('index.php');";
$statment[] = Indent::_(3) . "return false;";
$statment[] = Indent::_(2) . "}";
// return the genuine mentod statement
return implode(PHP_EOL, $statment);
}
/**
* set Bool License Lock
*
* @param type $boolMethod
* @param type $globalbool
*
* @return string
*/
public function setBoolLicenseLock($boolMethod, $globalbool)
{
$bool[] = PHP_EOL . PHP_EOL . Indent::_(1) . "/**";
$bool[] = Indent::_(1) . " * The private bool.";
$bool[] = Indent::_(1) . " **/";
$bool[] = Indent::_(1) . "private $" . $globalbool .
";";
$bool[] = PHP_EOL . Indent::_(1) . "/**";
$bool[] = Indent::_(1) . " * Check if this install has a
license.";
$bool[] = Indent::_(1) . " **/";
$bool[] = Indent::_(1) . "public function " . $boolMethod .
"()";
$bool[] = Indent::_(1) . "{";
$bool[] = Indent::_(2) . "if(!empty(\$this->" . $globalbool
. "))";
$bool[] = Indent::_(2) . "{";
$bool[] = Indent::_(3) . "return \$this->" . $globalbool .
";";
$bool[] = Indent::_(2) . "}";
$bool[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__)
. " Get the global params";
$bool[] = Indent::_(2) . "\$params =
ComponentHelper::getParams('com_"
. CFactory::_('Config')->component_code_name .
"', true);";
$bool[] = Indent::_(2)
. "\$whmcs_key = \$params->get('whmcs_key',
null);";
$bool[] = Indent::_(2) . "if (\$whmcs_key)";
$bool[] = Indent::_(2) . "{";
$bool[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__)
. " load the file";
$bool[] = Indent::_(3)
. "JLoader::import( 'whmcs', JPATH_ADMINISTRATOR
.'/components/com_"
. CFactory::_('Config')->component_code_name .
"');";
$bool[] = Indent::_(3) . "\$the = new \WHMCS(\$whmcs_key);";
$bool[] = Indent::_(3) . "\$this->" . $globalbool . " =
\$the->_is;";
$bool[] = Indent::_(3) . "return \$this->" . $globalbool .
";";
$bool[] = Indent::_(2) . "}";
$bool[] = Indent::_(2) . "return false;";
$bool[] = Indent::_(1) . "}";
// return the genuine method statement
return implode(PHP_EOL, $bool);
}
/**
* set Helper License Lock
*
* @param type $_WHMCS
* @param type $target
*
* @return string
*/
public function setHelperLicenseLock($_WHMCS, $target)
{
$helper[] = PHP_EOL . PHP_EOL . Indent::_(1) . "/**";
$helper[] = Indent::_(1) . " * Check if this install has a
license.";
$helper[] = Indent::_(1) . " **/";
$helper[] = Indent::_(1) . "public static function
isGenuine()";
$helper[] = Indent::_(1) . "{";
$helper[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__)
. " Get the global params";
$helper[] = Indent::_(2)
. "\$params = ComponentHelper::getParams('com_"
. CFactory::_('Config')->component_code_name .
"', true);";
$helper[] = Indent::_(2)
. "\$whmcs_key = \$params->get('whmcs_key',
null);";
$helper[] = Indent::_(2) . "if (\$whmcs_key)";
$helper[] = Indent::_(2) . "{";
$helper[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__)
. " load the file";
$helper[] = Indent::_(3)
. "JLoader::import( 'whmcs', JPATH_ADMINISTRATOR
.'/components/com_"
. CFactory::_('Config')->component_code_name .
"');";
$helper[] = Indent::_(3) . "\$the = new \WHMCS(\$whmcs_key);";
$helper[] = Indent::_(3) . "return \$the->_is;";
$helper[] = Indent::_(2) . "}";
$helper[] = Indent::_(2) . "return false;";
$helper[] = Indent::_(1) . "}";
// return the genuine mentod statement
return implode(PHP_EOL, $helper);
}
/**
* set Init License Lock
*
* @param type $_WHMCS
*
* @return string
*/
public function setInitLicenseLock($_WHMCS)
{
$init[] = PHP_EOL . "if (!defined('" . $_WHMCS .
"'))";
$init[] = "{";
$init[] = Indent::_(1) . "\$allow = "
.
CFactory::_('Compiler.Builder.Content.One')->get('Component')
. "Helper::isGenuine();";
$init[] = Indent::_(1) . "if (\$allow)";
$init[] = Indent::_(1) . "{";
$init[] = Indent::_(2) . "define('" . $_WHMCS .
"', 1);";
$init[] = Indent::_(1) . "}";
$init[] = "}";
// return the initializing statement
return implode(PHP_EOL, $init);
}
/**
* set WHMCS Cryption
*
* @return string
*/
public function setWHMCSCryption()
{
// make sure we have the correct file
if
(CFactory::_('Component')->isString('whmcs_key'))
{
// Get the basic encryption.
$basickey = \ComponentbuilderHelper::getCryptKey('basic');
$key =
CFactory::_('Component')->get('whmcs_key');
// Get the encryption object.
$basic = new AES($basickey);
if ($basickey && $key === base64_encode(
base64_decode((string) $key, true)
))
{
// basic decrypt data whmcs_key.
$key = rtrim(
(string) $basic->decryptString($key), "\0"
);
// set the needed string to connect to whmcs
$key["kasier"] =
CFactory::_('Component')->get('whmcs_url',
'');
$key["geheim"] = $key;
$key["onthou"] = 1;
// prep the call info
$theKey = base64_encode(serialize($key));
// set the script
$encrypt[] = "/**";
$encrypt[] = "* " . Line::_(__Line__, __Class__) .
"WHMCS Class ";
$encrypt[] = "**/";
$encrypt[] = "class WHMCS";
$encrypt[] = "{";
$encrypt[] = Indent::_(1) . "public \$_key = false;";
$encrypt[] = Indent::_(1) . "public \$_is = false;";
$encrypt[] = PHP_EOL . Indent::_(1)
. "public function __construct(\$Vk5smi0wjnjb)";
$encrypt[] = Indent::_(1) . "{";
$encrypt[] = Indent::_(2) . "// get the session";
$encrypt[] = Indent::_(2)
. "\$session = Factory::getSession();";
$encrypt[] = Indent::_(2)
. "\$V2uekt2wcgwk = \$session->get(\$Vk5smi0wjnjb,
null);";
$encrypt[] = Indent::_(2)
. "\$h4sgrGsqq =
\$this->get(\$Vk5smi0wjnjb,\$V2uekt2wcgwk);";
$encrypt[] = Indent::_(2)
. "if (isset(\$h4sgrGsqq['nuut']) &&
\$h4sgrGsqq['nuut'] &&
(isset(\$h4sgrGsqq['status']) && 'Active' ===
\$h4sgrGsqq['status']) &&
isset(\$h4sgrGsqq['eiegrendel']) &&
strlen(\$h4sgrGsqq['eiegrendel']) > 300)";
$encrypt[] = Indent::_(2) . "{";
$encrypt[] = Indent::_(3)
. "\$session->set(\$Vk5smi0wjnjb,
\$h4sgrGsqq['eiegrendel']);";
$encrypt[] = Indent::_(2) . "}";
$encrypt[] = Indent::_(2)
. "if ((isset(\$h4sgrGsqq['status']) &&
'Active' === \$h4sgrGsqq['status']) &&
isset(\$h4sgrGsqq['md5hash']) &&
strlen(\$h4sgrGsqq['md5hash']) == 32 &&
isset(\$h4sgrGsqq['customfields']) &&
strlen(\$h4sgrGsqq['customfields']) > 4)";
$encrypt[] = Indent::_(2) . "{";
$encrypt[] = Indent::_(3)
. "\$this->_key =
md5(\$h4sgrGsqq['customfields']);";
$encrypt[] = Indent::_(2) . "}";
$encrypt[] = Indent::_(2)
. "if ((isset(\$h4sgrGsqq['status']) &&
'Active' === \$h4sgrGsqq['status']) &&
isset(\$h4sgrGsqq['md5hash']) &&
strlen(\$h4sgrGsqq['md5hash']) == 32 )";
$encrypt[] = Indent::_(2) . "{";
$encrypt[] = Indent::_(3) . "\$this->_is = true;";
$encrypt[] = Indent::_(2) . "}";
$encrypt[] = Indent::_(1) . "}";
$encrypt[] = PHP_EOL . Indent::_(1)
. "private function get(\$Vk5smi0wjnjb,\$V2uekt2wcgwk)";
$encrypt[] = Indent::_(1) . "{";
$encrypt[] = Indent::_(2)
. "\$Viioj50xuqu2 = unserialize(base64_decode('" .
$theKey
. "'));";
$encrypt[] = Indent::_(2)
. "\$Visqfrd1caus = time() . md5(mt_rand(1000000000, 9999999999)
. \$Vk5smi0wjnjb);";
$encrypt[] = Indent::_(2) . "\$Vo4tezfgcf3e =
date(\"Ymd\");";
$encrypt[] = Indent::_(2)
. "\$Vozblwvfym2f = \$_SERVER['SERVER_NAME'];";
$encrypt[] = Indent::_(2)
. "\$Vozblwvfym2fdie = isset(\$_SERVER['SERVER_ADDR'])
? \$_SERVER['SERVER_ADDR'] :
\$_SERVER['LOCAL_ADDR'];";
$encrypt[] = Indent::_(2)
. "\$V343jp03dxco = dirname(__FILE__);";
$encrypt[] = Indent::_(2)
. "\$Vc2rayehw4f0 =
unserialize(base64_decode('czozNjoibW9kdWxlcy9zZXJ2ZXJzL2xpY2Vuc2luZy92ZXJpZnkucGhwIjs='));";
$encrypt[] = Indent::_(2) . "\$Vlpolphukogz = false;";
$encrypt[] = Indent::_(2) . "if (\$V2uekt2wcgwk) {";
$encrypt[] = Indent::_(3) . "\$V2uekt2wcgwk =
str_replace(\""
. '".PHP_EOL."' . "\", '',
\$V2uekt2wcgwk);";
$encrypt[] = Indent::_(3)
. "\$Vm5cxjdc43g4 = substr(\$V2uekt2wcgwk, 0,
strlen(\$V2uekt2wcgwk) - 32);";
$encrypt[] = Indent::_(3)
. "\$Vbgx0efeu2sy = substr(\$V2uekt2wcgwk, strlen(\$V2uekt2wcgwk)
- 32);";
$encrypt[] = Indent::_(3)
. "if (\$Vbgx0efeu2sy == md5(\$Vm5cxjdc43g4 .
\$Viioj50xuqu2['geheim'])) {";
$encrypt[] = Indent::_(4)
. "\$Vm5cxjdc43g4 = strrev(\$Vm5cxjdc43g4);";
$encrypt[] = Indent::_(4)
. "\$Vbgx0efeu2sy = substr(\$Vm5cxjdc43g4, 0, 32);";
$encrypt[] = Indent::_(4)
. "\$Vm5cxjdc43g4 = substr(\$Vm5cxjdc43g4, 32);";
$encrypt[] = Indent::_(4)
. "\$Vm5cxjdc43g4 = base64_decode(\$Vm5cxjdc43g4);";
$encrypt[] = Indent::_(4)
. "\$Vm5cxjdc43g4finding = unserialize(\$Vm5cxjdc43g4);";
$encrypt[] = Indent::_(4)
. "\$V3qqz0p00fbq =
\$Vm5cxjdc43g4finding['dan'];";
$encrypt[] = Indent::_(4)
. "if (\$Vbgx0efeu2sy == md5(\$V3qqz0p00fbq .
\$Viioj50xuqu2['geheim'])) {";
$encrypt[] = Indent::_(5)
. "\$Vbfbwv2y4kre = date(\"Ymd\", mktime(0, 0, 0,
date(\"m\"), date(\"d\") -
\$Viioj50xuqu2['onthou'], date(\"Y\")));";
$encrypt[] = Indent::_(5)
. "if (\$V3qqz0p00fbq > \$Vbfbwv2y4kre) {";
$encrypt[] = Indent::_(6) . "\$Vlpolphukogz = true;";
$encrypt[] = Indent::_(6)
. "\$Vwasqoybpyed = \$Vm5cxjdc43g4finding;";
$encrypt[] = Indent::_(6)
. "\$Vcixw3trerrt = explode(',',
\$Vwasqoybpyed['validdomain']);";
$encrypt[] = Indent::_(6)
. "if (!in_array(\$_SERVER['SERVER_NAME'],
\$Vcixw3trerrt)) {";
$encrypt[] = Indent::_(7) . "\$Vlpolphukogz = false;";
$encrypt[] = Indent::_(7)
. "\$Vm5cxjdc43g4finding['status'] =
\"sleg\";";
$encrypt[] = Indent::_(7) . "\$Vwasqoybpyed = [];";
$encrypt[] = Indent::_(6) . "}";
$encrypt[] = Indent::_(6)
. "\$Vkni3xyhkqzv = explode(',',
\$Vwasqoybpyed['validip']);";
$encrypt[] = Indent::_(6)
. "if (!in_array(\$Vozblwvfym2fdie, \$Vkni3xyhkqzv)) {";
$encrypt[] = Indent::_(7) . "\$Vlpolphukogz = false;";
$encrypt[] = Indent::_(7)
. "\$Vm5cxjdc43g4finding['status'] =
\"sleg\";";
$encrypt[] = Indent::_(7) . "\$Vwasqoybpyed = [];";
$encrypt[] = Indent::_(6) . "}";
$encrypt[] = Indent::_(6)
. "\$Vckfvnepoaxj = explode(',',
\$Vwasqoybpyed['validdirectory']);";
$encrypt[] = Indent::_(6)
. "if (!in_array(\$V343jp03dxco, \$Vckfvnepoaxj)) {";
$encrypt[] = Indent::_(7) . "\$Vlpolphukogz = false;";
$encrypt[] = Indent::_(7)
. "\$Vm5cxjdc43g4finding['status'] =
\"sleg\";";
$encrypt[] = Indent::_(7) . "\$Vwasqoybpyed = [];";
$encrypt[] = Indent::_(6) . "}";
$encrypt[] = Indent::_(5) . "}";
$encrypt[] = Indent::_(4) . "}";
$encrypt[] = Indent::_(3) . "}";
$encrypt[] = Indent::_(2) . "}";
$encrypt[] = Indent::_(2) . "if (!\$Vlpolphukogz) {";
$encrypt[] = Indent::_(3) . "\$V1u0c4dl3ehp = array(";
$encrypt[] = Indent::_(4) . "'licensekey' =>
\$Vk5smi0wjnjb,";
$encrypt[] = Indent::_(4) . "'domain' =>
\$Vozblwvfym2f,";
$encrypt[] = Indent::_(4) . "'ip' =>
\$Vozblwvfym2fdie,";
$encrypt[] = Indent::_(4) . "'dir' =>
\$V343jp03dxco,";
$encrypt[] = Indent::_(3) . ");";
$encrypt[] = Indent::_(3)
. "if (\$Visqfrd1caus) \$V1u0c4dl3ehp['check_token'] =
\$Visqfrd1caus;";
$encrypt[] = Indent::_(3) . "\$Vdsjeyjmpq2o =
'';";
$encrypt[] = Indent::_(3)
. "foreach (\$V1u0c4dl3ehp AS \$V2sgyscukmgi=>\$V1u00zkzmb1d)
{";
$encrypt[] = Indent::_(4)
. "\$Vdsjeyjmpq2o .=
\$V2sgyscukmgi.'='.urlencode(\$V1u00zkzmb1d).'&';";
$encrypt[] = Indent::_(3) . "}";
$encrypt[] = Indent::_(3)
. "if (function_exists('curl_exec')) {";
$encrypt[] = Indent::_(4) . "\$Vdathuqgjyf0 = curl_init();";
$encrypt[] = Indent::_(4)
. "curl_setopt(\$Vdathuqgjyf0, CURLOPT_URL,
\$Viioj50xuqu2['kasier'] . \$Vc2rayehw4f0);";
$encrypt[] = Indent::_(4)
. "curl_setopt(\$Vdathuqgjyf0, CURLOPT_POST, 1);";
$encrypt[] = Indent::_(4)
. "curl_setopt(\$Vdathuqgjyf0, CURLOPT_POSTFIELDS,
\$Vdsjeyjmpq2o);";
$encrypt[] = Indent::_(4)
. "curl_setopt(\$Vdathuqgjyf0, CURLOPT_TIMEOUT, 30);";
$encrypt[] = Indent::_(4)
. "curl_setopt(\$Vdathuqgjyf0, CURLOPT_RETURNTRANSFER,
1);";
$encrypt[] = Indent::_(4)
. "\$Vqojefyeohg5 = curl_exec(\$Vdathuqgjyf0);";
$encrypt[] = Indent::_(4) . "curl_close(\$Vdathuqgjyf0);";
$encrypt[] = Indent::_(3) . "} else {";
$encrypt[] = Indent::_(4)
. "\$Vrpmu4bvnmkp = fsockopen(\$Viioj50xuqu2['kasier'],
80, \$Vc0t5kmpwkwk, \$Va3g41fnofhu, 5);";
$encrypt[] = Indent::_(4) . "if (\$Vrpmu4bvnmkp) {";
$encrypt[] = Indent::_(5) . "\$Vznkm0a0me1y = \"\r" .
PHP_EOL
. "\";";
$encrypt[] = Indent::_(5)
. "\$V2sgyscukmgiop = \"POST
\".\$Viioj50xuqu2['kasier'] . \$Vc2rayehw4f0 . \"
HTTP/1.0\" . \$Vznkm0a0me1y;";
$encrypt[] = Indent::_(5)
. "\$V2sgyscukmgiop .= \"Host:
\".\$Viioj50xuqu2['kasier'] . \$Vznkm0a0me1y;";
$encrypt[] = Indent::_(5)
. "\$V2sgyscukmgiop .= \"Content-type:
application/x-www-form-urlencoded\" . \$Vznkm0a0me1y;";
$encrypt[] = Indent::_(5)
. "\$V2sgyscukmgiop .= \"Content-length:
\".@strlen(\$Vdsjeyjmpq2o) . \$Vznkm0a0me1y;";
$encrypt[] = Indent::_(5)
. "\$V2sgyscukmgiop .= \"Connection: close\" .
\$Vznkm0a0me1y . \$Vznkm0a0me1y;";
$encrypt[] = Indent::_(5)
. "\$V2sgyscukmgiop .= \$Vdsjeyjmpq2o;";
$encrypt[] = Indent::_(5) . "\$Vqojefyeohg5 =
'';";
$encrypt[] = Indent::_(5)
. "@stream_set_timeout(\$Vrpmu4bvnmkp, 20);";
$encrypt[] = Indent::_(5)
. "@fputs(\$Vrpmu4bvnmkp, \$V2sgyscukmgiop);";
$encrypt[] = Indent::_(5)
. "\$V2czq24pjexf = @socket_get_status(\$Vrpmu4bvnmkp);";
$encrypt[] = Indent::_(5)
. "while (!@feof(\$Vrpmu4bvnmkp)&&\$V2czq24pjexf)
{";
$encrypt[] = Indent::_(6)
. "\$Vqojefyeohg5 .= @fgets(\$Vrpmu4bvnmkp, 1024);";
$encrypt[] = Indent::_(6)
. "\$V2czq24pjexf = @socket_get_status(\$Vrpmu4bvnmkp);";
$encrypt[] = Indent::_(5) . "}";
$encrypt[] = Indent::_(5) . "@fclose (\$Vqojefyeohg5);";
$encrypt[] = Indent::_(4) . "}";
$encrypt[] = Indent::_(3) . "}";
$encrypt[] = Indent::_(3) . "if (!\$Vqojefyeohg5) {";
$encrypt[] = Indent::_(4)
. "\$Vbfbwv2y4kre = date(\"Ymd\", mktime(0, 0, 0,
date(\"m\"), date(\"d\") -
\$Viioj50xuqu2['onthou'], date(\"Y\")));";
$encrypt[] = Indent::_(4)
. "if (isset(\$V3qqz0p00fbq) && \$V3qqz0p00fbq >
\$Vbfbwv2y4kre) {";
$encrypt[] = Indent::_(5)
. "\$Vwasqoybpyed = \$Vm5cxjdc43g4finding;";
$encrypt[] = Indent::_(4) . "} else {";
$encrypt[] = Indent::_(5) . "\$Vwasqoybpyed = [];";
$encrypt[] = Indent::_(5)
. "\$Vwasqoybpyed['status'] =
\"sleg\";";
$encrypt[] = Indent::_(5)
. "\$Vwasqoybpyed['description'] = \"Remote Check
Failed\";";
$encrypt[] = Indent::_(5) . "return \$Vwasqoybpyed;";
$encrypt[] = Indent::_(4) . "}";
$encrypt[] = Indent::_(3) . "} else {";
$encrypt[] = Indent::_(4) . "preg_match_all('"
. '/<(.*?)>([^<]+)<\/\\1>/i'
. "', \$Vqojefyeohg5, \$V1ot20wob03f);";
$encrypt[] = Indent::_(4) . "\$Vwasqoybpyed = [];";
$encrypt[] = Indent::_(4)
. "foreach (\$V1ot20wob03f[1] AS
\$V2sgyscukmgi=>\$V1u00zkzmb1d) {";
$encrypt[] = Indent::_(5)
. "\$Vwasqoybpyed[\$V1u00zkzmb1d] =
\$V1ot20wob03f[2][\$V2sgyscukmgi];";
$encrypt[] = Indent::_(4) . "}";
$encrypt[] = Indent::_(3) . "}";
$encrypt[] = Indent::_(3) . "if (!is_array(\$Vwasqoybpyed))
{";
$encrypt[] = Indent::_(4)
. "die(\"Invalid License Server Response\");";
$encrypt[] = Indent::_(3) . "}";
$encrypt[] = Indent::_(3)
. "if (isset(\$Vwasqoybpyed['md5hash']) &&
\$Vwasqoybpyed['md5hash']) {";
$encrypt[] = Indent::_(4)
. "if (\$Vwasqoybpyed['md5hash'] !=
md5(\$Viioj50xuqu2['geheim'] . \$Visqfrd1caus)) {";
$encrypt[] = Indent::_(5)
. "\$Vwasqoybpyed['status'] =
\"sleg\";";
$encrypt[] = Indent::_(5)
. "\$Vwasqoybpyed['description'] = \"MD5 Checksum
Verification Failed\";";
$encrypt[] = Indent::_(5) . "return \$Vwasqoybpyed;";
$encrypt[] = Indent::_(4) . "}";
$encrypt[] = Indent::_(3) . "}";
$encrypt[] = Indent::_(3)
. "if (isset(\$Vwasqoybpyed['status']) &&
\$Vwasqoybpyed['status'] == \"Active\") {";
$encrypt[] = Indent::_(4)
. "\$Vwasqoybpyed['dan'] = \$Vo4tezfgcf3e;";
$encrypt[] = Indent::_(4)
. "\$Vqojefyeohg5ing = serialize(\$Vwasqoybpyed);";
$encrypt[] = Indent::_(4)
. "\$Vqojefyeohg5ing = base64_encode(\$Vqojefyeohg5ing);";
$encrypt[] = Indent::_(4)
. "\$Vqojefyeohg5ing = md5(\$Vo4tezfgcf3e .
\$Viioj50xuqu2['geheim']) . \$Vqojefyeohg5ing;";
$encrypt[] = Indent::_(4)
. "\$Vqojefyeohg5ing = strrev(\$Vqojefyeohg5ing);";
$encrypt[] = Indent::_(4)
. "\$Vqojefyeohg5ing = \$Vqojefyeohg5ing . md5(\$Vqojefyeohg5ing
. \$Viioj50xuqu2['geheim']);";
$encrypt[] = Indent::_(4)
. "\$Vqojefyeohg5ing = wordwrap(\$Vqojefyeohg5ing, 80,
\""
. '".PHP_EOL."' . "\", true);";
$encrypt[] = Indent::_(4)
. "\$Vwasqoybpyed['eiegrendel'] =
\$Vqojefyeohg5ing;";
$encrypt[] = Indent::_(3) . "}";
$encrypt[] = Indent::_(3) . "\$Vwasqoybpyed['nuut'] =
true;";
$encrypt[] = Indent::_(2) . "}";
$encrypt[] = Indent::_(2)
.
"unset(\$V1u0c4dl3ehp,\$Vqojefyeohg5,\$V1ot20wob03f,\$Viioj50xuqu2['kasier'],\$Viioj50xuqu2['geheim'],\$Vo4tezfgcf3e,\$Vozblwvfym2fdie,\$Viioj50xuqu2['onthou'],\$Vbgx0efeu2sy);";
$encrypt[] = Indent::_(2) . "return \$Vwasqoybpyed;";
$encrypt[] = Indent::_(1) . "}";
$encrypt[] = "}";
// return the help methods
return implode(PHP_EOL, $encrypt);
}
}
// give notice of this issue
$this->app->enqueueMessage(
Text::_('COM_COMPONENTBUILDER_HR_HTHREEWHMCS_ERRORHTHREE'),
'Error'
);
$this->app->enqueueMessage(
Text::_(
'The <b>WHMCS class</b> could not be added to this
component. You will need to enable the add-on in the Joomla Component area
(Add WHMCS)->Yes. If you have done this, then please check that you have
your own <b>Basic Encryption<b/> set in the global settings of
JCB. Then open and save this component again, making sure that your WHMCS
settings are still correct.'
), 'Error'
);
return "//" . Line::_(__Line__, __Class__)
. " The WHMCS class could not be added to this component." .
PHP_EOL
. "//" . Line::_(__Line__, __Class__)
. " Please note that you will need to enable the add-on in the
Joomla Component area (Add WHMCS)->Yes.";
}
/**
* set Get Crypt Key
*
* @return string
*/
public function setGetCryptKey()
{
// WHMCS_ENCRYPT_FILE
CFactory::_('Compiler.Builder.Content.One')->set('WHMCS_ENCRYPT_FILE',
'');
// check if encryption is ative
if
(CFactory::_('Compiler.Builder.Model.Basic.Field')->isActive()
||
CFactory::_('Compiler.Builder.Model.Medium.Field')->isActive()
||
CFactory::_('Compiler.Builder.Model.Whmcs.Field')->isActive()
|| CFactory::_('Component')->get('add_license'))
{
if
(CFactory::_('Compiler.Builder.Model.Whmcs.Field')->isActive()
||
CFactory::_('Component')->get('add_license'))
{
// set whmcs encrypt file into place
$target = array('admin' => 'whmcs');
$done =
CFactory::_('Utilities.Structure')->build($target,
'whmcs');
// the text for the file WHMCS_ENCRYPTION_BODY
CFactory::_('Compiler.Builder.Content.Multi')->set('whmcs'
. '|WHMCS_ENCRYPTION_BODY', $this->setWHMCSCryption());
// ENCRYPT_FILE
CFactory::_('Compiler.Builder.Content.One')->set('WHMCS_ENCRYPT_FILE',
PHP_EOL . Indent::_(3) .
"<filename>whmcs.php</filename>");
}
// get component name
$component = CFactory::_('Config')->component_code_name;
// set the getCryptKey function to the helper class
$function = [];
// start building the getCryptKey function/class method
$function[] = PHP_EOL . PHP_EOL . Indent::_(1) . "/**";
$function[] = Indent::_(1) . " * Get The Encryption Keys";
$function[] = Indent::_(1) . " *";
$function[] = Indent::_(1)
. " * @param string \$type The type of key";
$function[] = Indent::_(1)
. " * @param string/bool \$default The return value if no key
was found";
$function[] = Indent::_(1) . " *";
$function[] = Indent::_(1) . " * @return string On
success";
$function[] = Indent::_(1) . " *";
$function[] = Indent::_(1) . " **/";
$function[] = Indent::_(1)
. "public static function getCryptKey(\$type, \$default =
false)";
$function[] = Indent::_(1) . "{";
$function[] = Indent::_(2) . "//" . Line::_(__Line__,
__Class__)
. " Get the global params";
$function[] = Indent::_(2)
. "\$params = ComponentHelper::getParams('com_" .
$component
. "', true);";
// add the basic option
if
(CFactory::_('Compiler.Builder.Model.Basic.Field')->isActive())
{
$function[] = Indent::_(2) . "//" . Line::_(__Line__,
__Class__)
. " Basic Encryption Type";
$function[] = Indent::_(2) . "if ('basic' ===
\$type)";
$function[] = Indent::_(2) . "{";
$function[] = Indent::_(3)
. "\$basic_key = \$params->get('basic_key',
\$default);";
$function[] = Indent::_(3)
. "if (Super_" .
"__1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::check(\$basic_key))";
$function[] = Indent::_(3) . "{";
$function[] = Indent::_(4) . "return \$basic_key;";
$function[] = Indent::_(3) . "}";
$function[] = Indent::_(2) . "}";
}
// add the medium option
if
(CFactory::_('Compiler.Builder.Model.Medium.Field')->isActive())
{
$function[] = Indent::_(2) . "//" . Line::_(__Line__,
__Class__)
. " Medium Encryption Type";
$function[] = Indent::_(2) . "if ('medium' ===
\$type)";
$function[] = Indent::_(2) . "{";
$function[] = Indent::_(3) . "//" . Line::_(__Line__,
__Class__)
. " check if medium key is already loaded.";
$function[] = Indent::_(3)
. "if (Super_" .
"__1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::check(self::\$mediumCryptKey))";
$function[] = Indent::_(3) . "{";
$function[] = Indent::_(4)
. "return (self::\$mediumCryptKey !== 'none') ?
trim(self::\$mediumCryptKey) : \$default;";
$function[] = Indent::_(3) . "}";
$function[] = Indent::_(3) . "//" . Line::_(__Line__,
__Class__)
. " get the path to the medium encryption key.";
$function[] = Indent::_(3)
. "\$medium_key_path =
\$params->get('medium_key_path', null);";
$function[] = Indent::_(3)
. "if (Super_" .
"__1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::check(\$medium_key_path))";
$function[] = Indent::_(3) . "{";
$function[] = Indent::_(4) . "//" . Line::_(__Line__,
__Class__)
. " load the key from the file.";
$function[] = Indent::_(4)
. "if (self::getMediumCryptKey(\$medium_key_path))";
$function[] = Indent::_(4) . "{";
$function[] = Indent::_(5)
. "return trim(self::\$mediumCryptKey);";
$function[] = Indent::_(4) . "}";
$function[] = Indent::_(3) . "}";
$function[] = Indent::_(2) . "}";
}
// add the whmcs option
if
(CFactory::_('Compiler.Builder.Model.Whmcs.Field')->isActive()
||
CFactory::_('Component')->get('add_license'))
{
$function[] = Indent::_(2) . "//" . Line::_(__Line__,
__Class__)
. " WHMCS Encryption Type";
$function[] = Indent::_(2)
. "if ('whmcs' === \$type || 'advanced' ===
\$type)";
$function[] = Indent::_(2) . "{";
$function[] = Indent::_(3)
. "\$key = \$params->get('whmcs_key',
\$default);";
$function[] = Indent::_(3) . "if (Super_" .
"__1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::check(\$key))";
$function[] = Indent::_(3) . "{";
$function[] = Indent::_(4) . "//" . Line::_(__Line__,
__Class__)
. " load the file";
$function[] = Indent::_(4)
. "JLoader::import( 'whmcs',
JPATH_COMPONENT_ADMINISTRATOR);";
$function[] = PHP_EOL . Indent::_(4)
. "\$the = new \WHMCS(\$key);";
$function[] = PHP_EOL . Indent::_(4) . "return
\$the->_key;";
$function[] = Indent::_(3) . "}";
$function[] = Indent::_(2) . "}";
}
// end the function
$function[] = PHP_EOL . Indent::_(2) . "return \$default;";
$function[] = Indent::_(1) . "}";
// set the getMediumCryptKey class/method
if
(CFactory::_('Compiler.Builder.Model.Medium.Field')->isActive())
{
$function[] = PHP_EOL . PHP_EOL . Indent::_(1) . "/**";
$function[] = Indent::_(1) . " * The Medium Encryption Key";
$function[] = Indent::_(1) . " *";
$function[] = Indent::_(1) . " * @var string/bool";
$function[] = Indent::_(1) . " **/";
$function[] = Indent::_(1)
. "protected static \$mediumCryptKey = false;";
$function[] = PHP_EOL . Indent::_(1) . "/**";
$function[] = Indent::_(1)
. " * Get The Medium Encryption Key";
$function[] = Indent::_(1) . " *";
$function[] = Indent::_(1)
. " * @param string \$path The path to the medium crypt key
folder";
$function[] = Indent::_(1) . " *";
$function[] = Indent::_(1)
. " * @return string On success";
$function[] = Indent::_(1) . " *";
$function[] = Indent::_(1) . " **/";
$function[] = Indent::_(1)
. "public static function getMediumCryptKey(\$path)";
$function[] = Indent::_(1) . "{";
$function[] = Indent::_(2) . "//" . Line::_(__Line__,
__Class__)
. " Prep the path a little";
$function[] = Indent::_(2)
. "\$path = '/'. trim(str_replace('//',
'/', \$path), '/');";
$function[] = Indent::_(2) . "//" . Line::_(__Line__,
__Class__)
. " Check if folder exist";
$function[] = Indent::_(2) . "if (!Folder::exists(\$path))";
$function[] = Indent::_(2) . "{";
$function[] = Indent::_(3) . "//" . Line::_(__Line__,
__Class__)
. " Lock key.";
$function[] = Indent::_(3) . "self::\$mediumCryptKey =
'none';";
$function[] = Indent::_(3) . "//" . Line::_(__Line__,
__Class__)
. " Set the error message.";
$function[] = Indent::_(3)
. "Factory::getApplication()->enqueueMessage(Text:" .
":_('"
. CFactory::_('Config')->lang_prefix
. "_CONFIG_MEDIUM_KEY_PATH_ERROR'),
'Error');";
$function[] = Indent::_(3) . "return false;";
$function[] = Indent::_(2) . "}";
$function[] = Indent::_(2) . "//" . Line::_(__Line__,
__Class__)
. " Create FileName and set file path";
$function[] = Indent::_(2)
. "\$filePath =
\$path.'/.'.md5('medium_crypt_key_file');";
$function[] = Indent::_(2) . "//" . Line::_(__Line__,
__Class__)
. " Check if we already have the file set";
$function[] = Indent::_(2)
. "if ((self::\$mediumCryptKey = @file_get_contents(\$filePath))
!== FALSE)";
$function[] = Indent::_(2) . "{";
$function[] = Indent::_(3) . "return true;";
$function[] = Indent::_(2) . "}";
$function[] = Indent::_(2) . "//" . Line::_(__Line__,
__Class__)
. " Set the key for the first time";
$function[] = Indent::_(2)
. "self::\$mediumCryptKey = self::randomkey(128);";
$function[] = Indent::_(2) . "//" . Line::_(__Line__,
__Class__)
. " Open the key file";
$function[] = Indent::_(2) . "\$fh = @fopen(\$filePath,
'w');";
$function[] = Indent::_(2) . "if (!is_resource(\$fh))";
$function[] = Indent::_(2) . "{";
$function[] = Indent::_(3) . "//" . Line::_(__Line__,
__Class__)
. " Lock key.";
$function[] = Indent::_(3) . "self::\$mediumCryptKey =
'none';";
$function[] = Indent::_(3) . "//" . Line::_(__Line__,
__Class__)
. " Set the error message.";
$function[] = Indent::_(3)
. "Factory::getApplication()->enqueueMessage(Text:" .
":_('"
. CFactory::_('Config')->lang_prefix
. "_CONFIG_MEDIUM_KEY_PATH_ERROR'),
'Error');";
$function[] = Indent::_(3) . "return false;";
$function[] = Indent::_(2) . "}";
$function[] = Indent::_(2) . "//" . Line::_(__Line__,
__Class__)
. " Write to the key file";
$function[] = Indent::_(2)
. "if (!fwrite(\$fh, self::\$mediumCryptKey))";
$function[] = Indent::_(2) . "{";
$function[] = Indent::_(3) . "//" . Line::_(__Line__,
__Class__)
. " Close key file.";
$function[] = Indent::_(3) . "fclose(\$fh);";
$function[] = Indent::_(3) . "//" . Line::_(__Line__,
__Class__)
. " Lock key.";
$function[] = Indent::_(3) . "self::\$mediumCryptKey =
'none';";
$function[] = Indent::_(3) . "//" . Line::_(__Line__,
__Class__)
. " Set the error message.";
$function[] = Indent::_(3)
. "Factory::getApplication()->enqueueMessage(Text:" .
":_('"
. CFactory::_('Config')->lang_prefix
. "_CONFIG_MEDIUM_KEY_PATH_ERROR'),
'Error');";
$function[] = Indent::_(3) . "return false;";
$function[] = Indent::_(2) . "}";
$function[] = Indent::_(2) . "//" . Line::_(__Line__,
__Class__)
. " Close key file.";
$function[] = Indent::_(2) . "fclose(\$fh);";
$function[] = Indent::_(2) . "//" . Line::_(__Line__,
__Class__)
. " Key is set.";
$function[] = Indent::_(2) . "return true;";
$function[] = Indent::_(1) . "}";
}
// return the help methods
return implode(PHP_EOL, $function);
}
return '';
}
/**
* set Version Controller
*/
public function setVersionController()
{
if
(CFactory::_('Component')->isArray('version_update')
||
CFactory::_('Compiler.Builder.Update.Mysql')->isActive())
{
$updateXML = [];
// add the update server
if
(CFactory::_('Component')->get('update_server_target',
3) != 3)
{
$updateXML[] = '<updates>';
}
// add the dynamic sql switch
$addDynamicSQL = true;
$addActive = true;
if
(CFactory::_('Component')->isArray('version_update'))
{
$updates =
CFactory::_('Component')->get('version_update');
foreach ($updates as $nr => &$update)
{
$this->setUpdateXMLSQL($update, $updateXML, $addDynamicSQL);
if ($update['version']
==
CFactory::_('Component')->get('component_version'))
{
$addActive = false;
}
}
CFactory::_('Component')->set('version_update',
$updates);
}
// add the dynamic sql if not already added
if ($addDynamicSQL
&&
CFactory::_('Compiler.Builder.Update.Mysql')->isActive())
{
// add the dynamic sql
$this->setDynamicUpdateXMLSQL($updateXML);
}
// add the new active version if needed
if ($addActive &&
CFactory::_('Compiler.Builder.Update.Mysql')->isActive())
{
// add the dynamic sql
$this->setDynamicUpdateXMLSQL($updateXML, $addActive);
}
// add the update server file
if
(CFactory::_('Component')->get('update_server_target',
3) != 3)
{
$updateXML[] = '</updates>';
// UPDATE_SERVER_XML
$name = substr(
(string)
CFactory::_('Component')->get('update_server_url'),
strrpos((string)
CFactory::_('Component')->get('update_server_url'),
'/')
+ 1
);
$name = explode('.xml', $name)[0];
$target = array('admin' => $name);
CFactory::_('Utilities.Structure')->build($target,
'update_server');
CFactory::_('Compiler.Builder.Content.Multi')->set($name .
'|UPDATE_SERVER_XML', implode(PHP_EOL, $updateXML));
// set the Update server file name
$this->updateServerFileName = $name;
}
}
// add the update server link to component XML
if
(CFactory::_('Component')->get('add_update_server')
&&
CFactory::_('Component')->isString('update_server_url'))
{
// UPDATESERVER
$updateServer = [];
$updateServer[] = PHP_EOL . Indent::_(1) .
"<updateservers>";
$updateServer[] = Indent::_(2)
. '<server type="extension" enabled="1"
element="com_'
. CFactory::_('Config')->component_code_name .
'" name="'
.
CFactory::_('Compiler.Builder.Content.One')->get('Component_name')
. '">' .
CFactory::_('Component')->get('update_server_url')
. '</server>';
$updateServer[] = Indent::_(1) . '</updateservers>';
// return the array to string
$updateServer = implode(PHP_EOL, $updateServer);
// add update server details to component XML file
CFactory::_('Compiler.Builder.Content.One')->set('UPDATESERVER',
$updateServer);
}
else
{
// add update server details to component XML file
CFactory::_('Compiler.Builder.Content.One')->set('UPDATESERVER',
'');
}
// ensure to update Component version data
if
(CFactory::_('Compiler.Builder.Update.Mysql')->isActive())
{
$buket = [];
$nr = 0;
foreach
(CFactory::_('Component')->get('version_update') as
$values)
{
$buket['version_update' . $nr] = $values;
$nr++;
}
// update the joomla component table
$newJ = [];
$newJ['id'] = (int)
CFactory::_('Config')->component_id;
$newJ['component_version']
=
CFactory::_('Component')->get('component_version');
// update the component with the new dynamic SQL
CFactory::_('Data.Item')->table('joomla_component')->set((object)
$newJ, 'id'); // <-- to insure the history is also updated
// reset the watch here
CFactory::_('History')->get('joomla_component',
CFactory::_('Config')->component_id);
// update the component update table
$newU = [];
if
(CFactory::_('Component')->get('version_update_id',
0) > 0)
{
$newU['id'] = (int)
CFactory::_('Component')->get('version_update_id',
0);
}
else
{
$newU['joomla_component'] = (int)
CFactory::_('Config')->component_id;
}
$newU['version_update'] = $buket;
// update the component with the new dynamic SQL
CFactory::_('Data.Item')->table('component_updates')->set((object)
$newU, 'id'); // <-- to insure the history is also updated
}
}
/**
* set Dynamic Update XML SQL
*
* @param array $updateXML
* @param bool $current_version
*/
public function setDynamicUpdateXMLSQL(&$updateXML, $current_version =
false
)
{
// start building the update
$update_ = [];
if ($current_version)
{
// setup new version
$update_['version'] =
CFactory::_('Component')->get('component_version');
// setup SQL
$update_['mysql'] = '';
// setup URL
$update_['url'] = 'http://domain.com/demo.zip';
}
else
{
// setup new version
$update_['version'] =
CFactory::_('Component')->get('old_component_version');
// setup SQL
$update_['mysql'] = trim(
implode(PHP_EOL . PHP_EOL,
CFactory::_('Compiler.Builder.Update.Mysql')->allActive())
);
// setup URL
if (isset($this->lastupdateURL))
{
$paceholders = array(
CFactory::_('Component')->get('component_version')
=>
CFactory::_('Component')->get('old_component_version'),
str_replace(
'.', '-', (string)
CFactory::_('Component')->get('component_version')
) => str_replace(
'.', '-', (string)
CFactory::_('Component')->get('old_component_version')
),
str_replace(
'.', '_', (string)
CFactory::_('Component')->get('component_version')
) => str_replace(
'.', '_', (string)
CFactory::_('Component')->get('old_component_version')
),
str_replace(
'.', '', (string)
CFactory::_('Component')->get('component_version')
) => str_replace(
'.', '', (string)
CFactory::_('Component')->get('old_component_version')
)
);
$update_['url'] =
CFactory::_('Placeholder')->update(
$this->lastupdateURL, $paceholders
);
}
else
{
// setup URL
$update_['url'] = 'http://domain.com/demo.zip';
}
}
// stop it from being added double
$addDynamicSQL = false;
// add dynamic SQL
$this->setUpdateXMLSQL($update_, $updateXML, $addDynamicSQL);
CFactory::_('Component')->appendArray('version_update',
$update_);
}
/**
* set Update XML SQL
*
* @param array $update
* @param array $updateXML
* @param boolean $addDynamicSQL
*/
public function setUpdateXMLSQL(&$update, &$updateXML,
&$addDynamicSQL)
{
// ensure version naming is correct
$update['version'] = preg_replace('/^v/i',
'', (string) $update['version']);
// setup SQL
if (StringHelper::check($update['mysql']))
{
$update['mysql'] =
CFactory::_('Placeholder')->update_(
$update['mysql']
);
}
// add dynamic SQL
$force = false;
if ($addDynamicSQL
&&
CFactory::_('Compiler.Builder.Update.Mysql')->isActive()
&&
CFactory::_('Component')->get('old_component_version')
== $update['version'])
{
$searchMySQL = preg_replace('/\s+/', '', (string)
$update['mysql']);
// add the updates to the SQL only if not found
foreach
(CFactory::_('Compiler.Builder.Update.Mysql')->allActive() as
$search => $query)
{
if (strpos($searchMySQL, $search) === false)
{
$update['mysql'] .= PHP_EOL . PHP_EOL . $query;
}
}
// make sure no unneeded white space is added
$update['mysql'] = trim((string) $update['mysql']);
// update has been added
$addDynamicSQL = false;
}
// setup import files
if ($update['version'] !=
CFactory::_('Component')->get('component_version'))
{
$name = StringHelper::safe($update['version']);
$target = array('admin' => $name);
CFactory::_('Utilities.Structure')->build($target,
'sql_update', $update['version']);
$_name = preg_replace('/[\.]+/', '_', (string)
$update['version']);
CFactory::_('Compiler.Builder.Content.Multi')->set($name .
'_' . $_name . '|UPDATE_VERSION_MYSQL',
$update['mysql']
);
}
elseif (isset($update['url'])
&& StringHelper::check(
$update['url']
))
{
$this->lastupdateURL = $update['url'];
}
// add the update server
if
(CFactory::_('Component')->get('add_update_server',
3) != 3)
{
// we set the defaults
$u_element = 'com_' .
CFactory::_('Config')->component_code_name;
$u_server_type = 'component';
$u_state = 'stable';
$u_target_version = '3.*';
$u_client = null;
// check if we have advance options set
if (isset($update['update_server_adv']) &&
$update['update_server_adv'])
{
$u_element = (isset($update['update_element']) &&
strlen((string) $update['update_element']) > 0)
? $update['update_element'] : $u_element;
$u_server_type = (isset($update['update_server_type'])
&& strlen((string) $update['update_server_type']) >
0)
? $update['update_server_type'] : $u_server_type;
$u_state = (isset($update['update_state']) &&
strlen((string) $update['update_state']) > 0)
? $update['update_state'] : $u_state;
$u_target_version = (isset($update['update_target_version'])
&& strlen((string) $update['update_target_version']) >
0)
? $update['update_target_version'] : $u_target_version;
$u_client = (isset($update['update_client']) &&
strlen((string) $update['update_client']) > 0)
? $update['update_client'] : $u_client;
}
// build update xml
$updateXML[] = Indent::_(1) . "<update>";
$updateXML[] = Indent::_(2) . "<name>"
.
CFactory::_('Compiler.Builder.Content.One')->get('Component_name')
. "</name>";
$updateXML[] = Indent::_(2) . "<description>"
.
CFactory::_('Compiler.Builder.Content.One')->get('SHORT_DESCRIPTION')
. "</description>";
$updateXML[] = Indent::_(2) .
"<element>$u_element</element>";
$updateXML[] = Indent::_(2) .
"<type>$u_server_type</type>";
// check if we should add the target client value
if ($u_client)
{
$updateXML[] = Indent::_(2) .
"<client>$u_client</client>";
}
$updateXML[] = Indent::_(2) . "<version>" .
$update['version']
. "</version>";
$updateXML[] = Indent::_(2) . '<infourl title="'
.
CFactory::_('Compiler.Builder.Content.One')->get('Component_name')
. '!">' .
CFactory::_('Compiler.Builder.Content.One')->get('AUTHORWEBSITE')
. '</infourl>';
$updateXML[] = Indent::_(2) . "<downloads>";
if (!isset($update['url'])
|| !StringHelper::check(
$update['url']
))
{
$update['url'] = 'http://domain.com/demo.zip';
}
$updateXML[] = Indent::_(3)
. '<downloadurl type="full"
format="zip">' . $update['url']
. '</downloadurl>';
$updateXML[] = Indent::_(2) . "</downloads>";
$updateXML[] = Indent::_(2) . "<tags>";
$updateXML[] = Indent::_(3) .
"<tag>$u_state</tag>";
$updateXML[] = Indent::_(2) . "</tags>";
$updateXML[] = Indent::_(2) . "<maintainer>"
.
CFactory::_('Compiler.Builder.Content.One')->get('AUTHOR')
. "</maintainer>";
$updateXML[] = Indent::_(2) . "<maintainerurl>"
.
CFactory::_('Compiler.Builder.Content.One')->get('AUTHORWEBSITE')
. "</maintainerurl>";
$updateXML[] = Indent::_(2)
. '<targetplatform name="joomla" version="'
. $u_target_version . '"/>';
$updateXML[] = Indent::_(1) . "</update>";
}
}
/**
* no Help
*
* @return string
*/
public function noHelp()
{
$help = [];
$help[] = PHP_EOL . PHP_EOL . Indent::_(1) . "/**";
$help[] = Indent::_(1) . " * Can be used to build help urls.";
$help[] = Indent::_(1) . " **/";
$help[] = Indent::_(1) . "public static function
getHelpUrl(\$view)";
$help[] = Indent::_(1) . "{";
$help[] = Indent::_(2) . "return false;";
$help[] = Indent::_(1) . "}";
// return the no help method
return implode(PHP_EOL, $help);
}
public function checkHelp($nameSingleCode)
{
if ($nameSingleCode == "help_document")
{
// set help file into admin place
$target = array('admin' => 'help');
$admindone =
CFactory::_('Utilities.Structure')->build($target,
'help');
// set the help file into site place
$target = array('site' => 'help');
$sitedone =
CFactory::_('Utilities.Structure')->build($target,
'help');
if ($admindone && $sitedone)
{
// HELP
CFactory::_('Compiler.Builder.Content.One')->set('HELP',
$this->setHelp(1));
// HELP_SITE
CFactory::_('Compiler.Builder.Content.One')->set('HELP_SITE',
$this->setHelp(2));
// to make sure the file is updated TODO
CFactory::_('Compiler.Builder.Content.Multi')->set('help'
. '|BLABLA', 'blabla');
return true;
}
}
return false;
}
public function setHelp($location)
{
// set hte help function to the helper class
$target = 'admin_view';
if ($location == 2)
{
$target = 'site_view';
}
$help = [];
$help[] = PHP_EOL . PHP_EOL . Indent::_(1) . "/**";
$help[] = Indent::_(1) . " * Load the Component Help URLs.";
$help[] = Indent::_(1) . " **/";
$help[] = Indent::_(1) . "public static function
getHelpUrl(\$view)";
$help[] = Indent::_(1) . "{";
if (CFactory::_('Config')->get('joomla_version',
3) == 3)
{
$help[] = Indent::_(2) . "\$user = Factory::getUser();";
}
else
{
$help[] = Indent::_(2) . "\$user =
Factory::getApplication()->getIdentity();";
}
$help[] = Indent::_(2) . "\$groups =
\$user->get('groups');";
if (CFactory::_('Config')->get('joomla_version',
3) == 3)
{
$help[] = Indent::_(2) . "\$db = Factory::getDbo();";
}
else
{
$help[] = Indent::_(2) . "\$db =
Factory::getContainer()->get(DatabaseInterface::class);";
}
$help[] = Indent::_(2) . "\$query = \$db->getQuery(true);";
$help[] = Indent::_(2)
.
"\$query->select(array('a.id','a.groups','a.target','a.type','a.article','a.url'));";
$help[] = Indent::_(2) . "\$query->from('#__" .
CFactory::_('Config')->component_code_name
. "_help_document AS a');";
$help[] = Indent::_(2) . "\$query->where('a." .
$target
. " = '.\$db->quote(\$view));";
$help[] = Indent::_(2) . "\$query->where('a.location =
"
. (int) $location . "');";
$help[] = Indent::_(2) . "\$query->where('a.published =
1');";
$help[] = Indent::_(2) . "\$db->setQuery(\$query);";
$help[] = Indent::_(2) . "\$db->execute();";
$help[] = Indent::_(2) . "if(\$db->getNumRows())";
$help[] = Indent::_(2) . "{";
$help[] = Indent::_(3) . "\$helps =
\$db->loadObjectList();";
$help[] = Indent::_(3) . "if (Super_" .
"__0a59c65c_9daf_4bc9_baf4_e063ff9e6a8a___Power::check(\$helps))";
$help[] = Indent::_(3) . "{";
$help[] = Indent::_(4) . "foreach (\$helps as \$nr =>
\$help)";
$help[] = Indent::_(4) . "{";
$help[] = Indent::_(5) . "if (\$help->target == 1)";
$help[] = Indent::_(5) . "{";
$help[] = Indent::_(6)
. "\$targetgroups = json_decode(\$help->groups, true);";
$help[] = Indent::_(6)
. "if (!array_intersect(\$targetgroups, \$groups))";
$help[] = Indent::_(6) . "{";
$help[] = Indent::_(7) . "//" . Line::_(__Line__, __Class__)
. " if user not in those target groups then remove the item";
$help[] = Indent::_(7) . "unset(\$helps[\$nr]);";
$help[] = Indent::_(7) . "continue;";
$help[] = Indent::_(6) . "}";
$help[] = Indent::_(5) . "}";
$help[] = Indent::_(5) . "//" . Line::_(__Line__, __Class__)
. " set the return type";
$help[] = Indent::_(5) . "switch (\$help->type)";
$help[] = Indent::_(5) . "{";
$help[] = Indent::_(6) . "//" . Line::_(__Line__, __Class__)
. " set joomla article";
$help[] = Indent::_(6) . "case 1:";
$help[] = Indent::_(7)
. "return self::loadArticleLink(\$help->article);";
$help[] = Indent::_(7) . "break;";
$help[] = Indent::_(6) . "//" . Line::_(__Line__, __Class__)
. " set help text";
$help[] = Indent::_(6) . "case 2:";
$help[] = Indent::_(7) . "return
self::loadHelpTextLink(\$help->id);";
$help[] = Indent::_(7) . "break;";
$help[] = Indent::_(6) . "//" . Line::_(__Line__, __Class__) .
" set Link";
$help[] = Indent::_(6) . "case 3:";
$help[] = Indent::_(7) . "return \$help->url;";
$help[] = Indent::_(7) . "break;";
$help[] = Indent::_(5) . "}";
$help[] = Indent::_(4) . "}";
$help[] = Indent::_(3) . "}";
$help[] = Indent::_(2) . "}";
$help[] = Indent::_(2) . "return false;";
$help[] = Indent::_(1) . "}";
$help[] = PHP_EOL . Indent::_(1) . "/**";
$help[] = Indent::_(1) . " * Get the Article Link.";
$help[] = Indent::_(1) . " **/";
$help[] = Indent::_(1)
. "protected static function loadArticleLink(\$id)";
$help[] = Indent::_(1) . "{";
$help[] = Indent::_(2)
. "return Uri::root() .
'index.php?option=com_content&view=article&id='.\$id.'&tmpl=component&layout=modal';";
$help[] = Indent::_(1) . "}";
$help[] = PHP_EOL . Indent::_(1) . "/**";
$help[] = Indent::_(1) . " * Get the Help Text Link.";
$help[] = Indent::_(1) . " **/";
$help[] = Indent::_(1)
. "protected static function loadHelpTextLink(\$id)";
$help[] = Indent::_(1) . "{";
$help[] = Indent::_(2) . "\$token = Session::getFormToken();";
$help[] = Indent::_(2) . "return 'index.php?option=com_"
. CFactory::_('Config')->component_code_name
. "&task=help.getText&id=' . (int) \$id .
'&' . \$token . '=1';";
$help[] = Indent::_(1) . "}";
// return the help methods
return implode(PHP_EOL, $help);
}
public function setHelperExelMethods()
{
if (CFactory::_('Config')->get('add_eximport',
false))
{
// we use the company name set in the GUI
$company_name =
CFactory::_('Compiler.Builder.Content.One')->get('COMPANYNAME');
// start building the xml function
$exel = [];
$exel[] = PHP_EOL . PHP_EOL . Indent::_(1) . "/**";
$exel[] = Indent::_(1) . "* Prepares the xml document";
$exel[] = Indent::_(1) . "*/";
$exel[] = Indent::_(1)
. "public static function xls(\$rows, \$fileName = null, \$title =
null, \$subjectTab = null, \$creator = '$company_name',
\$description = null, \$category = null,\$keywords = null, \$modified =
null)";
$exel[] = Indent::_(1) . "{";
$exel[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__)
. " set the user";
if (CFactory::_('Config')->get('joomla_version',
3) == 3)
{
$exel[] = Indent::_(2) . "\$user = Factory::getUser();";
}
else
{
$help[] = Indent::_(2) . "\$user =
Factory::getApplication()->getIdentity();";
}
$exel[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__)
. " set fileName if not set";
$exel[] = Indent::_(2) . "if (!\$fileName)";
$exel[] = Indent::_(2) . "{";
$exel[] = Indent::_(3)
. "\$fileName =
'exported_'.Factory::getDate()->format('jS_F_Y');";
$exel[] = Indent::_(2) . "}";
$exel[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__)
. " set modified if not set";
$exel[] = Indent::_(2) . "if (!\$modified)";
$exel[] = Indent::_(2) . "{";
$exel[] = Indent::_(3) . "\$modified = \$user->name;";
$exel[] = Indent::_(2) . "}";
$exel[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__)
. " set title if not set";
$exel[] = Indent::_(2) . "if (!\$title)";
$exel[] = Indent::_(2) . "{";
$exel[] = Indent::_(3) . "\$title = 'Book1';";
$exel[] = Indent::_(2) . "}";
$exel[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__)
. " set tab name if not set";
$exel[] = Indent::_(2) . "if (!\$subjectTab)";
$exel[] = Indent::_(2) . "{";
$exel[] = Indent::_(3) . "\$subjectTab =
'Sheet1';";
$exel[] = Indent::_(2) . "}";
$exel[] = PHP_EOL . Indent::_(2) . "//" . Line::_(__Line__,
__Class__)
. " make sure we have the composer classes loaded";
$exel[] = Indent::_(2)
. "self::composerAutoload('phpspreadsheet');";
$exel[] = PHP_EOL . Indent::_(2) . "//" . Line::_(__Line__,
__Class__)
. " Create new Spreadsheet object";
$exel[] = Indent::_(2) . "\$spreadsheet = new
Spreadsheet();";
$exel[] = PHP_EOL . Indent::_(2) . "//" . Line::_(__Line__,
__Class__)
. " Set document properties";
$exel[] = Indent::_(2) . "\$spreadsheet->getProperties()";
$exel[] = Indent::_(3) . "->setCreator(\$creator)";
$exel[] = Indent::_(3) .
"->setCompany('$company_name')";
$exel[] = Indent::_(3) .
"->setLastModifiedBy(\$modified)";
$exel[] = Indent::_(3) . "->setTitle(\$title)";
$exel[] = Indent::_(3) . "->setSubject(\$subjectTab);";
$exel[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__)
. " The file type";
$exel[] = Indent::_(2) . "\$file_type = 'Xls';";
$exel[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__)
. " set description";
$exel[] = Indent::_(2) . "if (\$description)";
$exel[] = Indent::_(2) . "{";
$exel[] = Indent::_(3)
.
"\$spreadsheet->getProperties()->setDescription(\$description);";
$exel[] = Indent::_(2) . "}";
$exel[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__)
. " set keywords";
$exel[] = Indent::_(2) . "if (\$keywords)";
$exel[] = Indent::_(2) . "{";
$exel[] = Indent::_(3)
.
"\$spreadsheet->getProperties()->setKeywords(\$keywords);";
$exel[] = Indent::_(2) . "}";
$exel[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__)
. " set category";
$exel[] = Indent::_(2) . "if (\$category)";
$exel[] = Indent::_(2) . "{";
$exel[] = Indent::_(3)
.
"\$spreadsheet->getProperties()->setCategory(\$category);";
$exel[] = Indent::_(2) . "}";
$exel[] = PHP_EOL . Indent::_(2) . "//" . Line::_(__Line__,
__Class__)
. " Some styles";
$exel[] = Indent::_(2) . "\$headerStyles = array(";
$exel[] = Indent::_(3) . "'font' => array(";
$exel[] = Indent::_(4) . "'bold' => true,";
$exel[] = Indent::_(4) . "'color' =>
array('rgb' => '1171A3'),";
$exel[] = Indent::_(4) . "'size' => 12,";
$exel[] = Indent::_(4) . "'name' =>
'Verdana'";
$exel[] = Indent::_(2) . "));";
$exel[] = Indent::_(2) . "\$sideStyles = array(";
$exel[] = Indent::_(3) . "'font' => array(";
$exel[] = Indent::_(4) . "'bold' => true,";
$exel[] = Indent::_(4) . "'color' =>
array('rgb' => '444444'),";
$exel[] = Indent::_(4) . "'size' => 11,";
$exel[] = Indent::_(4) . "'name' =>
'Verdana'";
$exel[] = Indent::_(2) . "));";
$exel[] = Indent::_(2) . "\$normalStyles = array(";
$exel[] = Indent::_(3) . "'font' => array(";
$exel[] = Indent::_(4) . "'color' =>
array('rgb' => '444444'),";
$exel[] = Indent::_(4) . "'size' => 11,";
$exel[] = Indent::_(4) . "'name' =>
'Verdana'";
$exel[] = Indent::_(2) . "));";
$exel[] = PHP_EOL . Indent::_(2) . "//" . Line::_(__Line__,
__Class__)
. " Add some data";
$exel[] = Indent::_(2)
. "if ((\$size = Super_" .
"__0a59c65c_9daf_4bc9_baf4_e063ff9e6a8a___Power::check(\$rows)) !==
false)";
$exel[] = Indent::_(2) . "{";
$exel[] = Indent::_(3) . "\$i = 1;";
$exel[] = PHP_EOL . Indent::_(3) . "//" . Line::_(__Line__,
__Class__)
. " Based on data size we adapt the behaviour.";
$exel[] = Indent::_(3) . "\$xls_mode = 1;";
$exel[] = Indent::_(3) . "if (\$size > 3000)";
$exel[] = Indent::_(3) . "{";
$exel[] = Indent::_(4) . "\$xls_mode = 3;";
$exel[] = Indent::_(4) . "\$file_type = 'Csv';";
$exel[] = Indent::_(3) . "}";
$exel[] = Indent::_(3) . "elseif (\$size > 2000)";
$exel[] = Indent::_(3) . "{";
$exel[] = Indent::_(4) . "\$xls_mode = 2;";
$exel[] = Indent::_(3) . "}";
$exel[] = PHP_EOL . Indent::_(3) . "//" . Line::_(__Line__,
__Class__)
. " Set active sheet and get it.";
$exel[] = Indent::_(3)
. "\$active_sheet =
\$spreadsheet->setActiveSheetIndex(0);";
$exel[] = Indent::_(3) . "foreach (\$rows as \$array)";
$exel[] = Indent::_(3) . "{";
$exel[] = Indent::_(4) . "\$a = 'A';";
$exel[] = Indent::_(4) . "foreach (\$array as \$value)";
$exel[] = Indent::_(4) . "{";
$exel[] = Indent::_(5)
. "\$active_sheet->setCellValue(\$a.\$i, \$value);";
$exel[] = Indent::_(5) . "if (\$xls_mode != 3)";
$exel[] = Indent::_(5) . "{";
$exel[] = Indent::_(6) . "if (\$i == 1)";
$exel[] = Indent::_(6) . "{";
$exel[] = Indent::_(7)
.
"\$active_sheet->getColumnDimension(\$a)->setAutoSize(true);";
$exel[] = Indent::_(7)
.
"\$active_sheet->getStyle(\$a.\$i)->applyFromArray(\$headerStyles);";
$exel[] = Indent::_(7)
.
"\$active_sheet->getStyle(\$a.\$i)->getAlignment()->setHorizontal(PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER);";
$exel[] = Indent::_(6) . "}";
$exel[] = Indent::_(6) . "elseif (\$a === 'A')";
$exel[] = Indent::_(6) . "{";
$exel[] = Indent::_(7)
.
"\$active_sheet->getStyle(\$a.\$i)->applyFromArray(\$sideStyles);";
$exel[] = Indent::_(6) . "}";
$exel[] = Indent::_(6) . "elseif (\$xls_mode == 1)";
$exel[] = Indent::_(6) . "{";
$exel[] = Indent::_(7)
.
"\$active_sheet->getStyle(\$a.\$i)->applyFromArray(\$normalStyles);";
$exel[] = Indent::_(6) . "}";
$exel[] = Indent::_(5) . "}";
$exel[] = Indent::_(5) . "\$a++;";
$exel[] = Indent::_(4) . "}";
$exel[] = Indent::_(4) . "\$i++;";
$exel[] = Indent::_(3) . "}";
$exel[] = Indent::_(2) . "}";
$exel[] = Indent::_(2) . "else";
$exel[] = Indent::_(2) . "{";
$exel[] = Indent::_(3) . "return false;";
$exel[] = Indent::_(2) . "}";
$exel[] = PHP_EOL . Indent::_(2) . "//" . Line::_(__Line__,
__Class__)
. " Rename worksheet";
$exel[] = Indent::_(2)
.
"\$spreadsheet->getActiveSheet()->setTitle(\$subjectTab);";
$exel[] = PHP_EOL . Indent::_(2) . "//" . Line::_(__Line__,
__Class__)
. " Set active sheet index to the first sheet, so Excel opens this
as the first sheet";
$exel[] = Indent::_(2) .
"\$spreadsheet->setActiveSheetIndex(0);";
$exel[] = PHP_EOL . Indent::_(2) . "//" . Line::_(__Line__,
__Class__)
. " Redirect output to a client's web browser
(Excel5)";
$exel[] = Indent::_(2)
. "header('Content-Type:
application/vnd.ms-excel');";
$exel[] = Indent::_(2)
. "header('Content-Disposition:
attachment;filename=\"' . \$fileName . '.' .
strtolower(\$file_type) .'\"');";
$exel[] = Indent::_(2) . "header('Cache-Control:
max-age=0');";
$exel[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__)
. " If you're serving to IE 9, then the following may be
needed";
$exel[] = Indent::_(2) . "header('Cache-Control:
max-age=1');";
$exel[] = PHP_EOL . Indent::_(2) . "//" . Line::_(__Line__,
__Class__)
. " If you're serving to IE over SSL, then the following may
be needed";
$exel[] = Indent::_(2)
. "header ('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
//"
. Line::_(__Line__, __Class__) . " Date in the past";
$exel[] = Indent::_(2)
. "header ('Last-Modified: '.gmdate('D, d M Y
H:i:s').' GMT'); //"
. Line::_(__Line__, __Class__) . " always modified";
$exel[] = Indent::_(2)
. "header ('Cache-Control: cache, must-revalidate');
//"
. Line::_(__Line__, __Class__) . " HTTP/1.1";
$exel[] = Indent::_(2) . "header ('Pragma: public');
//"
. Line::_(__Line__, __Class__) . " HTTP/1.0";
$exel[] = PHP_EOL . Indent::_(2)
. "\$writer = IOFactory::createWriter(\$spreadsheet,
\$file_type);";
$exel[] = Indent::_(2) .
"\$writer->save('php://output');";
$exel[] = Indent::_(2) . "jexit();";
$exel[] = Indent::_(1) . "}";
$exel[] = PHP_EOL . Indent::_(1) . "/**";
$exel[] = Indent::_(1) . "* Get CSV Headers";
$exel[] = Indent::_(1) . "*/";
$exel[] = Indent::_(1)
. "public static function getFileHeaders(\$dataType)";
$exel[] = Indent::_(1) . "{";
$exel[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__)
. " make sure we have the composer classes loaded";
$exel[] = Indent::_(2)
. "self::composerAutoload('phpspreadsheet');";
$exel[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__)
. " get session object";
$exel[] = Indent::_(2) . "\$session =
Factory::getSession();";
$exel[] = Indent::_(2)
. "\$package = \$session->get('package',
null);";
$exel[] = Indent::_(2)
. "\$package = json_decode(\$package, true);";
$exel[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__)
. " set the headers";
$exel[] = Indent::_(2) .
"if(isset(\$package['dir']))";
$exel[] = Indent::_(2) . "{";
$exel[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__)
. " only load first three rows";
$exel[] = Indent::_(3)
. "\$chunkFilter = new
PhpOffice\PhpSpreadsheet\Reader\chunkReadFilter(2,1);";
$exel[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__)
. " identify the file type";
$exel[] = Indent::_(3)
. "\$inputFileType =
IOFactory::identify(\$package['dir']);";
$exel[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__)
. " create the reader for this file type";
$exel[] = Indent::_(3)
. "\$excelReader =
IOFactory::createReader(\$inputFileType);";
$exel[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__)
. " load the limiting filter";
$exel[] = Indent::_(3)
. "\$excelReader->setReadFilter(\$chunkFilter);";
$exel[] = Indent::_(3) .
"\$excelReader->setReadDataOnly(true);";
$exel[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__)
. " load the rows (only first three)";
$exel[] = Indent::_(3)
. "\$excelObj =
\$excelReader->load(\$package['dir']);";
$exel[] = Indent::_(3) . "\$headers = [];";
$exel[] = Indent::_(3)
. "foreach (\$excelObj->getActiveSheet()->getRowIterator()
as \$row)";
$exel[] = Indent::_(3) . "{";
$exel[] = Indent::_(4) . "if(\$row->getRowIndex() == 1)";
$exel[] = Indent::_(4) . "{";
$exel[] = Indent::_(5)
. "\$cellIterator = \$row->getCellIterator();";
$exel[] = Indent::_(5)
. "\$cellIterator->setIterateOnlyExistingCells(false);";
$exel[] = Indent::_(5) . "foreach (\$cellIterator as
\$cell)";
$exel[] = Indent::_(5) . "{";
$exel[] = Indent::_(6) . "if (!is_null(\$cell))";
$exel[] = Indent::_(6) . "{";
$exel[] = Indent::_(7)
. "\$headers[\$cell->getColumn()] =
\$cell->getValue();";
$exel[] = Indent::_(6) . "}";
$exel[] = Indent::_(5) . "}";
$exel[] = Indent::_(5) .
"\$excelObj->disconnectWorksheets();";
$exel[] = Indent::_(5) . "unset(\$excelObj);";
$exel[] = Indent::_(5) . "break;";
$exel[] = Indent::_(4) . "}";
$exel[] = Indent::_(3) . "}";
$exel[] = Indent::_(3) . "return \$headers;";
$exel[] = Indent::_(2) . "}";
$exel[] = Indent::_(2) . "return false;";
$exel[] = Indent::_(1) . "}";
$exel[] = PHP_EOL . Indent::_(1) . "/**";
$exel[] = Indent::_(1)
. "* Load the Composer Vendor phpspreadsheet";
$exel[] = Indent::_(1) . "*/";
$exel[] = Indent::_(1)
. "protected static function composephpspreadsheet()";
$exel[] = Indent::_(1) . "{";
$exel[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__)
. " load the autoloader for phpspreadsheet";
$exel[] = Indent::_(2)
. "require_once JPATH_SITE .
'/libraries/phpspreadsheet/vendor/autoload.php';";
$exel[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__)
. " do not load again";
$exel[] = Indent::_(2)
. "self::\$composer['phpspreadsheet'] = true;";
$exel[] = PHP_EOL . Indent::_(2) . "return true;";
$exel[] = Indent::_(1) . "}";
// return the help methods
return implode(PHP_EOL, $exel);
}
return '';
}
/**
* Generates the method definition for creating or updating a user based
on the provided parameters.
*
* This method returns a string representation of a PHP function that
includes various
* steps for handling user creation and updates, depending on the mode
(site registration or admin registration).
*
* @param int $add Determines whether to generate the user creation
method or not.
* If true, the method will be
generated and returned as a string.
*
* @return string The generated method code as a string if $add is true.
* Returns an empty string if $add is false.
*
* @since 3.0
* @deprecated 5.0.3 Use
CFactory::_('Architecture.ComHelperClass.CreateUser')->get($add);
*/
public function setCreateUserHelperMethod($add): string
{
return
CFactory::_('Architecture.ComHelperClass.CreateUser')->get($add);
}
public function setAdminViewMenu(&$nameSingleCode, &$view)
{
$xml = '';
// build the file target values
$target = array('site' => $nameSingleCode);
// build the edit.xml file
if (CFactory::_('Utilities.Structure')->build($target,
'admin_menu'))
{
// set the lang
$lang = StringHelper::safe(
'com_' .
CFactory::_('Config')->component_code_name .
'_menu_'
. $nameSingleCode,
'U'
);
CFactory::_('Language')->set(
'adminsys', $lang . '_TITLE',
'Create ' . $view['settings']->name_single
);
CFactory::_('Language')->set(
'adminsys', $lang . '_OPTION',
'Create ' . $view['settings']->name_single
);
CFactory::_('Language')->set(
'adminsys', $lang . '_DESC',
$view['settings']->short_description
);
//start loading xml
$xml = '<?xml version="1.0" encoding="utf-8"
?>';
$xml .= PHP_EOL . '<metadata>';
$xml .= PHP_EOL . Indent::_(1) . '<layout title="' .
$lang
. '_TITLE" option="' . $lang .
'_OPTION">';
$xml .= PHP_EOL . Indent::_(2) . '<message>';
$xml .= PHP_EOL . Indent::_(3) . '<![CDATA[' . $lang .
'_DESC]]>';
$xml .= PHP_EOL . Indent::_(2) . '</message>';
$xml .= PHP_EOL . Indent::_(1) . '</layout>';
$xml .= PHP_EOL . '</metadata>';
}
else
{
$this->app->enqueueMessage(
Text::sprintf(
'<hr /><p>Site menu for <b>%s</b> was not
build.</p>',
$nameSingleCode
), 'Warning'
);
}
return $xml;
}
public function setCustomViewMenu(&$view)
{
$target_area = 'Administrator';
if (CFactory::_('Config')->build_target ===
'site')
{
$target_area = 'Site';
}
$xml = '';
// build the file target values
$target = array('site' =>
$view['settings']->code);
// build the default.xml file
if (CFactory::_('Utilities.Structure')->build($target,
'menu'))
{
// set the lang
$lang = StringHelper::safe(
'com_' .
CFactory::_('Config')->component_code_name .
'_menu_'
. $view['settings']->code, 'U'
);
CFactory::_('Language')->set(
'adminsys', $lang . '_TITLE',
$view['settings']->name
);
CFactory::_('Language')->set(
'adminsys', $lang . '_OPTION',
$view['settings']->name
);
CFactory::_('Language')->set(
'adminsys', $lang . '_DESC',
$view['settings']->description
);
//start loading xml
$xml = '<?xml version="1.0" encoding="utf-8"
?>';
$xml .= PHP_EOL . '<metadata>';
$xml .= PHP_EOL . Indent::_(1) . '<layout title="' .
$lang
. '_TITLE" option="' . $lang .
'_OPTION">';
$xml .= PHP_EOL . Indent::_(2) . '<message>';
$xml .= PHP_EOL . Indent::_(3) . '<![CDATA[' . $lang .
'_DESC]]>';
$xml .= PHP_EOL . Indent::_(2) . '</message>';
$xml .= PHP_EOL . Indent::_(1) . '</layout>';
if
(CFactory::_('Compiler.Builder.Request')->isArray("id.{$view['settings']->code}")
||
CFactory::_('Compiler.Builder.Request')->isArray("catid.{$view['settings']->code}"))
{
$xml .= PHP_EOL . Indent::_(1) . '<!--' . Line::_(
__LINE__,__CLASS__
)
. ' Add fields to the request variables for the layout.
-->';
$xml .= PHP_EOL . Indent::_(1) . '<fields
name="request">';
$xml .= PHP_EOL . Indent::_(2) . '<fieldset
name="request"';
if (CFactory::_('Config')->get('joomla_version',
3) == 3)
{
$xml .= PHP_EOL . Indent::_(3)
. 'addrulepath="/administrator/components/com_'
. CFactory::_('Config')->component_code_name .
'/models/rules"';
$xml .= PHP_EOL . Indent::_(3)
. 'addfieldpath="/administrator/components/com_'
. CFactory::_('Config')->component_code_name .
'/models/fields">';
}
else
{
$xml .= PHP_EOL . Indent::_(3)
. 'addruleprefix="' .
CFactory::_('Config')->namespace_prefix
. '\Component\\' .
CFactory::_('Compiler.Builder.Content.One')->get('ComponentNamespace')
. '\\'. $target_area . '\Rule"';
$xml .= PHP_EOL . Indent::_(3)
. 'addfieldprefix="' .
CFactory::_('Config')->namespace_prefix
. '\Component\\' .
CFactory::_('Compiler.Builder.Content.One')->get('ComponentNamespace')
. '\\'. $target_area . '\Field">';
}
if
(CFactory::_('Compiler.Builder.Request')->isArray("id.{$view['settings']->code}"))
{
foreach (CFactory::_('Compiler.Builder.Request')->
get("id.{$view['settings']->code}") as
$requestFieldXML)
{
$xml .= PHP_EOL . Indent::_(3) . $requestFieldXML;
}
}
if
(CFactory::_('Compiler.Builder.Request')->isArray("catid.{$view['settings']->code}"))
{
foreach (CFactory::_('Compiler.Builder.Request')->
get("catid.{$view['settings']->code}") as
$requestFieldXML)
{
$xml .= PHP_EOL . Indent::_(3) . $requestFieldXML;
}
}
$xml .= PHP_EOL . Indent::_(2) . '</fieldset>';
$xml .= PHP_EOL . Indent::_(1) . '</fields>';
}
if
(CFactory::_('Compiler.Builder.Frontend.Params')->exists($view['settings']->name))
{
// first we must setup the fields for the page use
$params = $this->setupFrontendParamFields(
CFactory::_('Compiler.Builder.Frontend.Params')->get($view['settings']->name),
$view['settings']->code
);
// now load the fields
if (ArrayHelper::check($params))
{
$xml .= PHP_EOL . Indent::_(1) . '<!--' . Line::_(
__LINE__,__CLASS__
) . ' Adding page parameters -->';
$xml .= PHP_EOL . Indent::_(1) . '<fields
name="params">';
$xml .= PHP_EOL . Indent::_(2)
. '<fieldset name="basic" label="COM_'
.
CFactory::_('Compiler.Builder.Content.One')->get('COMPONENT')
. '"';
if
(CFactory::_('Config')->get('joomla_version', 3) ==
3)
{
$xml .= PHP_EOL . Indent::_(3)
. 'addrulepath="/administrator/components/com_'
. CFactory::_('Config')->component_code_name .
'/models/rules"';
$xml .= PHP_EOL . Indent::_(3)
. 'addfieldpath="/administrator/components/com_'
. CFactory::_('Config')->component_code_name .
'/models/fields">';
}
else
{
$xml .= PHP_EOL . Indent::_(3)
. 'addruleprefix="' .
CFactory::_('Config')->namespace_prefix
. '\Component\\' .
CFactory::_('Compiler.Builder.Content.One')->get('ComponentNamespace')
. '\\'. $target_area . '\Rule"';
$xml .= PHP_EOL . Indent::_(3)
. 'addfieldprefix="' .
CFactory::_('Config')->namespace_prefix
. '\Component\\' .
CFactory::_('Compiler.Builder.Content.One')->get('ComponentNamespace')
. '\\'. $target_area . '\Field">';
}
$xml .= implode(Indent::_(3), $params);
$xml .= PHP_EOL . Indent::_(2) . '</fieldset>';
$xml .= PHP_EOL . Indent::_(1) . '</fields>';
}
}
$xml .= PHP_EOL . '</metadata>';
}
else
{
$this->app->enqueueMessage(
Text::sprintf(
'<hr /><p>Site menu for <b>%s</b> was not
build.</p>',
$view['settings']->code
), 'Warning'
);
}
return $xml;
}
public function setupFrontendParamFields($params, $view)
{
$keep = [];
$menuSetter = $view . '_menu';
foreach ($params as $field)
{
// some switch to see if it should be added to front end params
$target = GetHelper::between(
$field, 'display="', '"'
);
if (!StringHelper::check($target)
|| $target === 'menu')
{
$field = str_replace('display="menu"',
'', (string) $field);
// we update fields that have options if not only added to menu
if ($target !== 'menu'
&& strpos($field, 'Option Set. -->') !== false
&& strpos($field, $menuSetter) === false
&& !StringHelper::check($target))
{
// we add the global option
$field = str_replace(
'Option Set. -->',
Line::_(__Line__, __Class__) . ' Global & Option Set.
-->'
. PHP_EOL . Indent::_(3) . '<option
value="">' . PHP_EOL
. Indent::_(4) . 'JGLOBAL_USE_GLOBAL</option>',
$field
);
// update the default to be global
$field = preg_replace(
'/default=".+"/',
'default=""', $field
);
// update the default to be filter
$field = preg_replace(
'/filter=".+"/',
'filter="string"', $field
);
// update required
$field = str_replace(
'required="true"',
'required="false"', $field
);
// add to keeper array
$keep[] = $field;
}
else
{
$keep[] = $field;
}
}
}
return $keep;
}
public function setCustomViewQuery(&$gets, &$code, $tab =
'', $type = 'main'
)
{
$query = '';
if (ArrayHelper::check($gets))
{
$mainAsArray = [];
$check = 'zzz';
foreach ($gets as $nr => $the_get)
{
// to insure that there be no double entries of a call
$checker = md5(serialize($the_get) . $code);
if
(!isset($this->customViewQueryChecker[CFactory::_('Config')->build_target])
|| !isset($checker,
$this->customViewQueryChecker[CFactory::_('Config')->build_target][$checker]))
{
// load this unuiqe key
$this->customViewQueryChecker[CFactory::_('Config')->build_target][$checker]
= true;
if (isset($the_get['selection']['type'])
&& StringHelper::check(
$the_get['selection']['type']
))
{
$getItem = PHP_EOL . PHP_EOL . Indent::_(1) . $tab
. Indent::_(1) . "//" . Line::_(__Line__, __Class__)
. " Get from " .
$the_get['selection']['table']
. " as " . $the_get['as'];
// set the selection
$getItem .= PHP_EOL . Indent::_(1) . $tab . Indent::_(1)
. $the_get['selection']['select'];
}
else
{
$getItem = PHP_EOL . PHP_EOL . Indent::_(1) . $tab
. Indent::_(1) . "//" . Line::_(__Line__, __Class__)
. " Get data";
// set the selection
$getItem .= PHP_EOL .
CFactory::_('Placeholder')->update_(
$the_get['selection']['select']
);
}
// load the from selection
if (($nr == 0
&& (!isset($the_get['join_field'])
|| !StringHelper::check(
$the_get['join_field']
))
&&
(isset($the_get['selection']['type'])
&& StringHelper::check(
$the_get['selection']['type']
)))
|| ($type === 'custom'
&&
(isset($the_get['selection']['type'])
&& StringHelper::check(
$the_get['selection']['type']
))))
{
$getItem .= PHP_EOL . Indent::_(1) . $tab . Indent::_(1)
. '$query->from(' .
$the_get['selection']['from']
. ');';
}
elseif (isset($the_get['join_field'])
&& StringHelper::check(
$the_get['join_field']
)
&& isset($the_get['selection']['type'])
&& StringHelper::check(
$the_get['selection']['type']
))
{
$getItem .= PHP_EOL . Indent::_(1) . $tab . Indent::_(1)
. "\$query->join('" . $the_get['type'];
$getItem .= "', (" .
$the_get['selection']['from'];
$getItem .= ") . ' ON (' .
\$db->quoteName('"
. $the_get['on_field'];
$getItem .= "') . ' " .
$the_get['operator'];
$getItem .= " ' . \$db->quoteName('"
. $the_get['join_field'] . "') .
')');";
$check = current(explode(".", (string)
$the_get['on_field']));
}
// set the method defaults
if (($default = $this->setCustomViewMethodDefaults($the_get,
$code)) !== false)
{
if (($join_field_ =
CFactory::_('Compiler.Builder.Site.Dynamic.Get')->get(CFactory::_('Config')->build_target
.
'.' . $default['code'] . '.' .
$default['as'] . '.' .
$default['join_field'])) !== null
&& !in_array($check, $mainAsArray))
{
// load to other query
CFactory::_('Compiler.Builder.Other.Query')->add(
CFactory::_('Config')->build_target . '.' .
$default['code'] . '.' . $join_field_ . '.' .
$default['valueName'],
$getItem,
false
);
}
else
{
$mainAsArray[] = $default['as'];
$query .= $getItem;
}
}
}
}
}
return $query;
}
public function setCustomViewFieldDecodeFilter(&$get, &$filters,
$string,
$removeString, $code, $tab
)
{
$filter = '';
// check if filter is set for this field
if (ArrayHelper::check($filters))
{
foreach ($filters as $field => $ter)
{
// build load counter
$key = md5(
'setCustomViewFieldDecodeFilter' . $code .
$get['key']
. $string . $ter['table_key']
);
// check if we should load this again
if (strpos((string) $get['selection']['select'],
(string) $ter['table_key'])
!== false
&& !isset($this->loadTracker[$key]))
{
// set the key
$this->loadTracker[$key] = $key;
$as = '';
$felt = '';
list($as, $felt) = array_map(
'trim', explode('.', (string)
$ter['table_key'])
);
if ($get['as'] == $as)
{
switch ($ter['filter_type'])
{
case 4:
// COM_COMPONENTBUILDER_DYNAMIC_GET_USER_GROUPS
$filter .= PHP_EOL . PHP_EOL . Indent::_(1)
. $tab . Indent::_(1) . "//"
. Line::_(__Line__, __Class__) . " filter "
. $as . " based on user groups";
$filter .= PHP_EOL . Indent::_(1) . $tab
. Indent::_(1)
. "\$remove = (count(array_intersect((array)
\$this->groups, (array) "
. $string . "->" . $field
. "))) ? false : true;";
$filter .= PHP_EOL . Indent::_(1) . $tab
. Indent::_(1) . "if (\$remove)";
$filter .= PHP_EOL . Indent::_(1) . $tab
. Indent::_(1) . "{";
if ($removeString == $string)
{
$filter .= PHP_EOL . Indent::_(1) . $tab
. Indent::_(2) . "//" . Line::_(
__LINE__,__CLASS__
) . " Remove " . $string
. " if user not in groups";
$filter .= PHP_EOL . Indent::_(1) . $tab
. Indent::_(2) . $string . " = null;";
$filter .= PHP_EOL . Indent::_(1) . $tab
. Indent::_(2) . "return false;";
}
else
{
$filter .= PHP_EOL . Indent::_(1) . $tab
. Indent::_(2) . "//" . Line::_(
__LINE__,__CLASS__
) . " Unset " . $string
. " if user not in groups";
$filter .= PHP_EOL . Indent::_(1) . $tab
. Indent::_(2) . "unset("
. $removeString . ");";
$filter .= PHP_EOL . Indent::_(1) . $tab
. Indent::_(2) . "continue;";
}
$filter .= PHP_EOL . Indent::_(1) . $tab
. Indent::_(1) . "}";
break;
case 9:
// COM_COMPONENTBUILDER_DYNAMIC_GET_ARRAY_VALUE
$filter .= PHP_EOL . PHP_EOL . Indent::_(1)
. $tab . Indent::_(1) . "if ("
. "Super_" .
"__0a59c65c_9daf_4bc9_baf4_e063ff9e6a8a___Power::check(" .
$string . "->"
. $field . "))";
$filter .= PHP_EOL . Indent::_(1) . $tab
. Indent::_(1) . "{";
$filter .= PHP_EOL . Indent::_(1) . $tab
. Indent::_(2) . "//" . Line::_(
__LINE__,__CLASS__
) . " do your thing here";
$filter .= PHP_EOL . Indent::_(1) . $tab
. Indent::_(1) . "}";
$filter .= PHP_EOL . Indent::_(1) . $tab
. Indent::_(1) . "else";
$filter .= PHP_EOL . Indent::_(1) . $tab
. Indent::_(1) . "{";
if ($removeString == $string)
{
$filter .= PHP_EOL . Indent::_(1) . $tab
. Indent::_(2) . "//" . Line::_(
__LINE__,__CLASS__
) . " Remove " . $string
. " if not array.";
$filter .= PHP_EOL . Indent::_(1) . $tab
. Indent::_(2) . $string . " = null;";
}
else
{
$filter .= PHP_EOL . Indent::_(1) . $tab
. Indent::_(2) . "//" . Line::_(
__LINE__,__CLASS__
) . " Unset " . $string
. " if not array.";
$filter .= PHP_EOL . Indent::_(1) . $tab
. Indent::_(2) . "unset("
. $removeString . ");";
$filter .= PHP_EOL . Indent::_(1) . $tab
. Indent::_(2) . "continue;";
}
$filter .= PHP_EOL . Indent::_(1) . $tab
. Indent::_(1) . "}";
break;
case 10:
// COM_COMPONENTBUILDER_DYNAMIC_GET_REPEATABLE_VALUE
$filter .= PHP_EOL . PHP_EOL . Indent::_(1)
. $tab . Indent::_(1) . "//"
. Line::_(__Line__, __Class__) . " filter "
. $as . " based on repeatable value";
$filter .= PHP_EOL . Indent::_(1) . $tab
. Indent::_(1) . "if ("
. "Super_" .
"__1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::check(" .
$string . "->"
. $field . "))";
$filter .= PHP_EOL . Indent::_(1) . $tab
. Indent::_(1) . "{";
$filter .= PHP_EOL . Indent::_(2) . $tab
. Indent::_(1) . "\$array = json_decode("
. $string . "->" . $field . ",true);";
$filter .= PHP_EOL . Indent::_(2) . $tab
. Indent::_(1) . "if ("
. "Super_" .
"__0a59c65c_9daf_4bc9_baf4_e063ff9e6a8a___Power::check(\$array))";
$filter .= PHP_EOL . Indent::_(2) . $tab
. Indent::_(1) . "{";
$filter .= PHP_EOL . Indent::_(2) . $tab
. Indent::_(2) . "//" . Line::_(
__LINE__,__CLASS__
) . " do your thing here";
$filter .= PHP_EOL . Indent::_(2) . $tab
. Indent::_(1) . "}";
$filter .= PHP_EOL . Indent::_(1) . $tab
. Indent::_(2) . "else";
$filter .= PHP_EOL . Indent::_(1) . $tab
. Indent::_(2) . "{";
if ($removeString == $string)
{
$filter .= PHP_EOL . Indent::_(1) . $tab
. Indent::_(3) . "//" . Line::_(
__LINE__,__CLASS__
) . " Remove " . $string
. " if not array.";
$filter .= PHP_EOL . Indent::_(1) . $tab
. Indent::_(3) . $string . " = null;";
}
else
{
$filter .= PHP_EOL . Indent::_(1) . $tab
. Indent::_(3) . "//" . Line::_(
__LINE__,__CLASS__
) . " Unset " . $string
. " if not array.";
$filter .= PHP_EOL . Indent::_(1) . $tab
. Indent::_(3) . "unset("
. $removeString . ");";
$filter .= PHP_EOL . Indent::_(1) . $tab
. Indent::_(3) . "continue;";
}
$filter .= PHP_EOL . Indent::_(1) . $tab
. Indent::_(2) . "}";
$filter .= PHP_EOL . Indent::_(1) . $tab
. Indent::_(1) . "}";
$filter .= PHP_EOL . Indent::_(1) . $tab
. Indent::_(1) . "else";
$filter .= PHP_EOL . Indent::_(1) . $tab
. Indent::_(1) . "{";
if ($removeString == $string)
{
$filter .= PHP_EOL . Indent::_(1) . $tab
. Indent::_(2) . "//" . Line::_(
__LINE__,__CLASS__
) . " Remove " . $string
. " if not string.";
$filter .= PHP_EOL . Indent::_(1) . $tab
. Indent::_(2) . $string . " = null;";
}
else
{
$filter .= PHP_EOL . Indent::_(1) . $tab
. Indent::_(2) . "//" . Line::_(
__LINE__,__CLASS__
) . " Unset " . $string
. " if not string.";
$filter .= PHP_EOL . Indent::_(1) . $tab
. Indent::_(2) . "unset("
. $removeString . ");";
$filter .= PHP_EOL . Indent::_(1) . $tab
. Indent::_(2) . "continue;";
}
$filter .= PHP_EOL . Indent::_(1) . $tab
. Indent::_(1) . "}";
break;
}
}
}
}
}
return $filter;
}
public function setCustomViewFieldDecode(&$get, $checker, $string,
$code,
$tab = ''
)
{
$fieldDecode = '';
foreach ($checker as $field => $array)
{
// build load counter
$key = md5(
'setCustomViewFieldDecode' . $code . $get['key'] .
$string
. $field
);
// check if we should load this again
if (strpos((string) $get['selection']['select'],
(string) $field) !== false
&& !isset($this->loadTracker[$key])
&& ArrayHelper::check($array['decode']))
{
// set the key
$this->loadTracker[$key] = $key;
// insure it is unique
$array['decode'] = (array) array_unique(
array_reverse((array) $array['decode'])
);
// now loop the array
foreach ($array['decode'] as $decode)
{
$if = '';
$decoder = '';
if ('json' === $decode)
{
$if = PHP_EOL . Indent::_(1) . $tab . Indent::_(1)
. "if (isset(" . $string . "->" . $field .
") && "
. "Super_" .
"__4b225c51_d293_48e4_b3f6_5136cf5c3f18___Power::check("
. $string . "->" . $field . "))" . PHP_EOL
. Indent::_(1) . $tab . Indent::_(1) . "{";
// json_decode
$decoder = $string . "->" . $field . " =
json_decode("
. $string . "->" . $field . ", true);";
}
elseif ('base64' === $decode)
{
$if = PHP_EOL . Indent::_(1) . $tab . Indent::_(1)
. "if (!empty(" . $string . "->" . $field .
") && "
. $string . "->" . $field
. " === base64_encode(base64_decode(" . $string
. "->" . $field . ")))" . PHP_EOL .
Indent::_(1)
. $tab . Indent::_(1) . "{";
// base64_decode
$decoder = $string . "->" . $field . " =
base64_decode("
. $string . "->" . $field . ");";
}
elseif (strpos((string) $decode, '_encryption') !== false
|| 'expert_mode' === $decode)
{
foreach (CFactory::_('Config')->cryption_types as
$cryptionType)
{
if ($cryptionType . '_encryption' === $decode
|| $cryptionType . '_mode' === $decode)
{
if ('expert' !== $cryptionType)
{
$if = PHP_EOL . Indent::_(1) . $tab
. Indent::_(1) . "if (!empty(" . $string
. "->" . $field . ") && \$"
. $cryptionType . "key && !is_numeric("
. $string . "->" . $field . ") &&
"
. $string . "->" . $field
. " === base64_encode(base64_decode("
. $string . "->" . $field . ", true)))"
. PHP_EOL . Indent::_(1) . $tab
. Indent::_(1) . "{";
// set decryption
$decoder = $string . "->" . $field
. " = rtrim(\$" . $cryptionType
. "->decryptString(" . $string . "->"
. $field . "), " . '"\0"' .
");";
}
elseif (CFactory::_('Compiler.Builder.Model.' .
ucfirst($cryptionType). '.Field')->
exists($array['admin_view'] . '.' . $field))
{
$_placeholder_for_field
= array('[[[field]]]' => $string
. "->" . $field);
$fieldDecode .= CFactory::_('Placeholder')->update(
PHP_EOL . Indent::_(1) . $tab
. Indent::_(1) . implode(
PHP_EOL . Indent::_(1) . $tab
. Indent::_(1),
CFactory::_('Compiler.Builder.Model.' .
ucfirst($cryptionType). '.Field')->get(
$array['admin_view'] . '.' . $field .
'.get', ['error'])
), $_placeholder_for_field
);
}
// activate site decryption
CFactory::_('Compiler.Builder.Site.Decrypt')->set("{$cryptionType}.{$code}",
true);
}
}
}
// check if we have found the details
if (StringHelper::check($if))
{
// build decoder string
$fieldDecode .= PHP_EOL . Indent::_(1) . $tab
. Indent::_(1) . "//" . Line::_(__Line__, __Class__)
. " Check if we can decode " . $field . $if
. PHP_EOL . Indent::_(1) . $tab . Indent::_(2)
. "//" . Line::_(__Line__, __Class__) . " Decode
"
. $field;
}
if (StringHelper::check($decoder))
{
// build decoder string
$fieldDecode .= PHP_EOL . Indent::_(1) . $tab
. Indent::_(2) . $decoder . PHP_EOL . Indent::_(1)
. $tab . Indent::_(1) . "}";
}
}
}
}
return $fieldDecode;
}
public function setCustomViewFieldonContentPrepareChecker(&$get,
$checker,
$string, $code,
$tab = ''
)
{
$fieldPrepare = '';
$runplugins = false;
// set component
$Component =
CFactory::_('Compiler.Builder.Content.One')->get('Component');
// set context
$context = (isset($get['context'])) ? $get['context']
: $code;
$context = 'com_' .
CFactory::_('Config')->component_code_name . '.' .
$context;
// load parms builder only once
$params = false;
foreach ($checker as $field => $array)
{
// build load counter
$key = md5(
'setCustomViewFieldonContentPrepareChecker' . $code
. $get['key'] . $string . $field
);
// check if we should load this again
if (strpos((string) $get['selection']['select'],
(string) $field) !== false
&& !isset($this->loadTracker[$key]))
{
// set the key
$this->loadTracker[$key] = $key;
// build decoder string
if (!$runplugins)
{
$runplugins = PHP_EOL . $tab . Indent::_(1) . "//"
. Line::_(__Line__, __Class__)
. " Load the JEvent Dispatcher";
$runplugins .= PHP_EOL . $tab . Indent::_(1)
. "PluginHelper::importPlugin('content');";
$runplugins .= PHP_EOL . $tab . Indent::_(1)
. '$this->_dispatcher = Factory::getApplication();';
}
if (!$params)
{
$fieldPrepare .= PHP_EOL . Indent::_(1) . $tab . Indent::_(
1
) . "//" . Line::_(__Line__, __Class__)
. " Check if item has params, or pass whole item.";
$fieldPrepare .= PHP_EOL . Indent::_(1) . $tab . Indent::_(
1
) . "\$params = (isset(" . $string . "->params)
&& "
. "Super_" .
"__4b225c51_d293_48e4_b3f6_5136cf5c3f18___Power::check(" .
$string
. "->params)) ? json_decode(" . $string .
"->params) : "
. $string . ";";
$params = true;
}
$fieldPrepare .= PHP_EOL . Indent::_(1) . $tab . Indent::_(1)
. "//" . Line::_(__Line__, __Class__)
. " Make sure the content prepare plugins fire on "
. $field;
$fieldPrepare .= PHP_EOL . Indent::_(1) . $tab . Indent::_(1)
. "\$_" . $field . " = new \stdClass();";
$fieldPrepare .= PHP_EOL . Indent::_(1) . $tab . Indent::_(1)
. "\$_" . $field . '->text =& ' . $string .
'->' . $field
. '; //' . Line::_(__Line__, __Class__)
. ' value must be in text';
$fieldPrepare .= PHP_EOL . Indent::_(1) . $tab . Indent::_(1)
. "//" . Line::_(__Line__, __Class__)
. " Since all values are now in text (Joomla Limitation), we also
add the field name ("
. $field . ") to context";
$fieldPrepare .= PHP_EOL . Indent::_(1) . $tab . Indent::_(1)
.
'$this->_dispatcher->triggerEvent("onContentPrepare",
array(\''
. $context . '.' . $field . '\', &$_' .
$field
. ', &$params, 0));';
}
}
// load dispatcher
if ($runplugins)
{
$this->JEventDispatcher = array(Placefix::_h('DISPATCHER')
=> $runplugins);
}
// return content prepare fix
return $fieldPrepare;
}
public function setCustomViewFieldUikitChecker(&$get, $checker,
$string,
$code, $tab = ''
)
{
$fieldUikit = '';
foreach ($checker as $field => $array)
{
// build load counter
$key = md5(
'setCustomViewFieldUikitChecker' . $code .
$get['key'] . $string
. $field
);
// check if we should load this again
if (strpos((string) $get['selection']['select'],
(string) $field) !== false
&& !isset($this->loadTracker[$key]))
{
// set the key
$this->loadTracker[$key] = $key;
// only load for uikit version 2 (TODO) we may need to add another
check here
if (2 == CFactory::_('Config')->uikit || 1 ==
CFactory::_('Config')->uikit)
{
$fieldUikit .= PHP_EOL . Indent::_(1) . $tab . Indent::_(1)
. "//" . Line::_(__Line__, __Class__) . " Checking if
"
. $field . " has uikit components that must be loaded.";
$fieldUikit .= PHP_EOL . Indent::_(1) . $tab . Indent::_(1)
. "\$this->uikitComp = "
.
CFactory::_('Compiler.Builder.Content.One')->get('Component')
. "Helper::getUikitComp(" . $string . "->"
. $field . ",\$this->uikitComp);";
}
}
}
// return UIKIT fix
return $fieldUikit;
}
public function setCustomViewCustomJoin(&$gets, $string, $code,
&$asBucket,
$tab = ''
)
{
if (ArrayHelper::check($gets))
{
$customJoin = '';
foreach ($gets as $get)
{
// set the value name $default
if (($default = $this->setCustomViewMethodDefaults($get, $code))
!== false)
{
if ($this->checkJoint($default, $get, $asBucket))
{
// build custom join string
$otherJoin = PHP_EOL . Indent::_(1) . Placefix::_h("TAB")
. Indent::_(1) . "//" . Line::_(__LINE__,__CLASS__)
. " set " . $default['valueName'] . " to
the "
. Placefix::_h("STRING") . " object.";
$otherJoin .= PHP_EOL . Indent::_(1) . Placefix::_h("TAB")
. Indent::_(1) . Placefix::_h("STRING") .
"->"
. $default['valueName'] . " = \$this->get"
. $default['methodName'] . "(" .
Placefix::_h("STRING") . "->"
. CFactory::_('Compiler.Builder.Get.As.Lookup')->
get($get['key'] . '.' .
$get['on_field'], 'Error')
. ");";
$join_field_ =
CFactory::_('Compiler.Builder.Site.Dynamic.Get')->get(CFactory::_('Config')->build_target
.
'.' . $default['code'] . '.' .
$default['as'] . '.' .
$default['join_field'], 'ZZZ');
// load to other join
CFactory::_('Compiler.Builder.Other.Join')->add(
CFactory::_('Config')->build_target . '.' .
$default['code'] . '.' . $join_field_ . '.' .
$default['valueName'],
$otherJoin,
false
);
}
else
{
// build custom join string
$customJoin .= PHP_EOL . Indent::_(1) . $tab
. Indent::_(1) . "//" . Line::_(__Line__, __Class__)
. " set " . $default['valueName'] . " to
the "
. $string . " object.";
$customJoin .= PHP_EOL . Indent::_(1) . $tab
. Indent::_(1) . $string . "->"
. $default['valueName'] . " = \$this->get"
. $default['methodName'] . "(" . $string .
"->"
. CFactory::_('Compiler.Builder.Get.As.Lookup')->
get($get['key'] . '.' .
$get['on_field'], 'Error')
. ");";
}
}
}
return $customJoin;
}
return '';
}
public function checkJoint(&$default, &$get, &$asBucket)
{
// check if this function is not linked to the main call
list($aJoin) = explode('.', (string)
$get['on_field']);
if (ArrayHelper::check($asBucket) && in_array($aJoin,
$asBucket))
{
return false;
}
// default fallback
elseif
(CFactory::_('Compiler.Builder.Site.Dynamic.Get')->exists(
CFactory::_('Config')->build_target . '.' .
$default['code'] . '.' .
$default['as'] . '.' .
$default['join_field']
))
{
return true;
}
return false;
}
public function setCustomViewFilter(&$filter, &$code, $tab =
'')
{
$filters = '';
if (ArrayHelper::check($filter))
{
foreach ($filter as $ter)
{
$as = '';
$field = '';
$string = '';
if (strpos((string) $ter['table_key'], '.') !==
false)
{
list($as, $field) = array_map(
'trim', explode('.', (string)
$ter['table_key'])
);
}
$path = $code . '.' . $ter['key'] . '.' .
$as . '.' . $field;
switch ($ter['filter_type'])
{
case 1:
// COM_COMPONENTBUILDER_DYNAMIC_GET_ID
$string = PHP_EOL . Indent::_(1) . $tab . Indent::_(1)
. "\$query->where('" . $ter['table_key']
. " "
. $ter['operator'] . " ' . (int) \$pk);";
break;
case 2:
// COM_COMPONENTBUILDER_DYNAMIC_GET_USER
$string = PHP_EOL . Indent::_(1) . $tab . Indent::_(1)
. "\$query->where('" . $ter['table_key']
. " "
. $ter['operator'] . " ' . (int)
\$this->userId);";
break;
case 3:
// COM_COMPONENTBUILDER_DYNAMIC_GET_ACCESS_LEVEL
$string = PHP_EOL . Indent::_(1) . $tab . Indent::_(1)
. "\$query->where('" . $ter['table_key']
. " "
. $ter['operator']
. " (' . implode(',', \$this->levels) .
')');";
break;
case 4:
// COM_COMPONENTBUILDER_DYNAMIC_GET_USER_GROUPS
$decodeChecker =
CFactory::_('Compiler.Builder.Site.Field.Data')->
get('decode.' . $path);
if (ArrayHelper::check($decodeChecker)
|| $ter['state_key'] === 'array')
{
// set needed fields to filter after query
CFactory::_('Compiler.Builder.Site.Field.Decode.Filter')->
set(CFactory::_('Config')->build_target .
'.' . $path, $ter);
}
else
{
$string = PHP_EOL . Indent::_(1) . $tab . Indent::_(
1
) . "\$query->where('" .
$ter['table_key'] . " "
. $ter['operator']
. " (' . implode(',', \$this->groups) .
')');";
}
break;
case 5:
// COM_COMPONENTBUILDER_DYNAMIC_GET_CATEGORIES
$string = PHP_EOL . Indent::_(2) . $tab . "//"
. Line::_(__Line__, __Class__)
. " (TODO) The dynamic category filter is not ready.";
break;
case 6:
// COM_COMPONENTBUILDER_DYNAMIC_GET_TAGS
$string = PHP_EOL . Indent::_(2) . $tab . "//"
. Line::_(__Line__, __Class__)
. " (TODO) The dynamic tags filter is not ready.";
break;
case 7:
// COM_COMPONENTBUILDER_DYNAMIC_GET_DATE
$string = PHP_EOL . Indent::_(2) . $tab . "//"
. Line::_(__Line__, __Class__)
. " (TODO) The dynamic date filter is not ready.";
break;
case 8:
// COM_COMPONENTBUILDER_DYNAMIC_GET_FUNCTIONVAR
if ($ter['operator'] === 'IN'
|| $ter['operator'] === 'NOT IN')
{
$string = PHP_EOL . Indent::_(2) . $tab . "//"
. Line::_(__Line__, __Class__) . " Check if "
. $ter['state_key']
. " is an array with values.";
$string .= PHP_EOL . Indent::_(2) . $tab
. "\$array = " . $ter['state_key'] .
";";
$string .= PHP_EOL . Indent::_(2) . $tab
. "if (isset(\$array) && "
. "Super_" .
"__0a59c65c_9daf_4bc9_baf4_e063ff9e6a8a___Power::check(\$array))";
$string .= PHP_EOL . Indent::_(2) . $tab . "{";
$string .= PHP_EOL . Indent::_(2) . $tab
. Indent::_(1) . "\$query->where('"
. $ter['table_key'] . " " .
$ter['operator']
. " (' . implode(',', \$array) .
')');";
$string .= PHP_EOL . Indent::_(2) . $tab . "}";
// check if empty is allowed
if (!isset($ter['empty']) || !$ter['empty'])
{
$string .= PHP_EOL . Indent::_(2) . $tab
. "else";
$string .= PHP_EOL . Indent::_(2) . $tab . "{";
$string .= PHP_EOL . Indent::_(2) . $tab
. Indent::_(1) . "return false;";
$string .= PHP_EOL . Indent::_(2) . $tab . "}";
}
}
else
{
$string = PHP_EOL . Indent::_(2) . $tab . "//"
. Line::_(__Line__, __Class__) . " Check if "
. $ter['state_key']
. " is a string or numeric value.";
$string .= PHP_EOL . Indent::_(2) . $tab
. "\$checkValue = " . $ter['state_key'] .
";";
$string .= PHP_EOL . Indent::_(2) . $tab
. "if (isset(\$checkValue) && "
. "Super_" .
"__1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::check(\$checkValue))";
$string .= PHP_EOL . Indent::_(2) . $tab . "{";
$string .= PHP_EOL . Indent::_(2) . $tab
. Indent::_(1) . "\$query->where('"
. $ter['table_key'] . " " .
$ter['operator']
. " ' . \$db->quote(\$checkValue));";
$string .= PHP_EOL . Indent::_(2) . $tab . "}";
$string .= PHP_EOL . Indent::_(2) . $tab
. "elseif (is_numeric(\$checkValue))";
$string .= PHP_EOL . Indent::_(2) . $tab . "{";
$string .= PHP_EOL . Indent::_(2) . $tab
. Indent::_(1) . "\$query->where('"
. $ter['table_key'] . " " .
$ter['operator']
. " ' . \$checkValue);";
$string .= PHP_EOL . Indent::_(2) . $tab . "}";
// check if empty is allowed
if (!isset($ter['empty']) || !$ter['empty'])
{
$string .= PHP_EOL . Indent::_(2) . $tab
. "else";
$string .= PHP_EOL . Indent::_(2) . $tab . "{";
$string .= PHP_EOL . Indent::_(2) . $tab
. Indent::_(1) . "return false;";
$string .= PHP_EOL . Indent::_(2) . $tab . "}";
}
}
break;
case 9:
case 10:
// COM_COMPONENTBUILDER_DYNAMIC_GET_ARRAY_VALUE
// COM_COMPONENTBUILDER_DYNAMIC_GET_REPEATABLE_VALUE
$string = "";
// set needed fields to filter after query
CFactory::_('Compiler.Builder.Site.Field.Decode.Filter')->
set(CFactory::_('Config')->build_target . '.'
. $path, $ter);
break;
case 11:
// COM_COMPONENTBUILDER_DYNAMIC_GET_OTHER
if (strpos($as, '(') !== false)
{
// TODO (for now we only fix extra sql methods here)
list($dump, $as) = array_map(
'trim', explode('(', $as)
);
$field = trim(str_replace(')', '', $field));
}
$string = PHP_EOL . Indent::_(1) . $tab . Indent::_(1)
. "\$query->where('" . $ter['table_key']
. " "
. $ter['operator'] . " " .
$ter['state_key']
. "');";
break;
}
// only add if the filter is set
if (StringHelper::check($string))
{
// sort where
if ($as === 'a' ||
CFactory::_('Compiler.Builder.Site.Main.Get')->
exists(CFactory::_('Config')->build_target .
'.' . $code . '.' . $as))
{
$filters .= $string;
}
elseif ($as !== 'a')
{
CFactory::_('Compiler.Builder.Other.Filter')->
set(CFactory::_('Config')->build_target . '.'
. $code . '.' . $as . '.' . $field, $string);;
}
}
}
}
return $filters;
}
public function setCustomViewGroup(&$group, &$code, $tab =
'')
{
$grouping = '';
if (ArrayHelper::check($group))
{
foreach ($group as $gr)
{
list($as, $field) = array_map(
'trim', explode('.', (string)
$gr['table_key'])
);
// set the string
$string = "\$query->group('" .
$gr['table_key'] . "');";
// sort where
if ($as === 'a' ||
CFactory::_('Compiler.Builder.Site.Main.Get')->
exists(CFactory::_('Config')->build_target .
'.' . $code . '.' . $as))
{
$grouping .= PHP_EOL . Indent::_(1) . $tab . Indent::_(1)
. $string;
}
else
{
CFactory::_('Compiler.Builder.Other.Group')->set(
CFactory::_('Config')->build_target . '.' .
$code . '.' . $as . '.' . $field,
PHP_EOL . Indent::_(2) . $string
);
}
}
}
return $grouping;
}
public function setCustomViewOrder(&$order, &$code, $tab =
'')
{
$ordering = '';
if (ArrayHelper::check($order))
{
foreach ($order as $or)
{
list($as, $field) = array_map(
'trim', explode('.', (string)
$or['table_key'])
);
// check if random
if ('RAND' === $or['direction'])
{
// set the string
$string = "\$query->order('RAND()');";
}
else
{
// set the string
$string = "\$query->order('" .
$or['table_key'] . " "
. $or['direction'] . "');";
}
// sort where
if ($as === 'a' ||
CFactory::_('Compiler.Builder.Site.Main.Get')->
exists(CFactory::_('Config')->build_target .
'.' . $code . '.' . $as))
{
$ordering .= PHP_EOL . Indent::_(1) . $tab . Indent::_(1) . $string;
}
else
{
CFactory::_('Compiler.Builder.Other.Order')->set(
CFactory::_('Config')->build_target . '.' .
$code . '.' . $as . '.' . $field,
PHP_EOL . Indent::_(2) . $string
);
}
}
}
return $ordering;
}
public function setCustomViewWhere(&$where, &$code, $tab =
'')
{
$wheres = '';
if (ArrayHelper::check($where))
{
foreach ($where as $whe)
{
$as = '';
$field = '';
$value = '';
list($as, $field) = array_map(
'trim', explode('.', (string)
$whe['table_key'])
);
if (is_numeric($whe['value_key']))
{
$value = " " . $whe['value_key'] .
"');";
}
elseif (strpos((string) $whe['value_key'], '$') !==
false)
{
if ($whe['operator'] === 'IN'
|| $whe['operator'] === 'NOT IN')
{
$value = " (' . implode(',', " .
$whe['value_key']
. ") . ')');";
}
else
{
$value = " ' . \$db->quote(" .
$whe['value_key']
. "));";
}
}
elseif (strpos((string) $whe['value_key'], '.') !==
false)
{
if (strpos((string) $whe['value_key'], "'")
!== false)
{
$value = " ' . \$db->quote(" .
$whe['value_key']
. "));";
}
else
{
$value = " " . $whe['value_key'] .
"');";
}
}
elseif (StringHelper::check($whe['value_key']))
{
$value = " " . $whe['value_key'] .
"');";
}
// only load if there is a value
if (StringHelper::check($value))
{
$tabe = '';
if ($as === 'a')
{
$tabe = $tab;
}
// set the string
if ($whe['operator'] === 'IN'
|| $whe['operator'] === 'NOT IN')
{
$string = "if (isset(" . $whe['value_key'] .
") && "
. "Super_" .
"__0a59c65c_9daf_4bc9_baf4_e063ff9e6a8a___Power::check("
. $whe['value_key'] . "))";
$string .= PHP_EOL . Indent::_(1) . $tabe . Indent::_(1)
. "{";
$string .= PHP_EOL . Indent::_(1) . $tabe . Indent::_(2)
. "//" . Line::_(__Line__, __Class__) . " Get where
"
. $whe['table_key'] . " is " .
$whe['value_key'];
$string .= PHP_EOL . Indent::_(1) . $tabe . Indent::_(2)
. "\$query->where('" . $whe['table_key']
. " "
. $whe['operator'] . $value;
$string .= PHP_EOL . Indent::_(1) . $tabe . Indent::_(1)
. "}";
$string .= PHP_EOL . Indent::_(1) . $tabe . Indent::_(1)
. "else";
$string .= PHP_EOL . Indent::_(1) . $tabe . Indent::_(1)
. "{";
$string .= PHP_EOL . Indent::_(1) . $tabe . Indent::_(2)
. "return false;";
$string .= PHP_EOL . Indent::_(1) . $tabe . Indent::_(1)
. "}";
}
else
{
$string = "//" . Line::_(__Line__, __Class__)
. " Get where " . $whe['table_key'] . " is
"
. $whe['value_key'];
$string .= PHP_EOL . Indent::_(1) . $tabe . Indent::_(1)
. "\$query->where('" . $whe['table_key']
. " "
. $whe['operator'] . $value;
}
// sort where
if ($as === 'a' ||
CFactory::_('Compiler.Builder.Site.Main.Get')->
exists(CFactory::_('Config')->build_target .
'.' . $code . '.' . $as))
{
$wheres .= PHP_EOL . Indent::_(1) . $tab . Indent::_(1) . $string;
}
elseif ($as !== 'a')
{
CFactory::_('Compiler.Builder.Other.Where')->set(
CFactory::_('Config')->build_target . '.' .
$code . '.' . $as . '.' . $field,
PHP_EOL . Indent::_(2) . $string
);
}
}
}
}
return $wheres;
}
public function setCustomViewGlobals(&$global, $string, $as, $tab =
'')
{
$globals = '';
if (ArrayHelper::check($global))
{
$as = array_unique($as);
foreach ($global as $glo)
{
if (in_array($glo['as'], $as))
{
switch ($glo['type'])
{
case 1:
// SET STATE
$value = "\$this->setState('" .
$glo['as'] . "."
. $glo['name'] . "', " . $string .
"->"
. $glo['key'] . ");";
break;
case 2:
// SET THIS
$value = "\$this->" . $glo['as'] .
"_"
. $glo['name'] . " = " . $string .
"->"
. $glo['key'] . ";";
break;
}
// only add if the filter is set
if (StringHelper::check($value))
{
$globals .= PHP_EOL . Indent::_(1) . $tab . Indent::_(1)
. "//" . Line::_(__Line__, __Class__)
. " set the global " . $glo['name'] . "
value."
. PHP_EOL . Indent::_(1) . $tab . Indent::_(1)
. $value;
}
}
}
}
return $globals;
}
/**
* @param $string
* @param string $type
*
* @return mixed
*/
public function removeAsDot($string, $type = '')
{
if (strpos((string) $string, '.') !== false)
{
list($dump, $field) = array_map('trim', explode('.',
(string) $string));
}
else
{
$field = $string;
}
return $field;
}
/**
* @param type $view
* @param type $type
*/
public function setUserPermissionCheckAccess($view, $type)
{
if (isset($view['access']) && $view['access']
== 1)
{
switch ($type)
{
case 1:
$userString = '$this->user';
break;
default:
$userString = '$user';
break;
}
// check that the default and the redirect page is not the same
if
(CFactory::_('Compiler.Builder.Content.One')->exists('SITE_DEFAULT_VIEW')
&&
CFactory::_('Compiler.Builder.Content.One')->get('SITE_DEFAULT_VIEW')
!= $view['settings']->code)
{
$redirectMessage = Indent::_(3) . "//" . Line::_(
__LINE__,__CLASS__
)
. " redirect away to the default view if no access
allowed.";
$redirectString = "Route::_('index.php?option=com_"
. CFactory::_('Config')->component_code_name .
"&view="
.
CFactory::_('Compiler.Builder.Content.One')->get('SITE_DEFAULT_VIEW')
. "')";
}
else
{
$redirectMessage = Indent::_(3) . "//" . Line::_(
__LINE__,__CLASS__
) . " redirect away to the home page if no access
allowed.";
$redirectString = 'Uri::root()';
}
$accessCheck[] = PHP_EOL . Indent::_(2) . "//" . Line::_(
__LINE__,__CLASS__
) . " check if this user has permission to access item";
$accessCheck[] = Indent::_(2) . "if (!" . $userString
. "->authorise('site." .
$view['settings']->code
. ".access', 'com_" .
CFactory::_('Config')->component_code_name .
"'))";
$accessCheck[] = Indent::_(2) . "{";
$accessCheck[] = Indent::_(3)
. "\$app = Factory::getApplication();";
// set lang
$langKeyWord = CFactory::_('Config')->lang_prefix .
'_'
. StringHelper::safe(
'Not authorised to view ' .
$view['settings']->code . '!',
'U'
);
CFactory::_('Language')->set(
'site', $langKeyWord,
'Not authorised to view ' .
$view['settings']->code . '!'
);
$accessCheck[] = Indent::_(3) .
"\$app->enqueueMessage(Text:"
. ":_('" . $langKeyWord . "'),
'error');";
$accessCheck[] = $redirectMessage;
$accessCheck[] = Indent::_(3) . "\$app->redirect(" .
$redirectString
. ");";
$accessCheck[] = Indent::_(3) . "return false;";
$accessCheck[] = Indent::_(2) . "}";
// return the access check
return implode(PHP_EOL, $accessCheck);
}
return '';
}
/**
* @param $get
* @param $code
* @param string $tab
* @param string $type
*
* @return string
*/
public function setCustomViewGetItem(&$get, &$code, $tab =
'', $type = 'main')
{
if (ObjectHelper::check($get))
{
// set the site decription switches
foreach (CFactory::_('Config')->cryption_types as
$cryptionType)
{
CFactory::_('Compiler.Builder.Site.Decrypt')->set("{$cryptionType}.{$code}",
false);
}
// start the get Item
$getItem = '';
// set before item php
if (isset($get->add_php_before_getitem)
&& $get->add_php_before_getitem == 1
&& isset($get->php_before_getitem)
&& StringHelper::check(
$get->php_before_getitem
))
{
$getItem .= CFactory::_('Placeholder')->update_(
$get->php_before_getitem
);
}
// start loadin the get Item
$getItem .= PHP_EOL . Indent::_(1) . $tab . Indent::_(1) .
"//"
. Line::_(__Line__, __Class__) . " Get a db connection.";
if (CFactory::_('Config')->get('joomla_version',
3) == 3)
{
$getItem .= PHP_EOL . Indent::_(1) . $tab . Indent::_(1)
. "\$db = Factory::getDbo();";
}
else
{
$getItem .= PHP_EOL . Indent::_(1) . $tab . Indent::_(1)
. "\$db = \$this->getDatabase();";
}
$getItem .= PHP_EOL . PHP_EOL . $tab . Indent::_(2) . "//"
. Line::_(__Line__, __Class__) . " Create a new query
object.";
$getItem .= PHP_EOL . Indent::_(1) . $tab . Indent::_(1)
. "\$query = \$db->getQuery(true);";
// set main get query
$getItem .= $this->setCustomViewQuery($get->main_get, $code,
$tab);
// setup filters
if (isset($get->filter))
{
$getItem .= $this->setCustomViewFilter(
$get->filter, $code, $tab
);
}
// setup Where
if (isset($get->where))
{
$getItem .= $this->setCustomViewWhere($get->where, $code, $tab);
}
// setup ordering
if (isset($get->order))
{
$getItem .= $this->setCustomViewOrder($get->order, $code, $tab);
}
// setup grouping
if (isset($get->group))
{
$getItem .= $this->setCustomViewGroup($get->group, $code, $tab);
}
// db set query data placeholder
$getItem .= Placefix::_h("DB_SET_QUERY_DATA") ;
// set after item php
if (isset($get->add_php_after_getitem)
&& $get->add_php_after_getitem == 1
&& isset($get->php_after_getitem)
&& StringHelper::check($get->php_after_getitem))
{
$getItem .= CFactory::_('Placeholder')->update_(
$get->php_after_getitem
);
}
// check the getItem string to see if we should still add set query to
data
if (strpos($getItem, '$data =') === false)
{
// get ready to get query
$setQuery[Placefix::_h("DB_SET_QUERY_DATA")] =
PHP_EOL . PHP_EOL . $tab . Indent::_(2) . "//"
. Line::_(__Line__, __Class__)
. " Reset the query using our newly populated query
object.";
$setQuery[Placefix::_h("DB_SET_QUERY_DATA")] .=
PHP_EOL . Indent::_(1) . $tab . Indent::_(1)
. "\$db->setQuery(\$query);";
$setQuery[Placefix::_h("DB_SET_QUERY_DATA")] .=
PHP_EOL . Indent::_(1) . $tab . Indent::_(1) . "//"
. Line::_(__Line__, __Class__)
. " Load the results as a stdClass object.";
$setQuery[Placefix::_h("DB_SET_QUERY_DATA")] .=
PHP_EOL . Indent::_(1) . $tab . Indent::_(1)
. "\$data = \$db->loadObject();";
// add the db set query to data
}
else
{
// remove our placeholder
$setQuery[Placefix::_h("DB_SET_QUERY_DATA")] = '';
}
// add the db set query to data
$getItem = str_replace(
array_keys($setQuery),
array_values($setQuery), $getItem
);
$getItem .= PHP_EOL . PHP_EOL . $tab . Indent::_(2)
. "if (empty(\$data))";
$getItem .= PHP_EOL . Indent::_(1) . $tab . Indent::_(1) .
"{";
if ($type === 'main')
{
$getItem .= PHP_EOL . Indent::_(1) . $tab . Indent::_(2)
. "\$app = Factory::getApplication();";
$langKeyWoord = CFactory::_('Config')->lang_prefix .
'_'
. StringHelper::safe(
'Not found or access denied', 'U'
);
CFactory::_('Language')->set(
CFactory::_('Config')->lang_target, $langKeyWoord,
'Not found, or access denied.'
);
$getItem .= PHP_EOL . Indent::_(1) . $tab . Indent::_(2) .
"//"
. Line::_(__Line__, __Class__)
. " If no data is found redirect to default page and show
warning.";
$getItem .= PHP_EOL . Indent::_(1) . $tab . Indent::_(2)
. "\$app->enqueueMessage(Text:" . ":_('" .
$langKeyWoord
. "'), 'warning');";
if ('site' ===
CFactory::_('Config')->build_target)
{
// check that the default and the redirect page is not the same
if
(CFactory::_('Compiler.Builder.Content.One')->exists('SITE_DEFAULT_VIEW')
&&
CFactory::_('Compiler.Builder.Content.One')->get('SITE_DEFAULT_VIEW')
!= $code)
{
$redirectString = "Route::_('index.php?option=com_"
. CFactory::_('Config')->component_code_name .
"&view="
.
CFactory::_('Compiler.Builder.Content.One')->get('SITE_DEFAULT_VIEW')
. "')";
}
else
{
$redirectString = 'Uri::root()';
}
$getItem .= PHP_EOL . Indent::_(1) . $tab . Indent::_(2)
. "\$app->redirect(" . $redirectString .
");";
}
else
{
$getItem .= PHP_EOL . Indent::_(1) . $tab . Indent::_(2)
. "\$app->redirect('index.php?option=com_"
. CFactory::_('Config')->component_code_name .
"');";
}
$getItem .= PHP_EOL . Indent::_(1) . $tab . Indent::_(2)
. "return false;";
}
else
{
$getItem .= PHP_EOL . Indent::_(1) . $tab . Indent::_(2)
. "return false;";
}
$getItem .= PHP_EOL . Indent::_(1) . $tab . Indent::_(1) .
"}";
// dispatcher placeholder
$getItem .= Placefix::_h("DISPATCHER") ;
if (ArrayHelper::check($get->main_get))
{
$asBucket = [];
foreach ($get->main_get as $main_get)
{
if (isset($main_get['key']) &&
isset($main_get['as']))
{
// build path
$path = $code . '.' . $main_get['key'] .
'.' . $main_get['as'];
$decodeChecker =
CFactory::_('Compiler.Builder.Site.Field.Data')->get('decode.'
. $path);
if (ArrayHelper::check($decodeChecker))
{
// set decoding of needed fields
$getItem .= $this->setCustomViewFieldDecode(
$main_get, $decodeChecker, '$data', $code,
$tab
);
}
$decodeFilter =
CFactory::_('Compiler.Builder.Site.Field.Decode.Filter')->
get(CFactory::_('Config')->build_target . '.'
. $path);
if (ArrayHelper::check($decodeFilter))
{
// also filter fields if needed
$getItem .= $this->setCustomViewFieldDecodeFilter(
$main_get, $decodeFilter, '$data', '$data',
$code, $tab
);
}
$contentprepareChecker =
CFactory::_('Compiler.Builder.Site.Field.Data')->
get('textareas.' . $path);
if (ArrayHelper::check($contentprepareChecker))
{
// set contentprepare checkers on needed fields
$getItem .= $this->setCustomViewFieldonContentPrepareChecker(
$main_get, $contentprepareChecker, '$data',
$code, $tab
);
}
$uikitChecker =
CFactory::_('Compiler.Builder.Site.Field.Data')->get('uikit.'
. $path);
if (ArrayHelper::check($uikitChecker))
{
// set uikit checkers on needed fields
$getItem .= $this->setCustomViewFieldUikitChecker(
$main_get, $uikitChecker, '$data', $code,
$tab
);
}
$asBucket[] = $main_get['as'];
}
}
}
// set the scripts
$Component =
CFactory::_('Compiler.Builder.Content.One')->get('Component');
$script = '';
foreach (CFactory::_('Config')->cryption_types as
$cryptionType)
{
if
(CFactory::_('Compiler.Builder.Site.Decrypt')->get("{$cryptionType}.{$code}",
false))
{
if ('expert' !== $cryptionType)
{
$script .= PHP_EOL . PHP_EOL . Indent::_(1) . $tab
. Indent::_(1) . "//" . Line::_(__Line__, __Class__)
. " Get the " . $cryptionType . " encryption.";
$script .= PHP_EOL . Indent::_(1) . $tab . Indent::_(1)
. "\$" . $cryptionType . "key = " . $Component
. "Helper::getCryptKey('" . $cryptionType .
"');";
$script .= PHP_EOL . Indent::_(1) . $tab . Indent::_(1)
. "//" . Line::_(__Line__, __Class__)
. " Get the encryption object.";
$script .= PHP_EOL . Indent::_(1) . $tab . Indent::_(1)
. "\$" . $cryptionType . " = new Super_" .
"__99175f6d_dba8_4086_8a65_5c4ec175e61d___Power(\$"
. $cryptionType . "key);";
}
elseif (CFactory::_('Compiler.Builder.Model.' .
ucfirst($cryptionType). '.Field.Initiator')->
exists("{$code}.get"))
{
foreach (CFactory::_('Compiler.Builder.Model.' .
ucfirst($cryptionType). '.Field.Initiator')->
get("{$code}.get") as $block)
{
$script .= PHP_EOL . Indent::_(1) . implode(
PHP_EOL . Indent::_(1), $block
);
}
}
}
}
$getItem = $script . $getItem;
// setup Globals
$getItem .= $this->setCustomViewGlobals(
$get->global, '$data', $asBucket, $tab
);
// setup the custom gets that returns multiple values
$getItem .= $this->setCustomViewCustomJoin(
$get->custom_get, '$data', $code, $asBucket, $tab
);
// set calculations
if ($get->addcalculation == 1)
{
$get->php_calculation = (array) explode(
PHP_EOL, (string) CFactory::_('Placeholder')->update_(
$get->php_calculation
)
);
$getItem .= PHP_EOL . Indent::_(1) . $tab
. Indent::_(1) . implode(
PHP_EOL . Indent::_(1) . $tab . Indent::_(1),
$get->php_calculation
);
}
if ($type === 'custom')
{
// return the object
$getItem .= PHP_EOL . PHP_EOL . Indent::_(1) . $tab . Indent::_(
1
) . "//" . Line::_(__Line__, __Class__)
. " return data object.";
$getItem .= PHP_EOL . Indent::_(1) . $tab . Indent::_(1)
. "return \$data;";
}
else
{
// set the object
$getItem .= PHP_EOL . PHP_EOL . Indent::_(1) . $tab . Indent::_(
1
) . "//" . Line::_(__Line__, __Class__)
. " set data object to item.";
$getItem .= PHP_EOL . Indent::_(1) . $tab . Indent::_(1)
. "\$this->_item[\$pk] = \$data;";
}
// only update if dispacher placholder is found
if (strpos($getItem, (string) Placefix::_h('DISPATCHER'))
!== false)
{
// check if the dispather should be added
if (!isset($this->JEventDispatcher)
|| !ArrayHelper::check(
$this->JEventDispatcher
))
{
$this->JEventDispatcher =
array(Placefix::_h('DISPATCHER') => '');
}
$getItem = str_replace(
array_keys($this->JEventDispatcher),
array_values($this->JEventDispatcher), $getItem
);
}
return $getItem;
}
return PHP_EOL . Indent::_(1) . $tab . Indent::_(1) . "//"
. Line::_(__Line__, __Class__) . "add your custom code
here.";
}
public function setCustomViewCustomMethods($main_view, $code)
{
$methods = '';
// then set the needed custom methods
if (ArrayHelper::check($main_view)
&& isset($main_view['settings'])
&& ObjectHelper::check($main_view['settings'])
&& isset($main_view['settings']->custom_get))
{
$_dynamic_get = $main_view['settings']->custom_get;
}
elseif (ObjectHelper::check($main_view)
&& isset($main_view->custom_get))
{
$_dynamic_get = $main_view->custom_get;
}
// check if we have an array
if (isset($_dynamic_get)
&& ArrayHelper::check(
$_dynamic_get
))
{
// start dynamic build
foreach ($_dynamic_get as $view)
{
// fix alias to use in code
$view->code = StringHelper::safe($code);
$view->Code = StringHelper::safe(
$view->code, 'F'
);
$view->CODE = StringHelper::safe(
$view->code, 'U'
);
$main = '';
if ($view->gettype == 3)
{
if
(CFactory::_('Config')->get('joomla_version', 3) ==
3)
{
// SITE_GET_ITEM <<<DYNAMIC>>>
$main .= PHP_EOL . PHP_EOL . Indent::_(2)
. "if (!isset(\$this->initSet) ||
!\$this->initSet)";
$main .= PHP_EOL . Indent::_(2) . "{";
$main .= PHP_EOL . Indent::_(3)
. "\$this->user = Factory::getUser();";
$main .= PHP_EOL . Indent::_(3)
. "\$this->userId =
\$this->user->get('id');";
$main .= PHP_EOL . Indent::_(3)
. "\$this->guest =
\$this->user->get('guest');";
$main .= PHP_EOL . Indent::_(3)
. "\$this->groups =
\$this->user->get('groups');";
$main .= PHP_EOL . Indent::_(3)
. "\$this->authorisedGroups =
\$this->user->getAuthorisedGroups();";
$main .= PHP_EOL . Indent::_(3)
. "\$this->levels =
\$this->user->getAuthorisedViewLevels();";
$main .= PHP_EOL . Indent::_(3) . "\$this->initSet =
true;";
$main .= PHP_EOL . Indent::_(2) . "}";
}
$main .= $this->setCustomViewGetItem(
$view, $view->code, '', 'custom'
);
$type
= 'mixed item data object on success, false on failure.';
}
elseif ($view->gettype == 4)
{
if
(CFactory::_('Config')->get('joomla_version', 3) ==
3)
{
$main .= PHP_EOL . PHP_EOL . Indent::_(2)
. "if (!isset(\$this->initSet) ||
!\$this->initSet)";
$main .= PHP_EOL . Indent::_(2) . "{";
$main .= PHP_EOL . Indent::_(3)
. "\$this->user = Factory::getUser();";
$main .= PHP_EOL . Indent::_(3)
. "\$this->userId =
\$this->user->get('id');";
$main .= PHP_EOL . Indent::_(3)
. "\$this->guest =
\$this->user->get('guest');";
$main .= PHP_EOL . Indent::_(3)
. "\$this->groups =
\$this->user->get('groups');";
$main .= PHP_EOL . Indent::_(3)
. "\$this->authorisedGroups =
\$this->user->getAuthorisedGroups();";
$main .= PHP_EOL . Indent::_(3)
. "\$this->levels =
\$this->user->getAuthorisedViewLevels();";
$main .= PHP_EOL . Indent::_(3) . "\$this->initSet =
true;";
$main .= PHP_EOL . Indent::_(2) . "}";
}
$main .= PHP_EOL . PHP_EOL . Indent::_(2) . "//"
. Line::_(__Line__, __Class__) . " Get the global params";
$main .= PHP_EOL . Indent::_(2)
. "\$globalParams = ComponentHelper::getParams('com_"
. CFactory::_('Config')->component_code_name .
"', true);";
// set php before listquery
if (isset($view->add_php_getlistquery)
&& $view->add_php_getlistquery == 1
&& isset($view->php_getlistquery)
&& StringHelper::check(
$view->php_getlistquery
))
{
$main .= CFactory::_('Placeholder')->update_(
$view->php_getlistquery
);
}
// SITE_GET_LIST_QUERY <<<DYNAMIC>>>
$main .= $this->setCustomViewListQuery(
$view, $view->code, false
);
// set before items php
if (isset($view->add_php_before_getitems)
&& $view->add_php_before_getitems == 1
&& isset($view->php_before_getitems)
&& StringHelper::check(
$view->php_before_getitems
))
{
$main .= CFactory::_('Placeholder')->update_(
$view->php_before_getitems
);
}
// load the object list
$main .= PHP_EOL . PHP_EOL . Indent::_(2) . "//"
. Line::_(__Line__, __Class__)
. " Reset the query using our newly populated query
object.";
$main .= PHP_EOL . Indent::_(2)
. "\$db->setQuery(\$query);";
$main .= PHP_EOL . Indent::_(2)
. "\$items = \$db->loadObjectList();";
// set after items php
if (isset($view->add_php_after_getitems)
&& $view->add_php_after_getitems == 1
&& isset($view->php_after_getitems)
&& StringHelper::check(
$view->php_after_getitems
))
{
$main .= CFactory::_('Placeholder')->update_(
$view->php_after_getitems
);
}
$main .= PHP_EOL . PHP_EOL . Indent::_(2)
. "if (empty(\$items))";
$main .= PHP_EOL . Indent::_(2) . "{";
$main .= PHP_EOL . Indent::_(3) . "return false;";
$main .= PHP_EOL . Indent::_(2) . "}";
// SITE_GET_ITEMS <<<DYNAMIC>>>
$main .= $this->setCustomViewGetItems($view, $view->code);
$main .= PHP_EOL . Indent::_(2) . "//" . Line::_(
__LINE__,__CLASS__
) . " return items";
$main .= PHP_EOL . Indent::_(2) . "return \$items;";
$type
= 'mixed An array of objects on success, false on
failure.';
}
// load the main mehtod
$methods .= $this->setMainCustomMehtod(
$main, $view->getcustom, $type
);
// SITE_CUSTOM_METHODS <<<DYNAMIC>>>
$methods .= $this->setCustomViewCustomItemMethods(
$view, $view->code
);
}
}
// load uikit get method
if (ArrayHelper::check($main_view)
&& isset($main_view['settings']))
{
$methods .= $this->setUikitGetMethod();
}
return $methods;
}
public function setUikitHelperMethods()
{
// only load for uikit version 2
if (2 == CFactory::_('Config')->uikit || 1 ==
CFactory::_('Config')->uikit)
{
// build uikit get method
$ukit = [];
$ukit[] = PHP_EOL . PHP_EOL . Indent::_(1) . "/**";
$ukit[] = Indent::_(1) . " * UIKIT Component Classes";
$ukit[] = Indent::_(1) . " **/";
$ukit[] = Indent::_(1) . "public static \$uk_components =
array(";
$ukit[] = Indent::_(3) . "'data-uk-grid' =>
array(";
$ukit[] = Indent::_(4) . "'grid' ),";
$ukit[] = Indent::_(3) . "'uk-accordion' =>
array(";
$ukit[] = Indent::_(4) . "'accordion' ),";
$ukit[] = Indent::_(3) . "'uk-autocomplete' =>
array(";
$ukit[] = Indent::_(4) . "'autocomplete' ),";
$ukit[] = Indent::_(3) . "'data-uk-datepicker' =>
array(";
$ukit[] = Indent::_(4) . "'datepicker' ),";
$ukit[] = Indent::_(3) . "'uk-form-password' =>
array(";
$ukit[] = Indent::_(4) . "'form-password' ),";
$ukit[] = Indent::_(3) . "'uk-form-select' =>
array(";
$ukit[] = Indent::_(4) . "'form-select' ),";
$ukit[] = Indent::_(3) . "'data-uk-htmleditor' =>
array(";
$ukit[] = Indent::_(4) . "'htmleditor' ),";
$ukit[] = Indent::_(3) . "'data-uk-lightbox' =>
array(";
$ukit[] = Indent::_(4) . "'lightbox' ),";
$ukit[] = Indent::_(3) . "'uk-nestable' =>
array(";
$ukit[] = Indent::_(4) . "'nestable' ),";
$ukit[] = Indent::_(3) . "'UIkit.notify' =>
array(";
$ukit[] = Indent::_(4) . "'notify' ),";
$ukit[] = Indent::_(3) . "'data-uk-parallax' =>
array(";
$ukit[] = Indent::_(4) . "'parallax' ),";
$ukit[] = Indent::_(3) . "'uk-search' =>
array(";
$ukit[] = Indent::_(4) . "'search' ),";
$ukit[] = Indent::_(3) . "'uk-slider' =>
array(";
$ukit[] = Indent::_(4) . "'slider' ),";
$ukit[] = Indent::_(3) . "'uk-slideset' =>
array(";
$ukit[] = Indent::_(4) . "'slideset' ),";
$ukit[] = Indent::_(3) . "'uk-slideshow' =>
array(";
$ukit[] = Indent::_(4) . "'slideshow',";
$ukit[] = Indent::_(4) . "'slideshow-fx' ),";
$ukit[] = Indent::_(3) . "'uk-sortable' =>
array(";
$ukit[] = Indent::_(4) . "'sortable' ),";
$ukit[] = Indent::_(3) . "'data-uk-sticky' =>
array(";
$ukit[] = Indent::_(4) . "'sticky' ),";
$ukit[] = Indent::_(3) . "'data-uk-timepicker' =>
array(";
$ukit[] = Indent::_(4) . "'timepicker' ),";
$ukit[] = Indent::_(3) . "'data-uk-tooltip' =>
array(";
$ukit[] = Indent::_(4) . "'tooltip' ),";
$ukit[] = Indent::_(3) . "'uk-placeholder' =>
array(";
$ukit[] = Indent::_(4) . "'placeholder' ),";
$ukit[] = Indent::_(3) . "'uk-dotnav' =>
array(";
$ukit[] = Indent::_(4) . "'dotnav' ),";
$ukit[] = Indent::_(3) . "'uk-slidenav' =>
array(";
$ukit[] = Indent::_(4) . "'slidenav' ),";
$ukit[] = Indent::_(3) . "'uk-form' => array(";
$ukit[] = Indent::_(4) . "'form-advanced' ),";
$ukit[] = Indent::_(3) . "'uk-progress' =>
array(";
$ukit[] = Indent::_(4) . "'progress' ),";
$ukit[] = Indent::_(3) . "'upload-drop' =>
array(";
$ukit[] = Indent::_(4) . "'upload', 'form-file'
)";
$ukit[] = Indent::_(3) . ");";
$ukit[] = PHP_EOL . Indent::_(1) . "/**";
$ukit[] = Indent::_(1) . " * Add UIKIT Components";
$ukit[] = Indent::_(1) . " **/";
$ukit[] = Indent::_(1) . "public static \$uikit = false;";
$ukit[] = "";
$ukit[] = Indent::_(1) . "/**";
$ukit[] = Indent::_(1) . " * Get UIKIT Components";
$ukit[] = Indent::_(1) . " **/";
$ukit[] = Indent::_(1)
. "public static function getUikitComp(\$content,\$classes =
array())";
$ukit[] = Indent::_(1) . "{";
$ukit[] = Indent::_(2)
. "if (strpos(\$content,'class=\"uk-') !==
false)";
$ukit[] = Indent::_(2) . "{";
$ukit[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) .
" reset";
$ukit[] = Indent::_(3) . "\$temp = [];";
$ukit[] = Indent::_(3)
. "foreach (self::\$uk_components as \$looking =>
\$add)";
$ukit[] = Indent::_(3) . "{";
$ukit[] = Indent::_(4)
. "if (strpos(\$content,\$looking) !== false)";
$ukit[] = Indent::_(4) . "{";
$ukit[] = Indent::_(5) . "\$temp[] = \$looking;";
$ukit[] = Indent::_(4) . "}";
$ukit[] = Indent::_(3) . "}";
$ukit[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__)
. " make sure uikit is loaded to config";
$ukit[] = Indent::_(3)
. "if (strpos(\$content,'class=\"uk-') !==
false)";
$ukit[] = Indent::_(3) . "{";
$ukit[] = Indent::_(4) . "self::\$uikit = true;";
$ukit[] = Indent::_(3) . "}";
$ukit[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__)
. " sorter";
$ukit[] = Indent::_(3) . "if (Super_" .
"__0a59c65c_9daf_4bc9_baf4_e063ff9e6a8a___Power::check(\$temp))";
$ukit[] = Indent::_(3) . "{";
$ukit[] = Indent::_(4) . "//" . Line::_(__Line__, __Class__)
. " merger";
$ukit[] = Indent::_(4) . "if (Super_" .
"__0a59c65c_9daf_4bc9_baf4_e063ff9e6a8a___Power::check(\$classes))";
$ukit[] = Indent::_(4) . "{";
$ukit[] = Indent::_(5)
. "\$newTemp = array_merge(\$temp,\$classes);";
$ukit[] = Indent::_(5) . "\$temp = array_unique(\$newTemp);";
$ukit[] = Indent::_(4) . "}";
$ukit[] = Indent::_(4) . "return \$temp;";
$ukit[] = Indent::_(3) . "}";
$ukit[] = Indent::_(2) . "}";
$ukit[] = Indent::_(2) . "if (Super_" .
"__0a59c65c_9daf_4bc9_baf4_e063ff9e6a8a___Power::check(\$classes))";
$ukit[] = Indent::_(2) . "{";
$ukit[] = Indent::_(3) . "return \$classes;";
$ukit[] = Indent::_(2) . "}";
$ukit[] = Indent::_(2) . "return false;";
$ukit[] = Indent::_(1) . "}";
// return the help methods
return implode(PHP_EOL, $ukit);
}
return '';
}
public function setUikitGetMethod()
{
$method = '';
// only load for uikit version 2
if (2 == CFactory::_('Config')->uikit || 1 ==
CFactory::_('Config')->uikit)
{
// build uikit get method
$method .= PHP_EOL . PHP_EOL . Indent::_(1) . "/**";
$method .= PHP_EOL . Indent::_(1)
. " * Get the uikit needed components";
$method .= PHP_EOL . Indent::_(1) . " *";
$method .= PHP_EOL . Indent::_(1)
. " * @return mixed An array of objects on success.";
$method .= PHP_EOL . Indent::_(1) . " *";
$method .= PHP_EOL . Indent::_(1) . " */";
$method .= PHP_EOL . Indent::_(1)
. "public function getUikitComp()";
$method .= PHP_EOL . Indent::_(1) . "{";
$method .= PHP_EOL . Indent::_(2)
. "if (isset(\$this->uikitComp) && "
. "Super_" .
"__0a59c65c_9daf_4bc9_baf4_e063ff9e6a8a___Power::check(\$this->uikitComp))";
$method .= PHP_EOL . Indent::_(2) . "{";
$method .= PHP_EOL . Indent::_(3) . "return
\$this->uikitComp;";
$method .= PHP_EOL . Indent::_(2) . "}";
$method .= PHP_EOL . Indent::_(2) . "return false;";
$method .= PHP_EOL . Indent::_(1) . "}";
}
return $method;
}
public function setMainCustomMehtod(&$body, $nAme, $type)
{
$method = '';
if (StringHelper::check($body))
{
// build custom method
$method .= PHP_EOL . PHP_EOL . Indent::_(1) . "/**";
$method .= PHP_EOL . Indent::_(1) . " * Custom Method";
$method .= PHP_EOL . Indent::_(1) . " *";
$method .= PHP_EOL . Indent::_(1) . " * @return " . $type;
$method .= PHP_EOL . Indent::_(1) . " *";
$method .= PHP_EOL . Indent::_(1) . " */";
$method .= PHP_EOL . Indent::_(1) . "public function " .
$nAme
. "()";
$method .= PHP_EOL . Indent::_(1) . "{" . $body;
$method .= PHP_EOL . Indent::_(1) . "}";
}
return $method;
}
public function setCustomViewCustomItemMethods(&$main_get, $code)
{
$methods = '';
$this->JEventDispatcher = '';
// first set the needed item/s methods
if (ObjectHelper::check($main_get))
{
if (isset($main_get->custom_get)
&& ArrayHelper::check($main_get->custom_get))
{
foreach ($main_get->custom_get as $get)
{
// set the site decription switch
foreach (CFactory::_('Config')->cryption_types as
$cryptionType)
{
CFactory::_('Compiler.Builder.Site.Decrypt')->set("{$cryptionType}.{$code}",
false);
}
// set the method defaults
if (($default = $this->setCustomViewMethodDefaults($get, $code))
!== false)
{
// build custom method
$methods .= PHP_EOL . PHP_EOL . Indent::_(1) . "/**";
$methods .= PHP_EOL . Indent::_(1)
. " * Method to get an array of " .
$default['name']
. " Objects.";
$methods .= PHP_EOL . Indent::_(1) . " *";
$methods .= PHP_EOL . Indent::_(1)
. " * @return mixed An array of "
. $default['name']
. " Objects on success, false on failure.";
$methods .= PHP_EOL . Indent::_(1) . " *";
$methods .= PHP_EOL . Indent::_(1) . " */";
$methods .= PHP_EOL . Indent::_(1)
. "public function get" .
$default['methodName']
. "(\$" . $default['on_field'] . ")";
$methods .= PHP_EOL . Indent::_(1) . "{" .
Placefix::_h("CRYPT") ;
$methods .= PHP_EOL . Indent::_(2) . "//"
. Line::_(__Line__, __Class__)
. " Get a db connection.";
if
(CFactory::_('Config')->get('joomla_version', 3) ==
3)
{
$methods .= PHP_EOL . Indent::_(2)
. "\$db = Factory::getDbo();";
}
else
{
$methods .= PHP_EOL . Indent::_(2)
. "\$db = \$this->getDatabase();";
}
$methods .= PHP_EOL . PHP_EOL . Indent::_(2) . "//"
. Line::_(__Line__, __Class__)
. " Create a new query object.";
$methods .= PHP_EOL . Indent::_(2)
. "\$query = \$db->getQuery(true);";
$methods .= PHP_EOL . PHP_EOL . Indent::_(2) . "//"
. Line::_(__Line__, __Class__) . " Get from "
. $get['selection']['table'] . " as "
. $default['as'];
$methods .= PHP_EOL . Indent::_(2)
. $get['selection']['select'];
$methods .= PHP_EOL . Indent::_(2) . '$query->from('
. $get['selection']['from'] . ');';
// set the string
if ($get['operator'] === 'IN'
|| $get['operator'] === 'NOT IN')
{
$methods .= PHP_EOL . PHP_EOL . Indent::_(2) . "//"
. Line::_(__Line__, __Class__) . " Check if \$"
. $default['on_field']
. " is an array with values.";
$methods .= PHP_EOL . Indent::_(2) . "\$array = ("
. "Super_" .
"__4b225c51_d293_48e4_b3f6_5136cf5c3f18___Power::check(\$"
. $default['on_field']
. ", true)) ? json_decode(\$"
. $default['on_field'] . ",true) : \$"
. $default['on_field'] . ";";
$methods .= PHP_EOL . Indent::_(2)
. "if (isset(\$array) && "
. "Super_" .
"__0a59c65c_9daf_4bc9_baf4_e063ff9e6a8a___Power::check(\$array,
true))";
$methods .= PHP_EOL . Indent::_(2) . "{";
$methods .= PHP_EOL . Indent::_(3)
. "\$query->where('" .
$get['join_field'] . " "
. $get['operator']
. " (' . implode(',', \$array) .
')');";
$methods .= PHP_EOL . Indent::_(2) . "}";
$methods .= PHP_EOL . Indent::_(2) . "else";
$methods .= PHP_EOL . Indent::_(2) . "{";
$methods .= PHP_EOL . Indent::_(3)
. "return false;";
$methods .= PHP_EOL . Indent::_(2) . "}";
}
else
{
$methods .= PHP_EOL . Indent::_(2)
. "\$query->where('" .
$get['join_field'] . " "
. $get['operator'] . " ' .
\$db->quote(\$"
. $default['on_field'] . "));";
}
// check if other queries should be loaded
foreach (CFactory::_('Compiler.Builder.Other.Query')->
get(CFactory::_('Config')->build_target . '.'
. $default['code'] . '.' . $default['as'],
[])
as $query)
{
$methods .= $query;
}
// add any other filter that was set
foreach (CFactory::_('Compiler.Builder.Other.Filter')->
get(CFactory::_('Config')->build_target . '.'
. $default['code'] . '.' . $default['as'],
[])
as $field => $string)
{
$methods .= $string;
}
// add any other where that was set
foreach (CFactory::_('Compiler.Builder.Other.Where')->
get(CFactory::_('Config')->build_target . '.'
. $default['code'] . '.' . $default['as'],
[])
as $field => $string)
{
$methods .= $string;
}
// add any other order that was set
foreach (CFactory::_('Compiler.Builder.Other.Order')->
get(CFactory::_('Config')->build_target . '.'
. $default['code'] . '.' . $default['as'],
[])
as $field => $string)
{
$methods .= $string;
}
// add any other grouping that was set
foreach (CFactory::_('Compiler.Builder.Other.Group')->
get(CFactory::_('Config')->build_target . '.'
. $default['code'] . '.' . $default['as'],
[])
as $field => $string)
{
$methods .= $string;
}
$methods .= PHP_EOL . PHP_EOL . Indent::_(2) . "//"
. Line::_(__Line__, __Class__)
. " Reset the query using our newly populated query
object.";
$methods .= PHP_EOL . Indent::_(2)
. "\$db->setQuery(\$query);";
$methods .= PHP_EOL . Indent::_(2) .
"\$db->execute();";
$methods .= PHP_EOL . PHP_EOL . Indent::_(2) . "//"
. Line::_(__Line__, __Class__)
. " check if there was data returned";
$methods .= PHP_EOL . Indent::_(2)
. "if (\$db->getNumRows())";
$methods .= PHP_EOL . Indent::_(2) . "{";
// set dispatcher placeholder
$methods .= Placefix::_h("DISPATCHER");
// build path
$path = $default['code'] . '.' .
$get['key'] . '.' . $default['as'];
// set decoding of needed fields
$decodeChecker =
CFactory::_('Compiler.Builder.Site.Field.Data')->get('decode.'
. $path);
// also filter fields if needed
$decodeFilter =
CFactory::_('Compiler.Builder.Site.Field.Decode.Filter')->
get(CFactory::_('Config')->build_target . '.'
. $path);
// set uikit checkers on needed fields
$uikitChecker =
CFactory::_('Compiler.Builder.Site.Field.Data')->get('uikit.'
. $path);
// set content prepare on needed fields
$contentprepareChecker =
CFactory::_('Compiler.Builder.Site.Field.Data')->
get('textareas.' . $path);
// set placeholder values
$placeholders = [
Placefix::_h('TAB') => Indent::_(2),
Placefix::_h('STRING') => '$item'
];
// set joined values
$joinedChecker =
CFactory::_('Compiler.Builder.Other.Join')->
get(CFactory::_('Config')->build_target . '.'
. $default['code'] . '.' . $default['as']);
if ($decodeChecker !== null || $uikitChecker !== null
|| $decodeFilter !== null || $contentprepareChecker !== null
|| $joinedChecker !== null)
{
$decoder = '';
if ($decodeChecker !== null &&
ArrayHelper::check($decodeChecker))
{
// also filter fields if needed
$decoder = $this->setCustomViewFieldDecode(
$get, $decodeChecker, '$item',
$default['code'], Indent::_(2)
);
}
$decoder_filter = '';
if ($decodeFilter !== null &&
ArrayHelper::check($decodeFilter))
{
$decoder_filter
= $this->setCustomViewFieldDecodeFilter(
$get, $decodeFilter, '$item', '$items[$nr]',
$default['code'], Indent::_(2)
);
}
$contentprepare = '';
if ($contentprepareChecker !== null &&
ArrayHelper::check($contentprepareChecker))
{
$contentprepare
= $this->setCustomViewFieldonContentPrepareChecker(
$get, $contentprepareChecker, '$item',
$default['code'], Indent::_(2)
);
}
$uikit = '';
if ($uikitChecker !== null &&
ArrayHelper::check($uikitChecker))
{
$uikit = $this->setCustomViewFieldUikitChecker(
$get, $uikitChecker, '$item',
$default['code'], Indent::_(2)
);
}
$joine = '';
if ($joinedChecker !== null &&
ArrayHelper::check($joinedChecker))
{
foreach ($joinedChecker as $joinedString)
{
$joine .= CFactory::_('Placeholder')->update(
$joinedString, $placeholders
);
}
}
if (StringHelper::check($decoder) ||
StringHelper::check($contentprepare)
|| StringHelper::check($uikit) ||
StringHelper::check($decoder_filter)
|| StringHelper::check($joine))
{
$methods .= PHP_EOL . Indent::_(3)
. "\$items = \$db->loadObjectList();";
$methods .= PHP_EOL . PHP_EOL . Indent::_(3)
. "//" . Line::_(__Line__, __Class__)
. " Convert the parameter fields into objects.";
$methods .= PHP_EOL . Indent::_(3)
. "foreach (\$items as \$nr => &\$item)";
$methods .= PHP_EOL . Indent::_(3) . "{";
if (StringHelper::check($decoder))
{
$methods .= $decoder;
}
if (StringHelper::check($decoder_filter))
{
$methods .= $decoder_filter;
}
if (StringHelper::check($contentprepare))
{
$methods .= $contentprepare;
}
if (StringHelper::check($uikit))
{
$methods .= $uikit;
}
if (StringHelper::check($joine))
{
$methods .= $joine;
}
$methods .= PHP_EOL . Indent::_(3) . "}";
$methods .= PHP_EOL . Indent::_(3)
. "return \$items;";
}
else
{
$methods .= PHP_EOL . Indent::_(3)
. "return \$db->loadObjectList();";
}
}
else
{
$methods .= PHP_EOL . Indent::_(3)
. "return \$db->loadObjectList();";
}
$methods .= PHP_EOL . Indent::_(2) . "}";
$methods .= PHP_EOL . Indent::_(2) . "return false;";
$methods .= PHP_EOL . Indent::_(1) . "}";
// set the script if it was found
$Component =
CFactory::_('Compiler.Builder.Content.One')->get('Component');
$script = '';
foreach (CFactory::_('Config')->cryption_types as
$cryptionType)
{
if
(CFactory::_('Compiler.Builder.Site.Decrypt')->get("{$cryptionType}.{$code}",
false))
{
if ('expert' !== $cryptionType)
{
$script .= PHP_EOL . Indent::_(2) . "//"
. Line::_(__Line__, __Class__) . " Get the "
. $cryptionType . " encryption.";
$script .= PHP_EOL . Indent::_(2) . "\$"
. $cryptionType . "key = " . $Component
. "Helper::getCryptKey('"
. $cryptionType . "');";
$script .= PHP_EOL . Indent::_(2) . "//"
. Line::_(__Line__, __Class__)
. " Get the encryption object.";
$script .= PHP_EOL . Indent::_(2) . "\$"
. $cryptionType
. " = new Super_" .
"__99175f6d_dba8_4086_8a65_5c4ec175e61d___Power(\$"
. $cryptionType . "key);" . PHP_EOL;
}
elseif (CFactory::_('Compiler.Builder.Model.' .
ucfirst($cryptionType). '.Field.Initiator')->
exists("{$code}.get"))
{
foreach (CFactory::_('Compiler.Builder.Model.' .
ucfirst($cryptionType). '.Field.Initiator')->
exists("{$code}.get") as $block)
{
$script .= PHP_EOL . Indent::_(2) . implode(
PHP_EOL . Indent::_(2), $block
);
}
}
}
}
$methods = str_replace(
Placefix::_h('CRYPT'), $script, $methods
);
}
}
// insure the crypt placeholder is removed
if (StringHelper::check($methods))
{
$methods = str_replace(
Placefix::_h('CRYPT'), '', $methods
);
}
}
}
// only update if dispacher placholder is found
if (strpos($methods, (string) Placefix::_h('DISPATCHER')) !==
false)
{
// check if the dispather should be added
if (!isset($this->JEventDispatcher)
|| !ArrayHelper::check($this->JEventDispatcher))
{
$this->JEventDispatcher = array(Placefix::_h('DISPATCHER')
=> '');
}
$methods = str_replace(
array_keys($this->JEventDispatcher),
array_values($this->JEventDispatcher), $methods
);
}
// insure the crypt placeholder is removed
if (StringHelper::check($methods))
{
return $methods . PHP_EOL;
}
return '';
}
public function setCustomViewMethodDefaults($get, $code)
{
if (isset($get['key']) && isset($get['as']))
{
$key = substr(
(string) StringHelper::safe(
preg_replace('/[0-9]+/', '', md5((string)
$get['key'])), 'F'
), 0, 4
);
$method['on_field'] = (isset($get['on_field']))
? $this->removeAsDot($get['on_field']) : null;
$method['join_field'] = (isset($get['join_field']))
? StringHelper::safe(
$this->removeAsDot($get['join_field'])
) : null;
$method['Join_field'] =
(isset($method['join_field']))
? StringHelper::safe($method['join_field'], 'F')
: null;
$method['name'] = StringHelper::safe(
$get['selection']['name'], 'F'
);
$method['code'] = StringHelper::safe($code);
$method['AS'] = StringHelper::safe(
$get['as'], 'U'
);
$method['as'] = StringHelper::safe(
$get['as']
);
$method['valueName'] = $method['on_field'] .
$method['Join_field']
. $method['name'] . $method['AS'];
$method['methodName'] = StringHelper::safe(
$method['on_field'], 'F'
) . $method['Join_field'] . $method['name'] . $key
. '_'
. $method['AS'];
// return
return $method;
}
return false;
}
public function setCustomViewListQuery(&$get, $code, $return = true)
{
if (ObjectHelper::check($get))
{
if ($get->pagination == 1)
{
$getItem = PHP_EOL . Indent::_(2) . "//" . Line::_(
__LINE__,__CLASS__
) . " Get a db connection.";
}
else
{
$getItem = PHP_EOL . Indent::_(2) . "//" . Line::_(
__LINE__,__CLASS__
)
. " Make sure all records load, since no pagination
allowed.";
$getItem .= PHP_EOL . Indent::_(2)
. "\$this->setState('list.limit', 0);";
$getItem .= PHP_EOL . Indent::_(2) . "//" . Line::_(
__LINE__,__CLASS__
) . " Get a db connection.";
}
if (CFactory::_('Config')->get('joomla_version',
3) == 3)
{
$getItem .= PHP_EOL . Indent::_(2) . "\$db =
Factory::getDbo();";
}
else
{
$getItem .= PHP_EOL . Indent::_(2) . "\$db =
\$this->getDatabase();";
}
$getItem .= PHP_EOL . PHP_EOL . Indent::_(2) . "//"
. Line::_(__Line__, __Class__) . " Create a new query
object.";
$getItem .= PHP_EOL . Indent::_(2)
. "\$query = \$db->getQuery(true);";
// set main get query
$getItem .= $this->setCustomViewQuery($get->main_get, $code);
// check if there is any custom script
$getItem .= CFactory::_('Customcode.Dispenser')->get(
CFactory::_('Config')->build_target .
'_php_getlistquery', $code, '',
PHP_EOL . PHP_EOL . Indent::_(2) . "//" . Line::_(
__LINE__,__CLASS__
) . " Filtering.", true
);
// setup filters
if (isset($get->filter))
{
$getItem .= $this->setCustomViewFilter($get->filter, $code);
}
// setup where
if (isset($get->where))
{
$getItem .= $this->setCustomViewWhere($get->where, $code);
}
// setup ordering
if (isset($get->order))
{
$getItem .= $this->setCustomViewOrder($get->order, $code);
}
// setup grouping
if (isset($get->group))
{
$getItem .= $this->setCustomViewGroup($get->group, $code);
}
if ($return)
{
// return the query object
$getItem .= PHP_EOL . PHP_EOL . Indent::_(2) . "//"
. Line::_(__Line__, __Class__) . " return the query object"
. PHP_EOL . Indent::_(2) . "return \$query;";
}
return $getItem;
}
return PHP_EOL . Indent::_(2) . "//" . Line::_(__Line__,
__Class__)
. "add your custom code here.";
}
/**
* @param $get
* @param $code
*
* @return string
*/
public function setCustomViewGetItems(&$get, $code)
{
$getItem = '';
// set the site decrypt switch
foreach (CFactory::_('Config')->cryption_types as
$cryptionType)
{
CFactory::_('Compiler.Builder.Site.Decrypt')->set("{$cryptionType}.{$code}",
false);
}
// set the component name
$Component =
CFactory::_('Compiler.Builder.Content.One')->get('Component');
// start load the get item
if (ObjectHelper::check($get))
{
$getItem .= PHP_EOL . PHP_EOL . Indent::_(2) . "//"
. Line::_(__Line__, __Class__)
. " Insure all item fields are adapted where needed.";
$getItem .= PHP_EOL . Indent::_(2) . "if ("
. "Super_" .
"__0a59c65c_9daf_4bc9_baf4_e063ff9e6a8a___Power::check(\$items))";
$getItem .= PHP_EOL . Indent::_(2) . "{";
$getItem .= Placefix::_h("DISPATCHER") ;
$getItem .= PHP_EOL . Indent::_(3)
. "foreach (\$items as \$nr => &\$item)";
$getItem .= PHP_EOL . Indent::_(3) . "{";
$getItem .= PHP_EOL . Indent::_(4) . "//" . Line::_(__Line__,
__Class__)
. " Always create a slug for sef URL's";
$getItem .= PHP_EOL . Indent::_(4)
. "\$item->slug = (\$item->id ?? '0') .
(isset(\$item->alias) ? ':' . \$item->alias :
'');";
if (isset($get->main_get)
&& ArrayHelper::check(
$get->main_get
))
{
$asBucket = [];
foreach ($get->main_get as $main_get)
{
// build path
$path = $code . '.' . $main_get['key'] .
'.' . $main_get['as'];
$decodeChecker =
CFactory::_('Compiler.Builder.Site.Field.Data')->get('decode.'
. $path);
if (ArrayHelper::check($decodeChecker))
{
// set decoding of needed fields
$getItem .= $this->setCustomViewFieldDecode(
$main_get, $decodeChecker, "\$item", $code,
Indent::_(2)
);
}
// also filter fields if needed
$decodeFilter =
CFactory::_('Compiler.Builder.Site.Field.Decode.Filter')->
get(CFactory::_('Config')->build_target . '.'
. $path);
if (ArrayHelper::check($decodeFilter))
{
$getItem .= $this->setCustomViewFieldDecodeFilter(
$main_get, $decodeFilter, "\$item",
'$items[$nr]', $code, Indent::_(2)
);
}
$contentprepareChecker =
CFactory::_('Compiler.Builder.Site.Field.Data')->get('textareas.'
. $path);
if (ArrayHelper::check($contentprepareChecker))
{
// set contentprepare checkers on needed fields
$getItem .= $this->setCustomViewFieldonContentPrepareChecker(
$main_get, $contentprepareChecker, "\$item",
$code, Indent::_(2)
);
}
$uikitChecker =
CFactory::_('Compiler.Builder.Site.Field.Data')->get('uikit.'
. $path);
if (ArrayHelper::check($uikitChecker))
{
// set uikit checkers on needed fields
$getItem .= $this->setCustomViewFieldUikitChecker(
$main_get, $uikitChecker, "\$item", $code,
Indent::_(2)
);
}
$asBucket[] = $main_get['as'];
}
}
// only update if dispacher placholder is found
if (strpos($getItem, (string) Placefix::_h('DISPATCHER'))
!== false)
{
// check if the dispather should be added
if (!isset($this->JEventDispatcher)
|| !ArrayHelper::check(
$this->JEventDispatcher
))
{
$this->JEventDispatcher =
array(Placefix::_h('DISPATCHER') => '');
}
$getItem = str_replace(
array_keys($this->JEventDispatcher),
array_values($this->JEventDispatcher), $getItem
);
}
// setup Globals
$getItem .= $this->setCustomViewGlobals(
$get->global, '$item', $asBucket, Indent::_(2)
);
// setup the custom gets that returns multipal values
$getItem .= $this->setCustomViewCustomJoin(
$get->custom_get, "\$item", $code, $asBucket,
Indent::_(2)
);
// set calculations
if ($get->addcalculation == 1)
{
$get->php_calculation = (array) explode(
PHP_EOL, (string) $get->php_calculation
);
if (ArrayHelper::check($get->php_calculation))
{
$_tmp = PHP_EOL . Indent::_(4) . implode(
PHP_EOL . Indent::_(4), $get->php_calculation
);
$getItem .= CFactory::_('Placeholder')->update_(
$_tmp
);
}
}
$getItem .= PHP_EOL . Indent::_(3) . "}";
$getItem .= PHP_EOL . Indent::_(2) . "}";
// remove empty foreach
if (strlen($getItem) <= 100)
{
$getItem = PHP_EOL;
}
}
// set the script if found
$script = '';
foreach (CFactory::_('Config')->cryption_types as
$cryptionType)
{
if
(CFactory::_('Compiler.Builder.Site.Decrypt')->get("{$cryptionType}.{$code}",
false))
{
if ('expert' !== $cryptionType)
{
$script .= PHP_EOL . PHP_EOL . Indent::_(2) . "//"
. Line::_(__Line__, __Class__) . " Get the " .
$cryptionType
. " encryption.";
$script .= PHP_EOL . Indent::_(2) . "\$" . $cryptionType
. "key = " . $Component .
"Helper::getCryptKey('"
. $cryptionType . "');";
$script .= PHP_EOL . Indent::_(2) . "//" . Line::_(
__LINE__,__CLASS__
) . " Get the encryption object.";
$script .= PHP_EOL . Indent::_(2) . "\$" . $cryptionType
. " = new Super_" .
"__99175f6d_dba8_4086_8a65_5c4ec175e61d___Power(\$" .
$cryptionType . "key);";
}
elseif (CFactory::_('Compiler.Builder.Model.' .
ucfirst($cryptionType). '.Field.Initiator')->
exists("{$code}.get"))
{
foreach (CFactory::_('Compiler.Builder.Model.' .
ucfirst($cryptionType). '.Field.Initiator')->
get("{$code}.get") as $block)
{
$script .= PHP_EOL . Indent::_(2) . implode(
PHP_EOL . Indent::_(2), $block
);
}
}
}
}
return $script . $getItem;
}
/**
* build code for the admin view display method
*
* @param string $nameListCode The list view name
*
* @return string The php to place in view.html.php
*
*/
public function setAdminViewDisplayMethod($nameListCode)
{
$script = '';
// add the new filter methods for the search toolbar above the list view
(2 = topbar)
if
(CFactory::_('Compiler.Builder.Admin.Filter.Type')->get($nameListCode,
1) == 2)
{
$script .= PHP_EOL . Indent::_(2) . "//"
. Line::_(
__LINE__,__CLASS__
) . " Load the filter form from xml.";
$script .= PHP_EOL . Indent::_(2) . "\$this->filterForm "
. "= \$this->get('FilterForm');";
$script .= PHP_EOL . Indent::_(2) . "//"
. Line::_(
__LINE__,__CLASS__
) . " Load the active filters.";
$script .= PHP_EOL . Indent::_(2) . "\$this->activeFilters
"
. "= \$this->get('ActiveFilters');";
}
// get the default ordering values
$default_ordering = $this->getListViewDefaultOrdering($nameListCode);
// now add the default ordering
$script .= PHP_EOL . Indent::_(2) . "//"
. Line::_(
__LINE__,__CLASS__
) . " Add the list ordering clause.";
$script .= PHP_EOL . Indent::_(2)
. "\$this->listOrder =
\$this->escape(\$this->state->get('list.ordering',
'"
. $default_ordering['name'] . "'));";
$script .= PHP_EOL . Indent::_(2)
. "\$this->listDirn =
\$this->escape(\$this->state->get('list.direction',
'"
. $default_ordering['direction'] . "'));";
return $script;
}
public function setCustomViewDisplayMethod(&$view)
{
$method = '';
if (isset($view['settings']->main_get)
&&
ObjectHelper::check($view['settings']->main_get))
{
// add events if needed
if ($view['settings']->main_get->gettype == 1
&& ArrayHelper::check(
$view['settings']->main_get->plugin_events
))
{
// load the dispatcher
$method .= PHP_EOL . Indent::_(2) . "//" . Line::_(
__LINE__,__CLASS__
) . " Initialise dispatcher.";
$method .= PHP_EOL . Indent::_(2)
. "\$dispatcher = JEventDispatcher::getInstance();";
}
if ($view['settings']->main_get->gettype == 1)
{
// for single views
$method .= PHP_EOL . Indent::_(2) . "//" . Line::_(
__LINE__,__CLASS__
) . " Initialise variables.";
$method .= PHP_EOL . Indent::_(2)
. "\$this->item = \$this->get('Item');";
}
elseif ($view['settings']->main_get->gettype == 2)
{
// for list views
$method .= PHP_EOL . Indent::_(2) . "//" . Line::_(
__LINE__,__CLASS__
) . " Initialise variables.";
$method .= PHP_EOL . Indent::_(2)
. "\$this->items = \$this->get('Items');";
// only add if pagination is requered
if ($view['settings']->main_get->pagination == 1)
{
$method .= PHP_EOL . Indent::_(2)
. "\$this->pagination =
\$this->get('Pagination');";
}
}
// add the custom get methods
if (isset($view['settings']->custom_get)
&& ArrayHelper::check(
$view['settings']->custom_get
))
{
foreach ($view['settings']->custom_get as $custom_get)
{
$custom_get_name = str_replace(
'get', '', (string) $custom_get->getcustom
);
$method .= PHP_EOL . Indent::_(2) . "\$this->"
. StringHelper::safe($custom_get_name)
. " = \$this->get('" . $custom_get_name .
"');";
}
}
// add custom script
if ($view['settings']->add_php_jview_display == 1)
{
$view['settings']->php_jview_display = (array) explode(
PHP_EOL, (string) $view['settings']->php_jview_display
);
if (ArrayHelper::check(
$view['settings']->php_jview_display
))
{
$_tmp = PHP_EOL . Indent::_(2) . implode(
PHP_EOL . Indent::_(2),
$view['settings']->php_jview_display
);
$method .= CFactory::_('Placeholder')->update_(
$_tmp
);
}
}
if ('site' ===
CFactory::_('Config')->build_target)
{
$method .= PHP_EOL . PHP_EOL . Indent::_(2) . "//"
. Line::_(__Line__, __Class__) . " Set the toolbar";
$method .= PHP_EOL . Indent::_(2) .
"\$this->addToolBar();";
$method .= PHP_EOL . PHP_EOL . Indent::_(2) . "//"
. Line::_(__Line__, __Class__) . " Set the html view document
stuff";
$method .= PHP_EOL . Indent::_(2)
. "\$this->_prepareDocument();";
}
elseif ('custom_admin' ===
CFactory::_('Config')->build_target)
{
$method .= PHP_EOL . PHP_EOL . Indent::_(2) . "//"
. Line::_(__Line__, __Class__)
. " We don't need toolbar in the modal window.";
$method .= PHP_EOL . Indent::_(2)
. "if (\$this->getLayout() !== 'modal')";
$method .= PHP_EOL . Indent::_(2) . "{";
$method .= PHP_EOL . Indent::_(3) . "//" . Line::_(
__LINE__,__CLASS__
) . " add the tool bar";
$method .= PHP_EOL . Indent::_(3) .
"\$this->addToolBar();";
$method .= PHP_EOL . Indent::_(2) . "}";
if (CFactory::_('Config')->get('joomla_version',
3) == 3)
{
$method .= PHP_EOL . PHP_EOL . Indent::_(2) . "//"
. Line::_(__Line__, __Class__) . " set the document";
$method .= PHP_EOL . Indent::_(2) .
"\$this->setDocument();";
}
}
$method .= PHP_EOL . PHP_EOL . Indent::_(2) . "//" . Line::_(
__LINE__,__CLASS__
) . " Check for errors.";
$method .= PHP_EOL . Indent::_(2)
. "if (count(\$errors =
\$this->get('Errors')))";
$method .= PHP_EOL . Indent::_(2) . "{";
$method .= PHP_EOL . Indent::_(3)
. "throw new \Exception(implode(PHP_EOL, \$errors), 500);";
$method .= PHP_EOL . Indent::_(2) . "}";
// add events if needed
if ($view['settings']->main_get->gettype == 1
&& ArrayHelper::check(
$view['settings']->main_get->plugin_events
))
{
$method .= PHP_EOL . Indent::_(2) . "//" . Line::_(
__LINE__,__CLASS__
) . " Process the content plugins.";
$method .= PHP_EOL . Indent::_(2) . "if ("
. "Super_" .
"__91004529_94a9_4590_b842_e7c6b624ecf5___Power::check(\$this->item))";
$method .= PHP_EOL . Indent::_(2) . "{";
$method .= PHP_EOL . Indent::_(3)
. "PluginHelper::importPlugin('content');";
$method .= PHP_EOL . Indent::_(3) . "//" . Line::_(
__LINE__,__CLASS__
) . " Setup Event Object.";
$method .= PHP_EOL . Indent::_(3)
. "\$this->item->event = new \stdClass;";
$method .= PHP_EOL . Indent::_(3) . "//" . Line::_(
__LINE__,__CLASS__
) . " Check if item has params, or pass global params";
$method .= PHP_EOL . Indent::_(3)
. "\$params = (isset(\$this->item->params) &&
"
. "Super_" .
"__4b225c51_d293_48e4_b3f6_5136cf5c3f18___Power::check(\$this->item->params))
? json_decode(\$this->item->params) : \$this->params;";
// load the defaults
foreach (
$view['settings']->main_get->plugin_events as
$plugin_event
)
{
// load the events
if ('onContentPrepare' === $plugin_event)
{
// TODO the onContentPrepare already gets triggered on the fields of
its relation
// $method .= PHP_EOL . Indent::_(2) . "//" .
Line::_(__Line__, __Class__) . " onContentPrepare Event
Trigger.";
// $method .= PHP_EOL . Indent::_(2) .
"\$dispatcher->trigger('onContentPrepare', array
('com_" . CFactory::_('Config')->component_code_name
. ".article', &\$this->item, &\$this->params,
0));";
}
else
{
$method .= PHP_EOL . Indent::_(3) . "//"
. Line::_(__Line__, __Class__) . " " . $plugin_event
. " Event Trigger.";
$method .= PHP_EOL . Indent::_(3)
. "\$results = \$dispatcher->trigger('"
. $plugin_event . "', array('com_"
. CFactory::_('Config')->component_code_name .
"."
. $view['settings']->context
. "', &\$this->item, &\$params, 0));";
$method .= PHP_EOL . Indent::_(3)
. '$this->item->event->' . $plugin_event
. ' = trim(implode("\n", $results));';
}
}
$method .= PHP_EOL . Indent::_(2) . "}";
}
$method .= PHP_EOL . PHP_EOL . Indent::_(2)
. "parent::display(\$tpl);";
}
return $method;
}
public function setPrepareDocument(&$view)
{
// fix just incase we missed it somewhere
$tmp = CFactory::_('Config')->lang_target;
if ('site' ===
CFactory::_('Config')->build_target)
{
CFactory::_('Config')->lang_target = 'site';
}
else
{
CFactory::_('Config')->lang_target = 'admin';
}
// ensure correct target is set
$TARGET =
StringHelper::safe(CFactory::_('Config')->build_target,
'U');
// set libraries $TARGET.'_LIBRARIES_LOADER
CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code
. '|' . $TARGET . '_LIBRARIES_LOADER',
$this->setLibrariesLoader($view)
);
// set uikit $TARGET.'_UIKIT_LOADER
CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code
. '|' . $TARGET . '_UIKIT_LOADER',
$this->setUikitLoader($view)
);
// set Google Charts $TARGET.'_GOOGLECHART_LOADER
CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code
. '|' .$TARGET . '_GOOGLECHART_LOADER',
$this->setGoogleChartLoader($view)
);
// set Footable FOOTABLE_LOADER
CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code
. '|' . $TARGET . '_FOOTABLE_LOADER',
$this->setFootableScriptsLoader($view)
);
// set metadata DOCUMENT_METADATA
CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code
. '|' . $TARGET . '_DOCUMENT_METADATA',
$this->setDocumentMetadata($view)
);
// set custom php scripting DOCUMENT_CUSTOM_PHP
CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code
. '|' . $TARGET . '_DOCUMENT_CUSTOM_PHP',
$this->setDocumentCustomPHP($view)
);
// set custom css DOCUMENT_CUSTOM_CSS
CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code
. '|' .$TARGET . '_DOCUMENT_CUSTOM_CSS',
$this->setDocumentCustomCSS($view)
);
// set custom javascript DOCUMENT_CUSTOM_JS
CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code
. '|' . $TARGET . '_DOCUMENT_CUSTOM_JS',
$this->setDocumentCustomJS($view)
);
// set custom css file VIEWCSS
CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code
. '|' . $TARGET . '_VIEWCSS',
$this->setCustomCSS($view)
);
// incase no buttons are found
CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code
. '|SITE_JAVASCRIPT_FOR_BUTTONS', '');
// set the custom buttons CUSTOM_BUTTONS
CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code
. '|' . $TARGET . '_CUSTOM_BUTTONS',
$this->setCustomButtons($view)
);
// see if we should add get modules to the view.html
CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code
. '|' . $TARGET . '_GET_MODULE',
$this->setGetModules($view, $TARGET)
);
// set a JavaScript file if needed
CFactory::_('Compiler.Builder.Content.Multi')->add($view['settings']->code
. '|' . $TARGET . '_LIBRARIES_LOADER',
$this->setJavaScriptFile($view, $TARGET), false
);
// fix just incase we missed it somewhere
CFactory::_('Config')->lang_target = $tmp;
}
public function setGetModules($view, $TARGET)
{
if (CFactory::_('Compiler.Builder.Get.Module')->
exists(CFactory::_('Config')->build_target . '.'
. $view['settings']->code))
{
$addModule = [];
$addModule[] = PHP_EOL . PHP_EOL . Indent::_(1) . "/**";
$addModule[] = Indent::_(1)
. " * Get the modules published in a position";
$addModule[] = Indent::_(1) . " */";
$addModule[] = Indent::_(1)
. "public function getModules(\$position, \$seperator =
'', \$class = '')";
$addModule[] = Indent::_(1) . "{";
$addModule[] = Indent::_(2) . "//" . Line::_(__Line__,
__Class__)
. " set default";
$addModule[] = Indent::_(2) . "\$found = false;";
$addModule[] = Indent::_(2) . "//" . Line::_(__Line__,
__Class__)
. " check if we aleady have these modules loaded";
$addModule[] = Indent::_(2)
. "if (isset(\$this->setModules[\$position]))";
$addModule[] = Indent::_(2) . "{";
$addModule[] = Indent::_(3) . "\$found = true;";
$addModule[] = Indent::_(2) . "}";
$addModule[] = Indent::_(2) . "else";
$addModule[] = Indent::_(2) . "{";
$addModule[] = Indent::_(3) . "//" . Line::_(__Line__,
__Class__)
. " this is where you want to load your module position";
$addModule[] = Indent::_(3)
. "\$modules = ModuleHelper::getModules(\$position);";
$addModule[] = Indent::_(3) . "if ("
. "Super_" .
"__0a59c65c_9daf_4bc9_baf4_e063ff9e6a8a___Power::check(\$modules,
true))";
$addModule[] = Indent::_(3) . "{";
$addModule[] = Indent::_(4) . "//" . Line::_(__Line__,
__Class__)
. " set the place holder";
$addModule[] = Indent::_(4)
. "\$this->setModules[\$position] = [];";
$addModule[] = Indent::_(4) . "foreach(\$modules as
\$module)";
$addModule[] = Indent::_(4) . "{";
$addModule[] = Indent::_(5)
. "\$this->setModules[\$position][] =
ModuleHelper::renderModule(\$module);";
$addModule[] = Indent::_(4) . "}";
$addModule[] = Indent::_(4) . "\$found = true;";
$addModule[] = Indent::_(3) . "}";
$addModule[] = Indent::_(2) . "}";
$addModule[] = Indent::_(2) . "//" . Line::_(__Line__,
__Class__)
. " check if modules were found";
$addModule[] = Indent::_(2)
. "if (\$found && isset(\$this->setModules[\$position])
&& "
. "Super_" .
"__0a59c65c_9daf_4bc9_baf4_e063ff9e6a8a___Power::check(\$this->setModules[\$position]))";
$addModule[] = Indent::_(2) . "{";
$addModule[] = Indent::_(3) . "//" . Line::_(__Line__,
__Class__)
. " set class";
$addModule[] = Indent::_(3) . "if ("
. "Super_" .
"__1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::check(\$class))";
$addModule[] = Indent::_(3) . "{";
$addModule[] = Indent::_(4)
. "\$class = ' class=\"'.\$class.'\"
';";
$addModule[] = Indent::_(3) . "}";
$addModule[] = Indent::_(3) . "//" . Line::_(__Line__,
__Class__)
. " set seperating return values";
$addModule[] = Indent::_(3) . "switch(\$seperator)";
$addModule[] = Indent::_(3) . "{";
$addModule[] = Indent::_(4) . "case 'none':";
$addModule[] = Indent::_(5)
. "return implode('',
\$this->setModules[\$position]);";
$addModule[] = Indent::_(5) . "break;";
$addModule[] = Indent::_(4) . "case 'div':";
$addModule[] = Indent::_(5)
. "return
'<div'.\$class.'>'.implode('</div><div'.\$class.'>',
\$this->setModules[\$position]).'</div>';";
$addModule[] = Indent::_(5) . "break;";
$addModule[] = Indent::_(4) . "case 'list':";
$addModule[] = Indent::_(5)
. "return
'<ul'.\$class.'><li>'.implode('</li><li>',
\$this->setModules[\$position]).'</li></ul>';";
$addModule[] = Indent::_(5) . "break;";
$addModule[] = Indent::_(4) . "case 'array':";
$addModule[] = Indent::_(4) . "case 'Array':";
$addModule[] = Indent::_(5)
. "return \$this->setModules[\$position];";
$addModule[] = Indent::_(5) . "break;";
$addModule[] = Indent::_(4) . "default:";
$addModule[] = Indent::_(5)
. "return implode('<br />',
\$this->setModules[\$position]);";
$addModule[] = Indent::_(5) . "break;";
$addModule[] = Indent::_(3) . "}";
$addModule[] = Indent::_(2) . "}";
$addModule[] = Indent::_(2) . "return false;";
$addModule[] = Indent::_(1) . "}";
CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code
. '|' . $TARGET . '_GET_MODULE_JIMPORT',
PHP_EOL . "use Joomla\CMS\Helper\ModuleHelper;"
);
return implode(PHP_EOL, $addModule);
}
CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code
. '|' . $TARGET . '_GET_MODULE_JIMPORT',
'');
return '';
}
public function setDocumentCustomPHP(&$view)
{
if ($view['settings']->add_php_document == 1)
{
$view['settings']->php_document = (array) explode(
PHP_EOL, (string) $view['settings']->php_document
);
if (ArrayHelper::check(
$view['settings']->php_document
))
{
$_tmp = PHP_EOL . Indent::_(2) . implode(
PHP_EOL . Indent::_(2), $view['settings']->php_document
);
return CFactory::_('Placeholder')->update_($_tmp);
}
}
return '';
}
public function setCustomButtons(&$view, $type = 1, $tab =
'')
{
// do not validate selection
$validateSelection = 'false';
// ensure correct target is set
$TARGET =
StringHelper::safe(CFactory::_('Config')->build_target,
'U');
if (1 == $type || 2 == $type)
{
if (1 == $type)
{
$viewCodeName = $view['settings']->code;
}
if (2 == $type)
{
$viewCodeName = $view['settings']->name_single_code;
}
}
elseif (3 == $type)
{
// set the names
$viewCodeName = $view['settings']->name_single_code;
$viewsCodeName = $view['settings']->name_list_code;
// if it's not been set before
if
(!CFactory::_('Compiler.Builder.Content.Multi')->exists($viewsCodeName
. '|' . $TARGET . '_CUSTOM_BUTTONS_METHOD_LIST'))
{
// set the custom buttons CUSTOM_BUTTONS_CONTROLLER_LIST
CFactory::_('Compiler.Builder.Content.Multi')->set($viewsCodeName
. '|' . $TARGET . '_CUSTOM_BUTTONS_CONTROLLER_LIST',
'');
// set the custom buttons CUSTOM_BUTTONS_METHOD_LIST
CFactory::_('Compiler.Builder.Content.Multi')->set($viewsCodeName
. '|' . $TARGET . '_CUSTOM_BUTTONS_METHOD_LIST',
'');
}
// validate selection
$validateSelection = 'true';
}
// if it's not been set before
if
(!CFactory::_('Compiler.Builder.Content.Multi')->exists($viewCodeName
. '|' . $TARGET . '_CUSTOM_BUTTONS_METHOD'))
{
// set the custom buttons CUSTOM_BUTTONS_CONTROLLER
CFactory::_('Compiler.Builder.Content.Multi')->set($viewCodeName
. '|' . $TARGET . '_CUSTOM_BUTTONS_CONTROLLER',
'');
// set the custom buttons CUSTOM_BUTTONS_METHOD
CFactory::_('Compiler.Builder.Content.Multi')->set($viewCodeName
. '|' . $TARGET . '_CUSTOM_BUTTONS_METHOD',
'');
}
// reset buttons
$buttons = [];
// if site add buttons to view
if (CFactory::_('Config')->build_target ===
'site')
{
// set the custom buttons SITE_TOP_BUTTON
CFactory::_('Compiler.Builder.Content.Multi')->set($viewCodeName
. '|SITE_TOP_BUTTON', '');
// set the custom buttons SITE_BOTTOM_BUTTON
CFactory::_('Compiler.Builder.Content.Multi')->set($viewCodeName
. '|SITE_BOTTOM_BUTTON', '');
// load into place
switch ($view['settings']->button_position)
{
case 1:
// set buttons to top right of the view
CFactory::_('Compiler.Builder.Content.Multi')->set($viewCodeName
. '|SITE_TOP_BUTTON',
'<div class="uk-clearfix"><div
class="uk-float-right"><?php echo
$this->toolbar->render(); ?></div></div>'
);
break;
case 2:
// set buttons to top left of the view
CFactory::_('Compiler.Builder.Content.Multi')->set($viewCodeName
. '|SITE_TOP_BUTTON', '<?php echo
$this->toolbar->render(); ?>');
break;
case 3:
// set buttons to buttom right of the view
CFactory::_('Compiler.Builder.Content.Multi')->set($viewCodeName
. '|SITE_BOTTOM_BUTTON',
'<div class="uk-clearfix"><div
class="uk-float-right"><?php echo
$this->toolbar->render(); ?></div></div>'
);
break;
case 4:
// set buttons to buttom left of the view
CFactory::_('Compiler.Builder.Content.Multi')->set($viewCodeName
. '|SITE_BOTTOM_BUTTON', '<?php echo
$this->toolbar->render(); ?>');
break;
case 5:
// set buttons to custom placement of the view
CFactory::_('Placeholder')->set_('SITE_TOOLBAR',
'<?php echo $this->toolbar->render(); ?>');
break;
}
}
// add some buttons if custom admin view
elseif (1 == $type)
{
// add this button only if this is not the default view
$dynamic_dashboard =
CFactory::_('Registry')->get('build.dashboard',
'');
$dynamic_dashboard_type =
CFactory::_('Registry')->get('build.dashboard.type',
'');
if ($dynamic_dashboard_type !== 'custom_admin_views'
|| ($dynamic_dashboard_type === 'custom_admin_views'
&& $dynamic_dashboard !== $viewCodeName))
{
$buttons[] = $tab . Indent::_(2)
. "//" . Line::_(__Line__, __Class__) . " add cpanel
button";
$buttons[] = $tab . Indent::_(2)
. "ToolbarHelper::custom('" . $viewCodeName .
"."
. "dashboard', 'grid-2', '',
'COM_"
.
CFactory::_('Compiler.Builder.Content.One')->get('COMPONENT')
. "_DASH', false);";
}
}
// check if custom button should be added
if (isset($view['settings']->add_custom_button)
&& $view['settings']->add_custom_button == 1)
{
$this->onlyFunctionButton = [];
$functionNames = [];
if (isset($view['settings']->custom_buttons)
&& ArrayHelper::check(
$view['settings']->custom_buttons
))
{
foreach ($view['settings']->custom_buttons as
$custom_button)
{
// Load to lang
$keyLang = CFactory::_('Config')->lang_prefix .
'_'
. StringHelper::safe(
$custom_button['name'], 'U'
);
$keyCode = StringHelper::safe(
$custom_button['name']
);
CFactory::_('Language')->set(
CFactory::_('Config')->lang_target, $keyLang,
$custom_button['name']
);
// load the button
if (3 !== $type
&& ($custom_button['target'] != 2
|| CFactory::_('Config')->build_target ===
'site'))
{
// add cpanel button TODO does not work well on site with
permissions
if ($custom_button['target'] == 2
|| CFactory::_('Config')->build_target ===
'site')
{
$buttons[] = Indent::_(1) . $tab . Indent::_(1)
. "if (\$this->user->authorise('"
. $viewCodeName
. "." . $keyCode . "', 'com_"
. CFactory::_('Config')->component_code_name .
"'))";
}
else
{
$buttons[] = Indent::_(1) . $tab . Indent::_(1)
. "if (\$this->canDo->get('" . $viewCodeName
. "."
. $keyCode . "'))";
}
$buttons[] = Indent::_(1) . $tab . Indent::_(1) . "{";
$buttons[] = Indent::_(1) . $tab . Indent::_(2) . "//"
. Line::_(__Line__, __Class__) . " add "
. $custom_button['name'] . " button.";
$buttons[] = Indent::_(1) . $tab . Indent::_(2)
. "ToolbarHelper::custom('" . $viewCodeName .
"."
. $custom_button['method'] . "', '"
. $custom_button['icomoon'] . " custom-button-"
. strtolower((string) $custom_button['method']) .
"', '', '"
. $keyLang
. "', false);";
$buttons[] = Indent::_(1) . $tab . Indent::_(1) . "}";
}
// load the list button
elseif (3 == $type && $custom_button['target'] !=
1)
{
// This is only for list admin views
if (isset($custom_button['type'])
&& $custom_button['type'] == 2)
{
if (!isset($this->onlyFunctionButton[$viewsCodeName]))
{
$this->onlyFunctionButton[$viewsCodeName]
= [];
}
$this->onlyFunctionButton[$viewsCodeName][]
= Indent::_(
1
) . $tab . "if (\$this->user->authorise('"
. $viewCodeName . "." . $keyCode . "',
'com_"
. CFactory::_('Config')->component_code_name .
"'))";
$this->onlyFunctionButton[$viewsCodeName][]
= Indent::_(
1
) . $tab . "{";
$this->onlyFunctionButton[$viewsCodeName][]
= Indent::_(
1
) . $tab . Indent::_(1) . "//" . Line::_(
__LINE__,__CLASS__
) . " add " . $custom_button['name']
. " button.";
$this->onlyFunctionButton[$viewsCodeName][]
= Indent::_(
1
) . $tab . Indent::_(1)
. "ToolbarHelper::custom('" . $viewsCodeName
. "."
. $custom_button['method'] . "', '"
. $custom_button['icomoon'] . "
custom-button-"
. strtolower((string) $custom_button['method'])
. "', '', '"
. $keyLang . "', false);";
$this->onlyFunctionButton[$viewsCodeName][]
= Indent::_(
1
) . $tab . "}";
}
else
{
$buttons[] = Indent::_(1) . $tab . Indent::_(1)
. "if (\$this->user->authorise('"
. $viewCodeName
. "." . $keyCode . "', 'com_"
. CFactory::_('Config')->component_code_name .
"'))";
$buttons[] = Indent::_(1) . $tab . Indent::_(1)
. "{";
$buttons[] = Indent::_(1) . $tab . Indent::_(2)
. "//" . Line::_(__Line__, __Class__) . " add
"
. $custom_button['name'] . " button.";
$buttons[] = Indent::_(1) . $tab . Indent::_(2)
. "ToolbarHelper::custom('" . $viewsCodeName
. "."
. $custom_button['method'] . "', '"
. $custom_button['icomoon'] . "
custom-button-"
. strtolower((string) $custom_button['method'])
. "', '', '"
. $keyLang . "', '" . $validateSelection
. "');";
$buttons[] = Indent::_(1) . $tab . Indent::_(1)
. "}";
}
}
}
}
// load the model and controller
if (3 == $type)
{
// insure the controller and model strings are added
if (isset($view['settings']->php_controller_list)
&& StringHelper::check(
$view['settings']->php_controller_list
)
&& $view['settings']->php_controller_list !=
'//')
{
// set the custom buttons CUSTOM_BUTTONS_CONTROLLER
CFactory::_('Compiler.Builder.Content.Multi')->set($viewsCodeName
. '|' . $TARGET . '_CUSTOM_BUTTONS_CONTROLLER_LIST',
PHP_EOL . PHP_EOL .
CFactory::_('Placeholder')->update_(
$view['settings']->php_controller_list
));
}
// load the model
if (isset($view['settings']->php_model_list)
&& StringHelper::check(
$view['settings']->php_model_list
)
&& $view['settings']->php_model_list !=
'//')
{
// set the custom buttons CUSTOM_BUTTONS_METHOD
CFactory::_('Compiler.Builder.Content.Multi')->set($viewsCodeName
. '|' . $TARGET
. '_CUSTOM_BUTTONS_METHOD_LIST', PHP_EOL . PHP_EOL .
CFactory::_('Placeholder')->update_(
$view['settings']->php_model_list
));
}
}
else
{
// insure the controller and model strings are added
if (StringHelper::check(
$view['settings']->php_controller
)
&& $view['settings']->php_controller !=
'//')
{
// set the custom buttons CUSTOM_BUTTONS_CONTROLLER
CFactory::_('Compiler.Builder.Content.Multi')->set($viewCodeName
. '|' . $TARGET
. '_CUSTOM_BUTTONS_CONTROLLER', PHP_EOL . PHP_EOL .
CFactory::_('Placeholder')->update_(
$view['settings']->php_controller
));
if ('site' ===
CFactory::_('Config')->build_target)
{
// add the controller for this view
// build the file
$target = array(CFactory::_('Config')->build_target
=> $viewCodeName);
CFactory::_('Utilities.Structure')->build($target,
'custom_form');
// GET_FORM_CUSTOM
}
}
// load the model
if (StringHelper::check(
$view['settings']->php_model
) && $view['settings']->php_model !=
'//')
{
// set the custom buttons CUSTOM_BUTTONS_METHOD
CFactory::_('Compiler.Builder.Content.Multi')->set($viewCodeName
. '|' . $TARGET
. '_CUSTOM_BUTTONS_METHOD', PHP_EOL . PHP_EOL .
CFactory::_('Placeholder')->update_(
$view['settings']->php_model
)
);
}
}
}
// return buttons if they were build
if (ArrayHelper::check($buttons))
{
// just to check if the submission script is manually added
if (!isset($view['settings']->php_document)
|| (ArrayHelper::check(
$view['settings']->php_document
)
&& strpos(
implode(' ',
$view['settings']->php_document),
'/submitbutton.js'
) === false)
|| (StringHelper::check(
$view['settings']->php_document
)
&& strpos(
(string) $view['settings']->php_document,
'/submitbutton.js'
) === false))
{
// set the custom get form method JAVASCRIPT_FOR_BUTTONS
CFactory::_('Compiler.Builder.Content.Multi')->set($viewCodeName
. '|' . $TARGET
. '_JAVASCRIPT_FOR_BUTTONS',
$this->setJavaScriptForButtons()
);
}
// insure the form is added (only if no form exist)
if (isset($view['settings']->default)
&& strpos(
(string) $view['settings']->default,
'<form'
) === false)
{
$this->addCustomForm[CFactory::_('Config')->build_target][$viewCodeName]
= true;
}
return PHP_EOL . implode(PHP_EOL, $buttons);
}
return '';
}
public function setJavaScriptForButtons()
{
// add behavior.framework to insure Joomla function is on the page
$script = [];
$script[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__)
. " Add the needed Javascript to insure that the buttons
work.";
$script[] = Indent::_(2) . "Html::_('behavior.framework',
true);";
$script[] = Indent::_(2)
.
"\$this->getDocument()->addScriptDeclaration(\"Joomla.submitbutton
= function(task){if (task == ''){ return false; } else {
Joomla.submitform(task); return true; }}\");";
// return the script
return PHP_EOL . implode(PHP_EOL, $script);
}
public function setFunctionOnlyButtons($nameListCode)
{
// return buttons if they were build
if (isset($this->onlyFunctionButton[$nameListCode])
&& ArrayHelper::check(
$this->onlyFunctionButton[$nameListCode]
))
{
return PHP_EOL . implode(
PHP_EOL, $this->onlyFunctionButton[$nameListCode]
);
}
return '';
}
public function setCustomCSS(&$view)
{
if ($view['settings']->add_css == 1)
{
if (StringHelper::check($view['settings']->css))
{
return CFactory::_('Placeholder')->update_(
$view['settings']->css
);
}
}
return '';
}
public function setDocumentCustomCSS(&$view)
{
if ($view['settings']->add_css_document == 1)
{
$view['settings']->css_document = (array) explode(
PHP_EOL, (string) $view['settings']->css_document
);
if (ArrayHelper::check(
$view['settings']->css_document
))
{
$script = PHP_EOL . Indent::_(2) . "//" . Line::_(
__LINE__,__CLASS__
) . " Set the Custom CSS script to view" . PHP_EOL
. Indent::_(2) .
'$this->document->addStyleDeclaration("';
$cssDocument = PHP_EOL . Indent::_(3) . str_replace(
'"', '\"', implode(
PHP_EOL . Indent::_(3),
$view['settings']->css_document
)
);
return $script . CFactory::_('Placeholder')->update_(
$cssDocument
) . PHP_EOL . Indent::_(2) . '");';
}
}
return '';
}
public function setJavaScriptFile(&$view, $TARGET)
{
if ($view['settings']->add_javascript_file == 1
&& StringHelper::check(
$view['settings']->javascript_file
))
{
// get dates
$created = CFactory::_('Model.Createdate')->get($view);
$modified = CFactory::_('Model.Modifieddate')->get($view);
// add file to view
$target = array(CFactory::_('Config')->build_target =>
$view['settings']->code);
$config = array(Placefix::_h('CREATIONDATE')
=> $created,
Placefix::_h('BUILDDATE') => $modified,
Placefix::_h('VERSION') =>
$view['settings']->version);
CFactory::_('Utilities.Structure')->build($target,
'javascript_file', false, $config);
// set path
if ('site' ===
CFactory::_('Config')->build_target)
{
$path = '/components/com_' .
CFactory::_('Config')->component_code_name
. '/assets/js/' . $view['settings']->code .
'.js';
}
else
{
$path = '/administrator/components/com_'
. CFactory::_('Config')->component_code_name .
'/assets/js/'
. $view['settings']->code . '.js';
}
// add script to file
CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code
. '|' . $TARGET
. '_JAVASCRIPT_FILE',
CFactory::_('Placeholder')->update_(
$view['settings']->javascript_file
));
// add script to view
return PHP_EOL . PHP_EOL . Indent::_(2) . "//" . Line::_(
__LINE__,__CLASS__
) . " Add View JavaScript File" . PHP_EOL . Indent::_(2)
. $this->setIncludeLibScript($path);
}
return '';
}
public function setDocumentCustomJS(&$view)
{
if ($view['settings']->add_js_document == 1)
{
$view['settings']->js_document = (array) explode(
PHP_EOL, (string) $view['settings']->js_document
);
if (ArrayHelper::check(
$view['settings']->js_document
))
{
$script = PHP_EOL . Indent::_(2) . "//" . Line::_(
__LINE__,__CLASS__
) . " Set the Custom JS script to view" . PHP_EOL
. Indent::_(2) .
'$this->getDocument()->addScriptDeclaration("';
$jsDocument = PHP_EOL . Indent::_(3) . str_replace(
'"', '\"', implode(
PHP_EOL . Indent::_(3),
$view['settings']->js_document
)
);
return $script . CFactory::_('Placeholder')->update_(
$jsDocument
) . PHP_EOL . Indent::_(2) . '");';
}
}
return '';
}
public function setFootableScriptsLoader(&$view)
{
if (CFactory::_('Compiler.Builder.Footable.Scripts')->
exists(CFactory::_('Config')->build_target . '.'
. $view['settings']->code))
{
return $this->setFootableScripts(false);
}
return '';
}
public function setDocumentMetadata(&$view)
{
if ($view['settings']->main_get->gettype == 1
&& isset($view['metadata'])
&& $view['metadata'] == 1)
{
return $this->setMetadataItem();
}
elseif (isset($view['metadata']) &&
$view['metadata'] == 1)
{
// lets check if we have a custom get method that has the same name as
the view
// if we do then it posibly can be that the metadata is loaded via that
method
// and we can load the full metadata structure with its vars
if (isset($view['settings']->custom_get)
&& ArrayHelper::check(
$view['settings']->custom_get
))
{
$found = false;
$searchFor = 'get' . $view['settings']->Code;
foreach ($view['settings']->custom_get as $custom_get)
{
if ($searchFor == $custom_get->getcustom)
{
$found = true;
break;
}
}
// now lets see
if ($found)
{
return
$this->setMetadataItem($view['settings']->code);
}
else
{
return $this->setMetadataList();
}
}
else
{
return $this->setMetadataList();
}
}
return '';
}
public function setMetadataItem($item = 'item')
{
if (CFactory::_('Config')->get('joomla_version',
3) == 3)
{
return $this->setMetadataItemJ3($item);
}
return $this->setMetadataItemJ4($item);
}
public function setMetadataList()
{
if (CFactory::_('Config')->get('joomla_version',
3) == 3)
{
return $this->setMetadataListJ3();
}
return $this->setMetadataListJ4();
}
public function setMetadataItemJ3($item = 'item')
{
$meta = [];
$meta[] = PHP_EOL . Indent::_(2) . "//" . Line::_(__Line__,
__Class__)
. " load the meta description";
$meta[] = Indent::_(2) . "if (isset(\$this->" . $item
. "->metadesc) && \$this->" . $item .
"->metadesc)";
$meta[] = Indent::_(2) . "{";
$meta[] = Indent::_(3) .
"\$this->document->setDescription(\$this->"
. $item . "->metadesc);";
$meta[] = Indent::_(2) . "}";
$meta[] = Indent::_(2)
. "elseif
(\$this->params->get('menu-meta_description'))";
$meta[] = Indent::_(2) . "{";
$meta[] = Indent::_(3)
.
"\$this->document->setDescription(\$this->params->get('menu-meta_description'));";
$meta[] = Indent::_(2) . "}";
$meta[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__)
. " load the key words if set";
$meta[] = Indent::_(2) . "if (isset(\$this->" . $item
. "->metakey) && \$this->" . $item .
"->metakey)";
$meta[] = Indent::_(2) . "{";
$meta[] = Indent::_(3)
. "\$this->document->setMetadata('keywords',
\$this->" . $item
. "->metakey);";
$meta[] = Indent::_(2) . "}";
$meta[] = Indent::_(2)
. "elseif
(\$this->params->get('menu-meta_keywords'))";
$meta[] = Indent::_(2) . "{";
$meta[] = Indent::_(3)
. "\$this->document->setMetadata('keywords',
\$this->params->get('menu-meta_keywords'));";
$meta[] = Indent::_(2) . "}";
$meta[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__)
. " check the robot params";
$meta[] = Indent::_(2) . "if (isset(\$this->" . $item
. "->robots) && \$this->" . $item .
"->robots)";
$meta[] = Indent::_(2) . "{";
$meta[] = Indent::_(3)
. "\$this->document->setMetadata('robots',
\$this->" . $item
. "->robots);";
$meta[] = Indent::_(2) . "}";
$meta[] = Indent::_(2) . "elseif
(\$this->params->get('robots'))";
$meta[] = Indent::_(2) . "{";
$meta[] = Indent::_(3)
. "\$this->document->setMetadata('robots',
\$this->params->get('robots'));";
$meta[] = Indent::_(2) . "}";
$meta[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__)
. " check if autor is to be set";
$meta[] = Indent::_(2) . "if (isset(\$this->" . $item
. "->created_by) &&
\$this->params->get('MetaAuthor') == '1')";
$meta[] = Indent::_(2) . "{";
$meta[] = Indent::_(3)
. "\$this->document->setMetaData('author',
\$this->" . $item
. "->created_by);";
$meta[] = Indent::_(2) . "}";
$meta[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__)
. " check if metadata is available";
$meta[] = Indent::_(2) . "if (isset(\$this->" . $item
. "->metadata) && \$this->" . $item .
"->metadata)";
$meta[] = Indent::_(2) . "{";
$meta[] = Indent::_(3) . "\$mdata = json_decode(\$this->" .
$item
. "->metadata,true);";
$meta[] = Indent::_(3) . "foreach (\$mdata as \$k => \$v)";
$meta[] = Indent::_(3) . "{";
$meta[] = Indent::_(4) . "if (\$v)";
$meta[] = Indent::_(4) . "{";
$meta[] = Indent::_(5) . "\$this->document->setMetadata(\$k,
\$v);";
$meta[] = Indent::_(4) . "}";
$meta[] = Indent::_(3) . "}";
$meta[] = Indent::_(2) . "}";
return implode(PHP_EOL, $meta);
}
public function setMetadataListJ3()
{
$meta = [];
$meta[] = PHP_EOL . Indent::_(2) . "//" . Line::_(__Line__,
__Class__)
. " load the meta description";
$meta[] = Indent::_(2)
. "if
(\$this->params->get('menu-meta_description'))";
$meta[] = Indent::_(2) . "{";
$meta[] = Indent::_(3)
.
"\$this->document->setDescription(\$this->params->get('menu-meta_description'));";
$meta[] = Indent::_(2) . "}";
$meta[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__)
. " load the key words if set";
$meta[] = Indent::_(2)
. "if
(\$this->params->get('menu-meta_keywords'))";
$meta[] = Indent::_(2) . "{";
$meta[] = Indent::_(3)
. "\$this->document->setMetadata('keywords',
\$this->params->get('menu-meta_keywords'));";
$meta[] = Indent::_(2) . "}";
$meta[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__)
. " check the robot params";
$meta[] = Indent::_(2) . "if
(\$this->params->get('robots'))";
$meta[] = Indent::_(2) . "{";
$meta[] = Indent::_(3)
. "\$this->document->setMetadata('robots',
\$this->params->get('robots'));";
$meta[] = Indent::_(2) . "}";
return implode(PHP_EOL, $meta);
}
public function setMetadataItemJ4($item = 'item')
{
$meta = [];
$meta[] = PHP_EOL . Indent::_(2) . "//" . Line::_(__Line__,
__Class__)
. " load the meta description";
$meta[] = Indent::_(2) . "if (isset(\$this->" . $item
. "->metadesc) && \$this->" . $item .
"->metadesc)";
$meta[] = Indent::_(2) . "{";
$meta[] = Indent::_(3) .
"\$this->getDocument()->setDescription(\$this->"
. $item . "->metadesc);";
$meta[] = Indent::_(2) . "}";
$meta[] = Indent::_(2)
. "elseif
(\$this->params->get('menu-meta_description'))";
$meta[] = Indent::_(2) . "{";
$meta[] = Indent::_(3)
.
"\$this->getDocument()->setDescription(\$this->params->get('menu-meta_description'));";
$meta[] = Indent::_(2) . "}";
$meta[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__)
. " load the key words if set";
$meta[] = Indent::_(2) . "if (isset(\$this->" . $item
. "->metakey) && \$this->" . $item .
"->metakey)";
$meta[] = Indent::_(2) . "{";
$meta[] = Indent::_(3)
. "\$this->getDocument()->setMetadata('keywords',
\$this->" . $item
. "->metakey);";
$meta[] = Indent::_(2) . "}";
$meta[] = Indent::_(2)
. "elseif
(\$this->params->get('menu-meta_keywords'))";
$meta[] = Indent::_(2) . "{";
$meta[] = Indent::_(3)
. "\$this->getDocument()->setMetadata('keywords',
\$this->params->get('menu-meta_keywords'));";
$meta[] = Indent::_(2) . "}";
$meta[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__)
. " check the robot params";
$meta[] = Indent::_(2) . "if (isset(\$this->" . $item
. "->robots) && \$this->" . $item .
"->robots)";
$meta[] = Indent::_(2) . "{";
$meta[] = Indent::_(3)
. "\$this->getDocument()->setMetadata('robots',
\$this->" . $item
. "->robots);";
$meta[] = Indent::_(2) . "}";
$meta[] = Indent::_(2) . "elseif
(\$this->params->get('robots'))";
$meta[] = Indent::_(2) . "{";
$meta[] = Indent::_(3)
. "\$this->getDocument()->setMetadata('robots',
\$this->params->get('robots'));";
$meta[] = Indent::_(2) . "}";
$meta[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__)
. " check if autor is to be set";
$meta[] = Indent::_(2) . "if (isset(\$this->" . $item
. "->created_by) &&
\$this->params->get('MetaAuthor') == '1')";
$meta[] = Indent::_(2) . "{";
$meta[] = Indent::_(3)
. "\$this->getDocument()->setMetaData('author',
\$this->" . $item
. "->created_by);";
$meta[] = Indent::_(2) . "}";
$meta[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__)
. " check if metadata is available";
$meta[] = Indent::_(2) . "if (isset(\$this->" . $item
. "->metadata) && \$this->" . $item .
"->metadata)";
$meta[] = Indent::_(2) . "{";
$meta[] = Indent::_(3) . "\$mdata = json_decode(\$this->" .
$item
. "->metadata,true);";
$meta[] = Indent::_(3) . "foreach (\$mdata as \$k => \$v)";
$meta[] = Indent::_(3) . "{";
$meta[] = Indent::_(4) . "if (\$v)";
$meta[] = Indent::_(4) . "{";
$meta[] = Indent::_(5) .
"\$this->getDocument()->setMetadata(\$k, \$v);";
$meta[] = Indent::_(4) . "}";
$meta[] = Indent::_(3) . "}";
$meta[] = Indent::_(2) . "}";
return implode(PHP_EOL, $meta);
}
public function setMetadataListJ4()
{
$meta = [];
$meta[] = PHP_EOL . Indent::_(2) . "//" . Line::_(__Line__,
__Class__)
. " load the meta description";
$meta[] = Indent::_(2)
. "if
(\$this->params->get('menu-meta_description'))";
$meta[] = Indent::_(2) . "{";
$meta[] = Indent::_(3)
.
"\$this->getDocument()->setDescription(\$this->params->get('menu-meta_description'));";
$meta[] = Indent::_(2) . "}";
$meta[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__)
. " load the key words if set";
$meta[] = Indent::_(2)
. "if
(\$this->params->get('menu-meta_keywords'))";
$meta[] = Indent::_(2) . "{";
$meta[] = Indent::_(3)
. "\$this->getDocument()->setMetadata('keywords',
\$this->params->get('menu-meta_keywords'));";
$meta[] = Indent::_(2) . "}";
$meta[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__)
. " check the robot params";
$meta[] = Indent::_(2) . "if
(\$this->params->get('robots'))";
$meta[] = Indent::_(2) . "{";
$meta[] = Indent::_(3)
. "\$this->getDocument()->setMetadata('robots',
\$this->params->get('robots'));";
$meta[] = Indent::_(2) . "}";
return implode(PHP_EOL, $meta);
}
public function setGoogleChartLoader(&$view)
{
if (CFactory::_('Compiler.Builder.Google.Chart')->
exists(CFactory::_('Config')->build_target . '.'
. $view['settings']->code))
{
$chart = [];
$chart[] = PHP_EOL . PHP_EOL . Indent::_(2) . "//" . Line::_(
__LINE__,__CLASS__
) . " add the google chart builder class.";
$chart[] = Indent::_(2)
. "require_once
JPATH_COMPONENT_ADMINISTRATOR.'/helpers/chartbuilder.php';";
$chart[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__)
. " load the google chart js.";
$chart[] = Indent::_(2)
. "Html::_('script', 'media/com_"
. CFactory::_('Config')->component_code_name .
"/js/google.jsapi.js', ['version' =>
'auto']);";
$chart[] = Indent::_(2)
. "Html::_('script',
'https://canvg.googlecode.com/svn/trunk/rgbcolor.js',
['version' => 'auto']);";
$chart[] = Indent::_(2)
. "Html::_('script',
'https://canvg.googlecode.com/svn/trunk/canvg.js',
['version' => 'auto']);";
return implode(PHP_EOL, $chart);
}
return '';
}
public function setLibrariesLoader($view)
{
// check call sig
if (isset($view['settings']) &&
isset($view['settings']->code))
{
$code = $view['settings']->code;
$view_active = true;
}
elseif (isset($view->code_name))
{
$code = $view->code_name;
$view_active = false;
}
// reset bucket
$setter = '';
// always load these in
if ($view_active)
{
$setter .= PHP_EOL . PHP_EOL . Indent::_(2) . "//" . Line::_(
__LINE__,__CLASS__
) . " Only load jQuery if needed. (default is true)";
$setter .= PHP_EOL . Indent::_(2) . "if
(\$this->params->get('add_jquery_framework', 1) ==
1)";
$setter .= PHP_EOL . Indent::_(2) . "{";
$setter .= PHP_EOL . Indent::_(3) .
"Html::_('jquery.framework');";
$setter .= PHP_EOL . Indent::_(2) . "}";
$setter .= PHP_EOL . Indent::_(2) . "//" . Line::_(__Line__,
__Class__)
. " Load the header checker class.";
if (CFactory::_('Config')->get('joomla_version',
3) == 3)
{
if (CFactory::_('Config')->build_target ===
'site')
{
$setter .= PHP_EOL . Indent::_(2)
. "require_once(
JPATH_COMPONENT_SITE.'/helpers/headercheck.php' );";
}
else
{
$setter .= PHP_EOL . Indent::_(2)
. "require_once(
JPATH_COMPONENT_ADMINISTRATOR.'/helpers/headercheck.php'
);";
}
$setter .= PHP_EOL . Indent::_(2) . "//" . Line::_(__Line__,
__Class__)
. " Initialize the header checker.";
$setter .= PHP_EOL . Indent::_(2) . "\$HeaderCheck = new "
. CFactory::_('Config')->component_code_name .
"HeaderCheck();";
}
else
{
$setter .= PHP_EOL . Indent::_(2) . "//" . Line::_(__Line__,
__Class__)
. " Initialize the header checker.";
$setter .= PHP_EOL . Indent::_(2) . "\$HeaderCheck = new
HeaderCheck();";
}
}
// check if this view should get libraries
if (($data =
CFactory::_('Compiler.Builder.Library.Manager')->
get(CFactory::_('Config')->build_target . '.' .
$code)) !== null)
{
foreach ($data as $id => $true)
{
// get the library
$library =
CFactory::_('Registry')->get("builder.libraries.$id",
null);
if (is_object($library) && isset($library->document)
&& StringHelper::check($library->document))
{
$setter .= PHP_EOL . PHP_EOL .
CFactory::_('Placeholder')->update_(
str_replace(
[
'$document->',
'$this->document->'
],
'$this->getDocument()->',
(string) $library->document
)
);
}
elseif (is_object($library)
&& isset($library->how))
{
$setter .= $this->setLibraryDocument($id);
}
}
}
// convert back to $document if module call (oops :)
if (!$view_active)
{
return str_replace(['$this->getDocument()->',
'$this->document->'], '$document->',
$setter);
}
return $setter;
}
protected function setLibraryDocument($id)
{
// get the library
$library =
CFactory::_('Registry')->get("builder.libraries.$id",
null);
// make sure we have an object
if (is_object($library))
{
if (isset($library->how) && 2 == $library->how
&& isset($library->conditions)
&& ArrayHelper::check(
$library->conditions
))
{
// build document with the conditions values
$this->setLibraryDocConditions(
$id, $this->setLibraryScripts($id, false)
);
}
elseif (isset($library->how) && 1 == $library->how)
{
// build document to allways add all files and urls
$this->setLibraryScripts($id);
}
// check if the document was build
if (isset($library->document)
&& StringHelper::check(
$library->document
))
{
return PHP_EOL . PHP_EOL . $library->document;
}
}
return '';
}
protected function setLibraryDocConditions($id, $scripts)
{
// Start script builder for library files
if (!isset($this->libwarning[$id]))
{
// set the warning only once
$this->libwarning[$id] = true;
// get the library
$library =
CFactory::_('Registry')->get("builder.libraries.$id",
null);
$this->app->enqueueMessage(
Text::_('COM_COMPONENTBUILDER_HR_HTHREECONDITIONAL_SCRIPT_WARNINGHTHREE'),
'Warning'
);
// message with name
if (is_object($library) && isset($library->name))
{
$this->app->enqueueMessage(
Text::sprintf(
'The conditional script builder for <b>%s</b> is not
ready, sorry!',
$library->name
), 'Warning'
);
}
else
{
$this->app->enqueueMessage(
Text::_(
'The conditional script builder for ID:<b>%s</b> is
not ready, sorry!',
$id
), 'Warning'
);
}
}
}
protected function setLibraryScripts($id, $buildDoc = true)
{
$scripts = [];
// get the library
$library =
CFactory::_('Registry')->get("builder.libraries.$id",
null);
// check that we have a library
if (is_object($library))
{
// load the urls if found
if (isset($library->urls)
&& ArrayHelper::check($library->urls))
{
// set all the files
foreach ($library->urls as $url)
{
// if local path is set, then use it first
if (isset($url['path']))
{
// update the root path
$path = $this->getScriptRootPath($url['path']);
// load document script
$scripts[md5((string) $url['path'])] =
$this->setIncludeLibScript(
$path
);
// load url also if not building document
if (!$buildDoc)
{
// load document script
$scripts[md5((string) $url['url'])] =
$this->setIncludeLibScript(
$url['url'], false
);
}
}
else
{
// load document script
$scripts[md5((string) $url['url'])] =
$this->setIncludeLibScript(
$url['url'], false
);
}
}
}
// load the local files if found
if (isset($library->files)
&& ArrayHelper::check($library->files))
{
// set all the files
foreach ($library->files as $file)
{
$path = '/' . trim((string) $file['path'],
'/');
// check if path has new file name (has extetion)
$pathInfo = pathinfo($path);
// update the root path
$_path = $this->getScriptRootPath($path);
if (isset($pathInfo['extension']) &&
$pathInfo['extension'])
{
// load document script
$scripts[md5($path)] = $this->setIncludeLibScript(
$_path, false, $pathInfo
);
}
else
{
// load document script
$scripts[md5($path . '/' . trim((string)
$file['file'], '/'))]
= $this->setIncludeLibScript(
$_path . '/' . trim((string) $file['file'],
'/')
);
}
}
}
// load the local folders if found
if (isset($library->folders)
&& ArrayHelper::check(
$library->folders
))
{
// get all the file paths
$files = [];
foreach ($library->folders as $folder)
{
if (isset($folder['path']) &&
isset($folder['folder']))
{
$path = '/' . trim((string)$folder['path'],
'/');
if (isset($folder['rename']) && 1 ==
$folder['rename'])
{
if ($_paths = FileHelper::getPaths(
CFactory::_('Utilities.Paths')->component_path .
$path
))
{
$files[$path] = $_paths;
}
}
else
{
$path = $path . '/' .
trim((string)$folder['folder'], '/');
if ($_paths = FileHelper::getPaths(
CFactory::_('Utilities.Paths')->component_path .
$path
))
{
$files[$path] = $_paths;
}
}
}
}
// now load the script
if (ArrayHelper::check($files))
{
foreach ($files as $root => $paths)
{
// update the root path
$_root = $this->getScriptRootPath($root);
// load per path
foreach ($paths as $path)
{
$scripts[md5($root . '/' . trim((string)$path,
'/'))]
= $this->setIncludeLibScript(
$_root . '/' . trim((string)$path, '/')
);
}
}
}
}
}
// if there was any code added to document then set globally
if ($buildDoc && ArrayHelper::check($scripts))
{
CFactory::_('Registry')->set("builder.libraries.${id}.document",
Indent::_(2) . "//"
. Line::_(__Line__, __Class__) . " always load these files."
. PHP_EOL . Indent::_(2) . implode(
PHP_EOL . Indent::_(2), $scripts
)
);
// success
return true;
}
elseif (ArrayHelper::check($scripts))
{
return $scripts;
}
return false;
}
protected function setIncludeLibScript($path, $local = true,
$pathInfo = false
)
{
// insure we have the path info
if (!$pathInfo)
{
$pathInfo = pathinfo((string) $path);
}
// use the path info to build the script
if (isset($pathInfo['extension']) &&
$pathInfo['extension'])
{
switch ($pathInfo['extension'])
{
case 'js':
return 'Html::_(\'script\', "' . ltrim($path,
'/')
. '", [\'version\' =>
\'auto\']);';
break;
case 'css':
case 'less':
return 'Html::_(\'stylesheet\', "'
. ltrim($path, '/') . '", [\'version\'
=> \'auto\']);';
break;
case 'php':
if (strpos((string) $path, 'http') === false)
{
return 'require_once("' . $path .
'");';
}
break;
}
}
return '';
}
protected function getScriptRootPath($root)
{
if (strpos((string) $root, '/media/') !== false
&& strpos((string) $root, '/admin/') === false
&& strpos((string) $root, '/site/') === false)
{
return str_replace(
'/media/', '/media/com_' .
CFactory::_('Config')->component_code_name . '/',
(string) $root
);
}
elseif (strpos((string) $root, '/media/') === false
&& strpos((string) $root, '/admin/') !== false
&& strpos((string) $root, '/site/') === false)
{
return str_replace(
'/admin/',
'/administrator/components/com_' .
CFactory::_('Config')->component_code_name
. '/', (string) $root
);
}
elseif (strpos((string) $root, '/media/') === false
&& strpos((string) $root, '/admin/') === false
&& strpos((string) $root, '/site/') !== false)
{
return str_replace(
'/site/', '/components/com_' .
CFactory::_('Config')->component_code_name . '/',
(string) $root
);
}
return $root;
}
public function setUikitLoader(&$view)
{
// reset setter
$setter = '';
// load the defaults needed
if (CFactory::_('Config')->uikit > 0)
{
$setter .= PHP_EOL . PHP_EOL . Indent::_(2) . "//" . Line::_(
__LINE__,__CLASS__
) . " Load uikit options.";
$setter .= PHP_EOL . Indent::_(2)
. "\$uikit =
\$this->params->get('uikit_load');";
$setter .= PHP_EOL . Indent::_(2) . "//" . Line::_(__Line__,
__Class__)
. " Set script size.";
$setter .= PHP_EOL . Indent::_(2)
. "\$size =
\$this->params->get('uikit_min');";
$tabV = "";
// if both versions should be loaded then add some more logic
if (2 == CFactory::_('Config')->uikit)
{
$setter .= PHP_EOL . PHP_EOL . Indent::_(2) . "//"
. Line::_(__Line__, __Class__) . " Load uikit version.";
$setter .= PHP_EOL . Indent::_(2)
. "\$this->uikitVersion =
\$this->params->get('uikit_version', 2);";
$setter .= PHP_EOL . PHP_EOL . Indent::_(2) . "//"
. Line::_(__Line__, __Class__) . " Use Uikit Version 2";
$setter .= PHP_EOL . Indent::_(2)
. "if (2 == \$this->uikitVersion)";
$setter .= PHP_EOL . Indent::_(2) . "{";
$tabV = Indent::_(1);
}
}
// load the defaults needed
if (2 == CFactory::_('Config')->uikit || 1 ==
CFactory::_('Config')->uikit)
{
$setter .= PHP_EOL . $tabV . Indent::_(2) . "//" . Line::_(
__LINE__,__CLASS__
) . " Set css style.";
$setter .= PHP_EOL . $tabV . Indent::_(2)
. "\$style =
\$this->params->get('uikit_style');";
$setter .= PHP_EOL . PHP_EOL . $tabV . Indent::_(2) . "//"
. Line::_(__Line__, __Class__) . " The uikit css.";
$setter .= PHP_EOL . $tabV . Indent::_(2)
. "if ((!\$HeaderCheck->css_loaded('uikit.min') ||
\$uikit == 1) && \$uikit != 2 && \$uikit != 3)";
$setter .= PHP_EOL . $tabV . Indent::_(2) . "{";
$setter .= PHP_EOL . $tabV . Indent::_(3)
. "Html::_('stylesheet', 'media/com_"
. CFactory::_('Config')->component_code_name
. "/uikit-v2/css/uikit'.\$style.\$size.'.css',
['version' => 'auto']);";
$setter .= PHP_EOL . $tabV . Indent::_(2) . "}";
$setter .= PHP_EOL . $tabV . Indent::_(2) . "//" . Line::_(
__LINE__,__CLASS__
) . " The uikit js.";
$setter .= PHP_EOL . $tabV . Indent::_(2)
. "if ((!\$HeaderCheck->js_loaded('uikit.min') ||
\$uikit == 1) && \$uikit != 2 && \$uikit != 3)";
$setter .= PHP_EOL . $tabV . Indent::_(2) . "{";
$setter .= PHP_EOL . $tabV . Indent::_(3)
. "Html::_('script', 'media/com_"
. CFactory::_('Config')->component_code_name
. "/uikit-v2/js/uikit'.\$size.'.js',
['version' => 'auto']);";
$setter .= PHP_EOL . $tabV . Indent::_(2) . "}";
}
// load the components need
if ((2 == CFactory::_('Config')->uikit || 1 ==
CFactory::_('Config')->uikit)
&& ($data_ =
CFactory::_('Compiler.Builder.Uikit.Comp')->get($view['settings']->code))
!== null)
{
$setter .= PHP_EOL . PHP_EOL . $tabV . Indent::_(2) . "//"
. Line::_(__Line__, __Class__)
. " Load the script to find all uikit components needed.";
$setter .= PHP_EOL . $tabV . Indent::_(2) . "if (\$uikit !=
2)";
$setter .= PHP_EOL . $tabV . Indent::_(2) . "{";
$setter .= PHP_EOL . $tabV . Indent::_(3) . "//" . Line::_(
__LINE__,__CLASS__
) . " Set the default uikit components in this view.";
$setter .= PHP_EOL . $tabV . Indent::_(3)
. "\$uikitComp = [];";
foreach ($data_ as $class)
{
$setter .= PHP_EOL . $tabV . Indent::_(3) . "\$uikitComp[] =
'"
. $class . "';";
}
// check content for more needed components
if
(CFactory::_('Compiler.Builder.Site.Field.Data')->exists('uikit.'
. $view['settings']->code))
{
$setter .= PHP_EOL . PHP_EOL . $tabV . Indent::_(3) . "//"
. Line::_(__Line__, __Class__)
. " Get field uikit components needed in this view.";
$setter .= PHP_EOL . $tabV . Indent::_(3)
. "\$uikitFieldComp =
\$this->get('UikitComp');";
$setter .= PHP_EOL . $tabV . Indent::_(3)
. "if (isset(\$uikitFieldComp) && "
. "Super_" .
"__0a59c65c_9daf_4bc9_baf4_e063ff9e6a8a___Power::check(\$uikitFieldComp))";
$setter .= PHP_EOL . $tabV . Indent::_(3) . "{";
$setter .= PHP_EOL . $tabV . Indent::_(4)
. "if (isset(\$uikitComp) && "
. "Super_" .
"__0a59c65c_9daf_4bc9_baf4_e063ff9e6a8a___Power::check(\$uikitComp))";
$setter .= PHP_EOL . $tabV . Indent::_(4) . "{";
$setter .= PHP_EOL . $tabV . Indent::_(5)
. "\$uikitComp = array_merge(\$uikitComp,
\$uikitFieldComp);";
$setter .= PHP_EOL . $tabV . Indent::_(5)
. "\$uikitComp = array_unique(\$uikitComp);";
$setter .= PHP_EOL . $tabV . Indent::_(4) . "}";
$setter .= PHP_EOL . $tabV . Indent::_(4) . "else";
$setter .= PHP_EOL . $tabV . Indent::_(4) . "{";
$setter .= PHP_EOL . $tabV . Indent::_(5)
. "\$uikitComp = \$uikitFieldComp;";
$setter .= PHP_EOL . $tabV . Indent::_(4) . "}";
$setter .= PHP_EOL . $tabV . Indent::_(3) . "}";
}
$setter .= PHP_EOL . $tabV . Indent::_(2) . "}";
$setter .= PHP_EOL . PHP_EOL . $tabV . Indent::_(2) . "//"
. Line::_(__Line__, __Class__)
. " Load the needed uikit components in this view.";
$setter .= PHP_EOL . $tabV . Indent::_(2)
. "if (\$uikit != 2 && isset(\$uikitComp) &&
"
. "Super_" .
"__0a59c65c_9daf_4bc9_baf4_e063ff9e6a8a___Power::check(\$uikitComp))";
$setter .= PHP_EOL . $tabV . Indent::_(2) . "{";
$setter .= PHP_EOL . $tabV . Indent::_(3) . "//" . Line::_(
__LINE__,__CLASS__
) . " loading...";
$setter .= PHP_EOL . $tabV . Indent::_(3)
. "foreach (\$uikitComp as \$class)";
$setter .= PHP_EOL . $tabV . Indent::_(3) . "{";
$setter .= PHP_EOL . $tabV . Indent::_(4) . "foreach ("
.
CFactory::_('Compiler.Builder.Content.One')->get('Component')
. "Helper::\$uk_components[\$class] as \$name)";
$setter .= PHP_EOL . $tabV . Indent::_(4) . "{";
$setter .= PHP_EOL . $tabV . Indent::_(5) . "//" . Line::_(
__LINE__,__CLASS__
) . " check if the CSS file exists.";
$setter .= PHP_EOL . $tabV . Indent::_(5)
. "if (@file_exists(JPATH_ROOT.'/media/com_"
. CFactory::_('Config')->component_code_name
.
"/uikit-v2/css/components/'.\$name.\$style.\$size.'.css'))";
$setter .= PHP_EOL . $tabV . Indent::_(5) . "{";
$setter .= PHP_EOL . $tabV . Indent::_(6) . "//" . Line::_(
__LINE__,__CLASS__
) . " load the css.";
$setter .= PHP_EOL . $tabV . Indent::_(6)
. "Html::_('stylesheet', 'media/com_"
. CFactory::_('Config')->component_code_name
.
"/uikit-v2/css/components/'.\$name.\$style.\$size.'.css',
['version' => 'auto']);";
$setter .= PHP_EOL . $tabV . Indent::_(5) . "}";
$setter .= PHP_EOL . $tabV . Indent::_(5) . "//" . Line::_(
__LINE__,__CLASS__
) . " check if the JavaScript file exists.";
$setter .= PHP_EOL . $tabV . Indent::_(5)
. "if (@file_exists(JPATH_ROOT.'/media/com_"
. CFactory::_('Config')->component_code_name
.
"/uikit-v2/js/components/'.\$name.\$size.'.js'))";
$setter .= PHP_EOL . $tabV . Indent::_(5) . "{";
$setter .= PHP_EOL . $tabV . Indent::_(6) . "//" . Line::_(
__LINE__,__CLASS__
) . " load the js.";
$setter .= PHP_EOL . $tabV . Indent::_(6)
. "Html::_('script', 'media/com_"
. CFactory::_('Config')->component_code_name
. "/uikit-v2/js/components/'.\$name.\$size.'.js',
['version' => 'auto'], ['type' =>
'text/javascript', 'async' =>
'async']);";
$setter .= PHP_EOL . $tabV . Indent::_(5) . "}";
$setter .= PHP_EOL . $tabV . Indent::_(4) . "}";
$setter .= PHP_EOL . $tabV . Indent::_(3) . "}";
$setter .= PHP_EOL . $tabV . Indent::_(2) . "}";
}
elseif ((2 == CFactory::_('Config')->uikit || 1 ==
CFactory::_('Config')->uikit)
&&
CFactory::_('Compiler.Builder.Site.Field.Data')->exists('uikit.'
. $view['settings']->code))
{
$setter .= PHP_EOL . PHP_EOL . $tabV . Indent::_(2) . "//"
. Line::_(__Line__, __Class__)
. " Load the needed uikit components in this view.";
$setter .= PHP_EOL . $tabV . Indent::_(2)
. "\$uikitComp = \$this->get('UikitComp');";
$setter .= PHP_EOL . $tabV . Indent::_(2)
. "if (\$uikit != 2 && isset(\$uikitComp) &&
"
. "Super_" .
"__0a59c65c_9daf_4bc9_baf4_e063ff9e6a8a___Power::check(\$uikitComp))";
$setter .= PHP_EOL . $tabV . Indent::_(2) . "{";
$setter .= PHP_EOL . $tabV . Indent::_(3) . "//" . Line::_(
__LINE__,__CLASS__
) . " loading...";
$setter .= PHP_EOL . $tabV . Indent::_(3)
. "foreach (\$uikitComp as \$class)";
$setter .= PHP_EOL . $tabV . Indent::_(3) . "{";
$setter .= PHP_EOL . $tabV . Indent::_(4) . "foreach ("
.
CFactory::_('Compiler.Builder.Content.One')->get('Component')
. "Helper::\$uk_components[\$class] as \$name)";
$setter .= PHP_EOL . $tabV . Indent::_(4) . "{";
$setter .= PHP_EOL . $tabV . Indent::_(5) . "//" . Line::_(
__LINE__,__CLASS__
) . " check if the CSS file exists.";
$setter .= PHP_EOL . $tabV . Indent::_(5)
. "if (@file_exists(JPATH_ROOT.'/media/com_"
. CFactory::_('Config')->component_code_name
.
"/uikit-v2/css/components/'.\$name.\$style.\$size.'.css'))";
$setter .= PHP_EOL . $tabV . Indent::_(5) . "{";
$setter .= PHP_EOL . $tabV . Indent::_(6) . "//" . Line::_(
__LINE__,__CLASS__
) . " load the css.";
$setter .= PHP_EOL . $tabV . Indent::_(6)
. "Html::_('stylesheet', 'media/com_"
. CFactory::_('Config')->component_code_name
.
"/uikit-v2/css/components/'.\$name.\$style.\$size.'.css',
['version' => 'auto']);";
$setter .= PHP_EOL . $tabV . Indent::_(5) . "}";
$setter .= PHP_EOL . $tabV . Indent::_(5) . "//" . Line::_(
__LINE__,__CLASS__
) . " check if the JavaScript file exists.";
$setter .= PHP_EOL . $tabV . Indent::_(5)
. "if (@file_exists(JPATH_ROOT.'/media/com_"
. CFactory::_('Config')->component_code_name
.
"/uikit-v2/js/components/'.\$name.\$size.'.js'))";
$setter .= PHP_EOL . $tabV . Indent::_(5) . "{";
$setter .= PHP_EOL . $tabV . Indent::_(6) . "//" . Line::_(
__LINE__,__CLASS__
) . " load the js.";
$setter .= PHP_EOL . $tabV . Indent::_(6)
. "Html::_('script', 'media/com_"
. CFactory::_('Config')->component_code_name
. "/uikit-v2/js/components/'.\$name.\$size.'.js',
['version' => 'auto'], ['type' =>
'text/javascript', 'async' =>
'async']);";
$setter .= PHP_EOL . $tabV . Indent::_(5) . "}";
$setter .= PHP_EOL . $tabV . Indent::_(4) . "}";
$setter .= PHP_EOL . $tabV . Indent::_(3) . "}";
$setter .= PHP_EOL . $tabV . Indent::_(2) . "}";
}
// now set the version 3
if (2 == CFactory::_('Config')->uikit || 3 ==
CFactory::_('Config')->uikit)
{
if (2 == CFactory::_('Config')->uikit)
{
$setter .= PHP_EOL . Indent::_(2) . "}";
$setter .= PHP_EOL . Indent::_(2) . "//" . Line::_(
__LINE__,__CLASS__
) . " Use Uikit Version 3";
$setter .= PHP_EOL . Indent::_(2)
. "elseif (3 == \$this->uikitVersion)";
$setter .= PHP_EOL . Indent::_(2) . "{";
}
// add version 3 fiels to page
$setter .= PHP_EOL . $tabV . Indent::_(2) . "//" . Line::_(
__LINE__,__CLASS__
) . " The uikit css.";
$setter .= PHP_EOL . $tabV . Indent::_(2)
. "if ((!\$HeaderCheck->css_loaded('uikit.min') ||
\$uikit == 1) && \$uikit != 2 && \$uikit != 3)";
$setter .= PHP_EOL . $tabV . Indent::_(2) . "{";
$setter .= PHP_EOL . $tabV . Indent::_(3)
. "Html::_('stylesheet', 'media/com_"
. CFactory::_('Config')->component_code_name
. "/uikit-v3/css/uikit'.\$size.'.css',
['version' => 'auto']);";
$setter .= PHP_EOL . $tabV . Indent::_(2) . "}";
$setter .= PHP_EOL . $tabV . Indent::_(2) . "//" . Line::_(
__LINE__,__CLASS__
) . " The uikit js.";
$setter .= PHP_EOL . $tabV . Indent::_(2)
. "if ((!\$HeaderCheck->js_loaded('uikit.min') ||
\$uikit == 1) && \$uikit != 2 && \$uikit != 3)";
$setter .= PHP_EOL . $tabV . Indent::_(2) . "{";
$setter .= PHP_EOL . $tabV . Indent::_(3)
. "Html::_('script', 'media/com_"
. CFactory::_('Config')->component_code_name
. "/uikit-v3/js/uikit'.\$size.'.js',
['version' => 'auto']);";
$setter .= PHP_EOL . $tabV . Indent::_(3)
. "Html::_('script', 'media/com_"
. CFactory::_('Config')->component_code_name
. "/uikit-v3/js/uikit-icons'.\$size.'.js',
['version' => 'auto']);";
$setter .= PHP_EOL . $tabV . Indent::_(2) . "}";
if (2 == CFactory::_('Config')->uikit)
{
$setter .= PHP_EOL . Indent::_(2) . "}";
}
}
return $setter;
}
public function setCustomViewExtraDisplayMethods(&$view)
{
if ($view['settings']->add_php_jview == 1)
{
return PHP_EOL . PHP_EOL .
CFactory::_('Placeholder')->update_(
$view['settings']->php_jview
);
}
return '';
}
public function setCustomViewBody(&$view)
{
if (StringHelper::check($view['settings']->default))
{
if ($view['settings']->main_get->gettype == 2
&& $view['settings']->main_get->pagination ==
1)
{
// does this view have a custom limitbox position
$has_limitbox = (strpos(
(string) $view['settings']->default,
(string) Placefix::_('LIMITBOX')
) !== false);
// does this view have a custom pages counter position
$has_pagescounter = (strpos(
(string) $view['settings']->default,
(string) Placefix::_('PAGESCOUNTER')
) !== false);
// does this view have a custom pages links position
$has_pageslinks = (strpos(
(string) $view['settings']->default,
(string) Placefix::_('PAGESLINKS')
) !== false);
// does this view have a custom pagination start position
$has_pagination_start = (strpos(
(string) $view['settings']->default,
(string) Placefix::_('PAGINATIONSTART')
) !== false);
// does this view have a custom pagination end position
$has_pagination_end = (strpos(
(string) $view['settings']->default,
(string) Placefix::_('PAGINATIONEND')
) !== false);
// add pagination start
CFactory::_('Placeholder')->add_('PAGINATIONSTART',
PHP_EOL
. '<?php if (isset($this->items) &&
isset($this->pagination) &&
isset($this->pagination->pagesTotal) &&
$this->pagination->pagesTotal > 1): ?>');
CFactory::_('Placeholder')->add_('PAGINATIONSTART',
PHP_EOL . Indent::_(1) . '<div
class="pagination">');
CFactory::_('Placeholder')->add_('PAGINATIONSTART',
PHP_EOL . Indent::_(2)
. '<?php if
($this->params->def(\'show_pagination_results\', 1)) :
?>');
// add pagination end
CFactory::_('Placeholder')->set_('PAGINATIONEND',
Indent::_(2) . '<?php endif; ?>');
// only add if no custom page link is found
if (!$has_pageslinks)
{
if (CFactory::_('Config')->build_target ===
'custom_admin')
{
CFactory::_('Placeholder')->add_('PAGINATIONEND',
PHP_EOL . Indent::_(2)
. '<?php echo $this->pagination->getListFooter();
?>');
}
else
{
CFactory::_('Placeholder')->add_('PAGINATIONEND',
PHP_EOL . Indent::_(2)
. '<?php echo $this->pagination->getPagesLinks();
?>');
}
}
CFactory::_('Placeholder')->add_('PAGINATIONEND',
PHP_EOL . Indent::_(1) . '</div>');
CFactory::_('Placeholder')->add_('PAGINATIONEND',
PHP_EOL . '<?php endif; ?>');
// add limit box
CFactory::_('Placeholder')->set_('LIMITBOX',
'<?php echo $this->pagination->getLimitBox();
?>');
// add pages counter
CFactory::_('Placeholder')->set_('PAGESCOUNTER',
'<?php echo $this->pagination->getPagesCounter();
?>');
// add pages links
if (CFactory::_('Config')->build_target ===
'custom_admin')
{
CFactory::_('Placeholder')->set_('PAGESLINKS',
'<?php echo $this->pagination->getListFooter();
?>');
}
else
{
CFactory::_('Placeholder')->set_('PAGESLINKS',
'<?php echo $this->pagination->getPagesLinks();
?>');
}
// build body
$body = [];
// Load the default values to the body
$body[] = CFactory::_('Placeholder')->update_(
$view['settings']->default
);
// add pagination start
if (!$has_pagination_start)
{
$body[] =
CFactory::_('Placeholder')->get_('PAGINATIONSTART');
}
if (!$has_limitbox && !$has_pagescounter)
{
$body[] = Indent::_(3)
. '<p class="counter pull-right"> <?php echo
$this->pagination->getPagesCounter(); ?> <?php echo
$this->pagination->getLimitBox(); ?></p>';
}
elseif (!$has_limitbox)
{
$body[] = Indent::_(3)
. '<p class="counter pull-right"> <?php echo
$this->pagination->getLimitBox(); ?></p>';
}
elseif (!$has_pagescounter)
{
$body[] = Indent::_(3)
. '<p class="counter pull-right"> <?php echo
$this->pagination->getPagesCounter(); ?> </p>';
}
// add pagination end
if (!$has_pagination_end)
{
$body[] =
CFactory::_('Placeholder')->get_('PAGINATIONEND');
}
// lets clear the placeholders just in case
CFactory::_('Placeholder')->remove_('LIMITBOX');
CFactory::_('Placeholder')->remove_('PAGESCOUNTER');
CFactory::_('Placeholder')->remove_('PAGESLINKS');
CFactory::_('Placeholder')->remove_('PAGINATIONSTART');
CFactory::_('Placeholder')->remove_('PAGINATIONEND');
// insure the form is added (only if no form exist)
if (strpos((string) $view['settings']->default,
'<form') === false)
{
$this->addCustomForm[CFactory::_('Config')->build_target][$view['settings']->code]
= true;
}
// return the body
return implode(PHP_EOL, $body);
}
else
{
// insure the form is added (only if no form exist)
if ('site' !==
CFactory::_('Config')->build_target
&& strpos(
(string) $view['settings']->default,
'<form'
) === false)
{
$this->addCustomForm[CFactory::_('Config')->build_target][$view['settings']->code]
= true;
}
return PHP_EOL . CFactory::_('Placeholder')->update_(
$view['settings']->default
);
}
}
return '';
}
public function setCustomViewForm(&$view, &$gettype, $type)
{
if
(isset($this->addCustomForm[CFactory::_('Config')->build_target])
&&
isset($this->addCustomForm[CFactory::_('Config')->build_target][$view])
&&
$this->addCustomForm[CFactory::_('Config')->build_target][$view])
{
switch ($type)
{
case 1:
// top
if ('site' ===
CFactory::_('Config')->build_target)
{
return '<form action="<?php echo
Route::_(\'index.php?option=com_'
. CFactory::_('Config')->component_code_name
. '\'); ?>" method="post"
name="adminForm" id="adminForm">'
. PHP_EOL;
}
else
{
if ($gettype == 2)
{
return '<form action="<?php echo
Route::_(\'index.php?option=com_'
. CFactory::_('Config')->component_code_name .
'&view=' . $view
. '\'); ?>" method="post"
name="adminForm" id="adminForm"
class="form-validate"
enctype="multipart/form-data">'
. PHP_EOL;
}
else
{
return '<form action="<?php echo
Route::_(\'index.php?option=com_'
. CFactory::_('Config')->component_code_name .
'&view=' . $view
. '\' . $urlId); ?>" method="post"
name="adminForm" id="adminForm"
class="form-validate"
enctype="multipart/form-data">'
. PHP_EOL;
}
}
break;
case 2:
// bottom
$input = '';
if ('admin' ===
CFactory::_('Config')->build_target
&& isset($this->customAdminViewListId[$view]))
{
$input = PHP_EOL . Indent::_(1)
. '<input type="hidden" name="id"
value="<?php echo
$this->app->input->getInt(\'id\', 0); ?>"
/>';
}
return $input . PHP_EOL
. '<input type="hidden" name="task"
value="" />'
. PHP_EOL . "<?php echo Html::_('form.token');
?>"
. PHP_EOL . '</form>';
break;
}
}
return '';
}
public function setCustomViewSubmitButtonScript(&$view)
{
if (StringHelper::check($view['settings']->default))
{
// add the script only if there is none set
if (strpos(
(string) $view['settings']->default,
'Joomla.submitbutton = function('
) === false)
{
$script = [];
$script[] = PHP_EOL . "<script
type=\"text/javascript\">";
$script[] = Indent::_(1)
. "Joomla.submitbutton = function(task) {";
$script[] = Indent::_(2) . "if (task === '"
. $view['settings']->code . ".back') {";
$script[] = Indent::_(3) . "parent.history.back();";
$script[] = Indent::_(3) . "return false;";
$script[] = Indent::_(2) . "} else {";
$script[] = Indent::_(3)
. "var form =
document.getElementById('adminForm');";
$script[] = Indent::_(3) . "form.task.value = task;";
$script[] = Indent::_(3) . "form.submit();";
$script[] = Indent::_(2) . "}";
$script[] = Indent::_(1) . "}";
$script[] = "</script>";
return implode(PHP_EOL, $script);
}
}
return '';
}
public function setCustomViewCodeBody(&$view)
{
if ($view['settings']->add_php_view == 1)
{
$view['settings']->php_view = (array) explode(
PHP_EOL, (string) $view['settings']->php_view
);
if (ArrayHelper::check($view['settings']->php_view))
{
$_tmp = PHP_EOL . PHP_EOL . implode(
PHP_EOL, $view['settings']->php_view
);
return CFactory::_('Placeholder')->update_($_tmp);
}
}
return '';
}
public function setCustomViewTemplateBody(&$view)
{
if (($data_ =
CFactory::_('Compiler.Builder.Template.Data')->
get(CFactory::_('Config')->build_target . '.' .
$view['settings']->code)) !== null)
{
$created = CFactory::_('Model.Createdate')->get($view);
$modified = CFactory::_('Model.Modifieddate')->get($view);
foreach ($data_ as $template => $data)
{
// build the file
$target = [
CFactory::_('Config')->build_target =>
$view['settings']->code
];
$config = [
Placefix::_h('CREATIONDATE') => $created,
Placefix::_h('BUILDDATE') => $modified,
Placefix::_h('VERSION') =>
$view['settings']->version
];
CFactory::_('Utilities.Structure')->build($target,
'template', $template, $config);
// set the file data
$TARGET = StringHelper::safe(
CFactory::_('Config')->build_target, 'U'
);
if (!isset($data['html']) || $data['html'] ===
null)
{
echo '<pre>';
var_dump($data);
exit;
}
// SITE_TEMPLATE_BODY <<<DYNAMIC>>>
CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code
. '_'
. $template . '|' . $TARGET . '_TEMPLATE_BODY',
PHP_EOL . CFactory::_('Placeholder')->update_(
$data['html']
));
if (!isset($data['php_view']) || $data['php_view']
=== null)
{
echo '<pre>';
var_dump($data);
exit;
}
// SITE_TEMPLATE_CODE_BODY <<<DYNAMIC>>>
CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code
. '_'
. $template . '|' . $TARGET .
'_TEMPLATE_CODE_BODY',
$this->setTemplateCode($data['php_view'])
);
}
}
}
public function setTemplateCode(&$php)
{
if (StringHelper::check($php))
{
$php_view = (array) explode(PHP_EOL, (string) $php);
if (ArrayHelper::check($php_view))
{
$php_view = PHP_EOL . PHP_EOL . implode(PHP_EOL, $php_view);
return CFactory::_('Placeholder')->update_($php_view);
}
}
return '';
}
public function setCustomViewLayouts()
{
if (($data_ = CFactory::_('Compiler.Builder.Layout.Data')->
get(CFactory::_('Config')->build_target)) !== null)
{
foreach ($data_ as $layout => $data)
{
// build the file
$target = array(CFactory::_('Config')->build_target =>
$layout);
CFactory::_('Utilities.Structure')->build($target,
'layout');
// set the file data
$TARGET = StringHelper::safe(
CFactory::_('Config')->build_target, 'U'
);
// SITE_LAYOUT_CODE <<<DYNAMIC>>>
$php_view = (array) explode(PHP_EOL, (string)
$data['php_view']);
if (ArrayHelper::check($php_view))
{
$php_view = PHP_EOL . PHP_EOL . implode(PHP_EOL, $php_view);
CFactory::_('Compiler.Builder.Content.Multi')->set($layout
. '|' . $TARGET . '_LAYOUT_CODE',
CFactory::_('Placeholder')->update_(
$php_view
)
);
}
else
{
CFactory::_('Compiler.Builder.Content.Multi')->set($layout
. '|' . $TARGET
. '_LAYOUT_CODE', '');
}
// SITE_LAYOUT_BODY <<<DYNAMIC>>>
CFactory::_('Compiler.Builder.Content.Multi')->set($layout
. '|' . $TARGET . '_LAYOUT_BODY',
PHP_EOL . CFactory::_('Placeholder')->update_(
$data['html']
)
);
// SITE_LAYOUT_HEADER <<<DYNAMIC>>>
CFactory::_('Compiler.Builder.Content.Multi')->set($layout
. '|' . $TARGET . '_LAYOUT_HEADER',
(($header = CFactory::_('Header')->get(
str_replace('_', '.', (string)
CFactory::_('Config')->build_target) . '.layout',
$layout, false)) !== false) ? PHP_EOL . PHP_EOL . $header :
''
);
}
}
}
public function getReplacementNames()
{
foreach (CFactory::_('Utilities.Files')->toArray() as $type
=> $files)
{
foreach ($files as $view => $file)
{
if (isset($file['path'])
&& ArrayHelper::check(
$file
))
{
if (@file_exists($file['path']))
{
$string = FileHelper::getContent(
$file['path']
);
$buket['static'][] = $this->getInbetweenStrings(
$string
);
}
}
elseif (ArrayHelper::check($file))
{
foreach ($file as $nr => $doc)
{
if (ArrayHelper::check($doc))
{
if (@file_exists($doc['path']))
{
$string
= FileHelper::getContent(
$doc['path']
);
$buket[$view][] = $this->getInbetweenStrings(
$string
);
}
}
}
}
}
}
foreach ($buket as $type => $array)
{
foreach ($array as $replacments)
{
$replacments = array_unique($replacments);
foreach ($replacments as $replacment)
{
if ($type !== 'static')
{
$echos[$replacment] = "#" . "#" . "#" .
$replacment
. "#" . "#" . "#<br />";
}
elseif ($type === 'static')
{
$echos[$replacment] = "#" . "#" . "#" .
$replacment
. "#" . "#" . "#<br />";
}
}
}
}
foreach ($echos as $echo)
{
echo $echo . '<br />';
}
}
public function setMethodGetItem(&$view)
{
$script = '';
// get the component name
$Component =
CFactory::_('Compiler.Builder.Content.One')->get('Component');
$component =
CFactory::_('Compiler.Builder.Content.One')->get('component');
// go from base64 to string
if
(CFactory::_('Compiler.Builder.Base.Six.Four')->exists($view))
{
foreach
(CFactory::_('Compiler.Builder.Base.Six.Four')->get($view) as
$baseString)
{
$script .= PHP_EOL . PHP_EOL . Indent::_(3)
. "if (!empty(\$item->" . $baseString
. "))"; // TODO &&
base64_encode(base64_decode(\$item->".$baseString.", true))
=== \$item->".$baseString.")";
$script .= PHP_EOL . Indent::_(3) . "{";
$script .= PHP_EOL . Indent::_(4) . "//" . Line::_(
__LINE__,__CLASS__
) . " base64 Decode " . $baseString . ".";
$script .= PHP_EOL . Indent::_(4) . "\$item->" .
$baseString
. " = base64_decode(\$item->" . $baseString .
");";
$script .= PHP_EOL . Indent::_(3) . "}";
}
}
// decryption
foreach (CFactory::_('Config')->cryption_types as
$cryptionType)
{
if (CFactory::_('Compiler.Builder.Model.' .
ucfirst($cryptionType). '.Field')->exists($view))
{
if ('expert' !== $cryptionType)
{
$script .= PHP_EOL . PHP_EOL . Indent::_(3) . "//"
. Line::_(__Line__, __Class__) . " Get the " .
$cryptionType
. " encryption.";
$script .= PHP_EOL . Indent::_(3) . "\$" . $cryptionType
. "key = " . $Component .
"Helper::getCryptKey('"
. $cryptionType . "');";
$script .= PHP_EOL . Indent::_(3) . "//" . Line::_(
__LINE__,__CLASS__
) . " Get the encryption object.";
$script .= PHP_EOL . Indent::_(3) . "\$" . $cryptionType
. " = new Super_" .
"__99175f6d_dba8_4086_8a65_5c4ec175e61d___Power(\$" .
$cryptionType . "key);";
foreach (CFactory::_('Compiler.Builder.Model.' .
ucfirst($cryptionType). '.Field')->get($view) as
$baseString)
{
$script .= PHP_EOL . PHP_EOL . Indent::_(3)
. "if (!empty(\$item->" . $baseString . ")
&& \$"
. $cryptionType . "key &&
!is_numeric(\$item->"
. $baseString . ") && \$item->" . $baseString
. " === base64_encode(base64_decode(\$item->"
. $baseString . ", true)))";
$script .= PHP_EOL . Indent::_(3) . "{";
$script .= PHP_EOL . Indent::_(4) . "//"
. Line::_(__Line__, __Class__) . " " . $cryptionType
. " decrypt data " . $baseString . ".";
$script .= PHP_EOL . Indent::_(4) . "\$item->"
. $baseString . " = rtrim(\$" . $cryptionType
. "->decryptString(\$item->" . $baseString .
"), "
. '"\0"' . ");";
$script .= PHP_EOL . Indent::_(3) . "}";
}
}
else
{
if (CFactory::_('Compiler.Builder.Model.' .
ucfirst($cryptionType). '.Field.Initiator')->
exists("{$view}.get"))
{
foreach (CFactory::_('Compiler.Builder.Model.' .
ucfirst($cryptionType). '.Field.Initiator')->
get("{$view}.get") as $block
)
{
$script .= PHP_EOL . Indent::_(3) . implode(
PHP_EOL . Indent::_(3), $block
);
}
}
// set the expert script
foreach (CFactory::_('Compiler.Builder.Model.' .
ucfirst($cryptionType). '.Field')->
get($view) as $baseString => $opener_)
{
$_placeholder_for_field = array('[[[field]]]' =>
'$item->' . $baseString);
$script .= CFactory::_('Placeholder')->update(
PHP_EOL . Indent::_(3) . implode(
PHP_EOL . Indent::_(3), $opener_['get']
), $_placeholder_for_field
);
}
}
}
}
// go from json to array
if
(CFactory::_('Compiler.Builder.Json.Item')->exists($view))
{
foreach
(CFactory::_('Compiler.Builder.Json.Item')->get($view) as
$jsonItem)
{
$script .= PHP_EOL . PHP_EOL . Indent::_(3)
. "if (!empty(\$item->" . $jsonItem . "))";
$script .= PHP_EOL . Indent::_(3) . "{";
$script .= PHP_EOL . Indent::_(4) . "//" . Line::_(
__LINE__,__CLASS__
) . " Convert the " . $jsonItem . " field to an
array.";
$script .= PHP_EOL . Indent::_(4) . "\$" . $jsonItem
. " = new Registry;";
$script .= PHP_EOL . Indent::_(4) . "\$" . $jsonItem
. "->loadString(\$item->" . $jsonItem .
");";
$script .= PHP_EOL . Indent::_(4) . "\$item->" .
$jsonItem
. " = \$" . $jsonItem . "->toArray();";
$script .= PHP_EOL . Indent::_(3) . "}";
}
}
// go from json to string
if
(CFactory::_('Compiler.Builder.Json.String')->exists($view))
{
$makeArray = '';
foreach
(CFactory::_('Compiler.Builder.Json.String')->get($view) as
$jsonString)
{
$script .= PHP_EOL . PHP_EOL . Indent::_(3)
. "if (!empty(\$item->" . $jsonString . "))";
$script .= PHP_EOL . Indent::_(3) . "{";
$script .= PHP_EOL . Indent::_(4) . "//" . Line::_(
__LINE__,__CLASS__
) . " JSON Decode " . $jsonString . ".";
if
(CFactory::_('Compiler.Builder.Json.Item.Array')->inArray($jsonString,
$view) ||
strpos((string) $jsonString, 'group') !== false)
{
$makeArray = ',true';
}
$script .= PHP_EOL . Indent::_(4) . "\$item->" .
$jsonString
. " = json_decode(\$item->" . $jsonString . $makeArray
. ");";
$script .= PHP_EOL . Indent::_(3) . "}";
}
}
// add the tag get options
if (CFactory::_('Compiler.Builder.Tags')->exists($view))
{
$script .= PHP_EOL . PHP_EOL . Indent::_(3)
. "if (!empty(\$item->id))";
$script .= PHP_EOL . Indent::_(3) . "{";
$script .= PHP_EOL . Indent::_(4) . "//" . Line::_(
__LINE__,__CLASS__
) . " Get Tag IDs.";
$script .= PHP_EOL . Indent::_(4) . "\$item->tags"
. " = new TagsHelper;";
$script .= PHP_EOL . Indent::_(4)
. "\$item->tags->getTagIds(\$item->id,
'com_$component.$view');";
$script .= PHP_EOL . Indent::_(3) . "}";
}
// add custom php to getitem method
$script .= CFactory::_('Customcode.Dispenser')->get(
'php_getitem', $view, PHP_EOL . PHP_EOL
);
return $script;
}
public function setCheckboxSave(&$view)
{
$script = '';
if
(CFactory::_('Compiler.Builder.Check.Box')->exists($view))
{
foreach
(CFactory::_('Compiler.Builder.Check.Box')->get($view) as
$checkbox)
{
$script .= PHP_EOL . PHP_EOL . Indent::_(2) . "//"
. Line::_(__Line__, __Class__) . " Set the empty " .
$checkbox
. " item to data";
$script .= PHP_EOL . Indent::_(2) . "if
(!isset(\$data['"
. $checkbox . "']))";
$script .= PHP_EOL . Indent::_(2) . "{";
$script .= PHP_EOL . Indent::_(3) . "\$data['" .
$checkbox
. "'] = '';";
$script .= PHP_EOL . Indent::_(2) . "}";
}
}
return $script;
}
public function setMethodItemSave(&$view)
{
$script = '';
// get component name
$Component =
CFactory::_('Compiler.Builder.Content.One')->get('Component');
$component = CFactory::_('Config')->component_code_name;
// check if there was script added before modeling of data
$script .= CFactory::_('Customcode.Dispenser')->get(
'php_before_save', $view, PHP_EOL . PHP_EOL
);
// turn array into JSON string
if
(CFactory::_('Compiler.Builder.Json.Item')->exists($view))
{
foreach
(CFactory::_('Compiler.Builder.Json.Item')->get($view) as
$jsonItem)
{
$script .= PHP_EOL . PHP_EOL . Indent::_(2) . "//"
. Line::_(__Line__, __Class__) . " Set the " . $jsonItem
. " items to data.";
$script .= PHP_EOL . Indent::_(2) . "if
(isset(\$data['"
. $jsonItem . "']) && is_array(\$data['" .
$jsonItem
. "']))";
$script .= PHP_EOL . Indent::_(2) . "{";
$script .= PHP_EOL . Indent::_(3) . "\$" . $jsonItem
. " = new Registry;";
$script .= PHP_EOL . Indent::_(3) . "\$" . $jsonItem
. "->loadArray(\$data['" . $jsonItem .
"']);";
$script .= PHP_EOL . Indent::_(3) . "\$data['" .
$jsonItem
. "'] = (string) \$" . $jsonItem . ";";
$script .= PHP_EOL . Indent::_(2) . "}";
if
(CFactory::_('Compiler.Builder.Permission.Fields')->isArray("$view.$jsonItem"))
{
$script .= PHP_EOL . Indent::_(2) . "//" . Line::_(
__LINE__,__CLASS__
)
. " Also check permission since the value may be removed due to
permissions";
$script .= PHP_EOL . Indent::_(2) . "//" . Line::_(
__LINE__,__CLASS__
)
. " Then we do not want to clear it out, but simple ignore the
empty "
. $jsonItem;
$script .= PHP_EOL . Indent::_(2)
. "elseif (!isset(\$data['" . $jsonItem .
"'])";
// only add permission that are available
foreach
(CFactory::_('Compiler.Builder.Permission.Fields')->get("$view.$jsonItem")
as $permission_option => $fieldType
)
{
if
(CFactory::_('Config')->get('joomla_version', 3) ==
3)
{
$script .= PHP_EOL . Indent::_(3)
. "&& Factory::getUser()->authorise('" .
$view
. "." . $permission_option . "." . $jsonItem
. "', 'com_" . $component .
"')";
}
else
{
$script .= PHP_EOL . Indent::_(3)
. "&&
Factory::getApplication()->getIdentity()->authorise('" .
$view
. "." . $permission_option . "." . $jsonItem
. "', 'com_" . $component .
"')";
}
}
$script .= ")";
}
else
{
$script .= PHP_EOL . Indent::_(2)
. "elseif (!isset(\$data['" . $jsonItem .
"']))";
}
$script .= PHP_EOL . Indent::_(2) . "{";
$script .= PHP_EOL . Indent::_(3) . "//" . Line::_(
__LINE__,__CLASS__
) . " Set the empty " . $jsonItem . " to data";
$script .= PHP_EOL . Indent::_(3) . "\$data['" .
$jsonItem
. "'] = '';";
$script .= PHP_EOL . Indent::_(2) . "}";
}
}
// turn string into json string
if
(CFactory::_('Compiler.Builder.Json.String')->exists($view))
{
foreach
(CFactory::_('Compiler.Builder.Json.String')->get($view) as
$jsonString)
{
$script .= PHP_EOL . PHP_EOL . Indent::_(2) . "//"
. Line::_(__Line__, __Class__) . " Set the " . $jsonString
. " string to JSON string.";
$script .= PHP_EOL . Indent::_(2) . "if
(isset(\$data['"
. $jsonString . "']))";
$script .= PHP_EOL . Indent::_(2) . "{";
$script .= PHP_EOL . Indent::_(3) . "\$data['" .
$jsonString
. "'] = (string) json_encode(\$data['" .
$jsonString
. "']);";
$script .= PHP_EOL . Indent::_(2) . "}";
}
}
// turn string into base 64 string
if
(CFactory::_('Compiler.Builder.Base.Six.Four')->exists($view))
{
foreach
(CFactory::_('Compiler.Builder.Base.Six.Four')->get($view) as
$baseString)
{
$script .= PHP_EOL . PHP_EOL . Indent::_(2) . "//"
. Line::_(__Line__, __Class__) . " Set the " . $baseString
. " string to base64 string.";
$script .= PHP_EOL . Indent::_(2) . "if
(isset(\$data['"
. $baseString . "']))";
$script .= PHP_EOL . Indent::_(2) . "{";
$script .= PHP_EOL . Indent::_(3) . "\$data['" .
$baseString
. "'] = base64_encode(\$data['" . $baseString .
"']);";
$script .= PHP_EOL . Indent::_(2) . "}";
}
}
// turn string into encrypted string
foreach (CFactory::_('Config')->cryption_types as
$cryptionType)
{
if (CFactory::_('Compiler.Builder.Model.' .
ucfirst($cryptionType). '.Field')->
exists($view))
{
if ('expert' !== $cryptionType)
{
$script .= PHP_EOL . PHP_EOL . Indent::_(2) . "//"
. Line::_(__Line__, __Class__) . " Get the " .
$cryptionType
. " encryption key.";
$script .= PHP_EOL . Indent::_(2) . "\$" . $cryptionType
. "key = " . $Component .
"Helper::getCryptKey('"
. $cryptionType . "');";
$script .= PHP_EOL . Indent::_(2) . "//" . Line::_(
__LINE__,__CLASS__
) . " Get the encryption object";
$script .= PHP_EOL . Indent::_(2) . "\$" . $cryptionType
. " = new Super_" .
"__99175f6d_dba8_4086_8a65_5c4ec175e61d___Power(\$" .
$cryptionType . "key);";
foreach (CFactory::_('Compiler.Builder.Model.' .
ucfirst($cryptionType). '.Field')->
get($view) as $baseString)
{
$script .= PHP_EOL . PHP_EOL . Indent::_(2) . "//"
. Line::_(__Line__, __Class__) . " Encrypt data "
. $baseString . ".";
$script .= PHP_EOL . Indent::_(2) . "if
(isset(\$data['"
. $baseString . "']) && \$" . $cryptionType
. "key)";
$script .= PHP_EOL . Indent::_(2) . "{";
$script .= PHP_EOL . Indent::_(3) . "\$data['"
. $baseString . "'] = \$" . $cryptionType
. "->encryptString(\$data['" . $baseString .
"']);";
$script .= PHP_EOL . Indent::_(2) . "}";
}
}
else
{
if (CFactory::_('Compiler.Builder.Model.' .
ucfirst($cryptionType). '.Field.Initiator')->
exists("{$view}.save"))
{
foreach (CFactory::_('Compiler.Builder.Model.' .
ucfirst($cryptionType). '.Field.Initiator')->
get("{$view}.save") as $block)
{
$script .= PHP_EOL . Indent::_(2) . implode(
PHP_EOL . Indent::_(2), $block
);
}
}
// set the expert script
foreach (CFactory::_('Compiler.Builder.Model.' .
ucfirst($cryptionType). '.Field')->
get($view) as $baseString => $locker_)
{
$_placeholder_for_field
= array('[[[field]]]' => "\$data['"
. $baseString . "']");
$script .= CFactory::_('Placeholder')->update(
PHP_EOL . Indent::_(2) . implode(
PHP_EOL . Indent::_(2), $locker_['save']
), $_placeholder_for_field
);
}
}
}
}
// add custom PHP to the save method
$script .= CFactory::_('Customcode.Dispenser')->get(
'php_save', $view, PHP_EOL . PHP_EOL
);
return $script;
}
public function setJtableConstructor(&$view)
{
// reset
$oserver = "";
// set component name
$component = CFactory::_('Config')->component_code_name;
// add the tags observer
if (CFactory::_('Compiler.Builder.Tags')->exists($view))
{
$oserver .= PHP_EOL . PHP_EOL . Indent::_(2) . "//"
. Line::_(__Line__, __Class__) . " Adding Tag Options";
$oserver .= PHP_EOL . Indent::_(2)
. "TableObserverTags::createObserver(\$this,
array('typeAlias' => 'com_"
. $component . "." . $view . "'));";
}
// add the history/version observer
if (CFactory::_('Compiler.Builder.History')->exists($view))
{
$oserver .= PHP_EOL . PHP_EOL . Indent::_(2) . "//"
. Line::_(__Line__, __Class__) . " Adding History Options";
$oserver .= PHP_EOL . Indent::_(2)
. "TableObserverContenthistory::createObserver(\$this,
array('typeAlias' => 'com_"
. $component . "." . $view . "'));";
}
return $oserver;
}
public function setJtableAliasCategory(&$view)
{
// only add Observers if both title, alias and category is available in
view
$code =
CFactory::_('Compiler.Builder.Category.Code')->get("{$view}.code");
if ($code !== null)
{
return ", '" . $code . "' =>
\$this->" . $code;
}
return '';
}
public function setComponentToContentTypes($action)
{
if
(CFactory::_('Component')->isArray('admin_views'))
{
// set component name
$component = CFactory::_('Config')->component_code_name;
// reset
$dbStuff = [];
// start loading the content type data
foreach
(CFactory::_('Component')->get('admin_views') as
$viewData)
{
// set main keys
$view = StringHelper::safe(
$viewData['settings']->name_single
);
// set list view keys
$views = StringHelper::safe(
$viewData['settings']->name_list
);
// get this views content type data
$dbStuff[$view] = $this->getContentType($view, $component);
// get the correct views name
$checkViews =
CFactory::_('Compiler.Builder.Category.Code')->getString("{$view}.views",
$views);
if (ArrayHelper::check($dbStuff[$view])
&&
CFactory::_('Compiler.Builder.Category.Code')->exists($view)
&& ($checkViews == $views))
{
$dbStuff[$view . ' category']
= $this->getCategoryContentType(
$view, $views, $component
);
}
elseif (!isset($dbStuff[$view])
|| !ArrayHelper::check($dbStuff[$view]))
{
// remove if not array
unset($dbStuff[$view]);
}
}
if (CFactory::_('Config')->get('joomla_version',
3) == 3)
{
return $this->setComponentToContentTypesJ3($action, $dbStuff);
}
return $this->setComponentToContentTypesJ4($action, $dbStuff);
}
return '';
}
protected function setComponentToContentTypesJ3($action, $dbStuff)
{
// build the db insert query
if (ArrayHelper::check($dbStuff))
{
$script = '';
$taabb = '';
if ($action === 'update')
{
$taabb = Indent::_(1);
}
$script .= PHP_EOL . PHP_EOL . Indent::_(3) . "//"
. Line::_(__Line__, __Class__) . " Get The Database object";
$script .= PHP_EOL . Indent::_(3)
. "\$db = Factory::getDbo();";
foreach ($dbStuff as $name => $tables)
{
if (ArrayHelper::check($tables))
{
$code = StringHelper::safe($name);
$script .= PHP_EOL . PHP_EOL . Indent::_(3) . "//"
. Line::_(__Line__, __Class__) . " Create the " . $name
. " content type object.";
$script .= PHP_EOL . Indent::_(3) . "\$" . $code
. " = new \stdClass();";
foreach ($tables as $table => $data)
{
$script .= PHP_EOL . Indent::_(3) . "\$" . $code
. "->" . $table . " = '" . $data .
"';";
}
if ($action === 'update')
{
// we first load script to check if data exist
$script .= PHP_EOL . PHP_EOL . Indent::_(3) . "//"
. Line::_(__Line__, __Class__) . " Check if "
. $name
. " type is already in content_type DB.";
$script .= PHP_EOL . Indent::_(3) . "\$" . $code
. "_id = null;";
$script .= PHP_EOL . Indent::_(3)
. "\$query = \$db->getQuery(true);";
$script .= PHP_EOL . Indent::_(3)
.
"\$query->select(\$db->quoteName(array('type_id')));";
$script .= PHP_EOL . Indent::_(3)
.
"\$query->from(\$db->quoteName('#__content_types'));";
$script .= PHP_EOL . Indent::_(3)
. "\$query->where(\$db->quoteName('type_alias')
. ' LIKE '. \$db->quote($"
. $code . "->type_alias));";
$script .= PHP_EOL . Indent::_(3)
. "\$db->setQuery(\$query);";
$script .= PHP_EOL . Indent::_(3)
. "\$db->execute();";
}
$script .= PHP_EOL . PHP_EOL . Indent::_(3) . "//"
. Line::_(__Line__, __Class__)
. " Set the object into the content types table.";
if ($action === 'update')
{
$script .= PHP_EOL . Indent::_(3)
. "if (\$db->getNumRows())";
$script .= PHP_EOL . Indent::_(3) . "{";
$script .= PHP_EOL . Indent::_(4) . "\$" . $code
. "->type_id = \$db->loadResult();";
$script .= PHP_EOL . Indent::_(4) . "\$" . $code
. "_Updated =
\$db->updateObject('#__content_types', \$"
. $code . ", 'type_id');";
$script .= PHP_EOL . Indent::_(3) . "}";
$script .= PHP_EOL . Indent::_(3) . "else";
$script .= PHP_EOL . Indent::_(3) . "{";
}
$script .= PHP_EOL . Indent::_(3) . $taabb . "\$"
. $code
. "_Inserted =
\$db->insertObject('#__content_types', \$"
. $code . ");";
if ($action === 'update')
{
$script .= PHP_EOL . Indent::_(3) . "}";
}
}
}
$script .= PHP_EOL . PHP_EOL;
return $script;
}
return '';
}
protected function setComponentToContentTypesJ4($action, $dbStuff)
{
// build the db insert query
if (ArrayHelper::check($dbStuff))
{
$script = PHP_EOL;
foreach ($dbStuff as $name => $columns)
{
if (ArrayHelper::check($columns))
{
$script .= PHP_EOL . Indent::_(3) . "//"
. Line::_(__Line__, __Class__) . " "
. StringHelper::safe($action, 'Ww') . " "
. StringHelper::safe($name, 'Ww') . " Content
Types.";
$script .= PHP_EOL . Indent::_(3) .
'$this->setContentType(';
$script .= PHP_EOL . Indent::_(4) .
"//" . Line::_(__Line__, __Class__) . "
typeTitle";
$script .= PHP_EOL . Indent::_(4) .
"'{$columns['type_title']}',";
$script .= PHP_EOL . Indent::_(4) .
"//" . Line::_(__Line__, __Class__) . "
typeAlias";
$script .= PHP_EOL . Indent::_(4) .
"'{$columns['type_alias']}',";
$script .= PHP_EOL . Indent::_(4) .
"//" . Line::_(__Line__, __Class__) . " table";
$script .= PHP_EOL . Indent::_(4) .
"'{$columns['table']}',";
$script .= PHP_EOL . Indent::_(4) .
"//" . Line::_(__Line__, __Class__) . " rules";
$script .= PHP_EOL . Indent::_(4) .
"'{$columns['rules']}',";
$script .= PHP_EOL . Indent::_(4) .
"//" . Line::_(__Line__, __Class__) . "
fieldMappings";
$script .= PHP_EOL . Indent::_(4) .
"'{$columns['field_mappings']}',";
$script .= PHP_EOL . Indent::_(4) .
"//" . Line::_(__Line__, __Class__) . " router";
$script .= PHP_EOL . Indent::_(4) .
"'{$columns['router']}',";
$script .= PHP_EOL . Indent::_(4) .
"//" . Line::_(__Line__, __Class__) . "
contentHistoryOptions";
$script .= PHP_EOL . Indent::_(4) .
"'{$columns['content_history_options']}'";
$script .= PHP_EOL . Indent::_(3) .
');';
}
}
$script .= PHP_EOL . PHP_EOL;
return $script;
}
return '';
}
public function setPostInstallScript()
{
// reset script
$script = $this->setComponentToContentTypes('install');
// add the Intelligent Fix script if needed
$script .= $this->getAssetsTableIntelligentInstall();
if (CFactory::_('Config')->get('joomla_version',
3) == 3)
{
$script .= $this->setPostInstallScriptJ3();
}
else
{
$script .= $this->setPostInstallScriptJ4();
}
// add the custom script
$script .= CFactory::_('Customcode.Dispenser')->get(
'php_postflight', 'install', PHP_EOL . PHP_EOL,
null, true
);
// add the component installation notice
if (StringHelper::check($script))
{
$script .= PHP_EOL . PHP_EOL . Indent::_(3)
. 'echo \'<div style="background-color: #fff;"
class="alert alert-info"><a target="_blank"
href="'
.
CFactory::_('Compiler.Builder.Content.One')->get('AUTHORWEBSITE')
. '" title="'
.
CFactory::_('Compiler.Builder.Content.One')->get('Component_name')
. '">';
$script .= PHP_EOL . Indent::_(4) . '<img
src="components/com_'
. CFactory::_('Config')->component_code_name .
'/assets/images/vdm-component.'
. $this->componentImageType . '"/>';
$script .= PHP_EOL . Indent::_(4) .
'</a></div>\';';
return $script;
}
return PHP_EOL . Indent::_(3) . "//" . Line::_(__Line__,
__Class__)
. " noting to install.";
}
public function setPostInstallScriptJ3()
{
// reset script
$script = '';
// set the component name
$component = CFactory::_('Config')->component_code_name;
// add the assets table update for permissions rules
if
(CFactory::_('Compiler.Builder.Assets.Rules')->isArray('site'))
{
if (StringHelper::check($script))
{
$script .= PHP_EOL . Indent::_(3) . "//" . Line::_(
__LINE__,__CLASS__
) . " Install the global extenstion assets permission.";
}
else
{
$script .= PHP_EOL . Indent::_(3) . "//" . Line::_(
__LINE__,__CLASS__
) . " Install the global extension assets permission.";
$script .= PHP_EOL . Indent::_(3)
. "\$db = Factory::getDbo();";
}
$script .= PHP_EOL . Indent::_(3)
. "\$query = \$db->getQuery(true);";
$script .= PHP_EOL . Indent::_(3) . "//" . Line::_(__Line__,
__Class__)
. " Field to update.";
$script .= PHP_EOL . Indent::_(3) . "\$fields = array(";
$script .= PHP_EOL . Indent::_(4)
. "\$db->quoteName('rules') . ' = ' .
\$db->quote('{" . implode(
',',
CFactory::_('Compiler.Builder.Assets.Rules')->get('site')
) . "}'),";
$script .= PHP_EOL . Indent::_(3) . ");";
$script .= PHP_EOL . Indent::_(3) . "//" . Line::_(__Line__,
__Class__)
. " Condition.";
$script .= PHP_EOL . Indent::_(3) . "\$conditions = array(";
$script .= PHP_EOL . Indent::_(4)
. "\$db->quoteName('name') . ' = ' .
\$db->quote('com_"
. $component . "')";
$script .= PHP_EOL . Indent::_(3) . ");";
$script .= PHP_EOL . Indent::_(3)
.
"\$query->update(\$db->quoteName('#__assets'))->set(\$fields)->where(\$conditions);";
$script .= PHP_EOL . Indent::_(3) .
"\$db->setQuery(\$query);";
$script .= PHP_EOL . Indent::_(3) . "\$allDone =
\$db->execute();"
. PHP_EOL;
}
// add the global params for the component global settings
if
(CFactory::_('Compiler.Builder.Extensions.Params')->isArray('component'))
{
if (StringHelper::check($script))
{
$script .= PHP_EOL . Indent::_(3) . "//" . Line::_(
__LINE__,__CLASS__
) . " Install the global extension params.";
}
else
{
$script .= PHP_EOL . Indent::_(3) . "//" . Line::_(
__LINE__,__CLASS__
) . " Install the global extension params.";
$script .= PHP_EOL . Indent::_(3)
. "\$db = Factory::getDbo();";
}
$script .= PHP_EOL . Indent::_(3)
. "\$query = \$db->getQuery(true);";
$script .= PHP_EOL . Indent::_(3) . "//" . Line::_(__Line__,
__Class__)
. " Field to update.";
$script .= PHP_EOL . Indent::_(3) . "\$fields = array(";
$script .= PHP_EOL . Indent::_(4)
. "\$db->quoteName('params') . ' = ' .
\$db->quote('{"
. implode(',',
CFactory::_('Compiler.Builder.Extensions.Params')->get('component'))
. "}'),";
$script .= PHP_EOL . Indent::_(3) . ");";
$script .= PHP_EOL . Indent::_(3) . "//" . Line::_(__Line__,
__Class__)
. " Condition.";
$script .= PHP_EOL . Indent::_(3) . "\$conditions = array(";
$script .= PHP_EOL . Indent::_(4)
. "\$db->quoteName('element') . ' = ' .
\$db->quote('com_"
. $component . "')";
$script .= PHP_EOL . Indent::_(3) . ");";
$script .= PHP_EOL . Indent::_(3)
.
"\$query->update(\$db->quoteName('#__extensions'))->set(\$fields)->where(\$conditions);";
$script .= PHP_EOL . Indent::_(3) .
"\$db->setQuery(\$query);";
$script .= PHP_EOL . Indent::_(3) . "\$allDone =
\$db->execute();"
. PHP_EOL;
}
return $script;
}
public function setPostInstallScriptJ4()
{
// reset script
$script = '';
// add the assets table update for permissions rules
if
(CFactory::_('Compiler.Builder.Assets.Rules')->isArray('site'))
{
$script .= PHP_EOL . Indent::_(3) . "//" . Line::_(
__LINE__,__CLASS__
) . " Install the global extension assets permission.";
$script .= PHP_EOL . Indent::_(3) .
"\$this->setAssetsRules(";
$script .= PHP_EOL . Indent::_(4) . "'{" . implode(
',',
CFactory::_('Compiler.Builder.Assets.Rules')->get('site')
) . "}'";
$script .= PHP_EOL . Indent::_(3) . ");" . PHP_EOL;
}
// add the global params for the component global settings
if
(CFactory::_('Compiler.Builder.Extensions.Params')->isArray('component'))
{
$script .= PHP_EOL . Indent::_(3) . "//" . Line::_(
__LINE__,__CLASS__
) . " Install the global extension params.";
$script .= PHP_EOL . Indent::_(3) .
"\$this->setExtensionsParams(";
$script .= PHP_EOL . Indent::_(4) . "'{"
. implode(',',
CFactory::_('Compiler.Builder.Extensions.Params')->get('component')
) . "}'";
$script .= PHP_EOL . Indent::_(3) . ");" . PHP_EOL;
}
return $script;
}
public function setPostUpdateScript()
{
// reset script
$script = $this->setComponentToContentTypes('update');
// add the custom script
$script .= CFactory::_('Customcode.Dispenser')->get(
'php_postflight', 'update', PHP_EOL . PHP_EOL, null,
true
);
if
(CFactory::_('Component')->isArray('admin_views'))
{
$script .= PHP_EOL . PHP_EOL . Indent::_(3)
. 'echo \'<div style="background-color: #fff;"
class="alert alert-info"><a target="_blank"
href="'
.
CFactory::_('Compiler.Builder.Content.One')->get('AUTHORWEBSITE')
. '" title="'
.
CFactory::_('Compiler.Builder.Content.One')->get('Component_name')
. '">';
$script .= PHP_EOL . Indent::_(4) . '<img
src="components/com_'
. CFactory::_('Config')->component_code_name .
'/assets/images/vdm-component.'
. $this->componentImageType . '"/>';
$script .= PHP_EOL . Indent::_(4) . '</a>';
$script .= PHP_EOL . Indent::_(4) . "<h3>Upgrade to Version
"
.
CFactory::_('Compiler.Builder.Content.One')->get('ACTUALVERSION')
. " Was Successful! Let us know if anything is not working as
expected.</h3></div>';";
}
if (StringHelper::check($script))
{
return $script;
}
return PHP_EOL . Indent::_(3) . "//" . Line::_(__Line__,
__Class__)
. " noting to update.";
}
public function setUninstallScript()
{
if (CFactory::_('Config')->get('joomla_version',
3) == 3)
{
return $this->setUninstallScriptJ3();
}
return $this->setUninstallScriptJ4();
}
public function setUninstallScriptJ3()
{
// reset script
$script = '';
if (isset($this->uninstallScriptBuilder)
&& ArrayHelper::check(
$this->uninstallScriptBuilder
))
{
$component = CFactory::_('Config')->component_code_name;
// start loading the data to delete
$script .= PHP_EOL . Indent::_(2) . "//" . Line::_(__Line__,
__Class__)
. " Get Application object";
$script .= PHP_EOL . Indent::_(2)
. "\$app = Factory::getApplication();";
$script .= PHP_EOL . PHP_EOL . Indent::_(2) . "//" . Line::_(
__LINE__,__CLASS__
) . " Get The Database object";
$script .= PHP_EOL . Indent::_(2) . "\$db =
Factory::getDbo();";
foreach (
$this->uninstallScriptBuilder as $viewsCodeName => $typeAlias
)
{
// set a var value
$view = StringHelper::safe($viewsCodeName);
// check if it has field relations
if (isset($this->uninstallScriptFields)
&& isset($this->uninstallScriptFields[$viewsCodeName]))
{
// First check if data is till in table
$script .= PHP_EOL . PHP_EOL . Indent::_(2) . "//"
. Line::_(__Line__, __Class__)
. " Create a new query object.";
$script .= PHP_EOL . Indent::_(2)
. "\$query = \$db->getQuery(true);";
$script .= PHP_EOL . Indent::_(2) . "//" . Line::_(
__LINE__,__CLASS__
) . " Select ids from fields";
$script .= PHP_EOL . Indent::_(2)
.
"\$query->select(\$db->quoteName('id'));";
$script .= PHP_EOL . Indent::_(2)
.
"\$query->from(\$db->quoteName('#__fields'));";
$script .= PHP_EOL . Indent::_(2) . "//" . Line::_(
__LINE__,__CLASS__
) . " Where " . $viewsCodeName . " context is
found";
$script .= PHP_EOL . Indent::_(2)
. "\$query->where( \$db->quoteName('context') .
' = '. \$db->quote('"
. $typeAlias . "') );";
$script .= PHP_EOL . Indent::_(2)
. "\$db->setQuery(\$query);";
$script .= PHP_EOL . Indent::_(2) . "//" . Line::_(
__LINE__,__CLASS__
) . " Execute query to see if context is found";
$script .= PHP_EOL . Indent::_(2) . "\$db->execute();";
$script .= PHP_EOL . Indent::_(2) . "\$" . $view
. "_found = \$db->getNumRows();";
$script .= PHP_EOL . Indent::_(2) . "//" . Line::_(
__LINE__,__CLASS__
) . " Now check if there were any rows";
$script .= PHP_EOL . Indent::_(2) . "if (\$" . $view
. "_found)";
$script .= PHP_EOL . Indent::_(2) . "{";
$script .= PHP_EOL . Indent::_(3) . "//" . Line::_(
__LINE__,__CLASS__
) . " Since there are load the needed " . $view
. " field ids";
$script .= PHP_EOL . Indent::_(3) . "\$" . $view
. "_field_ids = \$db->loadColumn();";
// Now remove the actual type entry
$script .= PHP_EOL . Indent::_(3) . "//" . Line::_(
__LINE__,__CLASS__
) . " Remove " . $viewsCodeName
. " from the field table";
$script .= PHP_EOL . Indent::_(3) . "\$" . $view
. "_condition = array( \$db->quoteName('context') .
' = '. \$db->quote('"
. $typeAlias . "') );";
$script .= PHP_EOL . Indent::_(3) . "//" . Line::_(
__LINE__,__CLASS__
) . " Create a new query object.";
$script .= PHP_EOL . Indent::_(3)
. "\$query = \$db->getQuery(true);";
$script .= PHP_EOL . Indent::_(3)
.
"\$query->delete(\$db->quoteName('#__fields'));";
$script .= PHP_EOL . Indent::_(3) . "\$query->where(\$"
. $view . "_condition);";
$script .= PHP_EOL . Indent::_(3)
. "\$db->setQuery(\$query);";
$script .= PHP_EOL . Indent::_(3) . "//" . Line::_(
__LINE__,__CLASS__
) . " Execute the query to remove " . $viewsCodeName
. " items";
$script .= PHP_EOL . Indent::_(3) . "\$" . $view
. "_done = \$db->execute();";
$script .= PHP_EOL . Indent::_(3) . "if (\$" . $view
. "_done)";
$script .= PHP_EOL . Indent::_(3) . "{";
$script .= PHP_EOL . Indent::_(4) . "//" . Line::_(
__LINE__,__CLASS__
) . " If successfully remove " . $viewsCodeName
. " add queued success message.";
// TODO lang is not translated
$script .= PHP_EOL . Indent::_(4)
. "\$app->enqueueMessage(Text:"
. ":_('The fields with type (" . $typeAlias
. ") context was removed from the <b>#__fields</b>
table'));";
$script .= PHP_EOL . Indent::_(3) . "}";
$script .= PHP_EOL . Indent::_(3) . "//" . Line::_(
__LINE__,__CLASS__
) . " Also Remove " . $viewsCodeName . " field
values";
$script .= PHP_EOL . Indent::_(3) . "\$" . $view
. "_condition = array( \$db->quoteName('field_id')
. ' IN ('. implode(',', \$"
. $view . "_field_ids) .')');";
$script .= PHP_EOL . Indent::_(3) . "//" . Line::_(
__LINE__,__CLASS__
) . " Create a new query object.";
$script .= PHP_EOL . Indent::_(3)
. "\$query = \$db->getQuery(true);";
$script .= PHP_EOL . Indent::_(3)
.
"\$query->delete(\$db->quoteName('#__fields_values'));";
$script .= PHP_EOL . Indent::_(3) . "\$query->where(\$"
. $view . "_condition);";
$script .= PHP_EOL . Indent::_(3)
. "\$db->setQuery(\$query);";
$script .= PHP_EOL . Indent::_(3) . "//" . Line::_(
__LINE__,__CLASS__
) . " Execute the query to remove " . $viewsCodeName
. " field values";
$script .= PHP_EOL . Indent::_(3) . "\$" . $view
. "_done = \$db->execute();";
$script .= PHP_EOL . Indent::_(3) . "if (\$" . $view
. "_done)";
$script .= PHP_EOL . Indent::_(3) . "{";
$script .= PHP_EOL . Indent::_(4) . "//" . Line::_(
__LINE__,__CLASS__
) . " If successfully remove " . $viewsCodeName
. " add queued success message.";
// TODO lang is not translated
$script .= PHP_EOL . Indent::_(4)
. "\$app->enqueueMessage(Text:"
. ":_('The fields values for " . $viewsCodeName
. " was removed from the <b>#__fields_values</b>
table'));";
$script .= PHP_EOL . Indent::_(3) . "}";
$script .= PHP_EOL . Indent::_(2) . "}";
// First check if data is till in table
$script .= PHP_EOL . PHP_EOL . Indent::_(2) . "//"
. Line::_(__Line__, __Class__)
. " Create a new query object.";
$script .= PHP_EOL . Indent::_(2)
. "\$query = \$db->getQuery(true);";
$script .= PHP_EOL . Indent::_(2) . "//" . Line::_(
__LINE__,__CLASS__
) . " Select ids from field groups";
$script .= PHP_EOL . Indent::_(2)
.
"\$query->select(\$db->quoteName('id'));";
$script .= PHP_EOL . Indent::_(2)
.
"\$query->from(\$db->quoteName('#__fields_groups'));";
$script .= PHP_EOL . Indent::_(2) . "//" . Line::_(
__LINE__,__CLASS__
) . " Where " . $viewsCodeName . " context is
found";
$script .= PHP_EOL . Indent::_(2)
. "\$query->where( \$db->quoteName('context') .
' = '. \$db->quote('"
. $typeAlias . "') );";
$script .= PHP_EOL . Indent::_(2)
. "\$db->setQuery(\$query);";
$script .= PHP_EOL . Indent::_(2) . "//" . Line::_(
__LINE__,__CLASS__
) . " Execute query to see if context is found";
$script .= PHP_EOL . Indent::_(2) . "\$db->execute();";
$script .= PHP_EOL . Indent::_(2) . "\$" . $view
. "_found = \$db->getNumRows();";
$script .= PHP_EOL . Indent::_(2) . "//" . Line::_(
__LINE__,__CLASS__
) . " Now check if there were any rows";
$script .= PHP_EOL . Indent::_(2) . "if (\$" . $view
. "_found)";
$script .= PHP_EOL . Indent::_(2) . "{";
// Now remove the actual type entry
$script .= PHP_EOL . Indent::_(3) . "//" . Line::_(
__LINE__,__CLASS__
) . " Remove " . $viewsCodeName
. " from the field groups table";
$script .= PHP_EOL . Indent::_(3) . "\$" . $view
. "_condition = array( \$db->quoteName('context') .
' = '. \$db->quote('"
. $typeAlias . "') );";
$script .= PHP_EOL . Indent::_(3) . "//" . Line::_(
__LINE__,__CLASS__
) . " Create a new query object.";
$script .= PHP_EOL . Indent::_(3)
. "\$query = \$db->getQuery(true);";
$script .= PHP_EOL . Indent::_(3)
.
"\$query->delete(\$db->quoteName('#__fields_groups'));";
$script .= PHP_EOL . Indent::_(3) . "\$query->where(\$"
. $view . "_condition);";
$script .= PHP_EOL . Indent::_(3)
. "\$db->setQuery(\$query);";
$script .= PHP_EOL . Indent::_(3) . "//" . Line::_(
__LINE__,__CLASS__
) . " Execute the query to remove " . $viewsCodeName
. " items";
$script .= PHP_EOL . Indent::_(3) . "\$" . $view
. "_done = \$db->execute();";
$script .= PHP_EOL . Indent::_(3) . "if (\$" . $view
. "_done)";
$script .= PHP_EOL . Indent::_(3) . "{";
$script .= PHP_EOL . Indent::_(4) . "//" . Line::_(
__LINE__,__CLASS__
) . " If successfully remove " . $viewsCodeName
. " add queued success message.";
// TODO lang is not translated
$script .= PHP_EOL . Indent::_(4)
. "\$app->enqueueMessage(Text:"
. ":_('The field groups with type (" . $typeAlias
. ") context was removed from the
<b>#__fields_groups</b> table'));";
$script .= PHP_EOL . Indent::_(3) . "}";
$script .= PHP_EOL . Indent::_(2) . "}";
}
// First check if data is till in table
$script .= PHP_EOL . PHP_EOL . Indent::_(2) . "//"
. Line::_(__Line__, __Class__) . " Create a new query
object.";
$script .= PHP_EOL . Indent::_(2)
. "\$query = \$db->getQuery(true);";
$script .= PHP_EOL . Indent::_(2) . "//" . Line::_(
__LINE__,__CLASS__
) . " Select id from content type table";
$script .= PHP_EOL . Indent::_(2)
.
"\$query->select(\$db->quoteName('type_id'));";
$script .= PHP_EOL . Indent::_(2)
.
"\$query->from(\$db->quoteName('#__content_types'));";
$script .= PHP_EOL . Indent::_(2) . "//" . Line::_(
__LINE__,__CLASS__
) . " Where " . $viewsCodeName . " alias is
found";
$script .= PHP_EOL . Indent::_(2)
. "\$query->where( \$db->quoteName('type_alias')
. ' = '. \$db->quote('"
. $typeAlias . "') );";
$script .= PHP_EOL . Indent::_(2) .
"\$db->setQuery(\$query);";
$script .= PHP_EOL . Indent::_(2) . "//" . Line::_(
__LINE__,__CLASS__
) . " Execute query to see if alias is found";
$script .= PHP_EOL . Indent::_(2) . "\$db->execute();";
$script .= PHP_EOL . Indent::_(2) . "\$" . $view
. "_found = \$db->getNumRows();";
$script .= PHP_EOL . Indent::_(2) . "//" . Line::_(
__LINE__,__CLASS__
) . " Now check if there were any rows";
$script .= PHP_EOL . Indent::_(2) . "if (\$" . $view
. "_found)";
$script .= PHP_EOL . Indent::_(2) . "{";
$script .= PHP_EOL . Indent::_(3) . "//" . Line::_(
__LINE__,__CLASS__
) . " Since there are load the needed " . $view
. " type ids";
$script .= PHP_EOL . Indent::_(3) . "\$" . $view
. "_ids = \$db->loadColumn();";
// Now remove the actual type entry
$script .= PHP_EOL . Indent::_(3) . "//" . Line::_(
__LINE__,__CLASS__
) . " Remove " . $viewsCodeName
. " from the content type table";
$script .= PHP_EOL . Indent::_(3) . "\$" . $view
. "_condition = array( \$db->quoteName('type_alias')
. ' = '. \$db->quote('"
. $typeAlias . "') );";
$script .= PHP_EOL . Indent::_(3) . "//" . Line::_(
__LINE__,__CLASS__
) . " Create a new query object.";
$script .= PHP_EOL . Indent::_(3)
. "\$query = \$db->getQuery(true);";
$script .= PHP_EOL . Indent::_(3)
.
"\$query->delete(\$db->quoteName('#__content_types'));";
$script .= PHP_EOL . Indent::_(3) . "\$query->where(\$" .
$view
. "_condition);";
$script .= PHP_EOL . Indent::_(3) .
"\$db->setQuery(\$query);";
$script .= PHP_EOL . Indent::_(3) . "//" . Line::_(
__LINE__,__CLASS__
) . " Execute the query to remove " . $viewsCodeName
. " items";
$script .= PHP_EOL . Indent::_(3) . "\$" . $view
. "_done = \$db->execute();";
$script .= PHP_EOL . Indent::_(3) . "if (\$" . $view .
"_done)";
$script .= PHP_EOL . Indent::_(3) . "{";
$script .= PHP_EOL . Indent::_(4) . "//" . Line::_(
__LINE__,__CLASS__
) . " If successfully remove " . $viewsCodeName
. " add queued success message.";
// TODO lang is not translated
$script .= PHP_EOL . Indent::_(4)
. "\$app->enqueueMessage(Text:" . ":_('The
(" . $typeAlias
. ") type alias was removed from the
<b>#__content_type</b> table'));";
$script .= PHP_EOL . Indent::_(3) . "}";
// Now remove the related items from contentitem tag map table
$script .= PHP_EOL . PHP_EOL . Indent::_(3) . "//"
. Line::_(__Line__, __Class__) . " Remove " .
$viewsCodeName
. " items from the contentitem tag map table";
$script .= PHP_EOL . Indent::_(3) . "\$" . $view
. "_condition = array( \$db->quoteName('type_alias')
. ' = '. \$db->quote('"
. $typeAlias . "') );";
$script .= PHP_EOL . Indent::_(3) . "//" . Line::_(
__LINE__,__CLASS__
) . " Create a new query object.";
$script .= PHP_EOL . Indent::_(3)
. "\$query = \$db->getQuery(true);";
$script .= PHP_EOL . Indent::_(3)
.
"\$query->delete(\$db->quoteName('#__contentitem_tag_map'));";
$script .= PHP_EOL . Indent::_(3) . "\$query->where(\$" .
$view
. "_condition);";
$script .= PHP_EOL . Indent::_(3) .
"\$db->setQuery(\$query);";
$script .= PHP_EOL . Indent::_(3) . "//" . Line::_(
__LINE__,__CLASS__
) . " Execute the query to remove " . $viewsCodeName
. " items";
$script .= PHP_EOL . Indent::_(3) . "\$" . $view
. "_done = \$db->execute();";
$script .= PHP_EOL . Indent::_(3) . "if (\$" . $view .
"_done)";
$script .= PHP_EOL . Indent::_(3) . "{";
$script .= PHP_EOL . Indent::_(4) . "//" . Line::_(
__LINE__,__CLASS__
) . " If successfully remove " . $viewsCodeName
. " add queued success message.";
// TODO lang is not translated
$script .= PHP_EOL . Indent::_(4)
. "\$app->enqueueMessage(Text:" . ":_('The
(" . $typeAlias
. ") type alias was removed from the
<b>#__contentitem_tag_map</b> table'));";
$script .= PHP_EOL . Indent::_(3) . "}";
// Now remove the related items from ucm content table
$script .= PHP_EOL . PHP_EOL . Indent::_(3) . "//"
. Line::_(__Line__, __Class__) . " Remove " .
$viewsCodeName
. " items from the ucm content table";
$script .= PHP_EOL . Indent::_(3) . "\$" . $view
. "_condition = array(
\$db->quoteName('core_type_alias') . ' = ' .
\$db->quote('"
. $typeAlias . "') );";
$script .= PHP_EOL . Indent::_(3) . "//" . Line::_(
__LINE__,__CLASS__
) . " Create a new query object.";
$script .= PHP_EOL . Indent::_(3)
. "\$query = \$db->getQuery(true);";
$script .= PHP_EOL . Indent::_(3)
.
"\$query->delete(\$db->quoteName('#__ucm_content'));";
$script .= PHP_EOL . Indent::_(3) . "\$query->where(\$" .
$view
. "_condition);";
$script .= PHP_EOL . Indent::_(3) .
"\$db->setQuery(\$query);";
$script .= PHP_EOL . Indent::_(3) . "//" . Line::_(
__LINE__,__CLASS__
) . " Execute the query to remove " . $viewsCodeName
. " items";
$script .= PHP_EOL . Indent::_(3) . "\$" . $view
. "_done = \$db->execute();";
$script .= PHP_EOL . Indent::_(3) . "if (\$" . $view .
"_done)";
$script .= PHP_EOL . Indent::_(3) . "{";
$script .= PHP_EOL . Indent::_(4) . "//" . Line::_(
__LINE__,__CLASS__
) . " If successfully removed " . $viewsCodeName
. " add queued success message.";
// TODO lang is not translated
$script .= PHP_EOL . Indent::_(4)
. "\$app->enqueueMessage(Text:" . ":_('The
(" . $typeAlias
. ") type alias was removed from the
<b>#__ucm_content</b> table'));";
$script .= PHP_EOL . Indent::_(3) . "}";
// setup the foreach loop of ids
$script .= PHP_EOL . PHP_EOL . Indent::_(3) . "//"
. Line::_(__Line__, __Class__) . " Make sure that all the "
. $viewsCodeName . " items are cleared from DB";
$script .= PHP_EOL . Indent::_(3) . "foreach (\$" . $view
. "_ids as \$" . $view . "_id)";
$script .= PHP_EOL . Indent::_(3) . "{";
// Now remove the related items from ucm base table
$script .= PHP_EOL . Indent::_(4) . "//" . Line::_(
__LINE__,__CLASS__
) . " Remove " . $viewsCodeName
. " items from the ucm base table";
$script .= PHP_EOL . Indent::_(4) . "\$" . $view
. "_condition = array(
\$db->quoteName('ucm_type_id') . ' = ' . \$"
. $view . "_id);";
$script .= PHP_EOL . Indent::_(4) . "//" . Line::_(
__LINE__,__CLASS__
) . " Create a new query object.";
$script .= PHP_EOL . Indent::_(4)
. "\$query = \$db->getQuery(true);";
$script .= PHP_EOL . Indent::_(4)
.
"\$query->delete(\$db->quoteName('#__ucm_base'));";
$script .= PHP_EOL . Indent::_(4) . "\$query->where(\$" .
$view
. "_condition);";
$script .= PHP_EOL . Indent::_(4) .
"\$db->setQuery(\$query);";
$script .= PHP_EOL . Indent::_(4) . "//" . Line::_(
__LINE__,__CLASS__
) . " Execute the query to remove " . $viewsCodeName
. " items";
$script .= PHP_EOL . Indent::_(4) . "\$db->execute();";
// Now remove the related items from ucm history table
$script .= PHP_EOL . PHP_EOL . Indent::_(4) . "//"
. Line::_(__Line__, __Class__) . " Remove " .
$viewsCodeName
. " items from the ucm history table";
$script .= PHP_EOL . Indent::_(4) . "\$" . $view
. "_condition = array(
\$db->quoteName('ucm_type_id') . ' = ' . \$"
. $view . "_id);";
$script .= PHP_EOL . Indent::_(4) . "//" . Line::_(
__LINE__,__CLASS__
) . " Create a new query object.";
$script .= PHP_EOL . Indent::_(4)
. "\$query = \$db->getQuery(true);";
$script .= PHP_EOL . Indent::_(4)
.
"\$query->delete(\$db->quoteName('#__ucm_history'));";
$script .= PHP_EOL . Indent::_(4) . "\$query->where(\$" .
$view
. "_condition);";
$script .= PHP_EOL . Indent::_(4) .
"\$db->setQuery(\$query);";
$script .= PHP_EOL . Indent::_(4) . "//" . Line::_(
__LINE__,__CLASS__
) . " Execute the query to remove " . $viewsCodeName
. " items";
$script .= PHP_EOL . Indent::_(4) . "\$db->execute();";
$script .= PHP_EOL . Indent::_(3) . "}";
$script .= PHP_EOL . Indent::_(2) . "}";
}
$script .= PHP_EOL . PHP_EOL . Indent::_(2) . "//" . Line::_(
__LINE__,__CLASS__
) . " If All related items was removed queued success
message.";
// TODO lang is not translated
$script .= PHP_EOL . Indent::_(2) .
"\$app->enqueueMessage(Text:"
. ":_('All related items was removed from the
<b>#__ucm_base</b> table'));";
$script .= PHP_EOL . Indent::_(2) .
"\$app->enqueueMessage(Text:"
. ":_('All related items was removed from the
<b>#__ucm_history</b> table'));";
// finaly remove the assets from the assets table
$script .= PHP_EOL . PHP_EOL . Indent::_(2) . "//" . Line::_(
__LINE__,__CLASS__
) . " Remove " . $component . " assets from the assets
table";
$script .= PHP_EOL . Indent::_(2) . "\$" . $component
. "_condition = array( \$db->quoteName('name') .
' LIKE ' . \$db->quote('com_"
. $component . "%') );";
$script .= PHP_EOL . PHP_EOL . Indent::_(2) . "//" . Line::_(
__LINE__,__CLASS__
) . " Create a new query object.";
$script .= PHP_EOL . Indent::_(2)
. "\$query = \$db->getQuery(true);";
$script .= PHP_EOL . Indent::_(2)
.
"\$query->delete(\$db->quoteName('#__assets'));";
$script .= PHP_EOL . Indent::_(2) . "\$query->where(\$" .
$component
. "_condition);";
$script .= PHP_EOL . Indent::_(2) .
"\$db->setQuery(\$query);";
$script .= PHP_EOL . Indent::_(2) . "\$" . $view
. "_done = \$db->execute();";
$script .= PHP_EOL . Indent::_(2) . "if (\$" . $view .
"_done)";
$script .= PHP_EOL . Indent::_(2) . "{";
$script .= PHP_EOL . Indent::_(3) . "//" . Line::_(__Line__,
__Class__)
. " If successfully removed " . $component
. " add queued success message.";
// TODO lang is not translated
$script .= PHP_EOL . Indent::_(3) .
"\$app->enqueueMessage(Text:"
. ":_('All related items was removed from the
<b>#__assets</b> table'));";
$script .= PHP_EOL . Indent::_(2) . "}";
// done
$script .= PHP_EOL;
}
elseif (CFactory::_('Config')->add_assets_table_fix == 2)
{
// start loading the data to delete (WE NEED THIS)
$script .= PHP_EOL . Indent::_(2) . "//" . Line::_(__Line__,
__Class__)
. " Get Application object";
$script .= PHP_EOL . Indent::_(2)
. "\$app = Factory::getApplication();";
$script .= PHP_EOL . PHP_EOL . Indent::_(2) . "//" . Line::_(
__LINE__,__CLASS__
) . " Get The Database object";
$script .= PHP_EOL . Indent::_(2) . "\$db =
Factory::getDbo();";
}
// add the Intelligent Reversal script if needed
$script .= $this->getAssetsTableIntelligentUninstall();
// add the custom uninstall script
$script .= CFactory::_('Customcode.Dispenser')->get(
'php_method', 'uninstall', "", null, true,
null, PHP_EOL
);
return $script;
}
public function setUninstallScriptJ4()
{
// reset script
$script = '';
if (isset($this->uninstallScriptBuilder)
&& ArrayHelper::check(
$this->uninstallScriptBuilder
))
{
// start loading the data to delete
$script .= PHP_EOL . Indent::_(2) . "//" . Line::_(__Line__,
__Class__)
. " Remove Related Component Data.";
foreach ($this->uninstallScriptBuilder as $viewsCodeName =>
$context)
{
// set a var value
$View = StringHelper::safe($viewsCodeName, 'Ww');
// First check if data is till in table
$script .= PHP_EOL . PHP_EOL . Indent::_(2) . "//"
. Line::_(__Line__, __Class__)
. " Remove $View Data";
$field = '';
// check if it has field relations
if (isset($this->uninstallScriptFields)
&& isset($this->uninstallScriptFields[$viewsCodeName]))
{
$field = ', true';
}
// First check if data is till in table
$script .= PHP_EOL . Indent::_(2) .
"\$this->removeViewData(\"$context\"$field);";
}
$script .= PHP_EOL . PHP_EOL . Indent::_(2) . "//" . Line::_(
__LINE__,__CLASS__
) . " Remove Asset Data.";
$script .= PHP_EOL . Indent::_(2) .
"\$this->removeAssetData();";
// done
$script .= PHP_EOL;
}
// add the Intelligent Reversal script if needed
$script .= $this->getAssetsTableIntelligentUninstall();
// add the custom uninstallation script
$script .= CFactory::_('Customcode.Dispenser')->get(
'php_method', 'uninstall', "", null, true,
null, PHP_EOL
);
return $script;
}
/**
* build code for the assets table script intelligent fix
*
* @return string The php to place in script.php
*
*/
protected function getAssetsTableIntelligentInstall()
{
// WHY DO WE NEED AN ASSET TABLE FIX?
// https://www.mysqltutorial.org/mysql-varchar/
// https://stackoverflow.com/a/15227917/1429677
// https://forums.mysql.com/read.php?24,105964,105964
//
https://git.vdm.dev/joomla/Component-Builder/issues/616#issuecomment-12085
// 30 actions each +-20 characters with 8 groups
// that makes 4800 characters and the current Joomla
// column size is varchar(5120)
// check if we should add the intelligent fix treatment for the assets
table
if (CFactory::_('Config')->add_assets_table_fix == 2)
{
// get worse case
$access_worse_case =
CFactory::_('Config')->get('access_worse_case', 0);
// get the type we will convert to
$data_type = ($access_worse_case > 64000) ? "MEDIUMTEXT"
: "TEXT";
if (CFactory::_('Config')->get('joomla_version',
3) != 3)
{
$script = [];
$script[] = Indent::_(3) . "//" . Line::_(__Line__,
__Class__)
. " Fix the assets table rules column size.";
$script[] = Indent::_(3) .
'$this->setDatabaseAssetsRulesFix('
. (int) $access_worse_case . ', "' . $data_type .
'");';
return PHP_EOL . implode(PHP_EOL, $script);
}
// the if statement about $rule_length
$codeIF = "\$rule_length <= " . $access_worse_case;
// fix column size
$script = [];
$script[] = Indent::_(5) . "//" . Line::_(__Line__,
__Class__)
. " Fix the assets table rules column size";
$script[] = Indent::_(5)
. '$fix_rules_size = "ALTER TABLE `#__assets` CHANGE `rules`
`rules` '
. $data_type
. ' NOT NULL COMMENT \'JSON encoded access control. Enlarged
to '
. $data_type . ' by JCB\';";';
$script[] = Indent::_(5) .
"\$db->setQuery(\$fix_rules_size);";
$script[] = Indent::_(5) . "\$db->execute();";
$codeA = implode(PHP_EOL, $script);
// fixed message
$messageA = Indent::_(5)
. "\$app->enqueueMessage(Text:" . ":_('The
<b>#__assets</b> table rules column was resized to the "
. $data_type
. " datatype for the components possible large permission
rules.'));";
// do nothing
$codeB = "";
// fix not needed so ignore
$messageB = "";
// done
return $this->getAssetsTableIntelligentCode(
$codeIF, $codeA, $codeB, $messageA, $messageB, 2
);
}
return '';
}
/**
* build code for the assets table script intelligent reversal
*
* @return string The php to place in script.php
*
*/
protected function getAssetsTableIntelligentUninstall()
{
// check if we should add the intelligent uninstall treatment for the
assets table
if (CFactory::_('Config')->add_assets_table_fix == 2)
{
if (CFactory::_('Config')->get('joomla_version',
3) != 3)
{
$script = [];
$script[] = Indent::_(2) . "//" . Line::_(__Line__,
__Class__)
. " Revert the assets table rules column back to the
default.";
$script[] = Indent::_(2) .
'$this->removeDatabaseAssetsRulesFix();';
return PHP_EOL . implode(PHP_EOL, $script);
}
// the if statement about $rule_length
$codeIF = "\$rule_length < 5120";
// reverse column size
$script = [];
$script[] = Indent::_(4) . "//" . Line::_(__Line__,
__Class__)
. " Revert the assets table rules column back to the
default";
$script[] = Indent::_(4)
. '$revert_rule = "ALTER TABLE `#__assets` CHANGE `rules`
`rules` varchar(5120) NOT NULL COMMENT \'JSON encoded access
control.\';";';
$script[] = Indent::_(4) .
"\$db->setQuery(\$revert_rule);";
$script[] = Indent::_(4) . "\$db->execute();";
$codeA = implode(PHP_EOL, $script);
// reverted message
$messageA = Indent::_(4)
.
"\$app->enqueueMessage(Text::_('COM_COMPONENTBUILDER_REVERTED_THE_B_ASSETSB_TABLE_RULES_COLUMN_BACK_TO_ITS_DEFAULT_SIZE_OF_VARCHARFIVE_THOUSAND_ONE_HUNDRED_AND_TWENTY'));";
// do nothing
$codeB = "";
// not reverted message
$messageB = Indent::_(4)
. "\$app->enqueueMessage(Text:" . ":_('Could not
revert the <b>#__assets</b> table rules column back to its
default size of varchar(5120), since there is still one or more components
that still requires the column to be larger.'));";
// done
return $this->getAssetsTableIntelligentCode(
$codeIF, $codeA, $codeB, $messageA, $messageB
);
}
return '';
}
/**
* set code for both install, update and uninstall
*
* @param string $codeIF The IF code to fix this issue
* @param string $codeA The a code to fix this issue
* @param string $codeB The b code to fix this issue
* @param string $messageA The fix a message
* @param string $messageB The fix b message
*
* @return string
*
*/
protected function getAssetsTableIntelligentCode($codeIF, $codeA, $codeB,
$messageA, $messageB,
$tab = 1
)
{
// reset script
$script = [];
$script[] = Indent::_($tab) . Indent::_(1) . "//" . Line::_(
__LINE__,__CLASS__
)
. " Get the biggest rule column in the assets table at this
point.";
$script[] = Indent::_($tab) . Indent::_(1)
. '$get_rule_length = "SELECT CHAR_LENGTH(`rules`) as
rule_size FROM #__assets ORDER BY rule_size DESC LIMIT 1";';
$script[] = Indent::_($tab) . Indent::_(1)
. "\$db->setQuery(\$get_rule_length);";
$script[] = Indent::_($tab) . Indent::_(1) . "if
(\$db->execute())";
$script[] = Indent::_($tab) . Indent::_(1) . "{";
$script[] = Indent::_($tab) . Indent::_(2)
. "\$rule_length = \$db->loadResult();";
//
https://github.com/joomla/joomla-cms/blob/3.10.0-alpha3/installation/sql/mysql/joomla.sql#L22
// Checked 1st December 2020 (let us know if this changes)
$script[] = Indent::_($tab) . Indent::_(2) . "//" . Line::_(
__LINE__,__CLASS__
)
. " Check the size of the rules column";
$script[] = Indent::_($tab) . Indent::_(2) . "if (" . $codeIF .
")";
$script[] = Indent::_($tab) . Indent::_(2) . "{";
$script[] = $codeA;
$script[] = $messageA;
$script[] = Indent::_($tab) . Indent::_(2) . "}";
// only ad this if there is a B part
if (StringHelper::check($codeB)
|| StringHelper::check($messageB))
{
$script[] = Indent::_($tab) . Indent::_(2) . "else";
$script[] = Indent::_($tab) . Indent::_(2) . "{";
$script[] = $codeB;
$script[] = $messageB;
$script[] = Indent::_($tab) . Indent::_(2) . "}";
}
$script[] = Indent::_($tab) . Indent::_(1) . "}";
// done
return PHP_EOL . implode(PHP_EOL, $script);
}
public function setMoveFolderScript()
{
if
(CFactory::_('Registry')->get('set_move_folders_install_script'))
{
$function = 'setDynamicF0ld3rs($app, $parent)';
if (CFactory::_('Config')->get('joomla_version',
3) != 3)
{
$function = 'moveFolders($adapter)';
}
// reset script
$script = [];
$script[] = Indent::_(2) . "//" . Line::_(__Line__,
__Class__)
. " We check if we have dynamic folders to copy";
$script[] = Indent::_(2)
. "\$this->{$function};";
// done
return PHP_EOL . implode(PHP_EOL, $script);
}
return '';
}
public function setMoveFolderMethod()
{
if
(CFactory::_('Registry')->get('set_move_folders_install_script'))
{
// reset script
$script = [];
if (CFactory::_('Config')->get('joomla_version',
3) != 3)
{
$script[] = Indent::_(1) . "/**";
$script[] = Indent::_(1)
. " * Method to move folders into place.";
$script[] = Indent::_(1) . " *";
$script[] = Indent::_(1) . " * @param InstallerAdapter
\$adapter The adapter calling this method";
$script[] = Indent::_(1) . " *";
$script[] = Indent::_(1) . " * @return void";
$script[] = Indent::_(1) . " * @since 4.4.2";
$script[] = Indent::_(1) . " */";
$script[] = Indent::_(1)
. "protected function moveFolders(InstallerAdapter \$adapter):
void";
$script[] = Indent::_(1) . "{";
$script[] = Indent::_(2) . "//" . Line::_(__Line__,
__Class__)
. " get the installation path";
$script[] = Indent::_(2) . "\$installer =
\$adapter->getParent();";
}
else
{
$script[] = Indent::_(1) . "/**";
$script[] = Indent::_(1)
. " * Method to set/copy dynamic folders into place (use with
caution)";
$script[] = Indent::_(1) . " *";
$script[] = Indent::_(1) . " * @return void";
$script[] = Indent::_(1) . " */";
$script[] = Indent::_(1)
. "protected function setDynamicF0ld3rs(\$app, \$parent)";
$script[] = Indent::_(1) . "{";
$script[] = Indent::_(2) . "//" . Line::_(__Line__,
__Class__)
. " get the installation path";
$script[] = Indent::_(2) . "\$installer =
\$parent->getParent();";
}
$script[] = Indent::_(2)
. "\$installPath =
\$installer->getPath('source');";
$script[] = Indent::_(2) . "//" . Line::_(__Line__,
__Class__)
. " get all the folders";
$script[] = Indent::_(2)
. "\$folders = Folder::folders(\$installPath);";
$script[] = Indent::_(2) . "//" . Line::_(__Line__,
__Class__)
. " check if we have folders we may want to copy";
$script[] = Indent::_(2)
. "\$doNotCopy =
['media','admin','site']; // Joomla already
deals with these";
$script[] = Indent::_(2) . "if (count((array) \$folders) >
1)";
$script[] = Indent::_(2) . "{";
$script[] = Indent::_(3) . "foreach (\$folders as \$folder)";
$script[] = Indent::_(3) . "{";
$script[] = Indent::_(4) . "//" . Line::_(__Line__,
__Class__)
. " Only copy if not a standard folders";
$script[] = Indent::_(4) . "if (!in_array(\$folder,
\$doNotCopy))";
$script[] = Indent::_(4) . "{";
$script[] = Indent::_(5) . "//" . Line::_(__Line__,
__Class__)
. " set the source path";
$script[] = Indent::_(5) . "\$src =
\$installPath.'/'.\$folder;";
$script[] = Indent::_(5) . "//" . Line::_(__Line__,
__Class__)
. " set the destination path";
$script[] = Indent::_(5) . "\$dest =
JPATH_ROOT.'/'.\$folder;";
$script[] = Indent::_(5) . "//" . Line::_(__Line__,
__Class__)
. " now try to copy the folder";
$script[] = Indent::_(5)
. "if (!Folder::copy(\$src, \$dest, '', true))";
$script[] = Indent::_(5) . "{";
if (CFactory::_('Config')->get('joomla_version',
3) != 3)
{
$script[] = Indent::_(6)
. "\$this->app->enqueueMessage('Could not copy
'.\$folder.' folder into place, please make sure destination is
writable!', 'error');";
}
else
{
$script[] = Indent::_(6)
. "\$app->enqueueMessage('Could not copy
'.\$folder.' folder into place, please make sure destination is
writable!', 'error');";
}
$script[] = Indent::_(5) . "}";
$script[] = Indent::_(4) . "}";
$script[] = Indent::_(3) . "}";
$script[] = Indent::_(2) . "}";
$script[] = Indent::_(1) . "}";
// done
return PHP_EOL . PHP_EOL . implode(PHP_EOL, $script);
}
return '';
}
public function getContentType($view, $component)
{
// add if history is to be kept or if tags is added
if (CFactory::_('Compiler.Builder.History')->exists($view)
|| CFactory::_('Compiler.Builder.Tags')->exists($view))
{
// reset array
$array = [];
// set needed defaults
$alias =
CFactory::_('Compiler.Builder.Alias')->get($view,
'null');
$title =
CFactory::_('Compiler.Builder.Title')->get($view,
'null');
$category =
CFactory::_('Compiler.Builder.Category.Code')->getString("{$view}.code",
'null');
$categoryHistory =
(CFactory::_('Compiler.Builder.Category.Code')->exists($view))
?
'{"sourceColumn": "' . $category
. '","targetTable":
"#__categories","targetColumn":
"id","displayColumn": "title"},'
: '';
$Component = StringHelper::safe(
$component, 'F'
);
$View = StringHelper::safe($view, 'F');
$maintext =
CFactory::_('Compiler.Builder.Main.Text.Field')->get($view,
'null');
$hiddenFields =
CFactory::_('Compiler.Builder.Hidden.Fields')->toString($view,
'');
$dynamicfields =
CFactory::_('Compiler.Builder.Dynamic.Fields')->toString($view,
',');
$intFields =
CFactory::_('Compiler.Builder.Integer.Fields')->toString($view,
'');
$customfieldlinks =
CFactory::_('Compiler.Builder.Custom.Field.Links')->toString($view,
'');
// build uninstall script for content types
$this->uninstallScriptBuilder[$View] = 'com_' . $component
. '.' . $view;
$this->uninstallScriptContent[$view] = $view;
// check if this view has metadata
if
(CFactory::_('Compiler.Builder.Meta.Data')->isString($view))
{
$core_metadata = 'metadata';
$core_metakey = 'metakey';
$core_metadesc = 'metadesc';
}
else
{
$core_metadata = 'null';
$core_metakey = 'null';
$core_metadesc = 'null';
}
// check if view has access
if
(CFactory::_('Compiler.Builder.Access.Switch')->exists($view))
{
$core_access = 'access';
$accessHistory
= ',{"sourceColumn":
"access","targetTable":
"#__viewlevels","targetColumn":
"id","displayColumn": "title"}';
}
else
{
$core_access = 'null';
$accessHistory = '';
}
// set the title
$array['type_title'] = $Component . ' ' . $View;
// set the alias
$array['type_alias'] = 'com_' . $component .
'.' . $view;
if (CFactory::_('Config')->get('joomla_version',
3) == 3)
{
// set the table
$array['table'] = '{"special":
{"dbtable": "#__' . $component . '_'
. $view . '","key":
"id","type": "' . $View .
'","prefix": "'
. $component
. 'Table","config":
"array()"},"common": {"dbtable":
"#__ucm_content","key":
"ucm_id","type":
"Corecontent","prefix":
"JTable","config": "array()"}}';
}
else
{
// set the table
$array['table'] = '{"special":
{"dbtable": "#__' . $component . '_'
. $view . '","key":
"id","type": "' . $View .
'Table","prefix": "' .
CFactory::_('Config')->namespace_prefix
. '\\Component\\' .
CFactory::_('Compiler.Builder.Content.One')->get('ComponentNamespace')
. '\\Administrator\\Table"}}';
// set rules field
$array['rules'] = '';
}
// set field map
$array['field_mappings']
= '{"common": {"core_content_item_id":
"id","core_title": "'
. $title . '","core_state":
"published","core_alias": "'
. $alias
. '","core_created_time":
"created","core_modified_time":
"modified","core_body": "'
. $maintext
. '","core_hits":
"hits","core_publish_up":
"null","core_publish_down":
"null","core_access": "'
. $core_access
. '","core_params":
"params","core_featured":
"null","core_metadata": "'
. $core_metadata
. '","core_language":
"null","core_images":
"null","core_urls":
"null","core_version":
"version","core_ordering":
"ordering","core_metakey": "'
. $core_metakey . '","core_metadesc": "'
. $core_metadesc
. '","core_catid": "' . $category
. '","core_xreference":
"null","asset_id":
"asset_id"},"special": {'
. $dynamicfields . '}}';
if (CFactory::_('Config')->get('joomla_version',
3) == 3)
{
// set the router class method
$array['router'] = $Component . 'HelperRoute::get'
. $View
. 'Route';
}
else
{
// set the router class method
$array['router'] = '';
}
if (CFactory::_('Config')->get('joomla_version',
3) == 3)
{
// set content history
$array['content_history_options']
= '{"formFile":
"administrator/components/com_' . $component
. '/models/forms/' . $view
. '.xml","hideFields":
["asset_id","checked_out","checked_out_time","version"'
. $hiddenFields
. '],"ignoreChanges":
["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt":
["published","ordering","version","hits"'
. $intFields . '],"displayLookup": [' .
$categoryHistory
. '{"sourceColumn":
"created_by","targetTable":
"#__users","targetColumn":
"id","displayColumn": "name"}'
. $accessHistory
. ',{"sourceColumn":
"modified_by","targetTable":
"#__users","targetColumn":
"id","displayColumn": "name"}'
. $customfieldlinks . ']}';
}
else
{
// set content history
$array['content_history_options']
= '{"formFile":
"administrator/components/com_' . $component
. '/forms/' . $view
. '.xml","hideFields":
["asset_id","checked_out","checked_out_time"'
. $hiddenFields
. '],"ignoreChanges":
["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt":
["published","ordering","version","hits"'
. $intFields . '],"displayLookup": [' .
$categoryHistory
. '{"sourceColumn":
"created_by","targetTable":
"#__users","targetColumn":
"id","displayColumn": "name"}'
. $accessHistory
. ',{"sourceColumn":
"modified_by","targetTable":
"#__users","targetColumn":
"id","displayColumn": "name"}'
. $customfieldlinks . ']}';
}
return $array;
}
return false;
}
public function getCategoryContentType($view, $views, $component)
{
// get the other view
$otherView =
CFactory::_('Compiler.Builder.Category.Code')->getString("{$view}.view",
'error');
$category =
CFactory::_('Compiler.Builder.Category.Code')->getString("{$view}.code",
'error');
$Component = StringHelper::safe($component, 'F');
$View = StringHelper::safe($view, 'F');
// build uninstall script for content types
$this->uninstallScriptBuilder[$View . ' ' . $category] =
'com_'
. $component . '.' . $otherView . '.category';
$this->uninstallScriptContent[$View . ' ' . $category] =
$View . ' '
. $category;
// set the title
$array['type_title'] = $Component . ' ' . $View .
' '
. StringHelper::safe($category, 'F');
// set the alias
$array['type_alias'] = 'com_' . $component .
'.' . $otherView
. '.category';
// set the table
$array['table']
=
'{"special":{"dbtable":"#__categories","key":"id","type":"Category","prefix":"JTable","config":"array()"},"common":{"dbtable":"#__ucm_content","key":"ucm_id","type":"Corecontent","prefix":"JTable","config":"array()"}}';
if (CFactory::_('Config')->get('joomla_version',
3) != 3)
{
// set rules field
$array['rules'] = '';
}
// set field map
$array['field_mappings']
=
'{"common":{"core_content_item_id":"id","core_title":"title","core_state":"published","core_alias":"alias","core_created_time":"created_time","core_modified_time":"modified_time","core_body":"description",
"core_hits":"hits","core_publish_up":"null","core_publish_down":"null","core_access":"access",
"core_params":"params",
"core_featured":"null",
"core_metadata":"metadata",
"core_language":"language",
"core_images":"null",
"core_urls":"null",
"core_version":"version",
"core_ordering":"null",
"core_metakey":"metakey",
"core_metadesc":"metadesc",
"core_catid":"parent_id",
"core_xreference":"null",
"asset_id":"asset_id"},
"special":{"parent_id":"parent_id","lft":"lft","rgt":"rgt","level":"level","path":"path","extension":"extension","note":"note"}}';
if (CFactory::_('Config')->get('joomla_version',
3) == 3)
{
// set the router class method
$array['router'] = $Component .
'HelperRoute::getCategoryRoute';
// set content history
$array['content_history_options']
=
'{"formFile":"administrator\/components\/com_categories\/models\/forms\/category.xml",
"hideFields":["asset_id","checked_out","checked_out_time","version","lft","rgt","level","path","extension"],
"ignoreChanges":["modified_user_id",
"modified_time", "checked_out",
"checked_out_time", "version", "hits",
"path"],"convertToInt":["publish_up",
"publish_down"],
"displayLookup":[{"sourceColumn":"created_user_id","targetTable":"#__users","targetColumn":"id","displayColumn":"name"},{"sourceColumn":"access","targetTable":"#__viewlevels","targetColumn":"id","displayColumn":"title"},{"sourceColumn":"modified_user_id","targetTable":"#__users","targetColumn":"id","displayColumn":"name"},{"sourceColumn":"parent_id","targetTable":"#__categories","targetColumn":"id","displayColumn":"title"}]}';
}
else
{
// set the router class method
$array['router'] = '';
// set content history
$array['content_history_options']
=
'{"formFile":"administrator\/components\/com_categories\/forms\/category.xml",
"hideFields":["asset_id","checked_out","checked_out_time","version","lft","rgt","level","path","extension"],
"ignoreChanges":["modified_user_id",
"modified_time", "checked_out",
"checked_out_time", "version", "hits",
"path"],"convertToInt":["publish_up",
"publish_down"],
"displayLookup":[{"sourceColumn":"created_user_id","targetTable":"#__users","targetColumn":"id","displayColumn":"name"},{"sourceColumn":"access","targetTable":"#__viewlevels","targetColumn":"id","displayColumn":"title"},{"sourceColumn":"modified_user_id","targetTable":"#__users","targetColumn":"id","displayColumn":"name"},{"sourceColumn":"parent_id","targetTable":"#__categories","targetColumn":"id","displayColumn":"title"}]}';
}
return $array;
}
public function setRouterHelp($nameSingleCode, $nameListCode,
$front = false
)
{
// add if tags is added, also for all front item views
if
((CFactory::_('Compiler.Builder.Tags')->exists($nameSingleCode)
|| $front)
&& (!in_array($nameSingleCode, $this->setRouterHelpDone)))
{
// insure we load a view only once
$this->setRouterHelpDone[] = $nameSingleCode;
// build view route helper
$View = StringHelper::safe(
$nameSingleCode, 'F'
);
$routeHelper = [];
$routeHelper[] = PHP_EOL . PHP_EOL . Indent::_(1) . "/**";
$routeHelper[] = Indent::_(1) . " * @param int The route of the
"
. $View;
$routeHelper[] = Indent::_(1) . " */";
if ('category' === $nameSingleCode
|| 'categories' === $nameSingleCode)
{
$routeHelper[] = Indent::_(1) . "public static function get"
. $View . "Route(\$id = 0)";
}
else
{
$routeHelper[] = Indent::_(1) . "public static function get"
. $View . "Route(\$id = 0, \$catid = 0)";
}
$routeHelper[] = Indent::_(1) . "{";
$routeHelper[] = Indent::_(2) . "if (\$id > 0)";
$routeHelper[] = Indent::_(2) . "{";
$routeHelper[] = Indent::_(3) . "//" . Line::_(__Line__,
__Class__)
. " Initialize the needel array.";
$routeHelper[] = Indent::_(3) . "\$needles = array(";
$routeHelper[] = Indent::_(4) . "'" . $nameSingleCode
. "' => array((int) \$id)";
$routeHelper[] = Indent::_(3) . ");";
$routeHelper[] = Indent::_(3) . "//" . Line::_(__Line__,
__Class__)
. " Create the link";
$routeHelper[] = Indent::_(3) . "\$link =
'index.php?option=com_"
. CFactory::_('Config')->component_code_name .
"&view=" . $nameSingleCode
. "&id='. \$id;";
$routeHelper[] = Indent::_(2) . "}";
$routeHelper[] = Indent::_(2) . "else";
$routeHelper[] = Indent::_(2) . "{";
$routeHelper[] = Indent::_(3) . "//" . Line::_(__Line__,
__Class__)
. " Initialize the needel array.";
$routeHelper[] = Indent::_(3) . "\$needles = array(";
$routeHelper[] = Indent::_(4) . "'" . $nameSingleCode
. "' => array()";
$routeHelper[] = Indent::_(3) . ");";
$routeHelper[] = Indent::_(3) . "//" . Line::_(__Line__,
__Class__)
. " Create the link but don't add the id.";
$routeHelper[] = Indent::_(3) . "\$link =
'index.php?option=com_"
. CFactory::_('Config')->component_code_name .
"&view=" . $nameSingleCode
. "';";
$routeHelper[] = Indent::_(2) . "}";
if ('category' != $nameSingleCode
&& 'categories' != $nameSingleCode)
{
$routeHelper[] = Indent::_(2) . "if (\$catid > 1)";
$routeHelper[] = Indent::_(2) . "{";
$routeHelper[] = Indent::_(3)
. "\$categories = Categories::getInstance('"
. CFactory::_('Config')->component_code_name .
"." . $nameListCode . "');";
$routeHelper[] = Indent::_(3)
. "\$category = \$categories->get(\$catid);";
$routeHelper[] = Indent::_(3) . "if (\$category)";
$routeHelper[] = Indent::_(3) . "{";
$routeHelper[] = Indent::_(4)
. "\$needles['category'] =
array_reverse(\$category->getPath());";
$routeHelper[] = Indent::_(4)
. "\$needles['categories'] =
\$needles['category'];";
$routeHelper[] = Indent::_(4) . "\$link .=
'&catid='.\$catid;";
$routeHelper[] = Indent::_(3) . "}";
$routeHelper[] = Indent::_(2) . "}";
}
if
(CFactory::_('Compiler.Builder.Has.Menu.Global')->exists($nameSingleCode))
{
$routeHelper[] = PHP_EOL . Indent::_(2)
. "if (\$item = self::_findItem(\$needles, '"
. $nameSingleCode . "'))";
}
else
{
$routeHelper[] = PHP_EOL . Indent::_(2)
. "if (\$item = self::_findItem(\$needles))";
}
$routeHelper[] = Indent::_(2) . "{";
$routeHelper[] = Indent::_(3) . "\$link .=
'&Itemid='.\$item;";
$routeHelper[] = Indent::_(2) . "}";
$routeHelper[] = PHP_EOL . Indent::_(2) . "return \$link;";
$routeHelper[] = Indent::_(1) . "}";
return implode(PHP_EOL, $routeHelper);
}
return '';
}
public function routerParseSwitch(&$view, $viewArray = null,
$aliasView = true, $idView = true
)
{
// reset buckets
$routerSwitch = [];
$isCategory = '';
$viewTable = false;
if ($viewArray && ArrayHelper::check($viewArray)
&& isset($viewArray['settings'])
&& isset($viewArray['settings']->main_get))
{
// check if we have custom script for this router parse switch case
if
(isset($viewArray['settings']->main_get->add_php_router_parse)
&&
$viewArray['settings']->main_get->add_php_router_parse ==
1
&&
isset($viewArray['settings']->main_get->php_router_parse)
&& StringHelper::check(
$viewArray['settings']->main_get->php_router_parse
))
{
// load the custom script for the switch based on dynamic get
$routerSwitch[] = PHP_EOL . Indent::_(3) . "case '" .
$view
. "':";
$routerSwitch[] = CFactory::_('Placeholder')->update_(
$viewArray['settings']->main_get->php_router_parse
);
$routerSwitch[] = Indent::_(4) . "break;";
return implode(PHP_EOL, $routerSwitch);
}
// is this a catogory
elseif
(isset($viewArray['settings']->main_get->db_table_main)
&&
$viewArray['settings']->main_get->db_table_main
=== 'categories')
{
$isCategory = ', true'; // TODO we will keep an eye on
this....
}
// get the main table name
elseif
(isset($viewArray['settings']->main_get->main_get)
&& ArrayHelper::check(
$viewArray['settings']->main_get->main_get
))
{
foreach ($viewArray['settings']->main_get->main_get as
$get)
{
if (isset($get['as']) && $get['as'] ===
'a')
{
if (isset($get['selection'])
&& ArrayHelper::check(
$get['selection']
)
&&
isset($get['selection']['select_gets'])
&& ArrayHelper::check(
$get['selection']['select_gets']
))
{
if (isset($get['selection']['table']))
{
$viewTable = str_replace(
'#__' .
CFactory::_('Config')->component_code_name . '_',
'',
(string) $get['selection']['table']
);
}
}
break;
}
}
}
}
// add if tags is added, also for all front item views
if ($aliasView)
{
$routerSwitch[] = PHP_EOL . Indent::_(3) . "case '" .
$view . "':";
$routerSwitch[] = Indent::_(4) . "\$vars['view'] =
'" . $view
. "';";
$routerSwitch[] = Indent::_(4)
. "if (is_numeric(\$segments[\$count-1]))";
$routerSwitch[] = Indent::_(4) . "{";
$routerSwitch[] = Indent::_(5)
. "\$vars['id'] = (int) \$segments[\$count-1];";
$routerSwitch[] = Indent::_(4) . "}";
$routerSwitch[] = Indent::_(4) . "elseif
(\$segments[\$count-1])";
$routerSwitch[] = Indent::_(4) . "{";
// we need to get from the table of this views main get the alias so we
need the table name
if ($viewTable)
{
$routerSwitch[] = Indent::_(5) . "\$id =
\$this->getVar('"
. $viewTable . "', \$segments[\$count-1], 'alias',
'id'"
. $isCategory . ");";
}
else
{
$routerSwitch[] = Indent::_(5) . "\$id =
\$this->getVar('"
. $view . "', \$segments[\$count-1], 'alias',
'id'"
. $isCategory . ");";
}
$routerSwitch[] = Indent::_(5) . "if(\$id)";
$routerSwitch[] = Indent::_(5) . "{";
$routerSwitch[] = Indent::_(6) . "\$vars['id'] =
\$id;";
$routerSwitch[] = Indent::_(5) . "}";
$routerSwitch[] = Indent::_(4) . "}";
$routerSwitch[] = Indent::_(4) . "break;";
}
elseif ($idView)
{
$routerSwitch[] = PHP_EOL . Indent::_(3) . "case '" .
$view . "':";
$routerSwitch[] = Indent::_(4) . "\$vars['view'] =
'" . $view
. "';";
$routerSwitch[] = Indent::_(4)
. "if (is_numeric(\$segments[\$count-1]))";
$routerSwitch[] = Indent::_(4) . "{";
$routerSwitch[] = Indent::_(5)
. "\$vars['id'] = (int) \$segments[\$count-1];";
$routerSwitch[] = Indent::_(4) . "}";
$routerSwitch[] = Indent::_(4) . "break;";
}
else
{
$routerSwitch[] = PHP_EOL . Indent::_(3) . "case '" .
$view . "':";
$routerSwitch[] = Indent::_(4) . "\$vars['view'] =
'" . $view
. "';";
$routerSwitch[] = Indent::_(4) . "break;";
}
return implode(PHP_EOL, $routerSwitch);
}
public function routerBuildViews(&$view)
{
if
(CFactory::_('Compiler.Builder.Content.One')->exists('ROUTER_BUILD_VIEWS')
&& StringHelper::check(
CFactory::_('Compiler.Builder.Content.One')->get('ROUTER_BUILD_VIEWS')
))
{
return " || \$view === '" . $view . "'";
}
else
{
return "\$view === '" . $view . "'";
}
}
public function setBatchMove($nameSingleCode)
{
// set needed defaults
$category =
CFactory::_('Compiler.Builder.Category.Code')->getString("{$nameSingleCode}.code");
$batchmove = [];
$VIEW = StringHelper::safe($nameSingleCode, 'U');
// component helper name
$Helper =
CFactory::_('Compiler.Builder.Content.One')->get('Component')
. 'Helper';
// prepare custom script
$customScript = CFactory::_('Customcode.Dispenser')->get(
'php_batchmove', $nameSingleCode, PHP_EOL . PHP_EOL, null,
true
);
$batchmove[] = PHP_EOL . Indent::_(1) . "/**";
$batchmove[] = Indent::_(1) . " * Batch move items to a new
category";
$batchmove[] = Indent::_(1) . " *";
$batchmove[] = Indent::_(1)
. " * @param integer \$value The new category ID.";
$batchmove[] = Indent::_(1)
. " * @param array \$pks An array of row IDs.";
$batchmove[] = Indent::_(1)
. " * @param array \$contexts An array of item
contexts.";
$batchmove[] = Indent::_(1) . " *";
$batchmove[] = Indent::_(1)
. " * @return boolean True if successful, false otherwise and
internal error is set.";
$batchmove[] = Indent::_(1) . " *";
$batchmove[] = Indent::_(1) . " * @since 12.2";
$batchmove[] = Indent::_(1) . " */";
$batchmove[] = Indent::_(1)
. "protected function batchMove(\$values, \$pks,
\$contexts)";
$batchmove[] = Indent::_(1) . "{";
$batchmove[] = Indent::_(2) . "if
(empty(\$this->batchSet))";
$batchmove[] = Indent::_(2) . "{";
$batchmove[] = Indent::_(3) . "//" . Line::_(__Line__,
__Class__)
. " Set some needed variables.";
if (CFactory::_('Config')->get('joomla_version',
3) == 3)
{
$batchmove[] = Indent::_(3)
. "\$this->user = Factory::getUser();";
}
else
{
$batchmove[] = Indent::_(3)
. "\$this->user =
Factory::getApplication()->getIdentity();";
}
$batchmove[] = Indent::_(3)
. "\$this->table = \$this->getTable();";
$batchmove[] = Indent::_(3)
. "\$this->tableClassName = get_class(\$this->table);";
$batchmove[] = Indent::_(3) . "\$this->canDo = " . $Helper
. "::getActions('" . $nameSingleCode .
"');";
$batchmove[] = Indent::_(2) . "}";
$batchmove[] = PHP_EOL . Indent::_(2) . "if
(!\$this->canDo->get('"
.
CFactory::_('Compiler.Creator.Permission')->getGlobal($nameSingleCode,
'core.edit') . "') &&
!\$this->canDo->get('"
.
CFactory::_('Compiler.Creator.Permission')->getGlobal($nameSingleCode,
'core.batch') . "'))";
$batchmove[] = Indent::_(2) . "{";
$batchmove[] = Indent::_(3) . "\$this->setError(Text:"
.
":_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT'));";
$batchmove[] = Indent::_(3) . "return false;";
$batchmove[] = Indent::_(2) . "}" . $customScript;
$batchmove[] = PHP_EOL . Indent::_(2) . "//" .
Line::_(__Line__, __Class__)
. " make sure published only updates if user has the
permission.";
$batchmove[] = Indent::_(2)
. "if (isset(\$values['published']) &&
!\$this->canDo->get('"
.
CFactory::_('Compiler.Creator.Permission')->getGlobal($nameSingleCode,
'core.edit.state') . "'))";
$batchmove[] = Indent::_(2) . "{";
$batchmove[] = Indent::_(3) .
"unset(\$values['published']);";
$batchmove[] = Indent::_(2) . "}";
$batchmove[] = Indent::_(2) . "//" . Line::_(__Line__,
__Class__)
. " remove move_copy from array";
$batchmove[] = Indent::_(2) .
"unset(\$values['move_copy']);";
if ($category !== null)
{
$batchmove[] = PHP_EOL . Indent::_(2)
. "if (isset(\$values['category']) && (int)
\$values['category'] > 0 &&
!static::checkCategoryId(\$values['category']))";
$batchmove[] = Indent::_(2) . "{";
$batchmove[] = Indent::_(3) . "return false;";
$batchmove[] = Indent::_(2) . "}";
$batchmove[] = Indent::_(2)
. "elseif (isset(\$values['category']) && (int)
\$values['category'] > 0)";
$batchmove[] = Indent::_(2) . "{";
$batchmove[] = Indent::_(3) . "//" . Line::_(__Line__,
__Class__)
. " move the category value to correct field name";
$batchmove[] = Indent::_(3) . "\$values['" . $category
. "'] = \$values['category'];";
$batchmove[] = Indent::_(3) .
"unset(\$values['category']);";
$batchmove[] = Indent::_(2) . "}";
$batchmove[] = Indent::_(2)
. "elseif (isset(\$values['category']))";
$batchmove[] = Indent::_(2) . "{";
$batchmove[] = Indent::_(3) .
"unset(\$values['category']);";
$batchmove[] = Indent::_(2) . "}" . PHP_EOL;
}
$batchmove[] = PHP_EOL . Indent::_(2) . "//" .
Line::_(__Line__, __Class__)
. " Parent exists so we proceed";
$batchmove[] = Indent::_(2) . "foreach (\$pks as \$pk)";
$batchmove[] = Indent::_(2) . "{";
$batchmove[] = Indent::_(3) . "if
(!\$this->user->authorise('"
.
CFactory::_('Compiler.Creator.Permission')->getAction($nameSingleCode,
'core.edit') . "', \$contexts[\$pk]))";
$batchmove[] = Indent::_(3) . "{";
$batchmove[] = Indent::_(4) . "\$this->setError(Text:"
.
":_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT'));";
$batchmove[] = Indent::_(4) . "return false;";
$batchmove[] = Indent::_(3) . "}";
$batchmove[] = PHP_EOL . Indent::_(3) . "//" .
Line::_(__Line__, __Class__)
. " Check that the row actually exists";
$batchmove[] = Indent::_(3) . "if
(!\$this->table->load(\$pk))";
$batchmove[] = Indent::_(3) . "{";
$batchmove[] = Indent::_(4)
. "if (\$error = \$this->table->getError())";
$batchmove[] = Indent::_(4) . "{";
$batchmove[] = Indent::_(5) . "//" . Line::_(__Line__,
__Class__)
. " Fatal error";
$batchmove[] = Indent::_(5) . "\$this->setError(\$error);";
$batchmove[] = Indent::_(5) . "return false;";
$batchmove[] = Indent::_(4) . "}";
$batchmove[] = Indent::_(4) . "else";
$batchmove[] = Indent::_(4) . "{";
$batchmove[] = Indent::_(5) . "//" . Line::_(__Line__,
__Class__)
. " Not fatal error";
$batchmove[] = Indent::_(5) . "\$this->setError(Text:"
.
":sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND',
\$pk));";
$batchmove[] = Indent::_(5) . "continue;";
$batchmove[] = Indent::_(4) . "}";
$batchmove[] = Indent::_(3) . "}";
$batchmove[] = PHP_EOL . Indent::_(3) . "//" .
Line::_(__Line__, __Class__)
. " insert all set values.";
$batchmove[] = Indent::_(3) . "if ("
. "Super_" .
"__0a59c65c_9daf_4bc9_baf4_e063ff9e6a8a___Power::check(\$values))";
$batchmove[] = Indent::_(3) . "{";
$batchmove[] = Indent::_(4) . "foreach (\$values as \$key =>
\$value)";
$batchmove[] = Indent::_(4) . "{";
$batchmove[] = Indent::_(5) . "//" . Line::_(__Line__,
__Class__)
. " Do special action for access.";
$batchmove[] = Indent::_(5)
. "if ('access' === \$key && strlen(\$value) >
0)";
$batchmove[] = Indent::_(5) . "{";
$batchmove[] = Indent::_(6) . "\$this->table->\$key =
\$value;";
$batchmove[] = Indent::_(5) . "}";
$batchmove[] = Indent::_(5)
. "elseif (strlen(\$value) > 0 &&
isset(\$this->table->\$key))";
$batchmove[] = Indent::_(5) . "{";
$batchmove[] = Indent::_(6) . "\$this->table->\$key =
\$value;";
$batchmove[] = Indent::_(5) . "}";
$batchmove[] = Indent::_(4) . "}";
$batchmove[] = Indent::_(3) . "}" . PHP_EOL;
$batchmove[] = PHP_EOL . Indent::_(3) . "//" .
Line::_(__Line__, __Class__)
. " Check the row.";
$batchmove[] = Indent::_(3) . "if
(!\$this->table->check())";
$batchmove[] = Indent::_(3) . "{";
$batchmove[] = Indent::_(4)
. "\$this->setError(\$this->table->getError());";
$batchmove[] = PHP_EOL . Indent::_(4) . "return false;";
$batchmove[] = Indent::_(3) . "}";
$batchmove[] = PHP_EOL . Indent::_(3) . "if
(!empty(\$this->type))";
$batchmove[] = Indent::_(3) . "{";
$batchmove[] = Indent::_(4)
. "\$this->createTagsHelper(\$this->tagsObserver,
\$this->type, \$pk, \$this->typeAlias, \$this->table);";
$batchmove[] = Indent::_(3) . "}";
$batchmove[] = PHP_EOL . Indent::_(3) . "//" .
Line::_(__Line__, __Class__)
. " Store the row.";
$batchmove[] = Indent::_(3) . "if
(!\$this->table->store())";
$batchmove[] = Indent::_(3) . "{";
$batchmove[] = Indent::_(4)
. "\$this->setError(\$this->table->getError());";
$batchmove[] = PHP_EOL . Indent::_(4) . "return false;";
$batchmove[] = Indent::_(3) . "}";
$batchmove[] = Indent::_(2) . "}";
$batchmove[] = PHP_EOL . Indent::_(2) . "//" .
Line::_(__Line__, __Class__)
. " Clean the cache";
$batchmove[] = Indent::_(2) . "\$this->cleanCache();";
$batchmove[] = PHP_EOL . Indent::_(2) . "return true;";
$batchmove[] = Indent::_(1) . "}";
return PHP_EOL . implode(PHP_EOL, $batchmove);
}
public function setBatchCopy($nameSingleCode)
{
// set needed defaults
$title = false;
$titles = [];
// only load alias if set in this view
$alias =
CFactory::_('Compiler.Builder.Alias')->get($nameSingleCode);
$category =
CFactory::_('Compiler.Builder.Category.Code')->getString("{$nameSingleCode}.code");
$batchcopy = [];
$VIEW = StringHelper::safe($nameSingleCode, 'U');
// component helper name
$Helper =
CFactory::_('Compiler.Builder.Content.One')->get('Component')
. 'Helper';
// only load title if set in this view
if (($customAliasBuilder =
CFactory::_('Compiler.Builder.Custom.Alias')->get($nameSingleCode))
!== null)
{
$titles = array_values(
$customAliasBuilder
);
$title = true;
}
elseif
(CFactory::_('Compiler.Builder.Title')->exists($nameSingleCode))
{
$titles =
[CFactory::_('Compiler.Builder.Title')->get($nameSingleCode)];
$title = true;
}
// se the dynamic title
if ($title)
{
// reset the bucket
$titleData = [];
// load the dynamic title builder
foreach ($titles as $_title)
{
$titleData[] = "\$this->table->" . $_title;
}
}
// prepare custom script
$customScript = CFactory::_('Customcode.Dispenser')->get(
'php_batchcopy', $nameSingleCode, PHP_EOL . PHP_EOL, null,
true
);
$batchcopy[] = PHP_EOL . Indent::_(1) . "/**";
$batchcopy[] = Indent::_(1)
. " * Batch copy items to a new category or current.";
$batchcopy[] = Indent::_(1) . " *";
$batchcopy[] = Indent::_(1)
. " * @param integer \$values The new values.";
$batchcopy[] = Indent::_(1)
. " * @param array \$pks An array of row IDs.";
$batchcopy[] = Indent::_(1)
. " * @param array \$contexts An array of item
contexts.";
$batchcopy[] = Indent::_(1) . " *";
$batchcopy[] = Indent::_(1)
. " * @return mixed An array of new IDs on success, boolean false
on failure.";
$batchcopy[] = Indent::_(1) . " *";
$batchcopy[] = Indent::_(1) . " * @since 12.2";
$batchcopy[] = Indent::_(1) . " */";
$batchcopy[] = Indent::_(1)
. "protected function batchCopy(\$values, \$pks,
\$contexts)";
$batchcopy[] = Indent::_(1) . "{";
$batchcopy[] = Indent::_(2) . "if
(empty(\$this->batchSet))";
$batchcopy[] = Indent::_(2) . "{";
$batchcopy[] = Indent::_(3) . "//" . Line::_(__Line__,
__Class__)
. " Set some needed variables.";
if (CFactory::_('Config')->get('joomla_version',
3) == 3)
{
$batchcopy[] = Indent::_(3)
. "\$this->user = Factory::getUser();";
}
else
{
$batchcopy[] = Indent::_(3)
. "\$this->user =
Factory::getApplication()->getIdentity();";
}
$batchcopy[] = Indent::_(3)
. "\$this->table = \$this->getTable();";
$batchcopy[] = Indent::_(3)
. "\$this->tableClassName = get_class(\$this->table);";
$batchcopy[] = Indent::_(3) . "\$this->canDo = " . $Helper
. "::getActions('" . $nameSingleCode .
"');";
$batchcopy[] = Indent::_(2) . "}";
$batchcopy[] = PHP_EOL . Indent::_(2) . "if
(!\$this->canDo->get('"
.
CFactory::_('Compiler.Creator.Permission')->getGlobal($nameSingleCode,
'core.create') . "') &&
!\$this->canDo->get('"
.
CFactory::_('Compiler.Creator.Permission')->getGlobal($nameSingleCode,
'core.batch') . "'))";
$batchcopy[] = Indent::_(2) . "{";
$batchcopy[] = Indent::_(3) . "return false;";
$batchcopy[] = Indent::_(2) . "}" . $customScript;
$batchcopy[] = PHP_EOL . Indent::_(2) . "//" .
Line::_(__Line__, __Class__)
. " get list of unique fields";
$batchcopy[] = Indent::_(2)
. "\$uniqueFields = \$this->getUniqueFields();";
$batchcopy[] = Indent::_(2) . "//" . Line::_(__Line__,
__Class__)
. " remove move_copy from array";
$batchcopy[] = Indent::_(2) .
"unset(\$values['move_copy']);";
$batchcopy[] = PHP_EOL . Indent::_(2) . "//" .
Line::_(__Line__, __Class__)
. " make sure published is set";
$batchcopy[] = Indent::_(2) . "if
(!isset(\$values['published']))";
$batchcopy[] = Indent::_(2) . "{";
$batchcopy[] = Indent::_(3) . "\$values['published'] =
0;";
$batchcopy[] = Indent::_(2) . "}";
$batchcopy[] = Indent::_(2)
. "elseif (isset(\$values['published']) &&
!\$this->canDo->get('"
.
CFactory::_('Compiler.Creator.Permission')->getGlobal($nameSingleCode,
'core.edit.state') . "'))";
$batchcopy[] = Indent::_(2) . "{";
$batchcopy[] = Indent::_(4) . "\$values['published'] =
0;";
$batchcopy[] = Indent::_(2) . "}";
if ($category)
{
$batchcopy[] = PHP_EOL . Indent::_(2)
. "if (isset(\$values['category']) && (int)
\$values['category'] > 0 &&
!static::checkCategoryId(\$values['category']))";
$batchcopy[] = Indent::_(2) . "{";
$batchcopy[] = Indent::_(3) . "return false;";
$batchcopy[] = Indent::_(2) . "}";
$batchcopy[] = Indent::_(2)
. "elseif (isset(\$values['category']) && (int)
\$values['category'] > 0)";
$batchcopy[] = Indent::_(2) . "{";
$batchcopy[] = Indent::_(3) . "//" . Line::_(__Line__,
__Class__)
. " move the category value to correct field name";
$batchcopy[] = Indent::_(3) . "\$values['" . $category
. "'] = \$values['category'];";
$batchcopy[] = Indent::_(3) .
"unset(\$values['category']);";
$batchcopy[] = Indent::_(2) . "}";
$batchcopy[] = Indent::_(2)
. "elseif (isset(\$values['category']))";
$batchcopy[] = Indent::_(2) . "{";
$batchcopy[] = Indent::_(3) .
"unset(\$values['category']);";
$batchcopy[] = Indent::_(2) . "}";
}
$batchcopy[] = PHP_EOL . Indent::_(2) . "\$newIds = [];";
$batchcopy[] = Indent::_(2) . "//" . Line::_(__Line__,
__Class__)
. " Parent exists so let's proceed";
$batchcopy[] = Indent::_(2) . "while (!empty(\$pks))";
$batchcopy[] = Indent::_(2) . "{";
$batchcopy[] = Indent::_(3) . "//" . Line::_(__Line__,
__Class__)
. " Pop the first ID off the stack";
$batchcopy[] = Indent::_(3) . "\$pk = array_shift(\$pks);";
$batchcopy[] = PHP_EOL . Indent::_(3) .
"\$this->table->reset();";
$batchcopy[] = PHP_EOL . Indent::_(3) . "//" .
Line::_(__Line__, __Class__)
. " only allow copy if user may edit this item.";
$batchcopy[] = Indent::_(3) . "if
(!\$this->user->authorise('"
.
CFactory::_('Compiler.Creator.Permission')->getAction($nameSingleCode,
'core.edit') . "', \$contexts[\$pk]))";
$batchcopy[] = Indent::_(3) . "{";
$batchcopy[] = Indent::_(4) . "//" . Line::_(__Line__,
__Class__)
. " Not fatal error";
$batchcopy[] = Indent::_(4) . "\$this->setError(Text:"
.
":sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND',
\$pk));";
$batchcopy[] = Indent::_(4) . "continue;";
$batchcopy[] = Indent::_(3) . "}";
$batchcopy[] = PHP_EOL . Indent::_(3) . "//" .
Line::_(__Line__, __Class__)
. " Check that the row actually exists";
$batchcopy[] = Indent::_(3) . "if
(!\$this->table->load(\$pk))";
$batchcopy[] = Indent::_(3) . "{";
$batchcopy[] = Indent::_(4)
. "if (\$error = \$this->table->getError())";
$batchcopy[] = Indent::_(4) . "{";
$batchcopy[] = Indent::_(5) . "//" . Line::_(__Line__,
__Class__)
. " Fatal error";
$batchcopy[] = Indent::_(5) . "\$this->setError(\$error);";
$batchcopy[] = Indent::_(5) . "return false;";
$batchcopy[] = Indent::_(4) . "}";
$batchcopy[] = Indent::_(4) . "else";
$batchcopy[] = Indent::_(4) . "{";
$batchcopy[] = Indent::_(5) . "//" . Line::_(__Line__,
__Class__)
. " Not fatal error";
$batchcopy[] = Indent::_(5) . "\$this->setError(Text:"
.
":sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND',
\$pk));";
$batchcopy[] = Indent::_(5) . "continue;";
$batchcopy[] = Indent::_(4) . "}";
$batchcopy[] = Indent::_(3) . "}";
if ($category && $alias === 'alias'
&& ($title && count($titles) == 1
&& in_array('title', $titles)))
{
$batchcopy[] = PHP_EOL . Indent::_(3) . "if
(isset(\$values['"
. $category . "']))";
$batchcopy[] = Indent::_(3) . "{";
$batchcopy[] = Indent::_(4)
. "static::generateTitle((int) \$values['" . $category
. "'], \$this->table);";
$batchcopy[] = Indent::_(3) . "}";
$batchcopy[] = Indent::_(3) . "else";
$batchcopy[] = Indent::_(3) . "{";
$batchcopy[] = Indent::_(4)
. "static::generateTitle((int) \$this->table->" .
$category
. ", \$this->table);";
$batchcopy[] = Indent::_(3) . "}";
}
elseif ($category && $alias && ($title &&
count($titles) == 1))
{
$batchcopy[] = PHP_EOL . Indent::_(3) . "if
(isset(\$values['"
. $category . "']))";
$batchcopy[] = Indent::_(3) . "{";
$batchcopy[] = Indent::_(4) . "list(\$this->table->" .
implode(
'', $titles
) . ", \$this->table->" . $alias
. ") = \$this->generateNewTitle(\$values['" .
$category
. "'], \$this->table->" . $alias . ",
\$this->table->"
. implode('', $titles) . ");";
$batchcopy[] = Indent::_(3) . "}";
$batchcopy[] = Indent::_(3) . "else";
$batchcopy[] = Indent::_(3) . "{";
$batchcopy[] = Indent::_(4) . "list(\$this->table->" .
implode(
'', $titles
) . ", \$this->table->" . $alias
. ") = \$this->generateNewTitle(\$this->table->" .
$category
. ", \$this->table->" . $alias . ",
\$this->table->" . implode(
'', $titles
) . ");";
$batchcopy[] = Indent::_(3) . "}";
}
elseif (!$category && $alias && ($title &&
count($titles) == 1))
{
$batchcopy[] = Indent::_(3) . "list(\$this->table->" .
implode(
'', $titles
) . ", \$this->table->" . $alias
. ") = \$this->_generateNewTitle(\$this->table->" .
$alias
. ", \$this->table->" . implode('', $titles)
. ");";
}
elseif (!$category && $alias && $title)
{
$batchcopy[] = Indent::_(3) . "list(" . implode(',
', $titleData)
. ", \$this->table->" . $alias
. ") = \$this->_generateNewTitle(\$this->table->" .
$alias
. ", array(" . implode(', ', $titleData) .
"));";
}
elseif (!$category && !$alias
&& ($title && count($titles) == 1
&& !in_array('user', $titles)
&& !in_array(
'jobnumber', $titles
))) // TODO [jobnumber] just for one project (not ideal)
{
$batchcopy[] = PHP_EOL . Indent::_(3) . "//" . Line::_(
__LINE__,__CLASS__
) . " Only for strings";
$batchcopy[] = Indent::_(3) . "if ("
. "Super_" .
"__1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::check(\$this->table->"
. implode('', $titles)
. ") && !is_numeric(\$this->table->" .
implode('', $titles)
. "))";
$batchcopy[] = Indent::_(3) . "{";
$batchcopy[] = Indent::_(4) . "\$this->table->" .
implode(
'', $titles
) . " = \$this->generateUnique('" .
implode('', $titles)
. "',\$this->table->" . implode('',
$titles) . ");";
$batchcopy[] = Indent::_(3) . "}";
}
$batchcopy[] = PHP_EOL . Indent::_(3) . "//" .
Line::_(__Line__, __Class__)
. " insert all set values";
$batchcopy[] = Indent::_(3) . "if ("
. "Super_" .
"__0a59c65c_9daf_4bc9_baf4_e063ff9e6a8a___Power::check(\$values))";
$batchcopy[] = Indent::_(3) . "{";
$batchcopy[] = Indent::_(4) . "foreach (\$values as \$key =>
\$value)";
$batchcopy[] = Indent::_(4) . "{";
$batchcopy[] = Indent::_(5)
. "if (strlen(\$value) > 0 &&
isset(\$this->table->\$key))";
$batchcopy[] = Indent::_(5) . "{";
$batchcopy[] = Indent::_(6) . "\$this->table->\$key =
\$value;";
$batchcopy[] = Indent::_(5) . "}";
$batchcopy[] = Indent::_(4) . "}";
$batchcopy[] = Indent::_(3) . "}" . PHP_EOL;
$batchcopy[] = Indent::_(3) . "//" . Line::_(__Line__,
__Class__)
. " update all unique fields";
$batchcopy[] = Indent::_(3) . "if ("
. "Super_" .
"__0a59c65c_9daf_4bc9_baf4_e063ff9e6a8a___Power::check(\$uniqueFields))";
$batchcopy[] = Indent::_(3) . "{";
$batchcopy[] = Indent::_(4)
. "foreach (\$uniqueFields as \$uniqueField)";
$batchcopy[] = Indent::_(4) . "{";
$batchcopy[] = Indent::_(5)
. "\$this->table->\$uniqueField =
\$this->generateUnique(\$uniqueField,\$this->table->\$uniqueField);";
$batchcopy[] = Indent::_(4) . "}";
$batchcopy[] = Indent::_(3) . "}";
$batchcopy[] = PHP_EOL . Indent::_(3) . "//" .
Line::_(__Line__, __Class__)
. " Reset the ID because we are making a copy";
$batchcopy[] = Indent::_(3) . "\$this->table->id = 0;";
$batchcopy[] = PHP_EOL . Indent::_(3) . "//" .
Line::_(__Line__, __Class__)
. " TODO: Deal with ordering?";
$batchcopy[] = Indent::_(3) . "//" . Line::_(__Line__,
__Class__)
. " \$this->table->ordering = 1;";
$batchcopy[] = PHP_EOL . Indent::_(3) . "//" .
Line::_(__Line__, __Class__)
. " Check the row.";
$batchcopy[] = Indent::_(3) . "if
(!\$this->table->check())";
$batchcopy[] = Indent::_(3) . "{";
$batchcopy[] = Indent::_(4)
. "\$this->setError(\$this->table->getError());";
$batchcopy[] = PHP_EOL . Indent::_(4) . "return false;";
$batchcopy[] = Indent::_(3) . "}";
$batchcopy[] = PHP_EOL . Indent::_(3) . "if
(!empty(\$this->type))";
$batchcopy[] = Indent::_(3) . "{";
$batchcopy[] = Indent::_(4)
. "\$this->createTagsHelper(\$this->tagsObserver,
\$this->type, \$pk, \$this->typeAlias, \$this->table);";
$batchcopy[] = Indent::_(3) . "}";
$batchcopy[] = PHP_EOL . Indent::_(3) . "//" .
Line::_(__Line__, __Class__)
. " Store the row.";
$batchcopy[] = Indent::_(3) . "if
(!\$this->table->store())";
$batchcopy[] = Indent::_(3) . "{";
$batchcopy[] = Indent::_(4)
. "\$this->setError(\$this->table->getError());";
$batchcopy[] = PHP_EOL . Indent::_(4) . "return false;";
$batchcopy[] = Indent::_(3) . "}";
$batchcopy[] = PHP_EOL . Indent::_(3) . "//" .
Line::_(__Line__, __Class__)
. " Get the new item ID";
$batchcopy[] = Indent::_(3) . "\$newId =
\$this->table->get('id');";
$batchcopy[] = PHP_EOL . Indent::_(3) . "//" .
Line::_(__Line__, __Class__)
. " Add the new ID to the array";
$batchcopy[] = Indent::_(3) . "\$newIds[\$pk] = \$newId;";
$batchcopy[] = Indent::_(2) . "}";
$batchcopy[] = PHP_EOL . Indent::_(2) . "//" .
Line::_(__Line__, __Class__)
. " Clean the cache";
$batchcopy[] = Indent::_(2) . "\$this->cleanCache();";
$batchcopy[] = PHP_EOL . Indent::_(2) . "return \$newIds;";
$batchcopy[] = Indent::_(1) . "}";
return PHP_EOL . implode(PHP_EOL, $batchcopy);
}
public function setAliasTitleFix($nameSingleCode)
{
$fixUnique = [];
// only load this if these two items are set
if
(CFactory::_('Compiler.Builder.Alias')->exists($nameSingleCode)
&&
(CFactory::_('Compiler.Builder.Title')->exists($nameSingleCode)
||
CFactory::_('Compiler.Builder.Custom.Alias')->exists($nameSingleCode)))
{
// set needed defaults
$category =
CFactory::_('Compiler.Builder.Category.Code')->getString("{$nameSingleCode}.code");
$alias =
CFactory::_('Compiler.Builder.Alias')->get($nameSingleCode);
$VIEW = StringHelper::safe(
$nameSingleCode, 'U'
);
// set the title stuff
if (($customAliasBuilder =
CFactory::_('Compiler.Builder.Custom.Alias')->get($nameSingleCode))
!== null)
{
$titles = array_values(
$customAliasBuilder
);
}
else
{
$titles =
[CFactory::_('Compiler.Builder.Title')->get($nameSingleCode)];
}
// start building the fix
$fixUnique[] = PHP_EOL . Indent::_(2) . "//" . Line::_(
__LINE__,__CLASS__
) . " Alter the " . implode(', ', $titles)
. " for save as copy";
$fixUnique[] = Indent::_(2)
. "if (\$input->get('task') ===
'save2copy')";
$fixUnique[] = Indent::_(2) . "{";
$fixUnique[] = Indent::_(3)
. "\$origTable = clone \$this->getTable();";
$fixUnique[] = Indent::_(3)
.
"\$origTable->load(\$input->getInt('id'));";
// reset the buckets
$ifStatment = [];
$titleVars = [];
$titleData = [];
$titleUpdate = [];
// load the dynamic title builder
foreach ($titles as $title)
{
$ifStatment[] = "\$data['" . $title . "'] ==
\$origTable->"
. $title;
$titleVars[] = "\$" . $title;
$titleData[] = "\$data['" . $title .
"']";
$titleUpdate[] = Indent::_(4) . "\$data['" . $title .
"'] = \$"
. $title . ";";
}
$fixUnique[] = PHP_EOL . Indent::_(3) . "if (" . implode(
' || ', $ifStatment
) . ")";
$fixUnique[] = Indent::_(3) . "{";
if ($category !== null && count((array) $titles) == 1)
{
$fixUnique[] = Indent::_(4) . "list(" . implode('',
$titleVars)
. ", \$" . $alias . ") =
\$this->generateNewTitle(\$data['"
. $category . "'], \$data['" . $alias .
"'], " . implode(
'', $titleData
) . ");";
}
elseif (count((array) $titles) == 1)
{
$fixUnique[] = Indent::_(4) . "list(" . implode(
', ', $titleVars
)
. ", \$" . $alias . ") =
\$this->_generateNewTitle(\$data['"
. $alias . "'], " . implode('', $titleData) .
");";
}
else
{
$fixUnique[] = Indent::_(4) . "list(" . implode(
', ', $titleVars
)
. ", \$" . $alias . ") =
\$this->_generateNewTitle(\$data['"
. $alias . "'], array(" . implode(', ',
$titleData) . "));";
}
$fixUnique[] = implode("\n", $titleUpdate);
$fixUnique[] = Indent::_(4) . "\$data['" . $alias .
"'] = \$"
. $alias . ";";
$fixUnique[] = Indent::_(3) . "}";
$fixUnique[] = Indent::_(3) . "else";
$fixUnique[] = Indent::_(3) . "{";
$fixUnique[] = Indent::_(4) . "if (\$data['" . $alias
. "'] == \$origTable->" . $alias . ")";
$fixUnique[] = Indent::_(4) . "{";
$fixUnique[] = Indent::_(5) . "\$data['" . $alias .
"'] = '';";
$fixUnique[] = Indent::_(4) . "}";
$fixUnique[] = Indent::_(3) . "}";
$fixUnique[] = PHP_EOL . Indent::_(3) .
"\$data['published'] = 0;";
$fixUnique[] = Indent::_(2) . "}";
$fixUnique[] = PHP_EOL . Indent::_(2) . "//" . Line::_(
__LINE__,__CLASS__
) . " Automatic handling of " . $alias . " for empty
fields";
$fixUnique[] = Indent::_(2)
. "if (in_array(\$input->get('task'),
array('apply', 'save', 'save2new'))
&& (int) \$input->get('id') == 0)";
$fixUnique[] = Indent::_(2) . "{";
$fixUnique[] = Indent::_(3) . "if (\$data['" . $alias
. "'] == null || empty(\$data['" . $alias .
"']))";
$fixUnique[] = Indent::_(3) . "{";
$fixUnique[] = Indent::_(4)
. "if (Factory::getConfig()->get('unicodeslugs') ==
1)";
$fixUnique[] = Indent::_(4) . "{";
$fixUnique[] = Indent::_(5) . "\$data['" . $alias
. "'] = OutputFilter::stringURLUnicodeSlug(" . implode(
' . " " . ', $titleData
) . ");";
$fixUnique[] = Indent::_(4) . "}";
$fixUnique[] = Indent::_(4) . "else";
$fixUnique[] = Indent::_(4) . "{";
$fixUnique[] = Indent::_(5) . "\$data['" . $alias
. "'] = OutputFilter::stringURLSafe(" . implode(
' . " " . ', $titleData
) . ");";
$fixUnique[] = Indent::_(4) . "}";
$fixUnique[] = PHP_EOL . Indent::_(4)
. "\$table = clone \$this->getTable();";
if ($category !== null && count($titles) == 1)
{
$fixUnique[] = PHP_EOL . Indent::_(4)
. "if (\$table->load(['" . $alias . "'
=> \$data['"
. $alias . "'], '" . $category . "'
=> \$data['" . $category
. "']]) && (\$table->id != \$data['id']
|| \$data['id'] == 0))";
$fixUnique[] = Indent::_(4) . "{";
$fixUnique[] = Indent::_(5) . "\$msg = Text:" .
":_('COM_"
.
CFactory::_('Compiler.Builder.Content.One')->get('COMPONENT')
. "_" . $VIEW . "_SAVE_WARNING');";
$fixUnique[] = Indent::_(4) . "}";
$fixUnique[] = PHP_EOL . Indent::_(4) . "list(" . implode(
'', $titleVars
) . ", \$" . $alias
. ") = \$this->generateNewTitle(\$data['" .
$category
. "'], \$data['" . $alias . "'], "
. implode('', $titleData)
. ");";
$fixUnique[] = Indent::_(4) . "\$data['" . $alias .
"'] = \$"
. $alias . ";";
}
else
{
$fixUnique[] = PHP_EOL . Indent::_(4)
. "if (\$table->load(array('" . $alias .
"' => \$data['"
. $alias
. "'])) && (\$table->id != \$data['id']
|| \$data['id'] == 0))";
$fixUnique[] = Indent::_(4) . "{";
$fixUnique[] = Indent::_(5) . "\$msg = Text:" .
":_('COM_"
.
CFactory::_('Compiler.Builder.Content.One')->get('COMPONENT')
. "_" . $VIEW . "_SAVE_WARNING');";
$fixUnique[] = Indent::_(4) . "}";
$fixUnique[] = PHP_EOL . Indent::_(4) . "\$data['" .
$alias
. "'] = \$this->_generateNewTitle(\$data['" .
$alias
. "']);";
}
$fixUnique[] = PHP_EOL . Indent::_(4) . "if (isset(\$msg))";
$fixUnique[] = Indent::_(4) . "{";
$fixUnique[] = Indent::_(5)
. "Factory::getApplication()->enqueueMessage(\$msg,
'warning');";
$fixUnique[] = Indent::_(4) . "}";
$fixUnique[] = Indent::_(3) . "}";
$fixUnique[] = Indent::_(2) . "}";
// $fixUnique[] = PHP_EOL . Indent::_(2) . "//" .
Line::_(__Line__, __Class__) . " Update alias if still empty at this
point";
// $fixUnique[] = Indent::_(2) . "if (\$data['" . $alias .
"'] == null || empty(\$data['" . $alias .
"']))";
// $fixUnique[] = Indent::_(2) . "{";
// $fixUnique[] = Indent::_(3) . "if
(Factory::getConfig()->get('unicodeslugs') == 1)";
// $fixUnique[] = Indent::_(3) . "{";
// $fixUnique[] = Indent::_(4) . "\$data['" . $alias .
"'] = OutputFilter::stringURLUnicodeSlug(" . implode('
. " " . ', $titleData) . ");";
// $fixUnique[] = Indent::_(3) . "}";
// $fixUnique[] = Indent::_(3) . "else";
// $fixUnique[] = Indent::_(3) . "{";
// $fixUnique[] = Indent::_(4) . "\$data['" . $alias .
"'] = OutputFilter::stringURLSafe(" . implode(' .
" " . ', $titleData) . ");";
// $fixUnique[] = Indent::_(3) . "}";
// $fixUnique[] = Indent::_(2) . "}";
}
// handel other unique fields
$fixUnique[] = PHP_EOL . Indent::_(2) . "//" .
Line::_(__Line__, __Class__)
. " Alter the unique field for save as copy";
$fixUnique[] = Indent::_(2)
. "if (\$input->get('task') ===
'save2copy')";
$fixUnique[] = Indent::_(2) . "{";
$fixUnique[] = Indent::_(3) . "//" . Line::_(__Line__,
__Class__)
. " Automatic handling of other unique fields";
$fixUnique[] = Indent::_(3)
. "\$uniqueFields = \$this->getUniqueFields();";
$fixUnique[] = Indent::_(3) . "if ("
. "Super_" .
"__0a59c65c_9daf_4bc9_baf4_e063ff9e6a8a___Power::check(\$uniqueFields))";
$fixUnique[] = Indent::_(3) . "{";
$fixUnique[] = Indent::_(4)
. "foreach (\$uniqueFields as \$uniqueField)";
$fixUnique[] = Indent::_(4) . "{";
$fixUnique[] = Indent::_(5)
. "\$data[\$uniqueField] =
\$this->generateUnique(\$uniqueField,\$data[\$uniqueField]);";
$fixUnique[] = Indent::_(4) . "}";
$fixUnique[] = Indent::_(3) . "}";
$fixUnique[] = Indent::_(2) . "}";
return PHP_EOL . implode(PHP_EOL, $fixUnique);
}
public function setGenerateNewTitle($nameSingleCode)
{
// if category is added to this view then do nothing
if
(CFactory::_('Compiler.Builder.Alias')->exists($nameSingleCode)
&&
(CFactory::_('Compiler.Builder.Title')->exists($nameSingleCode)
||
CFactory::_('Compiler.Builder.Custom.Alias')->exists($nameSingleCode)))
{
// get component name
$Component =
CFactory::_('Compiler.Builder.Content.One')->get('Component');
// rest the new function
$newFunction = [];
$newFunction[] = PHP_EOL . PHP_EOL . Indent::_(1) . "/**";
$newFunction[] = Indent::_(1)
. " * Method to change the title/s & alias.";
$newFunction[] = Indent::_(1) . " *";
$newFunction[] = Indent::_(1)
. " * @param string \$alias The alias.";
$newFunction[] = Indent::_(1)
. " * @param string/array \$title The title.";
$newFunction[] = Indent::_(1) . " *";
$newFunction[] = Indent::_(1)
. " * @return array/string Contains the modified title/s and/or
alias.";
$newFunction[] = Indent::_(1) . " *";
$newFunction[] = Indent::_(1) . " */";
$newFunction[] = Indent::_(1)
. "protected function _generateNewTitle(\$alias, \$title =
null)";
$newFunction[] = Indent::_(1) . "{";
$newFunction[] = PHP_EOL . Indent::_(2) . "//" . Line::_(
__LINE__,__CLASS__
) . " Alter the title/s & alias";
$newFunction[] = Indent::_(2) . "\$table =
\$this->getTable();";
$newFunction[] = PHP_EOL . Indent::_(2)
. "while (\$table->load(['alias' =>
\$alias]))";
$newFunction[] = Indent::_(2) . "{";
$newFunction[] = Indent::_(3) . "//" . Line::_(__Line__,
__Class__)
. " Check if this is an array of titles";
$newFunction[] = Indent::_(3) . "if ("
. "Super_" .
"__0a59c65c_9daf_4bc9_baf4_e063ff9e6a8a___Power::check(\$title))";
$newFunction[] = Indent::_(3) . "{";
$newFunction[] = Indent::_(4)
. "foreach(\$title as \$nr => &\$_title)";
$newFunction[] = Indent::_(4) . "{";
$newFunction[] = Indent::_(5)
. "\$_title = StringHelper::increment(\$_title);";
$newFunction[] = Indent::_(4) . "}";
$newFunction[] = Indent::_(3) . "}";
$newFunction[] = Indent::_(3) . "//" . Line::_(__Line__,
__Class__)
. " Make sure we have a title";
$newFunction[] = Indent::_(3) . "elseif (\$title)";
$newFunction[] = Indent::_(3) . "{";
$newFunction[] = Indent::_(4)
. "\$title = StringHelper::increment(\$title);";
$newFunction[] = Indent::_(3) . "}";
$newFunction[] = Indent::_(3)
. "\$alias = StringHelper::increment(\$alias,
'dash');";
$newFunction[] = Indent::_(2) . "}";
$newFunction[] = Indent::_(2) . "//" . Line::_(__Line__,
__Class__)
. " Check if this is an array of titles";
$newFunction[] = Indent::_(2) . "if ("
. "Super_" .
"__0a59c65c_9daf_4bc9_baf4_e063ff9e6a8a___Power::check(\$title))";
$newFunction[] = Indent::_(2) . "{";
$newFunction[] = Indent::_(3) . "\$title[] = \$alias;";
$newFunction[] = Indent::_(3) . "return \$title;";
$newFunction[] = Indent::_(2) . "}";
$newFunction[] = Indent::_(2) . "//" . Line::_(__Line__,
__Class__)
. " Make sure we have a title";
$newFunction[] = Indent::_(2) . "elseif (\$title)";
$newFunction[] = Indent::_(2) . "{";
$newFunction[] = Indent::_(3) . "return array(\$title,
\$alias);";
$newFunction[] = Indent::_(2) . "}";
$newFunction[] = Indent::_(2) . "//" . Line::_(__Line__,
__Class__)
. " We only had an alias";
$newFunction[] = Indent::_(2) . "return \$alias;";
$newFunction[] = Indent::_(1) . "}";
return implode(PHP_EOL, $newFunction);
}
elseif
(CFactory::_('Compiler.Builder.Title')->exists($nameSingleCode))
{
$newFunction = [];
$newFunction[] = PHP_EOL . PHP_EOL . Indent::_(1) . "/**";
$newFunction[] = Indent::_(1) . " * Method to change the
title";
$newFunction[] = Indent::_(1) . " *";
$newFunction[] = Indent::_(1)
. " * @param string \$title The title.";
$newFunction[] = Indent::_(1) . " *";
$newFunction[] = Indent::_(1)
. " * @return array Contains the modified title and
alias.";
$newFunction[] = Indent::_(1) . " *";
$newFunction[] = Indent::_(1) . " */";
$newFunction[] = Indent::_(1)
. "protected function _generateNewTitle(\$title)";
$newFunction[] = Indent::_(1) . "{";
$newFunction[] = PHP_EOL . Indent::_(2) . "//" . Line::_(
__LINE__,__CLASS__
) . " Alter the title";
$newFunction[] = Indent::_(2) . "\$table =
\$this->getTable();";
$newFunction[] = PHP_EOL . Indent::_(2)
. "while (\$table->load(['title' =>
\$title]))";
$newFunction[] = Indent::_(2) . "{";
$newFunction[] = Indent::_(3)
. "\$title = StringHelper::increment(\$title);";
$newFunction[] = Indent::_(2) . "}";
$newFunction[] = PHP_EOL . Indent::_(2) . "return \$title;";
$newFunction[] = Indent::_(1) . "}";
return implode(PHP_EOL, $newFunction);
}
return '';
}
public function setGenerateNewAlias($nameSingleCode)
{
// make sure this view has an alias
if
(CFactory::_('Compiler.Builder.Alias')->exists($nameSingleCode))
{
// set the title stuff
if (($customAliasBuilder =
CFactory::_('Compiler.Builder.Custom.Alias')->get($nameSingleCode))
!== null)
{
$titles = array_values(
$customAliasBuilder
);
}
elseif
(CFactory::_('Compiler.Builder.Title')->exists($nameSingleCode))
{
$titles =
[CFactory::_('Compiler.Builder.Title')->get($nameSingleCode)];
}
// reset the bucket
$titleData = [];
// load the dynamic title builder
if (isset($titles) && ArrayHelper::check($titles))
{
foreach ($titles as $title)
{
$titleData[] = "\$this->" . $title;
}
}
else
{
$titleData
= array("'-'"); // just encase some mad man does
not set a title/customAlias (we fall back on the date)
}
// rest the new function
$newFunction = [];
$newFunction[] = PHP_EOL . PHP_EOL . Indent::_(1) . "/**";
$newFunction[] = Indent::_(1)
. " * Generate a valid alias from title / date.";
$newFunction[] = Indent::_(1)
. " * Remains public to be able to check for duplicated alias
before saving";
$newFunction[] = Indent::_(1) . " *";
$newFunction[] = Indent::_(1) . " * @return string";
$newFunction[] = Indent::_(1) . " */";
$newFunction[] = Indent::_(1) . "public function
generateAlias()";
$newFunction[] = Indent::_(1) . "{";
$newFunction[] = Indent::_(2) . "if
(empty(\$this->alias))";
$newFunction[] = Indent::_(2) . "{";
$newFunction[] = Indent::_(3) . "\$this->alias = " .
implode(
".' '.", $titleData
) . ';';
$newFunction[] = Indent::_(2) . "}";
$newFunction[] = PHP_EOL . Indent::_(2)
. "\$this->alias =
ApplicationHelper::stringURLSafe(\$this->alias);";
$newFunction[] = PHP_EOL . Indent::_(2)
. "if (trim(str_replace('-', '',
\$this->alias)) == '')";
$newFunction[] = Indent::_(2) . "{";
$newFunction[] = Indent::_(3)
. "\$this->alias =
Factory::getDate()->format('Y-m-d-H-i-s');";
$newFunction[] = Indent::_(2) . "}";
$newFunction[] = PHP_EOL . Indent::_(2) . "return
\$this->alias;";
$newFunction[] = Indent::_(1) . "}";
return implode(PHP_EOL, $newFunction);
}
// rest the new function
$newFunction = [];
$newFunction[] = PHP_EOL . PHP_EOL . Indent::_(1) . "/**";
$newFunction[] = Indent::_(1)
. " * This view does not actually have an alias";
$newFunction[] = Indent::_(1) . " *";
$newFunction[] = Indent::_(1) . " * @return bool";
$newFunction[] = Indent::_(1) . " */";
$newFunction[] = Indent::_(1) . "public function
generateAlias()";
$newFunction[] = Indent::_(1) . "{";
$newFunction[] = Indent::_(2) . "return false;";
$newFunction[] = Indent::_(1) . "}";
return implode(PHP_EOL, $newFunction);
}
public function setInstall()
{
if (($database_tables =
CFactory::_('Compiler.Builder.Database.Tables')->allActive())
!== [])
{
// set the main db prefix
$component = CFactory::_('Config')->component_code_name;
// start building the db
$db = '';
if (CFactory::_('Config')->get('joomla_version',
3) != 3)
{
$db .= 'SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";' .
PHP_EOL;
$db .= 'SET time_zone = "+00:00";' . PHP_EOL .
PHP_EOL;;
}
foreach ($database_tables as $view => $fields)
{
// cast the object to an array TODO we must update all to use the
object
$fields = (array) $fields;
// build the uninstallation array
CFactory::_('Compiler.Builder.Database.Uninstall')->add('table',
"DROP TABLE IF EXISTS `#__"
. $component . "_" . $view . "`;");
// setup the table DB string
$db_ = '';
$db_ .= "CREATE TABLE IF NOT EXISTS `#__" . $component .
"_"
. $view . "` (";
// check if the table name has changed
if (($old_table_name = CFactory::_('Registry')->
get('builder.update_sql.table_name.' . $view .
'.old', null)) !== null)
{
$key_ = "RENAMETABLE`#__" . $component . "_" .
$old_table_name . "`";
$value_ = "RENAME TABLE `#__" . $component . "_" .
$old_table_name . "` to `#__"
. $component . "_" . $view . "`;";
CFactory::_('Compiler.Builder.Update.Mysql')->set($key_,
$value_);
}
// check if default field was overwritten
if
(!CFactory::_('Compiler.Builder.Field.Names')->isString($view
. '.id'))
{
$db_ .= PHP_EOL . Indent::_(1)
. "`id` INT(11) NOT NULL AUTO_INCREMENT,";
}
$db_ .= PHP_EOL . Indent::_(1)
. "`asset_id` INT(10) unsigned NULL DEFAULT 0 COMMENT 'FK to
the #__assets table.',";
ksort($fields);
$last_name = 'asset_id';
foreach ($fields as $field => $data)
{
// cast the object to an array TODO we must update all to use the
object
$data = (array) $data;
// set default
$default = $data['default'];
if ($default === 'Other')
{
$default = $data['other'];
}
// to get just null value add EMPTY to other value.
if ($default === 'EMPTY')
{
$default = $data['null_switch'];
}
elseif ($default === 'DATETIME'
|| $default === 'CURRENT_TIMESTAMP')
{
$default = $data['null_switch'] . ' DEFAULT '
. $default;
}
elseif (is_numeric($default))
{
$default = $data['null_switch'] . " DEFAULT "
. $default;
}
else
{
$default = $data['null_switch'] . " DEFAULT
'"
. $default . "'";
}
// set the length (lenght) <-- TYPO :: LVDM :: DON'T TOUCH
$length = '';
if (isset($data['lenght']) &&
$data['lenght'] === 'Other'
&& isset($data['lenght_other'])
&& $data['lenght_other'] > 0)
{
$length = '(' . $data['lenght_other'] .
')';
}
elseif (isset($data['lenght']) &&
$data['lenght'] > 0)
{
$length = '(' . $data['lenght'] . ')';
}
// set the field to db
$db_ .= PHP_EOL . Indent::_(1) . "`" . $field . "`
"
. $data['type'] . $length . " " . $default .
",";
// check if this a new field that should be added via SQL update
if (CFactory::_('Registry')->
get('builder.add_sql.field.' . $view . '.' .
$data['ID'], null))
{
// to soon....
// $key_ = "ALTERTABLE`#__" . $component . "_" .
$view . "`ADDCOLUMNIFNOTEXISTS`" . $field . "`";
// $value_ = "ALTER TABLE `#__" . $component .
"_" . $view . "` ADD COLUMN IF NOT EXISTS `" . $field .
"` " . $data['type']
// . length . " " . $default . " AFTER `" .
$last_name . "`;";
$key_ = "ALTERTABLE`#__" . $component . "_" .
$view . "`ADD`" . $field . "`";
$value_ = "ALTER TABLE `#__" . $component . "_" .
$view . "` ADD `" . $field . "` " .
$data['type']
. $length . " " . $default . " AFTER `" .
$last_name . "`;";
CFactory::_('Compiler.Builder.Update.Mysql')->set($key_,
$value_);
}
// check if the field has changed name and/or data type and lenght
elseif (CFactory::_('Registry')->
get('builder.update_sql.field.datatype.' . $view .
'.' . $field, null)
|| CFactory::_('Registry')->
get('builder.update_sql.field.lenght.' . $view .
'.' . $field, null)
|| CFactory::_('Registry')->
get('builder.update_sql.field.name.' . $view .
'.' . $field, null))
{
// if the name changed
if (($oldName = CFactory::_('Registry')->
get('builder.update_sql.field.name.' . $view .
'.' . $field . '.old', null)) === null)
{
$oldName = $field;
}
// now set the update SQL
$key_ = "ALTERTABLE`#__" . $component . "_" .
$view . "`CHANGE`" . $oldName . "``"
. $field . "`";
$value_ = "ALTER TABLE `#__" . $component . "_" .
$view . "` CHANGE `" . $oldName . "` `"
. $field . "` " . $data['type'] . $length .
" " . $default . ";";
CFactory::_('Compiler.Builder.Update.Mysql')->set($key_,
$value_);
}
// be sure to track the last name used :)
$last_name = $field;
}
// check if default field was overwritten
if
(!CFactory::_('Compiler.Builder.Field.Names')->isString($view
. '.params'))
{
$db_ .= PHP_EOL . Indent::_(1) . "`params` TEXT NULL,";
}
// check if default field was overwritten
if
(!CFactory::_('Compiler.Builder.Field.Names')->isString($view
. '.published'))
{
$db_ .= PHP_EOL . Indent::_(1)
. "`published` TINYINT(3) NULL DEFAULT 1,";
}
// check if default field was overwritten
if
(!CFactory::_('Compiler.Builder.Field.Names')->isString($view
. '.created_by'))
{
$db_ .= PHP_EOL . Indent::_(1)
. "`created_by` INT(10) unsigned NULL DEFAULT 0,";
}
// check if default field was overwritten
if
(!CFactory::_('Compiler.Builder.Field.Names')->isString($view
. '.modified_by'))
{
$db_ .= PHP_EOL . Indent::_(1)
. "`modified_by` INT(10) unsigned NULL DEFAULT 0,";
}
// check if default field was overwritten
if
(!CFactory::_('Compiler.Builder.Field.Names')->isString($view
. '.created'))
{
if
(CFactory::_('Config')->get('joomla_version', 3) ==
3)
{
$db_ .= PHP_EOL . Indent::_(1)
. "`created` DATETIME NULL DEFAULT '0000-00-00
00:00:00',";
}
else
{
$db_ .= PHP_EOL . Indent::_(1)
. "`created` DATETIME DEFAULT CURRENT_TIMESTAMP,";
}
}
// check if default field was overwritten
if
(!CFactory::_('Compiler.Builder.Field.Names')->isString($view
. '.modified'))
{
if
(CFactory::_('Config')->get('joomla_version', 3) ==
3)
{
$db_ .= PHP_EOL . Indent::_(1)
. "`modified` DATETIME NULL DEFAULT '0000-00-00
00:00:00',";
}
else
{
$db_ .= PHP_EOL . Indent::_(1)
. "`modified` DATETIME DEFAULT NULL,";
}
}
// check if default field was overwritten
if
(!CFactory::_('Compiler.Builder.Field.Names')->isString($view
. '.checked_out'))
{
$db_ .= PHP_EOL . Indent::_(1)
. "`checked_out` int(11) unsigned NULL DEFAULT 0,";
}
// check if default field was overwritten
if
(!CFactory::_('Compiler.Builder.Field.Names')->isString($view
. '.checked_out_time'))
{
if
(CFactory::_('Config')->get('joomla_version', 3) ==
3)
{
$db_ .= PHP_EOL . Indent::_(1)
. "`checked_out_time` DATETIME NULL DEFAULT '0000-00-00
00:00:00',";
}
else
{
$db_ .= PHP_EOL . Indent::_(1)
. "`checked_out_time` DATETIME DEFAULT NULL,";
}
}
// check if default field was overwritten
if
(!CFactory::_('Compiler.Builder.Field.Names')->isString($view
. '.version'))
{
$db_ .= PHP_EOL . Indent::_(1)
. "`version` INT(10) unsigned NULL DEFAULT 1,";
}
// check if default field was overwritten
if
(!CFactory::_('Compiler.Builder.Field.Names')->isString($view
. '.hits'))
{
$db_ .= PHP_EOL . Indent::_(1)
. "`hits` INT(10) unsigned NULL DEFAULT 0,";
}
// check if view has access
if
(CFactory::_('Compiler.Builder.Access.Switch')->exists($view)
&&
!CFactory::_('Compiler.Builder.Field.Names')->isString($view .
'.access'))
{
$db_ .= PHP_EOL . Indent::_(1)
. "`access` INT(10) unsigned NULL DEFAULT 0,";
// add to component dynamic fields
CFactory::_('Compiler.Builder.Component.Fields')->set($view
. '.access',
[
'name' => 'access',
'label' => 'Access',
'type' => 'accesslevel',
'title' => false,
'store' => NULL,
'tab_name' => NULL,
'db' => [
'type' => 'INT(10) unsigned',
'default' => '0',
'key' => true,
'null_switch' => 'NULL'
]
]
);
}
// check if default field was overwritten
if
(!CFactory::_('Compiler.Builder.Field.Names')->isString($view
. '.ordering'))
{
$db_ .= PHP_EOL . Indent::_(1)
. "`ordering` INT(11) NULL DEFAULT 0,";
}
// check if metadata is added to this view
if
(CFactory::_('Compiler.Builder.Meta.Data')->isString($view))
{
// check if default field was overwritten
if
(!CFactory::_('Compiler.Builder.Field.Names')->isString($view
. '.metakey'))
{
if
(CFactory::_('Config')->get('joomla_version', 3) ==
3)
{
$db_ .= PHP_EOL . Indent::_(1)
. "`metakey` TEXT NULL,";
}
else
{
$db_ .= PHP_EOL . Indent::_(1)
. "`metakey` TEXT,";
}
}
// check if default field was overwritten
if
(!CFactory::_('Compiler.Builder.Field.Names')->isString($view
. '.metadesc'))
{
if
(CFactory::_('Config')->get('joomla_version', 3) ==
3)
{
$db_ .= PHP_EOL . Indent::_(1)
. "`metadesc` TEXT NULL,";
}
else
{
$db_ .= PHP_EOL . Indent::_(1)
. "`metadesc` TEXT,";
}
}
// check if default field was overwritten
if
(!CFactory::_('Compiler.Builder.Field.Names')->isString($view
. '.metadata'))
{
if
(CFactory::_('Config')->get('joomla_version', 3) ==
3)
{
$db_ .= PHP_EOL . Indent::_(1)
. "`metadata` TEXT NULL,";
}
else
{
$db_ .= PHP_EOL . Indent::_(1)
. "`metadata` TEXT,";
}
}
// add to component dynamic fields
CFactory::_('Compiler.Builder.Component.Fields')->set($view
. '.metakey',
[
'name' => 'metakey',
'label' => 'Meta Keywords',
'type' => 'textarea',
'title' => false,
'store' => NULL,
'tab_name' => 'publishing',
'db' => [
'type' => 'TEXT'
]
]
);
CFactory::_('Compiler.Builder.Component.Fields')->set($view
. '.metadesc',
[
'name' => 'metadesc',
'label' => 'Meta Description',
'type' => 'textarea',
'title' => false,
'store' => NULL,
'tab_name' => 'publishing',
'db' => [
'type' => 'TEXT'
]
]
);
CFactory::_('Compiler.Builder.Component.Fields')->set($view
. '.metadata',
[
'name' => 'metadata',
'label' => 'Meta Data',
'type' => NULL,
'title' => false,
'store' => 'json',
'tab_name' => 'publishing',
'db' => [
'type' => 'TEXT'
]
]
);
}
// TODO (we may want this to be dynamicly set)
$db_ .= PHP_EOL . Indent::_(1) . "PRIMARY KEY (`id`)";
// check if a key was set for any of the default fields then we should
not set it again
$check_keys_set = [];
if
(CFactory::_('Compiler.Builder.Database.Unique.Keys')->exists($view))
{
foreach
(CFactory::_('Compiler.Builder.Database.Unique.Keys')->get($view)
as $nr => $key)
{
$db_ .= "," . PHP_EOL . Indent::_(1)
. "UNIQUE KEY `idx_" . $key . "` (`" . $key .
"`)";
$check_keys_set[$key] = $key;
}
}
if
(CFactory::_('Compiler.Builder.Database.Keys')->exists($view))
{
foreach
(CFactory::_('Compiler.Builder.Database.Keys')->get($view) as
$nr => $key)
{
$db_ .= "," . PHP_EOL . Indent::_(1)
. "KEY `idx_" . $key . "` (`" . $key .
"`)";
$check_keys_set[$key] = $key;
}
}
// check if view has access
if (!isset($check_keys_set['access'])
&&
CFactory::_('Compiler.Builder.Access.Switch')->exists($view))
{
$db_ .= "," . PHP_EOL . Indent::_(1)
. "KEY `idx_access` (`access`)";
}
// check if default field was overwritten
if (!isset($check_keys_set['checked_out']))
{
$db_ .= "," . PHP_EOL . Indent::_(1)
. "KEY `idx_checkout` (`checked_out`)";
}
// check if default field was overwritten
if (!isset($check_keys_set['created_by']))
{
$db_ .= "," . PHP_EOL . Indent::_(1)
. "KEY `idx_createdby` (`created_by`)";
}
// check if default field was overwritten
if (!isset($check_keys_set['modified_by']))
{
$db_ .= "," . PHP_EOL . Indent::_(1)
. "KEY `idx_modifiedby` (`modified_by`)";
}
// check if default field was overwritten
if (!isset($check_keys_set['published']))
{
$db_ .= "," . PHP_EOL . Indent::_(1)
. "KEY `idx_state` (`published`)";
}
// easy bucket
$easy = [];
// get the mysql table settings
foreach (
CFactory::_('Config')->mysql_table_keys as
$_mysqlTableKey => $_mysqlTableVal
)
{
if (($easy[$_mysqlTableKey] =
CFactory::_('Compiler.Builder.Mysql.Table.Setting')->
get($view . '.' . $_mysqlTableKey)) === null)
{
$easy[$_mysqlTableKey]
=
CFactory::_('Config')->mysql_table_keys[$_mysqlTableKey]['default'];
}
}
// add a little fix for the row_format
if (StringHelper::check($easy['row_format']))
{
$easy['row_format'] = ' ROW_FORMAT=' .
$easy['row_format'];
}
// now build db string
$db_ .= PHP_EOL . ") ENGINE=" . $easy['engine']
. " AUTO_INCREMENT=0 DEFAULT CHARSET=" .
$easy['charset']
. " DEFAULT COLLATE=" . $easy['collate']
. $easy['row_format'] . ";";
// check if this is a new table that should be added via update SQL
if (CFactory::_('Registry')->
get('builder.add_sql.adminview.' . $view, null))
{
// build the update array
$key_ = "CREATETABLEIFNOTEXISTS`#__" . $component .
"_" . $view . "`";
CFactory::_('Compiler.Builder.Update.Mysql')->set($key_,
$db_);
}
// check if the table row_format has changed
if (StringHelper::check($easy['row_format'])
&& CFactory::_('Registry')->
get('builder.update_sql.table_row_format.' . $view, null))
{
// build the update array
$key_ = "ALTERTABLE`#__" . $component . "_" .
$view . "`" . trim((string) $easy['row_format']);
$value_ = "ALTER TABLE `#__" . $component . "_" .
$view . "`" . $easy['row_format'] . ";";
CFactory::_('Compiler.Builder.Update.Mysql')->set($key_,
$value_);
}
// check if the table engine has changed
if (CFactory::_('Registry')->
get('builder.update_sql.table_engine.' . $view, null))
{
// build the update array
$key_ = "ALTERTABLE`#__" . $component . "_" .
$view . "`ENGINE=" . $easy['engine'];
$value_ = "ALTER TABLE `#__" . $component . "_" .
$view . "` ENGINE = " . $easy['engine'] .
";";
CFactory::_('Compiler.Builder.Update.Mysql')->set($key_,
$value_);
}
// check if the table charset OR collation has changed (must be updated
together)
if (CFactory::_('Registry')->
get('builder.update_sql.table_charset.' . $view, null)
|| CFactory::_('Registry')->
get('builder.update_sql.table_collate.' . $view, null))
{
// build the update array
$key_ = "ALTERTABLE`#__" . $component . "_" .
$view . "CONVERTTOCHARACTERSET"
. $easy['charset'] . "COLLATE" .
$easy['collate'];
$value_ = "ALTER TABLE `#__" . $component . "_" .
$view . "` CONVERT TO CHARACTER SET "
. $easy['charset'] . " COLLATE " .
$easy['collate'] . ";";
CFactory::_('Compiler.Builder.Update.Mysql')->set($key_,
$value_);
}
// add to main DB string
$db .= $db_ . PHP_EOL . PHP_EOL;
}
// add custom sql dump to the file
if
(isset(CFactory::_('Customcode.Dispenser')->hub['sql'])
&& ArrayHelper::check(
CFactory::_('Customcode.Dispenser')->hub['sql']
))
{
foreach
(CFactory::_('Customcode.Dispenser')->hub['sql'] as
$for => $customSql)
{
$placeholders = [
Placefix::_('component') => $component,
Placefix::_('view') => $for
]; // dont change this just use ###view### or componentbuilder (took
you a while to get here right :)
$db .= CFactory::_('Placeholder')->update(
$customSql, $placeholders
) . PHP_EOL . PHP_EOL;
}
unset(CFactory::_('Customcode.Dispenser')->hub['sql']);
}
// WHY DO WE NEED AN ASSET TABLE FIX?
// https://www.mysqltutorial.org/mysql-varchar/
// https://stackoverflow.com/a/15227917/1429677
// https://forums.mysql.com/read.php?24,105964,105964
//
https://github.com/vdm-io/Joomla-Component-Builder/issues/616#issuecomment-741502980
// 30 actions each +-20 characters with 8 groups
// that makes 4800 characters and the current Joomla
// column size is varchar(5120)
// just a little event tracking in classes
// count actions = setAccessSections
// around line206 (infusion call)
// around line26454 (interpretation function)
// first fix = setInstall
// around line1600 (infusion call)
// around line10063 (interpretation function)
// second fix = setUninstallScript
// around line2161 (infusion call)
// around line8030 (interpretation function)
// check if this component needs larger rules
// also check if the developer will allow this
// the access actions length must be checked before this
// only add this option if set to SQL fix
if (CFactory::_('Config')->add_assets_table_fix == 1)
{
// 400 actions worse case is larger the 65535 characters
if (CFactory::_('Utilities.Counter')->accessSize >
400)
{
$db .= PHP_EOL;
$db .= PHP_EOL . '--';
$db .= PHP_EOL
. '--' . Line::_(
__LINE__,__CLASS__
)
. ' Always insure this column rules is large enough for all the
access control values.';
$db .= PHP_EOL . '--';
$db .= PHP_EOL
. "ALTER TABLE `#__assets` CHANGE `rules` `rules` MEDIUMTEXT NOT
NULL COMMENT 'JSON encoded access control. Enlarged to MEDIUMTEXT by
JCB';";
}
// smaller then 400 makes TEXT large enough
elseif (CFactory::_('Config')->add_assets_table_fix == 1)
{
$db .= PHP_EOL;
$db .= PHP_EOL . '--';
$db .= PHP_EOL
. '--' . Line::_(
__LINE__,__CLASS__
)
. ' Always insure this column rules is large enough for all the
access control values.';
$db .= PHP_EOL . '--';
$db .= PHP_EOL
. "ALTER TABLE `#__assets` CHANGE `rules` `rules` TEXT NOT NULL
COMMENT 'JSON encoded access control. Enlarged to TEXT by
JCB';";
}
}
// check if this component needs larger names
// also check if the developer will allow this
// the config length must be checked before this
// only add this option if set to SQL fix
if (CFactory::_('Config')->add_assets_table_fix &&
CFactory::_('Config')->add_assets_table_name_fix)
{
$db .= PHP_EOL;
$db .= PHP_EOL . '--';
$db .= PHP_EOL
. '--' . Line::_(
__LINE__,__CLASS__
)
. ' Always insure this column name is large enough for long
component and view names.';
$db .= PHP_EOL . '--';
$db .= PHP_EOL
. "ALTER TABLE `#__assets` CHANGE `name` `name` VARCHAR(100)
CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'The
unique name for the asset.';";
}
return $db;
}
return '';
}
public function setUninstall()
{
$db = '';
if
(CFactory::_('Compiler.Builder.Database.Uninstall')->isArray('table'))
{
$db .= implode(PHP_EOL,
CFactory::_('Compiler.Builder.Database.Uninstall')->get('table'))
. PHP_EOL;
}
// add custom sql uninstall dump to the file
if
(isset(CFactory::_('Customcode.Dispenser')->hub['sql_uninstall'])
&& StringHelper::check(
CFactory::_('Customcode.Dispenser')->hub['sql_uninstall']
))
{
$db .= CFactory::_('Placeholder')->update_(
CFactory::_('Customcode.Dispenser')->hub['sql_uninstall']
) . PHP_EOL;
unset(CFactory::_('Customcode.Dispenser')->hub['sql_uninstall']);
}
// check if this component used larger rules
// now revert them back on uninstall
// only add this option if set to SQL fix
if (CFactory::_('Config')->add_assets_table_fix == 1)
{
//
https://github.com/joomla/joomla-cms/blob/3.10.0-alpha3/installation/sql/mysql/joomla.sql#L22
// Checked 1st December 2020 (let us know if this changes)
$db .= PHP_EOL;
$db .= PHP_EOL . '--';
$db .= PHP_EOL
. '--' . Line::_(
__LINE__,__CLASS__
)
. ' Always insure this column rules is reversed to Joomla defaults
on uninstall. (as on 1st Dec 2020)';
$db .= PHP_EOL . '--';
$db .= PHP_EOL
. "ALTER TABLE `#__assets` CHANGE `rules` `rules` varchar(5120)
NOT NULL COMMENT 'JSON encoded access control.';";
}
// check if this component used larger names
// now revert them back on uninstall
// only add this option if set to SQL fix
if (CFactory::_('Config')->add_assets_table_fix == 1
&& CFactory::_('Config')->add_assets_table_name_fix)
{
//
https://github.com/joomla/joomla-cms/blob/3.10.0-alpha3/installation/sql/mysql/joomla.sql#L20
// Checked 1st December 2020 (let us know if this changes)
$db .= PHP_EOL;
$db .= PHP_EOL . '--';
$db .= PHP_EOL
. '--' . Line::_(
__LINE__,__CLASS__
)
. ' Always insure this column name is reversed to Joomla defaults
on uninstall. (as on 1st Dec 2020).';
$db .= PHP_EOL . '--';
$db .= PHP_EOL
. "ALTER TABLE `#__assets` CHANGE `name` `name` VARCHAR(50)
CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'The
unique name for the asset.';";
}
return $db;
}
public function setLangAdmin(string $componentName): bool
{
// Trigger Event: jcb_ce_onBeforeBuildAdminLang
CFactory::_('Event')->trigger(
'jcb_ce_onBeforeBuildAdminLang'
);
// start loading the defaults
CFactory::_('Language')->set('adminsys',
CFactory::_('Config')->lang_prefix, $componentName);
CFactory::_('Language')->set(
'adminsys', CFactory::_('Config')->lang_prefix .
'_CONFIGURATION',
$componentName . ' Configuration'
);
CFactory::_('Language')->set('admin',
CFactory::_('Config')->lang_prefix, $componentName);
CFactory::_('Language')->set('admin',
CFactory::_('Config')->lang_prefix . '_BACK',
'Back');
CFactory::_('Language')->set(
'admin', CFactory::_('Config')->lang_prefix .
'_DASH', 'Dashboard'
);
CFactory::_('Language')->set(
'admin', CFactory::_('Config')->lang_prefix .
'_VERSION', 'Version'
);
CFactory::_('Language')->set('admin',
CFactory::_('Config')->lang_prefix . '_DATE',
'Date');
CFactory::_('Language')->set('admin',
CFactory::_('Config')->lang_prefix . '_AUTHOR',
'Author');
CFactory::_('Language')->set(
'admin', CFactory::_('Config')->lang_prefix .
'_WEBSITE', 'Website'
);
CFactory::_('Language')->set(
'admin', CFactory::_('Config')->lang_prefix .
'_LICENSE', 'License'
);
CFactory::_('Language')->set(
'admin', CFactory::_('Config')->lang_prefix .
'_CONTRIBUTORS', 'Contributors'
);
CFactory::_('Language')->set(
'admin', CFactory::_('Config')->lang_prefix .
'_CONTRIBUTOR', 'Contributor'
);
CFactory::_('Language')->set(
'admin', CFactory::_('Config')->lang_prefix .
'_DASHBOARD',
$componentName . ' Dashboard'
);
CFactory::_('Language')->set(
'admin', CFactory::_('Config')->lang_prefix .
'_SAVE_SUCCESS',
"Great! Item successfully saved."
);
CFactory::_('Language')->set(
'admin', CFactory::_('Config')->lang_prefix .
'_SAVE_WARNING',
"The value already existed so please select another."
);
CFactory::_('Language')->set(
'admin', CFactory::_('Config')->lang_prefix .
'_HELP_MANAGER', "Help"
);
CFactory::_('Language')->set('admin',
CFactory::_('Config')->lang_prefix . '_NEW',
"New");
CFactory::_('Language')->set(
'admin', CFactory::_('Config')->lang_prefix .
'_CLOSE_NEW', "Close & New"
);
CFactory::_('Language')->set(
'admin', CFactory::_('Config')->lang_prefix .
'_CREATE_NEW_S', "Create New %s"
);
CFactory::_('Language')->set(
'admin', CFactory::_('Config')->lang_prefix .
'_EDIT_S', "Edit %s"
);
CFactory::_('Language')->set(
'admin', CFactory::_('Config')->lang_prefix .
'_KEEP_ORIGINAL_STATE',
"- Keep Original State -"
);
CFactory::_('Language')->set(
'admin', CFactory::_('Config')->lang_prefix .
'_KEEP_ORIGINAL_ACCESS',
"- Keep Original Access -"
);
CFactory::_('Language')->set(
'admin', CFactory::_('Config')->lang_prefix .
'_KEEP_ORIGINAL_CATEGORY',
"- Keep Original Category -"
);
CFactory::_('Language')->set(
'admin', CFactory::_('Config')->lang_prefix .
'_PUBLISHED', 'Published'
);
CFactory::_('Language')->set(
'admin', CFactory::_('Config')->lang_prefix .
'_INACTIVE', 'Inactive'
);
CFactory::_('Language')->set(
'admin', CFactory::_('Config')->lang_prefix .
'_ARCHIVED', 'Archived'
);
CFactory::_('Language')->set(
'admin', CFactory::_('Config')->lang_prefix .
'_TRASHED', 'Trashed'
);
CFactory::_('Language')->set(
'admin', CFactory::_('Config')->lang_prefix .
'_NO_ACCESS_GRANTED',
"No Access Granted!"
);
CFactory::_('Language')->set(
'admin', CFactory::_('Config')->lang_prefix .
'_NOT_FOUND_OR_ACCESS_DENIED',
"Not found or access denied!"
);
if (CFactory::_('Component')->get('add_license')
&&
CFactory::_('Component')->get('license_type') == 3)
{
CFactory::_('Language')->set(
'admin', 'NIE_REG_NIE',
"<br /><br /><center><h1>License not set
for " . $componentName
. ".</h1><p>Notify your administrator!<br />The
license can be obtained from <a href='"
.
CFactory::_('Component')->get('whmcs_buy_link') .
"' target='_blank'>"
. CFactory::_('Component')->get('companyname') .
"</a>.</p></center>"
);
}
// add the langug files needed to import and export data
if (CFactory::_('Config')->get('add_eximport',
false))
{
CFactory::_('Language')->set(
'admin', CFactory::_('Config')->lang_prefix .
'_EXPORT_FAILED', "Export Failed"
);
CFactory::_('Language')->set(
'admin', CFactory::_('Config')->lang_prefix .
'_IMPORT_FAILED', "Import Failed"
);
CFactory::_('Language')->set(
'admin', CFactory::_('Config')->lang_prefix .
'_IMPORT_TITLE', "Data Importer"
);
CFactory::_('Language')->set(
'admin', CFactory::_('Config')->lang_prefix .
'_IMPORT_NO_IMPORT_TYPE_FOUND',
"Import type not found."
);
CFactory::_('Language')->set(
'admin',
CFactory::_('Config')->lang_prefix .
'_IMPORT_UNABLE_TO_FIND_IMPORT_PACKAGE',
"Package to import not found."
);
CFactory::_('Language')->set(
'admin', CFactory::_('Config')->lang_prefix .
'_IMPORT_ERROR', "Import error."
);
CFactory::_('Language')->set(
'admin', CFactory::_('Config')->lang_prefix .
'_IMPORT_SUCCESS',
"Great! Import successful."
);
CFactory::_('Language')->set(
'admin', CFactory::_('Config')->lang_prefix .
'_IMPORT_MSG_WARNIMPORTFILE',
"Warning, import file error."
);
CFactory::_('Language')->set(
'admin', CFactory::_('Config')->lang_prefix .
'_IMPORT_MSG_NO_FILE_SELECTED',
"No import file selected."
);
CFactory::_('Language')->set(
'admin', CFactory::_('Config')->lang_prefix .
'_IMPORT_MSG_PLEASE_SELECT_A_FILE',
"Please select a file to import."
);
CFactory::_('Language')->set(
'admin',
CFactory::_('Config')->lang_prefix .
'_IMPORT_MSG_PLEASE_SELECT_ALL_COLUMNS',
"Please link all columns."
);
CFactory::_('Language')->set(
'admin',
CFactory::_('Config')->lang_prefix .
'_IMPORT_MSG_PLEASE_SELECT_A_DIRECTORY',
"Please enter the file directory."
);
CFactory::_('Language')->set(
'admin',
CFactory::_('Config')->lang_prefix .
'_IMPORT_MSG_WARNIMPORTUPLOADERROR',
"Warning, import upload error."
);
CFactory::_('Language')->set(
'admin', CFactory::_('Config')->lang_prefix
. '_IMPORT_MSG_PLEASE_ENTER_A_PACKAGE_DIRECTORY',
"Please enter the file directory."
);
CFactory::_('Language')->set(
'admin', CFactory::_('Config')->lang_prefix
. '_IMPORT_MSG_PATH_DOES_NOT_HAVE_A_VALID_PACKAGE',
"Path does not have a valid file."
);
CFactory::_('Language')->set(
'admin', CFactory::_('Config')->lang_prefix
. '_IMPORT_MSG_DOES_NOT_HAVE_A_VALID_FILE_TYPE',
"Does not have a valid file type."
);
CFactory::_('Language')->set(
'admin', CFactory::_('Config')->lang_prefix .
'_IMPORT_MSG_ENTER_A_URL',
"Please enter a url."
);
CFactory::_('Language')->set(
'admin', CFactory::_('Config')->lang_prefix .
'_IMPORT_MSG_INVALID_URL',
"Invalid url."
);
CFactory::_('Language')->set(
'admin', CFactory::_('Config')->lang_prefix .
'_IMPORT_CONTINUE', "Continue"
);
CFactory::_('Language')->set(
'admin', CFactory::_('Config')->lang_prefix .
'_IMPORT_FROM_UPLOAD', "Upload"
);
CFactory::_('Language')->set(
'admin', CFactory::_('Config')->lang_prefix .
'_IMPORT_SELECT_FILE',
"Select File"
);
CFactory::_('Language')->set(
'admin', CFactory::_('Config')->lang_prefix .
'_IMPORT_UPLOAD_BOTTON',
"Upload File"
);
CFactory::_('Language')->set(
'admin', CFactory::_('Config')->lang_prefix .
'_IMPORT_FROM_DIRECTORY',
"Directory"
);
CFactory::_('Language')->set(
'admin', CFactory::_('Config')->lang_prefix .
'_IMPORT_SELECT_FILE_DIRECTORY',
"Set the path to file"
);
CFactory::_('Language')->set(
'admin', CFactory::_('Config')->lang_prefix .
'_IMPORT_GET_BOTTON', "Get File"
);
CFactory::_('Language')->set(
'admin', CFactory::_('Config')->lang_prefix .
'_IMPORT_FROM_URL', "URL"
);
CFactory::_('Language')->set(
'admin', CFactory::_('Config')->lang_prefix .
'_IMPORT_SELECT_FILE_URL',
"Enter file URL"
);
CFactory::_('Language')->set(
'admin', CFactory::_('Config')->lang_prefix .
'_IMPORT_UPDATE_DATA',
"Import Data"
);
CFactory::_('Language')->set(
'admin', CFactory::_('Config')->lang_prefix .
'_IMPORT_FORMATS_ACCEPTED',
"formats accepted"
);
CFactory::_('Language')->set(
'admin',
CFactory::_('Config')->lang_prefix .
'_IMPORT_LINK_FILE_TO_TABLE_COLUMNS',
"Link File to Table Columns"
);
CFactory::_('Language')->set(
'admin', CFactory::_('Config')->lang_prefix .
'_IMPORT_TABLE_COLUMNS',
"Table Columns"
);
CFactory::_('Language')->set(
'admin', CFactory::_('Config')->lang_prefix .
'_IMPORT_FILE_COLUMNS',
"File Columns"
);
CFactory::_('Language')->set(
'admin', CFactory::_('Config')->lang_prefix .
'_IMPORT_PLEASE_SELECT_COLUMN',
"-- Please Select Column --"
);
CFactory::_('Language')->set(
'admin', CFactory::_('Config')->lang_prefix .
'_IMPORT_IGNORE_COLUMN',
"-- Ignore This Column --"
);
}
// check if the both array is set
if (CFactory::_('Language')->exist('both'))
{
foreach
(CFactory::_('Language')->getTarget('both') as
$keylang => $langval)
{
CFactory::_('Language')->set('admin', $keylang,
$langval);
}
}
// check if the both admin array is set
if (CFactory::_('Language')->exist('bothadmin'))
{
foreach
(CFactory::_('Language')->getTarget('bothadmin') as
$keylang => $langval)
{
CFactory::_('Language')->set('admin', $keylang,
$langval);
}
}
if (CFactory::_('Language')->exist('admin'))
{
// Trigger Event: jcb_ce_onAfterBuildAdminLang
CFactory::_('Event')->trigger(
'jcb_ce_onAfterBuildAdminLang'
);
// get language content
$langContent =
CFactory::_('Language')->getTarget('admin');
// sort the strings
ksort($langContent);
// load to global languages
$langTag = CFactory::_('Config')->get('lang_tag',
'en-GB');
CFactory::_('Compiler.Builder.Languages')->set(
"components.{$langTag}.admin",
$langContent
);
// remove tmp array
CFactory::_('Language')->setTarget('admin',
null);
return true;
}
return false;
}
public function setLangSite(string $componentName): bool
{
// Trigger Event: jcb_ce_onBeforeBuildSiteLang
CFactory::_('Event')->trigger(
'jcb_ce_onBeforeBuildSiteLang'
);
// add final list of needed lang strings
CFactory::_('Language')->set('site',
CFactory::_('Config')->lang_prefix, $componentName);
// some more defaults
CFactory::_('Language')->set('site',
'JTOOLBAR_APPLY', "Save");
CFactory::_('Language')->set('site',
'JTOOLBAR_SAVE_AS_COPY', "Save as Copy");
CFactory::_('Language')->set('site',
'JTOOLBAR_SAVE', "Save & Close");
CFactory::_('Language')->set('site',
'JTOOLBAR_SAVE_AND_NEW', "Save & New");
CFactory::_('Language')->set('site',
'JTOOLBAR_CANCEL', "Cancel");
CFactory::_('Language')->set('site',
'JTOOLBAR_CLOSE', "Close");
CFactory::_('Language')->set('site',
'JTOOLBAR_HELP', "Help");
CFactory::_('Language')->set('site',
'JGLOBAL_FIELD_ID_LABEL', "ID");
CFactory::_('Language')->set(
'site', 'JGLOBAL_FIELD_ID_DESC', "Record number
in the database."
);
CFactory::_('Language')->set(
'site', 'JGLOBAL_FIELD_MODIFIED_LABEL',
"Modified Date"
);
CFactory::_('Language')->set(
'site', 'COM_CONTENT_FIELD_MODIFIED_DESC',
"The last date this item was modified."
);
CFactory::_('Language')->set(
'site', 'JGLOBAL_FIELD_MODIFIED_BY_LABEL',
"Modified By"
);
CFactory::_('Language')->set(
'site', 'JGLOBAL_FIELD_MODIFIED_BY_DESC',
"The user who did the last modification."
);
CFactory::_('Language')->set('site',
CFactory::_('Config')->lang_prefix . '_NEW',
"New");
CFactory::_('Language')->set(
'site', CFactory::_('Config')->lang_prefix .
'_CREATE_NEW_S', "Create New %s"
);
CFactory::_('Language')->set('site',
CFactory::_('Config')->lang_prefix . '_EDIT_S',
"Edit %s");
CFactory::_('Language')->set(
'site', CFactory::_('Config')->lang_prefix .
'_NO_ACCESS_GRANTED',
"No Access Granted!"
);
CFactory::_('Language')->set(
'site', CFactory::_('Config')->lang_prefix .
'_NOT_FOUND_OR_ACCESS_DENIED',
"Not found or access denied!"
);
// check if the both array is set
if (CFactory::_('Language')->exist('both'))
{
foreach
(CFactory::_('Language')->getTarget('both') as
$keylang => $langval)
{
CFactory::_('Language')->set('site', $keylang,
$langval);
}
}
// check if the both site array is set
if (CFactory::_('Language')->exist('bothsite'))
{
foreach
(CFactory::_('Language')->getTarget('bothsite') as
$keylang => $langval)
{
CFactory::_('Language')->set('site', $keylang,
$langval);
}
}
if (CFactory::_('Language')->exist('site'))
{
// Trigger Event: jcb_ce_onAfterBuildSiteLang
CFactory::_('Event')->trigger(
'jcb_ce_onAfterBuildSiteLang'
);
// Get the site language content
$langContent =
CFactory::_('Language')->getTarget('site');
// sort the strings
ksort($langContent);
// load to global languages
$langTag = CFactory::_('Config')->get('lang_tag',
'en-GB');
CFactory::_('Compiler.Builder.Languages')->set(
"components.{$langTag}.site",
$langContent
);
// remove tmp array
CFactory::_('Language')->setTarget('site',
null);
return true;
}
return false;
}
public function setLangSiteSys(string $componentName): bool
{
// Trigger Event: jcb_ce_onBeforeBuildSiteSysLang
CFactory::_('Event')->trigger(
'jcb_ce_onBeforeBuildSiteSysLang'
);
// add final list of needed lang strings
CFactory::_('Language')->set('sitesys',
CFactory::_('Config')->lang_prefix, $componentName);
CFactory::_('Language')->set(
'sitesys', CFactory::_('Config')->lang_prefix .
'_NO_ACCESS_GRANTED',
"No Access Granted!"
);
CFactory::_('Language')->set(
'sitesys', CFactory::_('Config')->lang_prefix .
'_NOT_FOUND_OR_ACCESS_DENIED',
"Not found or access denied!"
);
// check if the both site array is set
if (CFactory::_('Language')->exist('bothsite'))
{
foreach
(CFactory::_('Language')->getTarget('bothsite') as
$keylang => $langval)
{
CFactory::_('Language')->set('sitesys',
$keylang, $langval);
}
}
if (CFactory::_('Language')->exist('sitesys'))
{
// Trigger Event: jcb_ce_onAfterBuildSiteSysLang
CFactory::_('Event')->trigger(
'jcb_ce_onAfterBuildSiteSysLang'
);
// get site system language content
$langContent =
CFactory::_('Language')->getTarget('sitesys');
// sort strings
ksort($langContent);
// load to global languages
$langTag = CFactory::_('Config')->get('lang_tag',
'en-GB');
CFactory::_('Compiler.Builder.Languages')->set(
"components.{$langTag}.sitesys",
$langContent
);
// remove tmp array
CFactory::_('Language')->setTarget('sitesys',
null);
return true;
}
return false;
}
public function setLangAdminSys(): bool
{
// Trigger Event: jcb_ce_onBeforeBuildAdminSysLang
CFactory::_('Event')->trigger(
'jcb_ce_onBeforeBuildAdminSysLang'
);
// check if the both admin array is set
if (CFactory::_('Language')->exist('bothadmin'))
{
foreach
(CFactory::_('Language')->getTarget('bothadmin') as
$keylang => $langval)
{
CFactory::_('Language')->set('adminsys',
$keylang, $langval);
}
}
if (CFactory::_('Language')->exist('adminsys'))
{
// Trigger Event: jcb_ce_onAfterBuildAdminSysLang
CFactory::_('Event')->trigger(
'jcb_ce_onAfterBuildAdminSysLang'
);
// get admin system langauge content
$langContent =
CFactory::_('Language')->getTarget('adminsys');
// sort strings
ksort($langContent);
// load to global languages
$langTag = CFactory::_('Config')->get('lang_tag',
'en-GB');
CFactory::_('Compiler.Builder.Languages')->set(
"components.{$langTag}.adminsys",
$langContent
);
// remove tmp array
CFactory::_('Language')->setTarget('adminsys',
null);
return true;
}
return false;
}
public function setCustomAdminViewListLink($view, $nameListCode)
{
if
(CFactory::_('Component')->isArray('custom_admin_views'))
{
foreach
(CFactory::_('Component')->get('custom_admin_views')
as $custom_admin_view)
{
if (isset($custom_admin_view['adminviews'])
&& ArrayHelper::check(
$custom_admin_view['adminviews']
))
{
foreach ($custom_admin_view['adminviews'] as $adminview)
{
if (isset($view['adminview'])
&& $view['adminview'] == $adminview)
{
// set the needed keys
$setId = false;
if (ArrayHelper::check(
$custom_admin_view['settings']->main_get->filter
))
{
foreach (
$custom_admin_view['settings']->main_get->filter
as $filter
)
{
if ($filter['filter_type'] == 1
|| '$id' == $filter['state_key'])
{
$setId = true;
}
}
}
// set the needed array values
$set = array(
'icon' => $custom_admin_view['icomoon'],
'link' =>
$custom_admin_view['settings']->code,
'NAME' =>
$custom_admin_view['settings']->CODE,
'name' =>
$custom_admin_view['settings']->name);
// only load to list if it has id filter
if ($setId)
{
// now load it to the global object for items list
$this->customAdminViewListLink[$nameListCode][]
= $set;
// add to set id for list view if needed
$this->customAdminViewListId[$custom_admin_view['settings']->code]
= true;
}
else
{
// now load it to the global object for tool bar
$this->customAdminDynamicButtons[$nameListCode][]
= $set;
}
// log that it has been added already
$this->customAdminAdded[$custom_admin_view['settings']->code]
= $adminview;
}
}
}
}
}
}
/**
* set the list body
*
* @param string $nameSingleCode
* @param string $nameListCode
*
* @return string
*/
public function setListBody($nameSingleCode, $nameListCode)
{
if (($items =
CFactory::_('Compiler.Builder.Lists')->get($nameListCode)) !==
null)
{
// component helper name
$Helper =
CFactory::_('Compiler.Builder.Content.One')->get('Component')
. 'Helper';
// make sure the custom links are only added once
$firstTimeBeingAdded = true;
// add the default
$body = "<?php foreach (\$this->items as \$i => \$item):
?>";
$body .= PHP_EOL . Indent::_(1) . "<?php";
$body .= PHP_EOL . Indent::_(2)
. "\$canCheckin =
\$this->user->authorise('core.manage',
'com_checkin') || \$item->checked_out ==
\$this->user->id || \$item->checked_out == 0;";
if (CFactory::_('Config')->get('joomla_version',
3) == 3)
{
$body .= PHP_EOL . Indent::_(2)
. "\$userChkOut =
Factory::getUser(\$item->checked_out);";
}
else
{
$body .= PHP_EOL . Indent::_(2)
. "\$userChkOut = Factory::getContainer()->";
$body .= PHP_EOL . Indent::_(3)
. "get(\Joomla\CMS\User\UserFactoryInterface::class)->";
$body .= PHP_EOL . Indent::_(4)
. "loadUserById(\$item->checked_out);";
}
$body .= PHP_EOL . Indent::_(2) . "\$canDo = " . $Helper
. "::getActions('" . $nameSingleCode .
"',\$item,'"
. $nameListCode . "');";
$body .= PHP_EOL . Indent::_(1) . "?>";
$body .= PHP_EOL . Indent::_(1)
. '<tr class="row<?php echo $i % 2;
?>">';
// only load if not overwritten
if
(!CFactory::_('Compiler.Builder.Field.Names')->isString($nameSingleCode
. '.ordering'))
{
$body .= PHP_EOL . Indent::_(2)
. '<td class="order nowrap center
hidden-phone">';
// check if the item has permissions.
$body .= PHP_EOL . Indent::_(2) . "<?php if
(\$canDo->get('"
.
CFactory::_('Compiler.Creator.Permission')->getGlobal($nameSingleCode,
'core.edit.state') . "')): ?>";
$body .= PHP_EOL . Indent::_(3) . "<?php";
$body .= PHP_EOL . Indent::_(4) . "\$iconClass =
'';";
$body .= PHP_EOL . Indent::_(4) . "if
(!\$this->saveOrder)";
$body .= PHP_EOL . Indent::_(4) . "{";
$body .= PHP_EOL . Indent::_(5)
. "\$iconClass = ' inactive tip-top"
. '" hasTooltip" title="'
. "' .
Html::tooltipText('JORDERINGDISABLED');";
$body .= PHP_EOL . Indent::_(4) . "}";
$body .= PHP_EOL . Indent::_(3) . "?>";
$body .= PHP_EOL . Indent::_(3)
. '<span class="sortable-handler<?php echo $iconClass;
?>">';
$body .= PHP_EOL . Indent::_(4) . '<i
class="icon-menu"></i>';
$body .= PHP_EOL . Indent::_(3) . "</span>";
$body .= PHP_EOL . Indent::_(3)
. "<?php if (\$this->saveOrder) : ?>";
$body .= PHP_EOL . Indent::_(4)
. '<input type="text" style="display:none"
name="order[]" size="5"';
$body .= PHP_EOL . Indent::_(4)
. 'value="<?php echo $item->ordering; ?>"
class="width-20 text-area-order " />';
$body .= PHP_EOL . Indent::_(3) . "<?php endif; ?>";
$body .= PHP_EOL . Indent::_(2) . "<?php else: ?>";
$body .= PHP_EOL . Indent::_(3) . "⋮";
$body .= PHP_EOL . Indent::_(2) . "<?php endif; ?>";
$body .= PHP_EOL . Indent::_(2) . "</td>";
}
$body .= PHP_EOL . Indent::_(2) . '<td class="nowrap
center">';
// check if the item has permissions.
$body .= PHP_EOL . Indent::_(2) . "<?php if
(\$canDo->get('"
.
CFactory::_('Compiler.Creator.Permission')->getGlobal($nameSingleCode,
'core.edit') . "')): ?>";
$body .= PHP_EOL . Indent::_(4)
. "<?php if (\$item->checked_out) : ?>";
$body .= PHP_EOL . Indent::_(5) . "<?php if (\$canCheckin) :
?>";
$body .= PHP_EOL . Indent::_(6)
. "<?php echo Html::_('grid.id', \$i, \$item->id);
?>";
$body .= PHP_EOL . Indent::_(5) . "<?php else: ?>";
$body .= PHP_EOL . Indent::_(6) . "□";
$body .= PHP_EOL . Indent::_(5) . "<?php endif; ?>";
$body .= PHP_EOL . Indent::_(4) . "<?php else: ?>";
$body .= PHP_EOL . Indent::_(5)
. "<?php echo Html::_('grid.id', \$i, \$item->id);
?>";
$body .= PHP_EOL . Indent::_(4) . "<?php endif; ?>";
$body .= PHP_EOL . Indent::_(2) . "<?php else: ?>";
$body .= PHP_EOL . Indent::_(3) . "□";
$body .= PHP_EOL . Indent::_(2) . "<?php endif; ?>";
$body .= PHP_EOL . Indent::_(2) . "</td>";
// check if this view has fields that should not be escaped
$doNotEscape = false;
if
(CFactory::_('Compiler.Builder.Do.Not.Escape')->exists($nameListCode))
{
$doNotEscape = true;
}
// start adding the dynamic
foreach ($items as $item)
{
// check if target is admin list
if (1 == $item['target'] || 3 == $item['target'])
{
// set some defaults
$customAdminViewButtons = '';
// set the item default class
$itemClass = 'hidden-phone';
// set the item row
$itemRow = $this->getListItemBuilder(
$item, $nameSingleCode, $nameListCode, $itemClass, $doNotEscape
);
// check if buttons was already added
if ($firstTimeBeingAdded) // TODO we must improve this to allow more
items to be targeted instead of just the first item :)
{
// get custom admin view buttons
$customAdminViewButtons
= $this->getCustomAdminViewButtons($nameListCode);
// make sure the custom admin view buttons are only added once
$firstTimeBeingAdded = false;
}
// add row to body
$body .= PHP_EOL . Indent::_(2) . "<td class=\""
. $this->getListFieldClass(
$item['code'], $nameListCode, $itemClass
) . "\">";
$body .= $itemRow;
$body .= $customAdminViewButtons;
$body .= PHP_EOL . Indent::_(2) . "</td>";
}
}
// add the defaults
if
(!CFactory::_('Compiler.Builder.Field.Names')->isString($nameSingleCode
. '.published'))
{
$body .= PHP_EOL . Indent::_(2) . '<td
class="center">';
// check if the item has permissions.
$body .= PHP_EOL . Indent::_(2) . "<?php if
(\$canDo->get('"
.
CFactory::_('Compiler.Creator.Permission')->getGlobal($nameSingleCode,
'core.edit.state') . "')) : ?>";
$body .= PHP_EOL . Indent::_(4)
. "<?php if (\$item->checked_out) : ?>";
$body .= PHP_EOL . Indent::_(5)
. "<?php if (\$canCheckin) : ?>";
$body .= PHP_EOL . Indent::_(6)
. "<?php echo Html::_('jgrid.published',
\$item->published, \$i, '"
. $nameListCode . ".', true, 'cb'); ?>";
$body .= PHP_EOL . Indent::_(5) . "<?php else: ?>";
$body .= PHP_EOL . Indent::_(6)
. "<?php echo Html::_('jgrid.published',
\$item->published, \$i, '"
. $nameListCode . ".', false, 'cb'); ?>";
$body .= PHP_EOL . Indent::_(5) . "<?php endif; ?>";
$body .= PHP_EOL . Indent::_(4) . "<?php else: ?>";
$body .= PHP_EOL . Indent::_(5)
. "<?php echo Html::_('jgrid.published',
\$item->published, \$i, '"
. $nameListCode . ".', true, 'cb'); ?>";
$body .= PHP_EOL . Indent::_(4) . "<?php endif; ?>";
$body .= PHP_EOL . Indent::_(2) . "<?php else: ?>";
$body .= PHP_EOL . Indent::_(3)
. "<?php echo Html::_('jgrid.published',
\$item->published, \$i, '"
. $nameListCode . ".', false, 'cb'); ?>";
$body .= PHP_EOL . Indent::_(2) . "<?php endif; ?>";
$body .= PHP_EOL . Indent::_(2) . "</td>";
}
if
(!CFactory::_('Compiler.Builder.Field.Names')->isString($nameSingleCode
. '.id'))
{
$body .= PHP_EOL . Indent::_(2) . '<td class="'
. $this->getListFieldClass(
$item['code'], $nameListCode,
'nowrap center hidden-phone'
) . '">';
$body .= PHP_EOL . Indent::_(3) . "<?php echo \$item->id;
?>";
$body .= PHP_EOL . Indent::_(2) . "</td>";
}
$body .= PHP_EOL . Indent::_(1) . "</tr>";
$body .= PHP_EOL . "<?php endforeach; ?>";
// return the build
return $body;
}
return '';
}
/**
* Get the list item dynamic row
*
* @param array $item The item array
* @param string $nameSingleCode The single view code name
* @param string $nameListCode The list view code name
* @param string $itemClass The table row default class
* @param bool $doNotEscape The do not escape global switch
* @param bool $class The dive class adding switch
* @param string $ref The link referral string
* @param string $escape The escape code name
* @param string $user The user code name
* @param string $refview The override of the referral view
code name
*
* @return string of the completer item value for the table row
*
*/
protected function getListItemBuilder($item, $nameSingleCode,
$nameListCode, &$itemClass,
$doNotEscape,
$class = true, $ref = null, $escape
= '$this->escape',
$user = '$this->user',
$refview = null
)
{
// check if we have relation fields
if (($field_relations =
CFactory::_('Compiler.Builder.Field.Relations')->get($nameListCode
. '.' . (int) $item['id'] . '.2')) !== null)
{
// set the fields array
$field = [];
// use custom code
$useCustomCode
= (isset($field_relations['join_type'])
&& $field_relations['join_type']
== 2
&& isset($field_relations['set'])
&& StringHelper::check(
$field_relations['set']
));
// load the main list view field
$field['[field=' . (int) $item['id'] .
']'] = $this->getListItem(
$item, $nameSingleCode, $nameListCode, $itemClass,
$doNotEscape,false, $ref, $escape, $user,
$refview
);
// code name
if (isset($item['code']) && $useCustomCode)
{
$field['$item->{' . (int) $item['id'] .
'}'] = '$item->'
. $item['code'];
}
// now load the relations
if (isset($field_relations['joinfields'])
&&
ArrayHelper::check($field_relations['joinfields']))
{
foreach ($field_relations['joinfields'] as $join)
{
$blankClass = '';
if (($join_item =
CFactory::_('Compiler.Builder.List.Join')->get($nameListCode
. '.' . (int) $join)) !== null)
{
// code block
$field['[field=' . (int) $join . ']']
= $this->getListItem(
$join_item, $nameSingleCode, $nameListCode, $blankClass,
$doNotEscape, false, $ref,
$escape, $user, $refview
);
// code name
if (isset($join_item['code'])
&& $useCustomCode)
{
$field['$item->{' . (int) $join . '}'] =
'$item->'
. $join_item['code'];
}
}
}
}
// join based on join type
if ($useCustomCode)
{
// custom code
return PHP_EOL . Indent::_(3) . "<div>"
. CFactory::_('Placeholder')->update_(
str_replace(
array_keys($field), array_values($field),
(string) $field_relations['set']
)
) . PHP_EOL . Indent::_(3) . "</div>";
}
elseif (isset($field_relations['set'])
&& StringHelper::check(
$field_relations['set']
))
{
// concatenate
return PHP_EOL . Indent::_(3) . "<div>" . implode(
$field_relations['set'],
$field
) . PHP_EOL . Indent::_(3) . "</div>";
}
// default
return PHP_EOL . Indent::_(3) . "<div>" .
implode('', $field)
. PHP_EOL . Indent::_(3) . "</div>";
}
return $this->getListItem(
$item, $nameSingleCode, $nameListCode, $itemClass, $doNotEscape,
$class, $ref, $escape, $user, $refview
);
}
/**
* Get the list item row value
*
* @param array $item The item array
* @param string $nameSingleCode The single view code name
* @param string $nameListCode The list view code name
* @param string $itemClass The table row default class
* @param bool $doNotEscape The do not escape global switch
* @param bool $class The dive class adding switch
* @param string $ref The link referral string
* @param string $escape The escape code name
* @param string $user The user code name
* @param string $refview The override of the referral view
code name
*
* @return string of the single item value for the table row
*
*/
protected function getListItem($item, $nameSingleCode, $nameListCode,
&$itemClass, $doNotEscape, $class =
true, $ref = null,
$escape = '$this->escape',
$user = '$this->user', $refview = null
)
{
// get list item code
$itemCode = $this->getListItemCode(
$item, $nameListCode, $doNotEscape, $escape
);
// add default links
$defaultLink = true;
if (StringHelper::check($refview)
&& isset($item['custom'])
&& isset($item['custom']['view'])
&& $refview === $item['custom']['view'])
{
$defaultLink = false;
}
// is this a linked item
$extends_field = $item['custom']['extends'] ??
'';
if (($item['link'] || $extends_field === 'user')
&& $defaultLink)
{
// set some defaults
$checkoutTriger = false;
// set the item default class
$itemClass = 'nowrap';
// get list item link
$itemLink = $this->getListItemLink(
$item, $checkoutTriger, $nameSingleCode, $nameListCode, $ref
);
// get list item link authority
$itemLinkAuthority = $this->getListItemLinkAuthority(
$item, $nameSingleCode, $nameListCode, $user
);
// set item row
return $this->getListItemLinkLogic(
$itemCode, $itemLink, $itemLinkAuthority, $nameListCode,
$checkoutTriger, $class
);
}
// return the default (no link)
return PHP_EOL . Indent::_(3) . "<?php echo " . $itemCode .
"; ?>";
}
/**
* Get the list item link logic
*
* @param string $itemCode The item code string
* @param string $itemLink The item link string
* @param string $itemLinkAuthority The link authority string
* @param string $nameListCode The list view code name
* @param bool $checkoutTriger The check out trigger
* @param bool $class The dive class adding switch
*
* @return string of the complete link logic of row item
*
*/
protected function getListItemLinkLogic($itemCode, $itemLink,
$itemLinkAuthority, $nameListCode,
$checkoutTriger, $class = true
)
{
// build link
$link = '';
// add class
$tab = '';
if ($class)
{
$link .= PHP_EOL . Indent::_(3) . '<div
class="name">';
$tab = Indent::_(1);
}
// the link logic
$link .= PHP_EOL . $tab . Indent::_(3) . "<?php if ("
. $itemLinkAuthority . "): ?>";
$link .= PHP_EOL . $tab . Indent::_(4) . '<a href="' .
$itemLink
. '"><?php echo ' . $itemCode . ';
?></a>';
if ($checkoutTriger)
{
$link .= PHP_EOL . $tab . Indent::_(4)
. "<?php if (\$item->checked_out): ?>";
$link .= PHP_EOL . $tab . Indent::_(5)
. "<?php echo Html::_('jgrid.checkedout', \$i,
\$userChkOut->name, \$item->checked_out_time, '"
. $nameListCode . ".', \$canCheckin); ?>";
$link .= PHP_EOL . $tab . Indent::_(4) . "<?php endif;
?>";
}
$link .= PHP_EOL . $tab . Indent::_(3) . "<?php else:
?>";
$link .= PHP_EOL . $tab . Indent::_(4) . "<?php echo " .
$itemCode
. "; ?>";
$link .= PHP_EOL . $tab . Indent::_(3) . "<?php endif;
?>";
// add class
if ($class)
{
$link .= PHP_EOL . Indent::_(3) . "</div>";
}
// return the link logic
return $link;
}
/**
* Get the custom admin view buttons
*
* @param string $nameListCode The list view code name
* @param string $ref The link referral string
*
* @return string of the custom admin view buttons
*
*/
protected function getCustomAdminViewButtons($nameListCode, $ref =
'')
{
$customAdminViewButton = '';
// check if custom links should be added to this list views
if (isset($this->customAdminViewListLink[$nameListCode])
&& ArrayHelper::check(
$this->customAdminViewListLink[$nameListCode]
))
{
// start building the links
$customAdminViewButton .= PHP_EOL . Indent::_(3)
. '<div class="btn-group">';
foreach (
$this->customAdminViewListLink[$nameListCode] as
$customLinkView
)
{
$customAdminViewButton .= PHP_EOL . Indent::_(3)
. "<?php if (\$canDo->get('" .
$customLinkView['link']
. ".access')): ?>";
$customAdminViewButton .= PHP_EOL . Indent::_(4)
. '<a class="hasTooltip btn btn-mini"
href="index.php?option=com_'
. CFactory::_('Config')->component_code_name .
'&view='
. $customLinkView['link'] . '&id=<?php echo
$item->id; ?>'
. $ref . '" title="<?php echo Text:' .
':_(' . "'COM_"
.
CFactory::_('Compiler.Builder.Content.One')->get('COMPONENT')
. '_' . $customLinkView['NAME'] . "'"
. '); ?>" ><span class="icon-' .
$customLinkView['icon']
. '"></span></a>';
$customAdminViewButton .= PHP_EOL . Indent::_(3)
. "<?php else: ?>";
$customAdminViewButton .= PHP_EOL . Indent::_(4)
. '<a class="hasTooltip btn btn-mini disabled"
href="#" title="<?php echo Text:'
. ':_(' . "'COM_" .
CFactory::_('Compiler.Builder.Content.One')->get('COMPONENT')
. '_' . $customLinkView['NAME']
. "'" . '); ?>"><span
class="icon-'
. $customLinkView['icon'] .
'"></span></a>';
$customAdminViewButton .= PHP_EOL . Indent::_(3)
. "<?php endif; ?>";
}
$customAdminViewButton .= PHP_EOL . Indent::_(3) .
'</div>';
}
return $customAdminViewButton;
}
/**
* Get the list item code value
*
* @param array $item The item array
* @param string $nameListCode The list view code name
* @param bool $doNotEscape The do not escape global switch
* @param string $escape The escape code name
*
* @return string of the single item code
*
*/
protected function getListItemCode(&$item, $nameListCode,
$doNotEscape,
$escape = '$this->escape'
)
{
// first update the code id needed
if (isset($item['custom'])
&& ArrayHelper::check(
$item['custom']
)
&& isset($item['custom']['table'])
&&
StringHelper::check($item['custom']['table']))
{
$item['id_code'] = $item['code'];
if (!$item['multiple'])
{
$item['code'] = $item['code'] . '_' .
$item['custom']['text'];
}
}
// set the extends value
$extends_field = $item['custom']['extends'] ??
'';
$extends_text = $item['custom']['text'] ??
'';
// check if category
if ($item['type'] === 'category' &&
!$item['title'])
{
return $escape . '($item->category_title)';
}
// check if user
elseif ($item['type'] === 'user')
{
if (CFactory::_('Config')->get('joomla_version',
3) == 3)
{
return 'Factory::getUser((int)$item->' .
$item['code'] . ')->name';
}
else
{
return 'Factory::getContainer()->'
. 'get(\Joomla\CMS\User\UserFactoryInterface::class)->'
. 'loadUserById((int) $item->' . $item['code']
. ')->name';
}
}
// check if custom user
elseif (isset($item['custom'])
&& ArrayHelper::check($item['custom'])
&& $extends_field === 'user'
&& isset($item['id_code']))
{
if (CFactory::_('Config')->get('joomla_version',
3) == 3)
{
return 'Factory::getUser((int)$item->' .
$item['id_code'] . ')->name';
}
else
{
return 'Factory::getContainer()->'
. 'get(\Joomla\CMS\User\UserFactoryInterface::class)->'
. 'loadUserById((int) $item->' .
$item['id_code'] . ')->name';
}
}
// check if translated value is used
elseif
(CFactory::_('Compiler.Builder.Selection.Translation')->
exists($nameListCode . '.' . $item['code']))
{
return 'Text:' . ':_($item->' .
$item['code'] . ')';
}
elseif (isset($item['custom'])
&& ArrayHelper::check($item['custom'])
&& ($extends_text === 'user' || $extends_field ===
'user'))
{
if (CFactory::_('Config')->get('joomla_version',
3) == 3)
{
return 'Factory::getUser((int)$item->' .
$item['code'] . ')->name';
}
else
{
return 'Factory::getContainer()->'
. 'get(\Joomla\CMS\User\UserFactoryInterface::class)->'
. 'loadUserById((int) $item->' . $item['code']
. ')->name';
}
}
elseif ($doNotEscape)
{
if
(CFactory::_('Compiler.Builder.Do.Not.Escape')->exists($nameListCode
. '.' . $item['code']))
{
return '$item->' . $item['code'];
}
}
// default
return $escape . '($item->' . $item['code'] .
')';
}
/**
* Get the list item link
*
* @param array $item The item array
* @param bool $checkoutTriger The checkout trigger switch
* @param string $nameSingleCode The single view code name
* @param string $nameListCode The list view code name
* @param string $ref The link referral string
*
* @return string of the single item link
*
*/
protected function getListItemLink($item, &$checkoutTriger,
$nameSingleCode, $nameListCode, $ref =
null
)
{
// set referal if not set
$referal = '';
if (!$ref)
{
$ref = '&return=<?php echo $this->return_here;
?>';
}
// in linked tab/view so must add ref to default
else
{
$referal = $ref;
}
// if to be linked
if ($item['type'] === 'category' &&
!$item['title'])
{
// return the link to category
return
'index.php?option=com_categories&task=category.edit&id=<?php
echo (int)$item->'
. $item['code'] . '; ?>&extension='
.
CFactory::_('Compiler.Builder.Category')->get("{$nameListCode}.extension",
'error');
}
elseif ($item['type'] === 'user' &&
!$item['title'])
{
// return user link
return
'index.php?option=com_users&task=user.edit&id=<?php echo
(int) $item->'
. $item['code'] . ' ?>';
}
elseif (isset($item['custom'])
&& ArrayHelper::check(
$item['custom']
)
&& $item['custom']['extends'] !=
'user'
&& !$item['title']
&& isset($item['id_code']))
{
// build GUID link
if (isset($item['custom']['id']) &&
$item['custom']['id'] !== 'id')
{
// link to that linked item
return 'index.php?option=' .
$item['custom']['component'] . '&view='
. $item['custom']['views'] .
'&task=' . $item['custom']['view']
. '.edit&id=<?php echo $item->' .
$item['id_code'] . '_id; ?>'
. $ref;
}
// link to that linked item
return 'index.php?option=' .
$item['custom']['component'] . '&view='
. $item['custom']['views'] . '&task='
. $item['custom']['view']
. '.edit&id=<?php echo $item->' .
$item['id_code'] . '; ?>'
. $ref;
}
elseif (isset($item['custom'])
&& ArrayHelper::check(
$item['custom']
)
&& $item['custom']['extends'] ===
'user'
&& !$item['title']
&& isset($item['id_code']))
{
// return user link
return
'index.php?option=com_users&task=user.edit&id=<?php echo
(int) $item->'
. $item['id_code'] . ' ?>';
}
// make sure to triger the checkout
$checkoutTriger = true;
// basic default item link
return '<?php echo $edit; ?>&id=<?php echo
$item->id; ?>' . $referal;
}
/**
* Get the list item authority
*
* @param array $item The item array
* @param string $nameSingleCode The single view code name
* @param string $nameListCode The list view code name
* @param string $user The user code name
*
* @return string of the single item link authority
*
*/
protected function getListItemLinkAuthority($item, $nameSingleCode,
$nameListCode, $user = '$this->user'
)
{
// if to be linked
if ($item['type'] === 'category' &&
!$item['title'])
{
// get the other view
$otherView =
CFactory::_('Compiler.Builder.Category.Code')->getString("{$nameSingleCode}.view",
'error');
// return the authority to category
return $user . "->authorise('core.edit',
'com_"
. CFactory::_('Config')->component_code_name .
"." . $otherView
. ".category.' . (int)\$item->" .
$item['code'] . ")";
}
elseif ($item['type'] === 'user' &&
!$item['title'])
{
// return user authority
return $user . "->authorise('core.edit',
'com_users')";
}
elseif (isset($item['custom'])
&& ArrayHelper::check(
$item['custom']
)
&& $item['custom']['extends'] !=
'user'
&& !$item['title']
&& isset($item['id_code']))
{
// do this with GUID
if (isset($item['custom']['id']) &&
$item['custom']['id'] !== 'id')
{
return $user . "->authorise('" .
CFactory::_('Compiler.Creator.Permission')->getAction($item['custom']['view'],
'core.edit')
. "', 'com_" .
CFactory::_('Config')->component_code_name . "."
. $item['custom']['view'] . ".' . (int)
\$item->" . $item['id_code'] . "_id)";
}
else
{
return $user . "->authorise('" .
CFactory::_('Compiler.Creator.Permission')->getAction($item['custom']['view'],
'core.edit')
. "', 'com_" .
CFactory::_('Config')->component_code_name . "."
. $item['custom']['view'] . ".' . (int)
\$item->" . $item['id_code'] . ")";
}
}
elseif (isset($item['custom'])
&& ArrayHelper::check(
$item['custom']
)
&& $item['custom']['extends'] ===
'user'
&& !$item['title']
&& isset($item['id_code']))
{
// return user link
return $user . "->authorise('core.edit',
'com_users')";
}
// set core permissions.
return "\$canDo->get('" .
CFactory::_('Compiler.Creator.Permission')->getGlobal($nameSingleCode,
'core.edit') . "')";
}
/**
* Get the list field class
*
* @param string $name The field code name
* @param string $nameListCode The list view code name
* @param string $default The default
*
* @return string The list field class
*
*/
protected function getListFieldClass($name, $nameListCode, $default =
'')
{
return
CFactory::_('Compiler.Builder.List.Field.Class')->get($nameListCode
. '.' . $name, $default);
}
/**
* set the default views body
*
* @param string $nameSingleCode
* @param string $nameListCode
*
* @return string
*/
public function setDefaultViewsBody(string $nameSingleCode, string
$nameListCode): string
{
// set component name
$component = CFactory::_('Config')->component_code_name;
$Component = ucfirst((string) $component);
$COMPONENT = strtoupper((string) $component);
// set uppercase view
$VIEWS = strtoupper($nameListCode);
// build the body
$body = [];
// check if the filter type is sidebar (1 = sidebar)
if
(CFactory::_('Compiler.Builder.Admin.Filter.Type')->get($nameListCode,
1) == 1)
{
$body[] = "<script
type=\"text/javascript\">";
$body[] = Indent::_(1) . "Joomla.orderTable = function()";
$body[] = Indent::_(1) . "{";
$body[] = Indent::_(2)
. "table =
document.getElementById(\"sortTable\");";
$body[] = Indent::_(2)
. "direction =
document.getElementById(\"directionTable\");";
$body[] = Indent::_(2)
. "order = table.options[table.selectedIndex].value;";
$body[] = Indent::_(2)
. "if (order != '<?php echo \$this->listOrder;
?>')";
$body[] = Indent::_(2) . "{";
$body[] = Indent::_(3) . "dirn = 'asc';";
$body[] = Indent::_(2) . "}";
$body[] = Indent::_(2) . "else";
$body[] = Indent::_(2) . "{";
$body[] = Indent::_(3)
. "dirn =
direction.options[direction.selectedIndex].value;";
$body[] = Indent::_(2) . "}";
$body[] = Indent::_(2) . "Joomla.tableOrdering(order, dirn,
'');";
$body[] = Indent::_(1) . "}";
$body[] = "</script>";
}
// Trigger Event: jcb_ce_onSetDefaultViewsBodyTop
CFactory::_('Event')->trigger(
'jcb_ce_onSetDefaultViewsBodyTop', [&$body,
&$nameSingleCode, &$nameListCode]
);
$body[] = "<form action=\"<?php echo
Route::_('index.php?option=com_"
. $component . "&view=" . $nameListCode
. "'); ?>\" method=\"post\"
name=\"adminForm\" id=\"adminForm\">";
if (CFactory::_('Config')->get('joomla_version',
3) == 3)
{
$body[] = "<?php if(!empty( \$this->sidebar)): ?>";
$body[] = Indent::_(1)
. "<div id=\"j-sidebar-container\"
class=\"span2\">";
$body[] = Indent::_(2) . "<?php echo \$this->sidebar;
?>";
$body[] = Indent::_(1) . "</div>";
$body[] = Indent::_(1)
. "<div id=\"j-main-container\"
class=\"span10\">";
$body[] = "<?php else : ?>";
$body[] = Indent::_(1) . "<div
id=\"j-main-container\">";
$body[] = "<?php endif; ?>";
}
else
{
$body[] = Indent::_(1)
. "<div id=\"j-main-container\">";
}
// Trigger Event: jcb_ce_onSetDefaultViewsFormTop
CFactory::_('Event')->trigger(
'jcb_ce_onSetDefaultViewsFormTop', [&$body,
&$nameSingleCode, &$nameListCode]
);
// check if the filter type is sidebar (2 = topbar)
if
(CFactory::_('Compiler.Builder.Admin.Filter.Type')->get($nameListCode,
1) == 2)
{
$body[] = "<?php";
// build code to add the trash helper layout
$addTrashHelper = Indent::_(1)
. "echo LayoutHelper::render('trashhelper',
\$this);";
// add the trash helper layout if found in JCB
if
(CFactory::_('Templatelayout.Data')->set($addTrashHelper,
$nameListCode))
{
$body[] = Indent::_(1) . "//" . Line::_(
__LINE__,__CLASS__
) . " Add the trash helper layout";
$body[] = $addTrashHelper;
}
// add the new search toolbar ;)
$body[] = Indent::_(1) . "//" . Line::_(
__LINE__,__CLASS__
) . " Add the searchtools";
$body[] = Indent::_(1)
. "echo
LayoutHelper::render('joomla.searchtools.default',
array('view' => \$this));";
$body[] = "?>";
}
$body[] = "<?php if (empty(\$this->items)): ?>";
// check if the filter type is sidebar (1 = sidebar)
if
(CFactory::_('Compiler.Builder.Admin.Filter.Type')->get($nameListCode,
1) == 1)
{
$body[] = Indent::_(1)
. "<?php echo
\$this->loadTemplate('toolbar');?>";
}
$body[] = Indent::_(1)
. "<div class=\"alert alert-no-items\">";
$body[] = Indent::_(2)
. "<?php echo Text:" .
":_('JGLOBAL_NO_MATCHING_RESULTS'); ?>";
$body[] = Indent::_(1) . "</div>";
$body[] = "<?php else : ?>";
// check if the filter type is sidebar (1 = sidebar)
if
(CFactory::_('Compiler.Builder.Admin.Filter.Type')->get($nameListCode,
1) == 1)
{
$body[] = Indent::_(1)
. "<?php echo
\$this->loadTemplate('toolbar');?>";
}
$body[] = Indent::_(1) . "<table class=\"table
table-striped\" id=\""
. $nameSingleCode . "List\">";
$body[] = Indent::_(2)
. "<thead><?php echo
\$this->loadTemplate('head');?></thead>";
$body[] = Indent::_(2)
. "<tfoot><?php echo
\$this->loadTemplate('foot');?></tfoot>";
$body[] = Indent::_(2)
. "<tbody><?php echo
\$this->loadTemplate('body');?></tbody>";
$body[] = Indent::_(1) . "</table>";
if (CFactory::_('Config')->get('joomla_version',
3) == 3)
{
$body[] = Indent::_(1) . "<?php //" . Line::_(
__LINE__, __CLASS__
) . " Load the batch processing form. ?>";
$body[] = Indent::_(1)
. "<?php if (\$this->canCreate &&
\$this->canEdit) : ?>";
$body[] = Indent::_(2) . "<?php echo Html::_(";
$body[] = Indent::_(3) .
"'bootstrap.renderModal',";
$body[] = Indent::_(3) . "'collapseModal',";
$body[] = Indent::_(3) . "array(";
$body[] = Indent::_(4) . "'title' => Text:" .
":_('COM_" . $COMPONENT . "_"
. $VIEWS
. "_BATCH_OPTIONS'),";
$body[] = Indent::_(4)
. "'footer' =>
\$this->loadTemplate('batch_footer')";
$body[] = Indent::_(3) . "),";
$body[] = Indent::_(3) .
"\$this->loadTemplate('batch_body')";
$body[] = Indent::_(2) . "); ?>";
$body[] = Indent::_(1) . "<?php endif; ?>";
}
// check if the filter type is sidebar (1 = sidebar)
if
(CFactory::_('Compiler.Builder.Admin.Filter.Type')->get($nameListCode,
1) == 1)
{
$body[] = Indent::_(1)
. "<input type=\"hidden\"
name=\"filter_order\" value=\"<?php echo
\$this->listOrder; ?>\" />";
$body[] = Indent::_(1)
. "<input type=\"hidden\"
name=\"filter_order_Dir\" value=\"<?php echo
\$this->listDirn; ?>\" />";
}
$body[] = Indent::_(1)
. "<input type=\"hidden\"
name=\"boxchecked\" value=\"0\" />";
$body[] = Indent::_(1) . "</div>";
$body[] = "<?php endif; ?>";
$body[] = Indent::_(1)
. "<input type=\"hidden\" name=\"task\"
value=\"\" />";
$body[] = Indent::_(1) . "<?php echo
Html::_('form.token'); ?>";
// Trigger Event: jcb_ce_onSetDefaultViewsFormBottom
CFactory::_('Event')->trigger(
'jcb_ce_onSetDefaultViewsFormBottom', [&$body,
&$nameSingleCode, &$nameListCode]
);
$body[] = "</form>";
// Trigger Event: jcb_ce_onSetDefaultViewsBodyBottom
CFactory::_('Event')->trigger(
'jcb_ce_onSetDefaultViewsBodyBottom', [&$body,
&$nameSingleCode, &$nameListCode]
);
return implode(PHP_EOL, $body);
}
/**
* set the list body table head
*
* @param string $nameSingleCode
* @param string $nameListCode
*
* @return string
*/
public function setListHead($nameSingleCode, $nameListCode)
{
if (($items =
CFactory::_('Compiler.Builder.Lists')->get($nameListCode)) !==
null)
{
// set the Html values based on filter type
$jhtml_sort = "grid.sort";
$jhtml_sort_icon = "<i
class=\"icon-menu-2\"></i>";
$jhtml_sort_icon_2 = "";
// for the new filter (2 = topbar)
if
(CFactory::_('Compiler.Builder.Admin.Filter.Type')->get($nameListCode,
1) == 2)
{
$jhtml_sort = "searchtools.sort";
$jhtml_sort_icon = "";
$jhtml_sort_icon_2 = ", 'icon-menu-2'";
}
// main lang prefix
$langView = CFactory::_('Config')->lang_prefix .
'_'
. StringHelper::safe($nameSingleCode, 'U');
// set status lang
$statusLangName = $langView . '_STATUS';
// set id lang
$idLangName = $langView . '_ID';
// add to lang array
CFactory::_('Language')->set(CFactory::_('Config')->lang_target,
$statusLangName, 'Status');
// add to lang array
CFactory::_('Language')->set(CFactory::_('Config')->lang_target,
$idLangName, 'Id');
// set default
$head = '<tr>';
$head .= PHP_EOL . Indent::_(1)
. "<?php if (\$this->canEdit&& \$this->canState):
?>";
if
(!CFactory::_('Compiler.Builder.Field.Names')->isString($nameSingleCode
. '.ordering'))
{
$head .= PHP_EOL . Indent::_(2)
. '<th width="1%" class="nowrap center
hidden-phone">';
$head .= PHP_EOL . Indent::_(3)
. "<?php echo Html::_('" . $jhtml_sort .
"', '"
. $jhtml_sort_icon . "'"
. ", 'a.ordering', \$this->listDirn,
\$this->listOrder, null, 'asc',
'JGRID_HEADING_ORDERING'"
. $jhtml_sort_icon_2 . "); ?>";
$head .= PHP_EOL . Indent::_(2) . "</th>";
}
$head .= PHP_EOL . Indent::_(2)
. '<th width="20" class="nowrap
center">';
$head .= PHP_EOL . Indent::_(3)
. "<?php echo Html::_('grid.checkall'); ?>";
$head .= PHP_EOL . Indent::_(2) . "</th>";
$head .= PHP_EOL . Indent::_(1) . "<?php else: ?>";
$head .= PHP_EOL . Indent::_(2)
. '<th width="20" class="nowrap center
hidden-phone">';
$head .= PHP_EOL . Indent::_(3) . "▾";
$head .= PHP_EOL . Indent::_(2) . "</th>";
$head .= PHP_EOL . Indent::_(2)
. '<th width="20" class="nowrap
center">';
$head .= PHP_EOL . Indent::_(3) . "■";
$head .= PHP_EOL . Indent::_(2) . "</th>";
$head .= PHP_EOL . Indent::_(1) . "<?php endif; ?>";
// set footer Column number
$this->listColnrBuilder[$nameListCode] = 4;
// build the dynamic fields
foreach ($items as $item)
{
// check if target is admin list
if (1 == $item['target'] || 3 == $item['target'])
{
// check if we have an over-ride
if (($list_head_override =
CFactory::_('Compiler.Builder.List.Head.Override')->
get($nameListCode . '.' . (int) $item['id'])) !==
null)
{
$item['lang'] = $list_head_override;
}
$class = 'nowrap hidden-phone';
if ($item['link'])
{
$class = 'nowrap';
}
// add sort options if required
if ($item['sort'])
{
// if category
if ($item['type'] === 'category')
{
// only one category per/view allowed at this point
$title = "<?php echo Html::_('" . $jhtml_sort
. "', '"
. $item['lang'] . "',
'category_title"
. "', \$this->listDirn, \$this->listOrder);
?>";
}
// set the custom code
elseif (ArrayHelper::check(
$item['custom']
))
{
// keep an eye on this
$title = "<?php echo Html::_('" . $jhtml_sort
. "', '"
. $item['lang'] . "', '" .
$item['custom']['db']
. "." . $item['custom']['text']
. "', \$this->listDirn, \$this->listOrder);
?>";
}
else
{
$title = "<?php echo Html::_('" . $jhtml_sort
. "', '"
. $item['lang'] . "', 'a." .
$item['code']
. "', \$this->listDirn, \$this->listOrder);
?>";
}
}
else
{
$title = "<?php echo Text:" . ":_('" .
$item['lang']
. "'); ?>";
}
$head .= PHP_EOL . Indent::_(1) . '<th class="' .
$class
. '" >';
$head .= PHP_EOL . Indent::_(3) . $title;
$head .= PHP_EOL . Indent::_(1) . "</th>";
$this->listColnrBuilder[$nameListCode]++;
}
}
// set default
if
(!CFactory::_('Compiler.Builder.Field.Names')->isString($nameSingleCode
. '.published'))
{
$head .= PHP_EOL . Indent::_(1)
. "<?php if (\$this->canState): ?>";
$head .= PHP_EOL . Indent::_(2)
. '<th width="10" class="nowrap center"
>';
$head .= PHP_EOL . Indent::_(3)
. "<?php echo Html::_('" . $jhtml_sort .
"', '"
. $statusLangName
. "', 'a.published', \$this->listDirn,
\$this->listOrder); ?>";
$head .= PHP_EOL . Indent::_(2) . "</th>";
$head .= PHP_EOL . Indent::_(1) . "<?php else: ?>";
$head .= PHP_EOL . Indent::_(2)
. '<th width="10" class="nowrap center"
>';
$head .= PHP_EOL . Indent::_(3) . "<?php echo Text:" .
":_('"
. $statusLangName . "'); ?>";
$head .= PHP_EOL . Indent::_(2) . "</th>";
$head .= PHP_EOL . Indent::_(1) . "<?php endif; ?>";
}
if
(!CFactory::_('Compiler.Builder.Field.Names')->isString($nameSingleCode
. '.id'))
{
$head .= PHP_EOL . Indent::_(1)
. '<th width="5" class="nowrap center
hidden-phone" >';
$head .= PHP_EOL . Indent::_(3)
. "<?php echo Html::_('" . $jhtml_sort .
"', '"
. $idLangName
. "', 'a.id', \$this->listDirn,
\$this->listOrder); ?>";
$head .= PHP_EOL . Indent::_(1) . "</th>";
}
$head .= PHP_EOL . "</tr>";
return $head;
}
return '';
}
public function setListColnr($nameListCode)
{
if (isset($this->listColnrBuilder[$nameListCode]))
{
return $this->listColnrBuilder[$nameListCode];
}
return '';
}
/**
* set Tabs Layouts Fields Array
*
* @param string $nameSingleCode The single view name
*
* @return string The array
*
*/
public function getTabLayoutFieldsArray($nameSingleCode)
{
// check if the load build is set for this view
if
(CFactory::_('Compiler.Builder.Layout')->exists($nameSingleCode))
{
$layout_builder =
CFactory::_('Compiler.Builder.Layout')->get($nameSingleCode);
$layoutArray = [];
foreach ($layout_builder as $layout => $alignments)
{
$alignments = (array) $alignments;
// sort the alignments
ksort($alignments);
$alignmentArray = [];
foreach ($alignments as $alignment => $fields)
{
$fields = (array) $fields;
// sort the fields
ksort($fields);
$fieldArray = [];
foreach ($fields as $field)
{
// add each field
$fieldArray[] = PHP_EOL . Indent::_(4) . "'" . $field
. "'";
}
// add the alignemnt key
$alignmentArray[] = PHP_EOL . Indent::_(3) . "'"
. $this->alignmentOptions[$alignment] . "' =>
array("
. implode(',', $fieldArray) . PHP_EOL . Indent::_(3)
. ")";
}
// add the layout key
$layoutArray[] = PHP_EOL . Indent::_(2) . "'"
. StringHelper::safe($layout)
. "' => array(" . implode(',',
$alignmentArray) . PHP_EOL
. Indent::_(2) . ")";
}
return 'array(' . implode(',', $layoutArray) .
PHP_EOL . Indent::_(
1
) . ")";
}
return 'array()';
}
/**
* set Edit Body
*
* @param array $view The view data
*
* @return string The edit body
*
*/
public function setEditBody(&$view)
{
// set view name
$nameSingleCode = $view['settings']->name_single_code;
// main lang prefix
$langView = CFactory::_('Config')->lang_prefix .
'_'
. StringHelper::safe($nameSingleCode, 'U');
// check if the load build is set for this view
if
(CFactory::_('Compiler.Builder.Layout')->exists($nameSingleCode))
{
// reset the linked keys
$keys = [];
$linkedViewIdentifier = [];
// set the linked view tabs
$linkedTab = $this->getEditBodyLinkedAdminViewsTabs(
$view, $nameSingleCode, $keys, $linkedViewIdentifier
);
// custom tab searching array
$searchTabs = [];
// reset tab values
$leftside = '';
$rightside = '';
$side_open = '';
$side_close = '';
$footer = '';
$header = '';
$mainwidth = 12;
$sidewidth = 0;
$width_class = 'span';
$row_class = 'row-fluid form-horizontal-desktop';
$form_class = 'form-horizontal';
$uitab = 'bootstrap';
if (CFactory::_('Config')->get('joomla_version',
3) != 3)
{
$width_class = 'col-md-';
$row_class = 'row';
$form_class = 'main-card';
$uitab = 'uitab';
$side_open = '<div class="m-md-3">';
$side_close = '</div>';
}
// get the tabs with positions
$tabBucket = $this->getEditBodyTabs(
$nameSingleCode, $langView, $linkedTab, $keys,
$linkedViewIdentifier, $searchTabs, $leftside, $rightside,
$footer, $header, $mainwidth, $sidewidth
);
// tab counter
$tabCounter = 0;
// check if width is still 12
$span = '';
if ($mainwidth != 12)
{
$span = $width_class . $mainwidth;
}
// start building body
$body = PHP_EOL . '<div class="' . $form_class .
'">';
if (CFactory::_('Config')->get('joomla_version',
3) != 3 &&
(strlen((string) $leftside) > 2 || strlen((string) $rightside) >
2))
{
$body .= PHP_EOL . '<div class="row">';
}
if (StringHelper::check($span))
{
$body .= PHP_EOL . Indent::_(1) . '<div class="' .
$span . '">';
}
// now build the dynamic tabs
foreach ($tabBucket as $tabCodeName => $positions)
{
// get lang string
$tabLangName = $positions['lang'];
// build main center position
$main = '';
$mainbottom = '';
$this->setEditBodyTabMainCenterPositionDiv(
$main, $mainbottom, $positions
);
// set acctive tab (must be in side foreach loop to get active tab code
name)
if ($tabCounter == 0)
{
$body .= PHP_EOL . PHP_EOL . Indent::_(1)
. "<?php echo Html::_('{$uitab}.startTabSet',
'"
. $nameSingleCode . "Tab', ['active' =>
'"
. $tabCodeName . "', 'recall' => true]);
?>";
}
// check if custom tab must be added
if (($_customTabHTML = $this->addCustomTabs(
$searchTabs[$tabCodeName], $nameSingleCode, 1
)) !== false)
{
$body .= $_customTabHTML;
}
// if this is a linked view set permissions
$closeIT = false;
if (ArrayHelper::check($linkedViewIdentifier)
&& in_array($tabCodeName, $linkedViewIdentifier))
{
// get view name
$linkedViewId = array_search(
$tabCodeName, $linkedViewIdentifier
);
$linkedViewData =
CFactory::_('Adminview.Data')->get($linkedViewId);
$linkedCodeName = StringHelper::safe(
$linkedViewData->name_single
);
// check if the item has permissions.
if
(CFactory::_('Compiler.Creator.Permission')->globalExist($linkedCodeName,
'core.access'))
{
$body .= PHP_EOL . PHP_EOL . Indent::_(1)
. "<?php if (\$this->canDo->get('"
.
CFactory::_('Compiler.Creator.Permission')->getGlobal($linkedCodeName,
'core.access') . "')) : ?>";
$closeIT = true;
}
else
{
$body .= PHP_EOL;
}
}
else
{
$body .= PHP_EOL;
}
// start addtab body
$body .= PHP_EOL . Indent::_(1)
. "<?php echo Html::_('{$uitab}.addTab',
'"
. $nameSingleCode . "Tab', '" . $tabCodeName .
"', Text:"
. ":_('" . $tabLangName . "', true));
?>";
// add the main
$body .= PHP_EOL . Indent::_(2)
. '<div class="' . $row_class .
'">';
$body .= $main;
$body .= PHP_EOL . Indent::_(2) . "</div>";
// add main body bottom div if needed
if (strlen((string) $mainbottom) > 0)
{
// add the main bottom
$body .= PHP_EOL . Indent::_(2)
. '<div class="' . $row_class .
'">';
$body .= $mainbottom;
$body .= PHP_EOL . Indent::_(2) . "</div>";
}
// end addtab body
$body .= PHP_EOL . Indent::_(1)
. "<?php echo Html::_('{$uitab}.endTab');
?>";
// if we had permissions added
if ($closeIT)
{
$body .= PHP_EOL . Indent::_(1) . "<?php endif; ?>";
}
// check if custom tab must be added
if (($_customTabHTML = $this->addCustomTabs(
$searchTabs[$tabCodeName], $nameSingleCode, 2
)) !== false)
{
$body .= $_customTabHTML;
}
// set counter
$tabCounter++;
}
// add option to load forms loaded in via plugins (TODO) we may want to
move these tab locations
$body .= PHP_EOL . PHP_EOL . Indent::_(1)
. "<?php \$this->ignore_fieldsets =
array('details','metadata','vdmmetadata','accesscontrol');
?>";
$body .= PHP_EOL . Indent::_(1) . "<?php \$this->tab_name =
'"
. $nameSingleCode . "Tab'; ?>";
$body .= PHP_EOL . Indent::_(1)
. "<?php echo
LayoutHelper::render('joomla.edit.params', \$this); ?>";
// add the publish and meta data tabs
$body .= $this->getEditBodyPublishMetaTabs(
$nameSingleCode, $langView
);
// end the tab set
$body .= PHP_EOL . PHP_EOL . Indent::_(1)
. "<?php echo Html::_('{$uitab}.endTabSet');
?>";
$body .= PHP_EOL . PHP_EOL . Indent::_(1) . "<div>";
$body .= PHP_EOL . Indent::_(2)
. '<input type="hidden" name="task"
value="' . $nameSingleCode
. '.edit" />';
$body .= PHP_EOL . Indent::_(2)
. "<?php echo Html::_('form.token'); ?>";
$body .= PHP_EOL . Indent::_(1) . "</div>";
// close divs
if (StringHelper::check($span))
{
$body .= PHP_EOL . Indent::_(1) . "</div>";
}
if (CFactory::_('Config')->get('joomla_version',
3) == 3)
{
$body .= PHP_EOL . "</div>";
}
// check if left has been set
if (strlen((string) $leftside) > 2)
{
$left = PHP_EOL . Indent::_(1) . '<div class="' .
$width_class . $sidewidth . '">' . $side_open;
$left .= $leftside;
$left .= PHP_EOL . Indent::_(1) . $side_close .
"</div>";
}
else
{
$left = '';
}
// check if right has been set
if (strlen((string) $rightside) > 2)
{
$right = PHP_EOL . Indent::_(1) . '<div class="' .
$width_class . $sidewidth . '">' . $side_open;
$right .= $rightside;
$right .= PHP_EOL . Indent::_(1) . $side_close .
"</div>";
}
else
{
$right = '';
}
if (CFactory::_('Config')->get('joomla_version',
3) != 3 &&
(strlen((string) $leftside) > 2 || strlen((string) $rightside) >
2))
{
$right .= PHP_EOL . '</div>';
$right .= PHP_EOL . '</div>';
}
elseif
(CFactory::_('Config')->get('joomla_version', 3) !=
3)
{
$body .= PHP_EOL . '</div>';
}
// set active tab and return
return $header . $left . $body . $right . $footer;
}
return '';
}
/**
* get Edit Body Linked Admin Views
*
* @param array $view The view data
* @param string $nameSingleCode The single view name
* @param array $keys The tabs to add in layout
* @param array $linkedViewIdentifier The linked view identifier
*
* @return array The linked Admin Views tabs
*
*/
protected function getEditBodyLinkedAdminViewsTabs(&$view,
&$nameSingleCode,
&$keys, &$linkedViewIdentifier
)
{
// start linked tabs bucket
$linkedTab = [];
// check if the view has linked admin view
if (($linkedAdminViews =
CFactory::_('Registry')->get('builder.linked_admin_views.'
. $nameSingleCode, null)) !== null
&& ArrayHelper::check($linkedAdminViews))
{
foreach ($linkedAdminViews as $linkedView)
{
// when this happens tell me.
if (!isset($view['settings']->tabs[(int)
$linkedView['tab']]))
{
echo "Tab Mismatch Oops! Check your linked views in admin view
($nameSingleCode) that they line-up.";
echo '<pre>';
var_dump($view['settings']->tabs, $linkedView);
exit;
}
// get the tab name
$tabName = $view['settings']->tabs[(int)
$linkedView['tab']];
// update the tab counter
CFactory::_('Compiler.Builder.Tab.Counter')->set($nameSingleCode
. '.' . $linkedView['tab'], $tabName);
// add the linked view
$linkedTab[$linkedView['adminview']] =
$linkedView['tab'];
// set the keys if values are set
if (StringHelper::check($linkedView['key'])
&& StringHelper::check(
$linkedView['parentkey']
))
{
$keys[$linkedView['adminview']]
= array('key' => $linkedView['key'],
'parentKey' => $linkedView['parentkey']);
}
else
{
$keys[$linkedView['adminview']] = array('key'
=> null,
'parentKey' => null);
}
// set the button switches
if (isset($linkedView['addnew']))
{
$keys[$linkedView['adminview']]['addNewButton']
= (int) $linkedView['addnew'];
}
else
{
$keys[$linkedView['adminview']]['addNewButton'] =
0;
}
}
}
return $linkedTab;
}
/**
* get Edit Body Tabs
*
* @param string $nameSingleCode The single view name
* @param string $langView The main lang prefix
* @param array $linkedTab The linked admin view tabs
* @param array $keys The tabs to add in layout
* @param array $linkedViewIdentifier The linked view identifier
* @param array $searchTabs The tabs to add in layout
* @param string $leftside The left side html string
* @param string $rightside The right side html string
* @param string $footer The footer html string
* @param string $header The header html string
* @param int $mainwidth The main width value
* @param int $sidewidth The side width value
*
* @return array The linked tabs
*
*/
protected function getEditBodyTabs(&$nameSingleCode, &$langView,
&$linkedTab, &$keys,
&$linkedViewIdentifier, &$searchTabs, &$leftside,
&$rightside, &$footer,
&$header, &$mainwidth, &$sidewidth
)
{
// start tabs
$tabs = [];
// sort the tabs based on key order
$tab_counter = (array)
CFactory::_('Compiler.Builder.Tab.Counter')->get($nameSingleCode,
[]);
ksort($tab_counter);
// start tab building loop
foreach ($tab_counter as $tabNr => $tabName)
{
$tabWidth = 12;
$lrCounter = 0;
// set tab lang
$tabLangName = $langView . '_' . StringHelper::safe(
$tabName, 'U'
);
// set tab code name
$tabCodeName = StringHelper::safe($tabName);
/// set the values to use in search latter
$searchTabs[$tabCodeName] = $tabNr;
// add to lang array
CFactory::_('Language')->set(CFactory::_('Config')->lang_target,
$tabLangName, $tabName);
// check if linked view belongs to this tab
$buildLayout = true;
$linkedViewId = '';
if (ArrayHelper::check($linkedTab))
{
if (($linkedViewId = array_search($tabNr, $linkedTab))
!== false)
{
// don't build (since this is a linked view)
$buildLayout = false;
}
}
// build layout these are actual fields
if ($buildLayout &&
CFactory::_('Compiler.Builder.Layout')->exists($nameSingleCode
. '.' . $tabName))
{
// sort to make sure it loads left first
$alignments =
CFactory::_('Compiler.Builder.Layout')->get($nameSingleCode .
'.' . $tabName);
ksort($alignments);
foreach ($alignments as $alignment => $names)
{
// set layout code name
$layoutCodeName = $tabCodeName . '_'
. $this->alignmentOptions[$alignment];
// reset each time
$items = '';
$itemCounter = 0;
// sort the names based on order of keys
$names = (array) $names;
ksort($names);
// build the items array for this alignment
foreach ($names as $nr => $name)
{
if ($itemCounter == 0)
{
$items .= "'" . $name . "'";
}
else
{
$items .= "," . PHP_EOL . Indent::_(1) .
"'" . $name
. "'";
}
$itemCounter++;
}
// based on alignment build the layout
switch ($alignment)
{
case 1: // left
case 2: // right
// count
$lrCounter++;
// set as items layout
$this->setLayout(
$nameSingleCode, $layoutCodeName, $items,
'layoutitems'
);
// set the lang to tab
$tabs[$tabCodeName]['lang'] = $tabLangName;
// load the body
if (!isset($tabs[$tabCodeName][(int) $alignment]))
{
$tabs[$tabCodeName][(int) $alignment] = '';
}
$tabs[$tabCodeName][(int) $alignment] .= "<?php echo
LayoutHelper::render('"
. $nameSingleCode . "." . $layoutCodeName
. "', \$this); ?>";
break;
case 3: // fullwidth
// set as items layout
$this->setLayout(
$nameSingleCode, $layoutCodeName, $items,
'layoutfull'
);
// set the lang to tab
$tabs[$tabCodeName]['lang'] = $tabLangName;
// load the body
if (!isset($tabs[$tabCodeName][(int) $alignment]))
{
$tabs[$tabCodeName][(int) $alignment] = '';
}
$tabs[$tabCodeName][(int) $alignment] .= "<?php echo
LayoutHelper::render('"
. $nameSingleCode . "." . $layoutCodeName
. "', \$this); ?>";
break;
case 4: // above
// set as title layout
$this->setLayout(
$nameSingleCode, $layoutCodeName, $items,
'layouttitle'
);
// load to header
$header .= PHP_EOL
. "<?php echo LayoutHelper::render('"
. $nameSingleCode . "." . $layoutCodeName
. "', \$this); ?>";
break;
case 5: // under
// set as title layout
$this->setLayout(
$nameSingleCode, $layoutCodeName, $items,
'layouttitle'
);
// load to footer
$footer .= PHP_EOL . PHP_EOL
. "<div class=\"clearfix\"></div>"
. PHP_EOL
. "<?php echo LayoutHelper::render('"
. $nameSingleCode . "." . $layoutCodeName
. "', \$this); ?>";
break;
case 6: // left side
$tabWidth = $tabWidth - 2;
// set as items layout
$this->setLayout(
$nameSingleCode, $layoutCodeName, $items,
'layoutitems'
);
// load the body
$leftside .= PHP_EOL . Indent::_(2)
. "<?php echo LayoutHelper::render('"
. $nameSingleCode . "." . $layoutCodeName
. "', \$this); ?>";
break;
case 7: // right side
$tabWidth = $tabWidth - 2;
// set as items layout
$this->setLayout(
$nameSingleCode, $layoutCodeName, $items,
'layoutitems'
);
// load the body
$rightside .= PHP_EOL . Indent::_(2)
. "<?php echo LayoutHelper::render('"
. $nameSingleCode . "." . $layoutCodeName
. "', \$this); ?>";
break;
}
}
}
else
{
// set layout code name
$layoutCodeName = $tabCodeName . '_fullwidth';
// set identifiers
$linkedViewIdentifier[$linkedViewId] = $tabCodeName;
//set function name
$codeName = StringHelper::safe(
$this->uniquekey(3) . $tabCodeName
);
// set as items layout
$this->setLayout(
$nameSingleCode, $layoutCodeName, $codeName,
'layoutlinkedview'
);
// set the lang to tab
$tabs[$tabCodeName]['lang'] = $tabLangName;
// set all the linked view stuff
$this->secondRunAdmin['setLinkedView'][] = array(
'viewId' => $linkedViewId,
'nameSingleCode' => $nameSingleCode,
'codeName' => $codeName,
'layoutCodeName' => $layoutCodeName,
'key' =>
$keys[$linkedViewId]['key'],
'parentKey' =>
$keys[$linkedViewId]['parentKey'],
'addNewButon' =>
$keys[$linkedViewId]['addNewButton']);
// load the body
if (!isset($tabs[$tabCodeName][3]))
{
$tabs[$tabCodeName][3] = '';
}
$tabs[$tabCodeName][3] .= "<?php echo
LayoutHelper::render('"
. $nameSingleCode . "." . $layoutCodeName
. "', \$this); ?>";
}
// width calculator :)
if ($tabWidth == 8)
{
$mainwidth = 8;
$sidewidth = 2;
}
elseif ($tabWidth == 10 && $mainwidth != 8)
{
$mainwidth = 9;
$sidewidth = 3;
}
$tabs[$tabCodeName]['lr'] = $lrCounter;
}
return $tabs;
}
/**
* set Edit Body Main Center Positions Div
*
* @param string $main The main position of this tab
* @param string $mainbottom The main bottom position of this tab
* @param array $positions The build positions of this tab
*
* @return array The linked Admin Views tabs
*
*/
protected function setEditBodyTabMainCenterPositionDiv(&$main,
&$mainbottom,
&$positions
)
{
$width_class = 'span';
if (CFactory::_('Config')->get('joomla_version',
3) != 3)
{
$width_class = 'col-md-';
}
foreach ($positions as $position => $string)
{
if ($positions['lr'] == 2)
{
switch ($position)
{
case 1: // left
case 2: // right
$main .= PHP_EOL . Indent::_(3) . '<div class="' .
$width_class . '6">';
$main .= PHP_EOL . Indent::_(4) . $string;
$main .= PHP_EOL . Indent::_(3) . '</div>';
break;
}
}
else
{
switch ($position)
{
case 1: // left
case 2: // right
$main .= PHP_EOL . Indent::_(3)
. '<div class="' . $width_class .
'12">';
$main .= PHP_EOL . Indent::_(4) . $string;
$main .= PHP_EOL . Indent::_(3) . '</div>';
break;
}
}
switch ($position)
{
case 3: // fullwidth
$mainbottom .= PHP_EOL . Indent::_(3)
. '<div class="' . $width_class .
'12">';
$mainbottom .= PHP_EOL . Indent::_(4) . $string;
$mainbottom .= PHP_EOL . Indent::_(3) . '</div>';
break;
}
}
}
/**
* get Edit Body Publish and Meta Tab
*
* @param string $nameSingleCode The single view name
* @param string $langView The main lang prefix
*
* @return string The published and Meta Data Tabs
*
*/
protected function getEditBodyPublishMetaTabs(&$nameSingleCode,
&$langView
)
{
// build the two tabs
$tabs = '';
// set default publishing tab lang
$tabLangName = $langView . '_PUBLISHING';
// add to lang array
CFactory::_('Language')->set(CFactory::_('Config')->lang_target,
$tabLangName, 'Publishing');
// the default publishing items
$items = array('left' => array(), 'right' =>
array());
// Setup the default (custom) fields
// only load (1 => 'left', 2 => 'right')
$fieldsAddedRight = false;
$width_class = 'span';
$row_class = 'row-fluid form-horizontal-desktop';
$uitab = 'bootstrap';
if (CFactory::_('Config')->get('joomla_version',
3) != 3)
{
$width_class = 'col-md-';
$row_class = 'row';
$uitab = 'uitab';
}
if
(CFactory::_('Compiler.Builder.New.Publishing.Fields')->exists($nameSingleCode))
{
$new_published_fields =
CFactory::_('Compiler.Builder.New.Publishing.Fields')->get($nameSingleCode);
foreach ($new_published_fields as $df_alignment => $df_items)
{
foreach ($df_items as $df_order => $df_name)
{
if ($df_alignment == 2 || $df_alignment == 1)
{
$items[$this->alignmentOptions[$df_alignment]][$df_order]
= $df_name;
}
else
{
$this->app->enqueueMessage(
Text::_('COM_COMPONENTBUILDER_HR_HTHREEFIELD_WARNINGHTHREE'),
'Warning'
);
$this->app->enqueueMessage(
Text::sprintf(
'Your <b>%s</b> field could not be added, since
the <b>%s</b> alignment position is not available in the %s
(publishing) tab. Please only target <b>Left or right</b> in
the publishing tab.',
$df_name,
$this->alignmentOptions[$df_alignment],
$nameSingleCode
), 'Warning'
);
}
}
}
// set switch to trigger notice if custom fields added to right
if (ArrayHelper::check($items['right']))
{
$fieldsAddedRight = true;
}
}
// load all defaults
$loadDefaultFields = array(
'left' => array('created',
'created_by', 'modified',
'modified_by'),
'right' => array('published',
'ordering', 'access', 'version',
'hits', 'id')
);
foreach ($loadDefaultFields as $d_alignment => $defaultFields)
{
foreach ($defaultFields as $defaultField)
{
if
(!CFactory::_('Compiler.Builder.Moved.Publishing.Fields')->exists($nameSingleCode
. '.' . $defaultField))
{
if ($defaultField != 'access')
{
$items[$d_alignment][] = $defaultField;
}
elseif ($defaultField === 'access'
&&
CFactory::_('Compiler.Builder.Access.Switch')->exists($nameSingleCode))
{
$items[$d_alignment][] = $defaultField;
}
}
}
}
// check if metadata is added to this view
if
(CFactory::_('Compiler.Builder.Meta.Data')->exists($nameSingleCode))
{
// set default publishing tab code name
$tabCodeNameLeft = 'publishing';
$tabCodeNameRight = 'metadata';
// the default publishing tiems
if (ArrayHelper::check($items['left'])
|| ArrayHelper::check($items['right']))
{
$items_one = '';
// load the items into one side
if (ArrayHelper::check($items['left']))
{
$items_one .= "'" . implode(
"'," . PHP_EOL . Indent::_(1) . "'",
$items['left']
) . "'";
}
if (ArrayHelper::check($items['right']))
{
// there is already fields just add these
if (strlen($items_one) > 3)
{
$items_one .= "," . PHP_EOL . Indent::_(1) .
"'"
. implode(
"'," . PHP_EOL . Indent::_(1) . "'",
$items['right']
) . "'";
}
// no fields has been added yet
else
{
$items_one .= "'" . implode(
"'," . PHP_EOL . Indent::_(1) . "'",
$items['right']
) . "'";
}
}
// only triger the info notice if there were custom fields targeted to
the right alignment position.
if ($fieldsAddedRight)
{
$this->app->enqueueMessage(
Text::_('COM_COMPONENTBUILDER_HR_HTHREEFIELD_NOTICEHTHREE'),
'Notice'
);
$this->app->enqueueMessage(
Text::sprintf(
'Your field/s added to the <b>right</b> alignment
position in the %s (publishing) tab was added to the
<b>left</b>. Since we have metadata fields on the right. Fields
can only be loaded to the right of the publishing tab if there is no
metadata fields.',
$nameSingleCode
), 'Notice'
);
}
// set the publishing layout
$this->setLayout(
$nameSingleCode, $tabCodeNameLeft, $items_one,
'layoutpublished'
);
$items_one = true;
}
else
{
$items_one = false;
}
// set the metadata layout
$this->setLayout(
$nameSingleCode, $tabCodeNameRight, false, 'layoutmetadata'
);
$items_two = true;
}
else
{
// set default publishing tab code name
$tabCodeNameLeft = 'publishing';
$tabCodeNameRight = 'publlshing';
// the default publishing tiems
if (ArrayHelper::check($items['left'])
|| ArrayHelper::check($items['right']))
{
// load left items that remain
if (ArrayHelper::check($items['left']))
{
// load all items
$items_one = "'" . implode(
"'," . PHP_EOL . Indent::_(1) . "'",
$items['left']
) . "'";
// set the publishing layout
$this->setLayout(
$nameSingleCode, $tabCodeNameLeft, $items_one,
'layoutpublished'
);
$items_one = true;
}
// load right items that remain
if (ArrayHelper::check($items['right']))
{
// load all items
$items_two = "'" . implode(
"'," . PHP_EOL . Indent::_(1) . "'",
$items['right']
) . "'";
// set the publishing layout
$this->setLayout(
$nameSingleCode, $tabCodeNameRight, $items_two,
'layoutpublished'
);
$items_two = true;
}
}
else
{
$items_one = false;
$items_two = false;
}
}
if ($items_one && $items_two)
{
$classs = "{$width_class}6";
}
elseif ($items_one || $items_two)
{
$classs = "{$width_class}12";
}
// only load this if needed
if ($items_one || $items_two)
{
// check if the item has permissions.
$publishingPerOR = [];
$allToBeChekcedOR = array('core.edit.created_by',
'core.edit.created',
'core.edit.state');
foreach ($allToBeChekcedOR as $core_permission)
{
// set permissions.
$publishingPerOR[] = "\$this->canDo->get('"
.
CFactory::_('Compiler.Creator.Permission')->getGlobal($nameSingleCode,
$core_permission) . "')";
}
$publishingPerAND = [];
$allToBeChekcedAND = array('core.delete',
'core.edit.state');
foreach ($allToBeChekcedAND as $core_permission)
{
// set permissions.
$publishingPerAND[] = "\$this->canDo->get('"
.
CFactory::_('Compiler.Creator.Permission')->getGlobal($nameSingleCode,
$core_permission) . "')";
}
// check if custom tab must be added
if (($_customTabHTML = $this->addCustomTabs(
15, $nameSingleCode, 1
)) !== false)
{
$tabs .= $_customTabHTML;
}
// add the AND values to OR
$publishingPerOR[] = '(' . implode(' && ',
$publishingPerAND) . ')';
// now build the complete showhide behaviour for the publishing area
$tabs .= PHP_EOL . PHP_EOL . Indent::_(1) . "<?php if (" .
implode(
' || ', $publishingPerOR
) . ") : ?>";
// set the default publishing tab
$tabs .= PHP_EOL . Indent::_(1)
. "<?php echo Html::_('{$uitab}.addTab',
'"
. $nameSingleCode . "Tab', '" . $tabCodeNameLeft .
"', Text:"
. ":_('" . $tabLangName . "', true));
?>";
$tabs .= PHP_EOL . Indent::_(2)
. '<div class="' . $row_class .
'">';
if ($items_one)
{
$tabs .= PHP_EOL . Indent::_(3) . '<div class="' .
$classs
. '">';
$tabs .= PHP_EOL . Indent::_(4)
. "<?php echo LayoutHelper::render('" .
$nameSingleCode
. "." . $tabCodeNameLeft . "', \$this);
?>";
$tabs .= PHP_EOL . Indent::_(3) . "</div>";
}
if ($items_two)
{
$tabs .= PHP_EOL . Indent::_(3) . '<div class="' .
$classs
. '">';
$tabs .= PHP_EOL . Indent::_(4)
. "<?php echo LayoutHelper::render('" .
$nameSingleCode
. "." . $tabCodeNameRight . "', \$this);
?>";
$tabs .= PHP_EOL . Indent::_(3) . "</div>";
}
$tabs .= PHP_EOL . Indent::_(2) . "</div>";
$tabs .= PHP_EOL . Indent::_(1)
. "<?php echo Html::_('{$uitab}.endTab');
?>";
$tabs .= PHP_EOL . Indent::_(1) . "<?php endif; ?>";
// check if custom tab must be added
if (($_customTabHTML = $this->addCustomTabs(
15, $nameSingleCode, 2
)) !== false)
{
$tabs .= $_customTabHTML;
}
}
// make sure we don't load it to a view with the name component (as
this will cause conflict with Joomla conventions)
if ($nameSingleCode != 'component'
&&
CFactory::_('Compiler.Builder.Has.Permissions')->exists($nameSingleCode))
{
// set permissions tab lang
$tabLangName = $langView . '_PERMISSION';
// set permissions tab code name
$tabCodeName = 'permissions';
// add to lang array
CFactory::_('Language')->set(CFactory::_('Config')->lang_target,
$tabLangName, 'Permissions');
// set the permissions tab
$tabs .= PHP_EOL . PHP_EOL . Indent::_(1)
. "<?php if (\$this->canDo->get('core.admin'))
: ?>";
$tabs .= PHP_EOL . Indent::_(1)
. "<?php echo Html::_('{$uitab}.addTab',
'"
. $nameSingleCode . "Tab', '" . $tabCodeName .
"', Text:"
. ":_('" . $tabLangName . "', true));
?>";
$tabs .= PHP_EOL . Indent::_(2)
. '<div class="' . $row_class .
'">';
$tabs .= PHP_EOL . Indent::_(3) . '<div class="' .
$width_class . '12">';
if (CFactory::_('Config')->get('joomla_version',
3) == 3)
{
$tabs .= PHP_EOL . Indent::_(4) . '<fieldset
class="adminform">';
$tabs .= PHP_EOL . Indent::_(5) . '<div
class="adminformlist">';
$tabs .= PHP_EOL . Indent::_(5)
. "<?php foreach
(\$this->form->getFieldset('accesscontrol') as \$field):
?>";
$tabs .= PHP_EOL . Indent::_(6) . "<div>";
$tabs .= PHP_EOL . Indent::_(7)
. "<?php echo \$field->label; echo
\$field->input;?>";
$tabs .= PHP_EOL . Indent::_(6) . "</div>";
$tabs .= PHP_EOL . Indent::_(6) . '<div
class="clearfix"></div>';
$tabs .= PHP_EOL . Indent::_(5) . "<?php endforeach;
?>";
$tabs .= PHP_EOL . Indent::_(5) . "</div>";
$tabs .= PHP_EOL . Indent::_(4) . "</fieldset>";
}
else
{
$tabs .= PHP_EOL . Indent::_(4) . '<fieldset
id="fieldset-rules" class="options-form">';
$tabs .= PHP_EOL . Indent::_(5)
. "<legend><?php echo Text:"
. ":_('{$tabLangName}'); ?></legend>";
$tabs .= PHP_EOL . Indent::_(5) . "<div>";
$tabs .= PHP_EOL . Indent::_(6)
. "<?php echo \$this->form->getInput('rules');
?>";
$tabs .= PHP_EOL . Indent::_(5) . "</div>";
$tabs .= PHP_EOL . Indent::_(4) . "</fieldset>";
}
$tabs .= PHP_EOL . Indent::_(3) . "</div>";
$tabs .= PHP_EOL . Indent::_(2) . "</div>";
$tabs .= PHP_EOL . Indent::_(1)
. "<?php echo Html::_('{$uitab}.endTab');
?>";
$tabs .= PHP_EOL . Indent::_(1) . "<?php endif; ?>";
}
return $tabs;
}
protected function addCustomTabs($nr, $name_single, $target)
{
// check if this view is having custom tabs
if (($tabs =
CFactory::_('Compiler.Builder.Custom.Tabs')->get($name_single))
!== null
&& ArrayHelper::check($tabs))
{
$html = [];
foreach ($tabs as $customTab)
{
if (ArrayHelper::check($customTab)
&& isset($customTab['html']))
{
if ($customTab['tab'] == $nr
&& $customTab['position'] == $target
&& isset($customTab['html'])
&& StringHelper::check(
$customTab['html']
))
{
$html[] = $customTab['html'];
}
}
}
// return if found
if (ArrayHelper::check($html))
{
return PHP_EOL . implode(PHP_EOL, $html);
}
}
return false;
}
public function setFadeInEfect(&$view)
{
// check if we should load the fade in affect
if ($view['settings']->add_fadein == 1)
{
// set view name
$fadein[] = "<script
type=\"text/javascript\">";
$fadein[] = Indent::_(1) . "// waiting spinner";
$fadein[] = Indent::_(1) . "var outerDiv =
document.querySelector('body');";
$fadein[] = Indent::_(1) . "var loadingDiv =
document.createElement('div');";
$fadein[] = Indent::_(1) . "loadingDiv.id =
'loading';";
$fadein[] = Indent::_(1) . "loadingDiv.style.cssText =
\"background: rgba(255, 255, 255, .8) url('components/com_"
. CFactory::_('Config')->component_code_name
. "/assets/images/import.gif') 50% 15% no-repeat; top:
\" + (outerDiv.getBoundingClientRect().top + window.pageYOffset) +
\"px; left: \" + (outerDiv.getBoundingClientRect().left +
window.pageXOffset) + \"px; width: \" + outerDiv.offsetWidth +
\"px; height: \" + outerDiv.offsetHeight + \"px; position:
fixed; opacity: 0.80; -ms-filter:
progid:DXImageTransform.Microsoft.Alpha(Opacity=80); filter:
alpha(opacity=80); display: none;\";";
$fadein[] = Indent::_(1) .
"outerDiv.appendChild(loadingDiv);";
$fadein[] = Indent::_(1) . "loadingDiv.style.display =
'block';";
$fadein[] = Indent::_(1) . "// when page is ready remove and
show";
$fadein[] = Indent::_(1) .
"window.addEventListener('load', function() {";
$fadein[] = Indent::_(2) . "var componentLoader =
document.getElementById('" .
CFactory::_('Config')->component_code_name .
"_loader');";
$fadein[] = Indent::_(2) . "if (componentLoader)
componentLoader.style.display = 'block';";
$fadein[] = Indent::_(2) . "loadingDiv.style.display =
'none';";
$fadein[] = Indent::_(1) . "});";
$fadein[] = "</script>";
$fadein[] = "<div id=\"" .
CFactory::_('Config')->component_code_name .
"_loader\" style=\"display: none;\">";
return implode(PHP_EOL, $fadein);
}
return "<div id=\"" .
CFactory::_('Config')->component_code_name .
"_loader\">";
}
/**
* @param $nameSingleCode
* @param $layoutName
* @param $items
* @param $type
*/
public function setLayout($nameSingleCode, $layoutName, $items, $type)
{
// we check if there is a local override
if (!$this->setLayoutOverride($nameSingleCode, $layoutName, $items))
{
// first build the layout file
$target = array('admin' => $nameSingleCode);
CFactory::_('Utilities.Structure')->build($target, $type,
$layoutName);
// add to front if needed
if (CFactory::_('Config')->lang_target ===
'both')
{
$target = array('site' => $nameSingleCode);
CFactory::_('Utilities.Structure')->build($target, $type,
$layoutName);
}
if (StringHelper::check($items))
{
// LAYOUTITEMS <<<DYNAMIC>>>
CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode
. '_' . $layoutName . '|LAYOUTITEMS', $items);
}
else
{
// LAYOUTITEMS <<<DYNAMIC>>>
CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode
. '_' . $layoutName . '|bogus', 'boom');
}
}
}
/**
* @param string $nameSingleCode
* @param string $layoutName
* @param string $items
*
* @return boolean true if override was found
*/
protected function setLayoutOverride($nameSingleCode, $layoutName,
$items)
{
if (($data = $this->getLayoutOverride($nameSingleCode, $layoutName))
!== null)
{
// first build the layout file
$target = array('admin' => $nameSingleCode);
CFactory::_('Utilities.Structure')->build($target,
'layoutoverride', $layoutName);
// add to front if needed
if (CFactory::_('Config')->lang_target ===
'both')
{
$target = array('site' => $nameSingleCode);
CFactory::_('Utilities.Structure')->build($target,
'layoutoverride', $layoutName);
}
// make sure items is an empty string (should not be needed.. but)
if (!StringHelper::check($items))
{
$items = '';
}
// set placeholder
$placeholder =
CFactory::_('Placeholder')->active;
$placeholder[Placefix::_h('LAYOUTITEMS')] = $items;
// OVERRIDE_LAYOUT_CODE <<<DYNAMIC>>>
$php_view = (array) explode(PHP_EOL, (string)
$data['php_view'] ?? '');
if (ArrayHelper::check($php_view))
{
$php_view = PHP_EOL . PHP_EOL . implode(PHP_EOL, $php_view);
CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode
. '_' . $layoutName . '|OVERRIDE_LAYOUT_CODE',
CFactory::_('Placeholder')->update(
$php_view, $placeholder
)
);
}
else
{
CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode
. '_' . $layoutName . '|OVERRIDE_LAYOUT_CODE',
'');
}
// OVERRIDE_LAYOUT_BODY <<<DYNAMIC>>>
CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode
. '_' . $layoutName . '|OVERRIDE_LAYOUT_BODY',
PHP_EOL . CFactory::_('Placeholder')->update(
$data['html'] ?? '', $placeholder
)
);
// OVERRIDE_LAYOUT_HEADER <<<DYNAMIC>>>
CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode
. '_' . $layoutName . '|OVERRIDE_LAYOUT_HEADER',
(($header = CFactory::_('Header')->get(
'override.layout',
$layoutName, false)
) !== false) ? PHP_EOL . PHP_EOL . $header : ''
);
// since override was found
return true;
}
return false;
}
/**
* @param string $nameSingleCode
* @param string $layoutName
*
* @return array|null the layout data
*/
protected function getLayoutOverride($nameSingleCode, $layoutName):
?array
{
$get_key = null;
// check if there is an override by component name, view name, &
layout name
if ($this->setTemplateAndLayoutData(
'override', $nameSingleCode, false, array(''),
array(CFactory::_('Config')->component_code_name .
$nameSingleCode . $layoutName)
))
{
$get_key = CFactory::_('Config')->component_code_name .
$nameSingleCode . $layoutName;
}
// check if there is an override by component name & layout name
elseif ($this->setTemplateAndLayoutData(
'override', $nameSingleCode, false, array(''),
array(CFactory::_('Config')->component_code_name .
$layoutName)
))
{
$get_key = CFactory::_('Config')->component_code_name .
$layoutName;
}
// check if there is an override by view & layout name
elseif ($this->setTemplateAndLayoutData(
'override', $nameSingleCode, false, array(''),
array($nameSingleCode . $layoutName)
))
{
$get_key = $nameSingleCode . $layoutName;
}
// check if there is an override by layout name (global layout)
elseif ($this->setTemplateAndLayoutData(
'override', $nameSingleCode, false, array(''),
array($layoutName)
))
{
$get_key = $layoutName;
}
// check if we have a get key
if ($get_key)
{
$data = CFactory::_('Compiler.Builder.Layout.Data')->
get(CFactory::_('Config')->build_target . '.' .
$get_key);
if ($data === null)
{
var_dump(CFactory::_('Config')->build_target .
'.' . $get_key);
var_dump('admin.' .$get_key);
var_dump(CFactory::_('Compiler.Builder.Layout.Data')->get('admin.'
.$get_key));
var_dump('site.' .$get_key);
var_dump(CFactory::_('Compiler.Builder.Layout.Data')->get('site.'
. $get_key));
var_dump('both.' .$get_key);
var_dump(CFactory::_('Compiler.Builder.Layout.Data')->get('both.'
. $get_key));
exit;
}
// remove since we will add the layout now
if (CFactory::_('Config')->lang_target ===
'both')
{
CFactory::_('Compiler.Builder.Layout.Data')->
remove('admin.' . $get_key);
CFactory::_('Compiler.Builder.Layout.Data')->
remove('site.' . $get_key);
CFactory::_('Compiler.Builder.Layout.Data')->
remove('both.' . $get_key);
}
else
{
CFactory::_('Compiler.Builder.Layout.Data')->
remove(CFactory::_('Config')->build_target .
'.' . $get_key);
}
return $data;
}
return null;
}
/**
* @param $args
*/
public function setLinkedView($args)
{
/**
* @var $viewId
* @var $nameSingleCode
* @var $codeName
* @var $layoutCodeName
* @var $key
* @var $parentKey
* @var $addNewButon
*/
extract($args, EXTR_PREFIX_SAME, "oops");
$single = '';
$name_list_code = '';
foreach
(CFactory::_('Component')->get('admin_views') as
$array)
{
if ($array['adminview'] == $viewId)
{
$name_single_code = $array['settings']->name_single_code;
$name_list_code = $array['settings']->name_list_code;
break;
}
}
if (StringHelper::check($name_single_code)
&& StringHelper::check($name_list_code))
{
$head = $this->setListHeadLinked(
$name_single_code, $name_list_code, $addNewButon,
$nameSingleCode
);
$body = $this->setListBodyLinked(
$name_single_code, $name_list_code, $nameSingleCode
);
$functionName = StringHelper::safe($codeName, 'F');
// LAYOUTITEMSTABLE <<<DYNAMIC>>>
CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode
. '_' . $layoutCodeName . '|LAYOUTITEMSTABLE',
$head . $body
);
// LAYOUTITEMSHEADER <<<DYNAMIC>>>
$headerscript = '//' . Line::_(__Line__, __Class__)
. ' set the edit URL';
$headerscript .= PHP_EOL . '$edit =
"index.php?option=com_'
. CFactory::_('Config')->component_code_name .
'&view=' . $name_list_code
. '&task='
. $name_single_code . '.edit";';
$headerscript .= PHP_EOL . '//' . Line::_(__Line__,
__Class__)
. ' set a return value';
$headerscript .= PHP_EOL
. '$return = ($id) ? "index.php?option=com_'
. CFactory::_('Config')->component_code_name .
'&view=' . $nameSingleCode
. '&layout=edit&id=" . $id : "";';
$headerscript .= PHP_EOL . '//' . Line::_(__Line__,
__Class__)
. ' check for a return value';
$headerscript .= PHP_EOL
. '$jinput = Factory::getApplication()->input;';
$headerscript .= PHP_EOL
. "if (\$_return = \$jinput->get('return', null,
'base64'))";
$headerscript .= PHP_EOL . '{';
$headerscript .= PHP_EOL . Indent::_(1)
. '$return .= "&return=" . $_return;';
$headerscript .= PHP_EOL . '}';
$headerscript .= PHP_EOL . '//' . Line::_(__Line__,
__Class__)
. ' check if return value was set';
$headerscript .= PHP_EOL . 'if ('
. 'Super' .
'___1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::check($return))';
$headerscript .= PHP_EOL . '{';
$headerscript .= PHP_EOL . Indent::_(1) . '//' . Line::_(
__LINE__,__CLASS__
) . ' set the referral values';
$headerscript .= PHP_EOL . Indent::_(1) . '$ref = ($id) ?
"&ref='
. $nameSingleCode
. '&refid=" . $id . "&return=" .
urlencode(base64_encode($return)) : "&return=" .
urlencode(base64_encode($return));';
$headerscript .= PHP_EOL . '}';
$headerscript .= PHP_EOL . 'else';
$headerscript .= PHP_EOL . '{';
$headerscript .= PHP_EOL . Indent::_(1) . '$ref = ($id) ?
"&ref='
. $nameSingleCode . '&refid=" . $id :
"";';
$headerscript .= PHP_EOL . '}';
if ($addNewButon > 0)
{
if (CFactory::_('Config')->get('joomla_version',
3) == 3)
{
$add_key = 'edit';
}
else
{
$add_key = 'add';
}
// add the link for new
if ($addNewButon == 1 || $addNewButon == 2)
{
$headerscript .= PHP_EOL . '//' . Line::_(__Line__,
__Class__)
. ' set the create new URL';
$headerscript .= PHP_EOL . '$new =
"index.php?option=com_'
. CFactory::_('Config')->component_code_name .
'&view=' . $name_list_code
. '&task='
. $name_single_code . '.' . $add_key . '" .
$ref;';
}
// and the link for close and new
if ($addNewButon == 2 || $addNewButon == 3)
{
$headerscript .= PHP_EOL . '//' . Line::_(__Line__,
__Class__)
. ' set the create new and close URL';
$headerscript .= PHP_EOL
. '$close_new = "index.php?option=com_'
. CFactory::_('Config')->component_code_name .
'&view=' . $name_list_code
. '&task='
. $name_single_code . '.' . $add_key .
'";';
}
$headerscript .= PHP_EOL . '//' . Line::_(__Line__,
__Class__)
. ' load the action object';
$headerscript .= PHP_EOL . '$can = '
.
CFactory::_('Compiler.Builder.Content.One')->get('Component')
. 'Helper::getActions(' . "'"
. $name_single_code . "'"
. ');';
}
CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode
. '_' . $layoutCodeName . '|LAYOUTITEMSHEADER',
$headerscript
);
// LINKEDVIEWITEMS <<<DYNAMIC>>>
CFactory::_('Compiler.Builder.Content.Multi')->add($nameSingleCode
. '|LINKEDVIEWITEMS',
PHP_EOL . PHP_EOL . Indent::_(2) . "//" . Line::_(
__LINE__,__CLASS__
) . " Get Linked view data" . PHP_EOL . Indent::_(2)
. "\$this->" . $codeName . " =
\$this->get('" . $functionName
. "');", false
);
// LINKEDVIEWTABLESCRIPTS <<<DYNAMIC>>>
CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode
. '|LINKEDVIEWTABLESCRIPTS', $this->setFootableScripts());
if (strpos((string) $parentKey, '-R>') !== false
|| strpos((string) $parentKey, '-A>') !== false)
{
list($parent_key) = explode('-', (string) $parentKey);
}
elseif (strpos((string) $parentKey, '-OR>') !== false)
{
// this is not good... (TODO)
$parent_keys = explode('-OR>', (string) $parentKey);
}
else
{
$parent_key = $parentKey;
}
if (strpos((string) $key, '-R>') !== false ||
strpos((string) $key, '-A>') !== false)
{
list($_key) = explode('-', (string) $key);
}
elseif (strpos((string) $key, '-OR>') !== false)
{
$_key = str_replace('-OR>', '', (string) $key);
}
else
{
$_key = $key;
}
// LINKEDVIEWGLOBAL <<<DYNAMIC>>>
if (isset($parent_keys)
&& ArrayHelper::check(
$parent_keys
))
{
$globalKey = [];
foreach ($parent_keys as $parent_key)
{
$globalKey[$parent_key]
= StringHelper::safe(
$_key . $this->uniquekey(4)
);
CFactory::_('Compiler.Builder.Content.Multi')->add($nameSingleCode
. '|LINKEDVIEWGLOBAL',
PHP_EOL . Indent::_(2) . "\$this->"
. $globalKey[$parent_key] . " = \$item->" . $parent_key
. ";", false
);
}
}
else
{
// set the global key
$globalKey = StringHelper::safe(
$_key . $this->uniquekey(4)
);
CFactory::_('Compiler.Builder.Content.Multi')->add($nameSingleCode
. '|LINKEDVIEWGLOBAL',
PHP_EOL . Indent::_(2) . "\$this->" . $globalKey
. " = \$item->" . $parent_key . ";", false
);
}
// LINKEDVIEWMETHODS <<<DYNAMIC>>>
CFactory::_('Compiler.Builder.Content.Multi')->add($nameSingleCode
. '|LINKEDVIEWMETHODS',
$this->setListQueryLinked(
$name_single_code, $name_list_code, $functionName, $key, $_key,
$parentKey,
$parent_key, $globalKey
), false
);
}
else
{
CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode
. '_' . $layoutCodeName . '|LAYOUTITEMSTABLE',
'oops! error.....'
);
CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode
. '_' . $layoutCodeName . '|LAYOUTITEMSHEADER',
'');
}
}
/**
* @param bool $init
*
* @return string
*/
public function setFootableScripts($init = true)
{
$footable_version =
CFactory::_('Config')->get('footable_version', 2);
if (2 == $footable_version) // loading version 2
{
$foo = PHP_EOL . PHP_EOL . Indent::_(2) . "//" . Line::_(
__LINE__,__CLASS__
) . " Add the CSS for Footable.";
$foo .= PHP_EOL . Indent::_(2)
. "Html::_('stylesheet', 'media/com_"
. CFactory::_('Config')->component_code_name
. "/footable-v2/css/footable.core.min.css',
['version' => 'auto']);";
$foo .= PHP_EOL . PHP_EOL . Indent::_(2) . "//" . Line::_(
__LINE__,__CLASS__
) . " Use the Metro Style";
$foo .= PHP_EOL . Indent::_(2)
. "if (!isset(\$this->fooTableStyle) || 0 ==
\$this->fooTableStyle)";
$foo .= PHP_EOL . Indent::_(2) . "{";
$foo .= PHP_EOL . Indent::_(3)
. "Html::_('stylesheet', 'media/com_"
. CFactory::_('Config')->component_code_name
. "/footable-v2/css/footable.metro.min.css',
['version' => 'auto']);";
$foo .= PHP_EOL . Indent::_(2) . "}";
$foo .= PHP_EOL . Indent::_(2) . "//" . Line::_(__Line__,
__Class__)
. " Use the Legacy Style.";
$foo .= PHP_EOL . Indent::_(2)
. "elseif (isset(\$this->fooTableStyle) && 1 ==
\$this->fooTableStyle)";
$foo .= PHP_EOL . Indent::_(2) . "{";
$foo .= PHP_EOL . Indent::_(3)
. "Html::_('stylesheet', 'media/com_"
. CFactory::_('Config')->component_code_name
. "/footable-v2/css/footable.standalone.min.css',
['version' => 'auto']);";
$foo .= PHP_EOL . Indent::_(2) . "}";
$foo .= PHP_EOL . PHP_EOL . Indent::_(2) . "//" . Line::_(
__LINE__,__CLASS__
) . " Add the JavaScript for Footable";
$foo .= PHP_EOL . Indent::_(2)
. "Html::_('script', 'media/com_"
. CFactory::_('Config')->component_code_name .
"/footable-v2/js/footable.js', ['version' =>
'auto']);";
$foo .= PHP_EOL . Indent::_(2)
. "Html::_('script', 'media/com_"
. CFactory::_('Config')->component_code_name
. "/footable-v2/js/footable.sort.js', ['version'
=> 'auto']);";
$foo .= PHP_EOL . Indent::_(2)
. "Html::_('script', 'media/com_"
. CFactory::_('Config')->component_code_name
. "/footable-v2/js/footable.filter.js', ['version'
=> 'auto']);";
$foo .= PHP_EOL . Indent::_(2)
. "Html::_('script', 'media/com_"
. CFactory::_('Config')->component_code_name
. "/footable-v2/js/footable.paginate.js',
['version' => 'auto']);";
if ($init)
{
$foo .= PHP_EOL . PHP_EOL . Indent::_(2)
. '$footable = "jQuery(document).ready(function() {
jQuery(function () { jQuery('
. "'.footable'" . ').footable(); });
jQuery('
. "'.nav-tabs'" . ').on(' .
"'click'" . ', ' .
"'li'"
. ', function() { setTimeout(tableFix, 10); }); }); function
tableFix() { jQuery('
. "'.footable'" . ').trigger(' .
"'footable_resize'"
. '); }";';
$foo .= PHP_EOL . Indent::_(2)
.
"\$this->getDocument()->addScriptDeclaration(\$footable);"
. PHP_EOL;
}
}
elseif (3 == $footable_version) // loading version 3
{
$foo = PHP_EOL . PHP_EOL . Indent::_(2) . "//" . Line::_(
__LINE__,__CLASS__
) . " Add the CSS for Footable";
$foo .= PHP_EOL . Indent::_(2)
. "Html::_('stylesheet',
'https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css',
['version' => 'auto']);";
$foo .= PHP_EOL . Indent::_(2)
. "Html::_('stylesheet', 'media/com_"
. CFactory::_('Config')->component_code_name
. "/footable-v3/css/footable.standalone.min.css',
['version' => 'auto']);";
$foo .= PHP_EOL . Indent::_(2) . "//" . Line::_(__Line__,
__Class__)
. " Add the JavaScript for Footable (adding all functions)";
$foo .= PHP_EOL . Indent::_(2)
. "Html::_('script', 'media/com_"
. CFactory::_('Config')->component_code_name
. "/footable-v3/js/footable.min.js', ['version'
=> 'auto']);";
if ($init)
{
$foo .= PHP_EOL . PHP_EOL . Indent::_(2)
. '$footable = "jQuery(document).ready(function() {
jQuery(function () { jQuery('
. "'.footable'" .
').footable();});});";';
$foo .= PHP_EOL . Indent::_(2)
.
"\$this->getDocument()->addScriptDeclaration(\$footable);"
. PHP_EOL;
}
}
return $foo;
}
/**
* set the list body of the linked admin view
*
* @param string $nameSingleCode
* @param string $nameListCode
* @param string $refview
*
* @return string
*/
public function setListBodyLinked($nameSingleCode, $nameListCode,
$refview)
{
if (($items =
CFactory::_('Compiler.Builder.Lists')->get($nameListCode)) !==
null)
{
// component helper name
$Helper =
CFactory::_('Compiler.Builder.Content.One')->get('Component')
. 'Helper';
$footable_version =
CFactory::_('Config')->get('footable_version', 2);
// make sure the custom links are only added once
$firstTimeBeingAdded = true;
$counter = 0;
// add the default
$body = PHP_EOL . "<tbody>";
$body .= PHP_EOL . "<?php foreach (\$items as \$i => \$item):
?>";
$body .= PHP_EOL . Indent::_(1) . "<?php";
$body .= PHP_EOL . Indent::_(2)
. "\$canCheckin = \$user->authorise('core.manage',
'com_checkin') || \$item->checked_out == \$user->id ||
\$item->checked_out == 0;";
if (CFactory::_('Config')->get('joomla_version',
3) == 3)
{
$body .= PHP_EOL . Indent::_(2)
. "\$userChkOut =
Factory::getUser(\$item->checked_out);";
}
else
{
$body .= PHP_EOL . Indent::_(2)
. "\$userChkOut = Factory::getContainer()->";
$body .= PHP_EOL . Indent::_(3)
. "get(\Joomla\CMS\User\UserFactoryInterface::class)->";
$body .= PHP_EOL . Indent::_(4)
. "loadUserById(\$item->checked_out);";
}
$body .= PHP_EOL . Indent::_(2) . "\$canDo = " . $Helper
. "::getActions('" . $nameSingleCode .
"',\$item,'"
. $nameListCode . "');";
$body .= PHP_EOL . Indent::_(1) . "?>";
$body .= PHP_EOL . Indent::_(1) . '<tr>';
// check if this view has fields that should not be escaped
$doNotEscape = false;
if
(CFactory::_('Compiler.Builder.Do.Not.Escape')->exists($nameListCode))
{
$doNotEscape = true;
}
// start adding the dynamic
foreach ($items as $item)
{
// check if target is linked list view
if (1 == $item['target'] || 4 == $item['target'])
{
// set the ref
$ref = '<?php echo $ref; ?>';
// set some defaults
$customAdminViewButtons = '';
// set the item row
$itemRow = $this->getListItemBuilder(
$item, $nameSingleCode, $nameListCode, $itemClass,
$doNotEscape, false, $ref,
'$displayData->escape', '$user', $refview
);
// check if buttons was aready added
if ($firstTimeBeingAdded) // TODO we must improve this to allow more
items to be targeted instead of just the first item :)
{
// get custom admin view buttons
$customAdminViewButtons
= $this->getCustomAdminViewButtons(
$nameListCode, $ref
);
// make sure the custom admin view buttons are only added once
$firstTimeBeingAdded = false;
}
// add row to body
$body .= PHP_EOL . Indent::_(2) . "<td>";
$body .= $itemRow;
$body .= $customAdminViewButtons;
$body .= PHP_EOL . Indent::_(2) . "</td>";
// increment counter
$counter++;
}
}
$data_value = (3 == $footable_version) ? 'data-sort-value'
: 'data-value';
// add the defaults
if
(!CFactory::_('Compiler.Builder.Field.Names')->isString($nameSingleCode
. '.published'))
{
$counter++;
// add the defaults
$body .= PHP_EOL . Indent::_(2)
. "<?php if (\$item->published == 1): ?>";
$body .= PHP_EOL . Indent::_(3) . '<td class="center"
'
. $data_value . '="1">';
$body .= PHP_EOL . Indent::_(4)
. '<span class="status-metro status-published"
title="<?php echo Text:'
. ':_(' . "'" .
CFactory::_('Config')->lang_prefix .
"_PUBLISHED'"
. '); ?>">';
$body .= PHP_EOL . Indent::_(5) . '<?php echo Text:' .
':_('
. "'"
. CFactory::_('Config')->lang_prefix .
"_PUBLISHED'" . '); ?>';
$body .= PHP_EOL . Indent::_(4) . '</span>';
$body .= PHP_EOL . Indent::_(3) . '</td>';
$body .= PHP_EOL . Indent::_(2)
. "<?php elseif (\$item->published == 0): ?>";
$body .= PHP_EOL . Indent::_(3) . '<td class="center"
'
. $data_value . '="2">';
$body .= PHP_EOL . Indent::_(4)
. '<span class="status-metro status-inactive"
title="<?php echo Text:'
. ':_(' . "'" .
CFactory::_('Config')->lang_prefix .
"_INACTIVE'"
. '); ?>">';
$body .= PHP_EOL . Indent::_(5) . '<?php echo Text:' .
':_('
. "'"
. CFactory::_('Config')->lang_prefix .
"_INACTIVE'" . '); ?>';
$body .= PHP_EOL . Indent::_(4) . '</span>';
$body .= PHP_EOL . Indent::_(3) . '</td>';
$body .= PHP_EOL . Indent::_(2)
. "<?php elseif (\$item->published == 2): ?>";
$body .= PHP_EOL . Indent::_(3) . '<td class="center"
'
. $data_value . '="3">';
$body .= PHP_EOL . Indent::_(4)
. '<span class="status-metro status-archived"
title="<?php echo Text:'
. ':_(' . "'" .
CFactory::_('Config')->lang_prefix .
"_ARCHIVED'"
. '); ?>">';
$body .= PHP_EOL . Indent::_(5) . '<?php echo Text:' .
':_('
. "'"
. CFactory::_('Config')->lang_prefix .
"_ARCHIVED'" . '); ?>';
$body .= PHP_EOL . Indent::_(4) . '</span>';
$body .= PHP_EOL . Indent::_(3) . '</td>';
$body .= PHP_EOL . Indent::_(2)
. "<?php elseif (\$item->published == -2): ?>";
$body .= PHP_EOL . Indent::_(3) . '<td class="center"
'
. $data_value . '="4">';
$body .= PHP_EOL . Indent::_(4)
. '<span class="status-metro status-trashed"
title="<?php echo Text:'
. ':_(' . "'" .
CFactory::_('Config')->lang_prefix .
"_TRASHED'"
. '); ?>">';
$body .= PHP_EOL . Indent::_(5) . '<?php echo Text:' .
':_('
. "'"
. CFactory::_('Config')->lang_prefix .
"_TRASHED'" . '); ?>';
$body .= PHP_EOL . Indent::_(4) . '</span>';
$body .= PHP_EOL . Indent::_(3) . '</td>';
$body .= PHP_EOL . Indent::_(2) . '<?php endif; ?>';
}
// add the defaults
if
(!CFactory::_('Compiler.Builder.Field.Names')->isString($nameSingleCode
. '.id'))
{
$counter++;
$body .= PHP_EOL . Indent::_(2)
. '<td class="nowrap center
hidden-phone">';
$body .= PHP_EOL . Indent::_(3) . "<?php echo \$item->id;
?>";
$body .= PHP_EOL . Indent::_(2) . "</td>";
}
$body .= PHP_EOL . Indent::_(1) . "</tr>";
$body .= PHP_EOL . "<?php endforeach; ?>";
$body .= PHP_EOL . "</tbody>";
if (2 == $footable_version)
{
$body .= PHP_EOL . '<tfoot
class="hide-if-no-paging">';
$body .= PHP_EOL . Indent::_(1) . '<tr>';
$body .= PHP_EOL . Indent::_(2) . '<td colspan="' .
$counter
. '">';
$body .= PHP_EOL . Indent::_(3)
. '<div class="pagination
pagination-centered"></div>';
$body .= PHP_EOL . Indent::_(2) . '</td>';
$body .= PHP_EOL . Indent::_(1) . '</tr>';
$body .= PHP_EOL . '</tfoot>';
}
$body .= PHP_EOL . '</table>';
$body .= PHP_EOL . '<?php else: ?>';
$body .= PHP_EOL . Indent::_(1)
. '<div class="alert alert-no-items">';
$body .= PHP_EOL . Indent::_(2) . '<?php echo Text:' .
':_('
. "'JGLOBAL_NO_MATCHING_RESULTS'" . ');
?>';
$body .= PHP_EOL . Indent::_(1) . '</div>';
$body .= PHP_EOL . '<?php endif; ?>';
// return the build
return $body;
}
return '';
}
/**
* set the list body table head linked admin view
*
* @param string $nameSingleCode
* @param string $nameListCode
* @param bool $addNewButon
* @param string $refview
*
* @return string
*/
public function setListHeadLinked($nameSingleCode, $nameListCode,
$addNewButon, $refview
)
{
if (($items =
CFactory::_('Compiler.Builder.Lists')->get($nameListCode)) !==
null)
{
// component helper name
$Helper =
CFactory::_('Compiler.Builder.Content.One')->get('Component')
. 'Helper';
$head = '';
$footable_version =
CFactory::_('Config')->get('footable_version', 2);
// only add new button if set
if ($addNewButon > 0)
{
// set permissions.
$accessCheck = "\$can->get('" .
CFactory::_('Compiler.Creator.Permission')->getGlobal($nameSingleCode,
'core.create') . "')";
// add a button for new
$head = '<?php if (' . $accessCheck . '):
?>';
// make group button if needed
$tabB = "";
if ($addNewButon == 2)
{
$head .= PHP_EOL . Indent::_(1) . '<div
class="btn-group">';
$tabB = Indent::_(1);
}
// add the new buttons
if ($addNewButon == 1 || $addNewButon == 2)
{
$head .= PHP_EOL . $tabB . Indent::_(1)
. '<a class="btn btn-small btn-success"
href="<?php echo $new; ?>"><span class="icon-new
icon-white"></span> <?php echo Text:'
. ':_(' . "'" .
CFactory::_('Config')->lang_prefix . "_NEW'"
. '); ?></a>';
}
// add the close and new button
if ($addNewButon == 2 || $addNewButon == 3)
{
$head .= PHP_EOL . $tabB . Indent::_(1)
. '<a class="btn btn-small"
onclick="Joomla.submitbutton(\''
. $refview
. '.cancel\');" href="<?php echo $close_new;
?>"><span class="icon-new"></span>
<?php echo Text:'
. ':_(' . "'" .
CFactory::_('Config')->lang_prefix .
"_CLOSE_NEW'"
. '); ?></a>';
}
// close group button if needed
if ($addNewButon == 2)
{
$head .= PHP_EOL . Indent::_(1) . '</div><br /><br
/>';
}
else
{
$head .= '<br /><br />';
}
$head .= PHP_EOL . '<?php endif; ?>' . PHP_EOL;
}
$head .= '<?php if (Super_' .
'__0a59c65c_9daf_4bc9_baf4_e063ff9e6a8a___Power::check($items)):
?>';
// set the style for V2
$metro_blue = (2 == $footable_version) ? ' metro-blue' :
'';
// set the toggle for V3
$toggle = (3 == $footable_version)
? ' data-show-toggle="true"
data-toggle-column="first"' : '';
// set paging
$paging = (2 == $footable_version)
? ' data-page-size="20" data-filter="#filter_'
. $nameListCode
. '"'
: ' data-sorting="true" data-paging="true"
data-paging-size="20" data-filtering="true"';
// add html fix for V3
$htmlFix = (3 == $footable_version)
? ' data-type="html"
data-sort-use="text"' : '';
$head .= PHP_EOL . '<table class="footable table data
'
. $nameListCode . $metro_blue . '"' . $toggle . $paging
. '>';
$head .= PHP_EOL . "<thead>";
// main lang prefix
$langView = CFactory::_('Config')->lang_prefix .
'_'
. StringHelper::safe($nameSingleCode, 'U');
// set status lang
$statusLangName = $langView . '_STATUS';
// set id lang
$idLangName = $langView . '_ID';
// make sure only first link is used as togeler
$firstLink = true;
// add to lang array
CFactory::_('Language')->set(CFactory::_('Config')->lang_target,
$statusLangName, 'Status');
// add to lang array
CFactory::_('Language')->set(CFactory::_('Config')->lang_target,
$idLangName, 'Id');
$head .= PHP_EOL . Indent::_(1) . "<tr>";
// set controller for data hiding options
$controller = 1;
// build the dynamic fields
foreach ($items as $item)
{
// check if target is linked list view
if (1 == $item['target'] || 4 == $item['target'])
{
// check if we have an over-ride
if (($list_head_override =
CFactory::_('Compiler.Builder.List.Head.Override')->
get($nameListCode . '.' . (int) $item['id'])) !==
null)
{
$item['lang'] = $list_head_override;
}
$setin = (2 == $footable_version)
? ' data-hide="phone"' : '
data-breakpoints="xs sm"';
if ($controller > 3)
{
$setin = (2 == $footable_version)
? ' data-hide="phone,tablet"'
: ' data-breakpoints="xs sm md"';
}
if ($controller > 6)
{
$setin = (2 == $footable_version)
? ' data-hide="all"' : '
data-breakpoints="all"';
}
if ($item['link'] && $firstLink)
{
$setin = (2 == $footable_version)
? ' data-toggle="true"' : '';
$firstLink = false;
}
$head .= PHP_EOL . Indent::_(2) . "<th" . $setin .
$htmlFix
. ">";
$head .= PHP_EOL . Indent::_(3) . "<?php echo Text:"
. ":_('" . $item['lang'] . "');
?>";
$head .= PHP_EOL . Indent::_(2) . "</th>";
$controller++;
}
}
// set some V3 attr
$data_hide = (2 == $footable_version)
? 'data-hide="phone,tablet"' :
'data-breakpoints="xs sm md"';
// add the defaults
if
(!CFactory::_('Compiler.Builder.Field.Names')->isString($nameSingleCode
. '.published'))
{
$head .= PHP_EOL . Indent::_(2) . '<th width="10"
' . $data_hide
. '>';
$head .= PHP_EOL . Indent::_(3) . "<?php echo Text:" .
":_('"
. $statusLangName . "'); ?>";
$head .= PHP_EOL . Indent::_(2) . "</th>";
}
// add the defaults
if
(!CFactory::_('Compiler.Builder.Field.Names')->isString($nameSingleCode
. '.id'))
{
$data_type = (2 == $footable_version)
? 'data-type="numeric"'
: 'data-type="number"';
$head .= PHP_EOL . Indent::_(2) . '<th width="5"
'
. $data_type
. ' ' . $data_hide . '>';
$head .= PHP_EOL . Indent::_(3) . "<?php echo Text:"
. ":_('"
. $idLangName . "'); ?>";
$head .= PHP_EOL . Indent::_(2) . "</th>";
}
$head .= PHP_EOL . Indent::_(1) . "</tr>";
$head .= PHP_EOL . "</thead>";
return $head;
}
return '';
}
/**
* @param $nameSingleCode
* @param $nameListCode
* @param $functionName
* @param $key
* @param $_key
* @param $parentKey
* @param $parent_key
* @param $globalKey
*
* @return string
*/
public function setListQueryLinked($nameSingleCode, $nameListCode,
$functionName, $key, $_key, $parentKey, $parent_key, $globalKey)
{
// check if this view has category added
if
(CFactory::_('Compiler.Builder.Category')->exists("{$nameListCode}.code"))
{
$categoryCodeName =
CFactory::_('Compiler.Builder.Category')->get("{$nameListCode}.code");
$addCategory = true;
}
else
{
$addCategory = false;
}
$query = PHP_EOL . PHP_EOL . Indent::_(1) . "/**";
$query .= PHP_EOL . Indent::_(1) . " * Method to get list
data.";
$query .= PHP_EOL . Indent::_(1) . " *";
$query .= PHP_EOL . Indent::_(1)
. " * @return mixed An array of data items on success, false on
failure.";
$query .= PHP_EOL . Indent::_(1) . " */";
$query .= PHP_EOL . Indent::_(1) . "public function get" .
$functionName
. "()";
$query .= PHP_EOL . Indent::_(1) . "{";
// setup the query
$query .= PHP_EOL . Indent::_(2) . "//" . Line::_(__Line__,
__Class__)
. " Get the user object.";
if (CFactory::_('Config')->get('joomla_version',
3) == 3)
{
$query .= PHP_EOL . Indent::_(2) . "\$user =
Factory::getUser();";
}
else
{
$query .= PHP_EOL . Indent::_(2) . "\$user =
Factory::getApplication()->getIdentity();";
}
$query .= PHP_EOL . Indent::_(2) . "//" . Line::_(__Line__,
__Class__)
. " Create a new query object.";
if (CFactory::_('Config')->get('joomla_version',
3) == 3)
{
$query .= PHP_EOL . Indent::_(2) . "\$db =
Factory::getDBO();";
}
else
{
$query .= PHP_EOL . Indent::_(2) . "\$db =
\$this->getDatabase();";
}
$query .= PHP_EOL . Indent::_(2) . "\$query =
\$db->getQuery(true);";
$query .= PHP_EOL . PHP_EOL . Indent::_(2) . "//" . Line::_(
__LINE__,__CLASS__
) . " Select some fields";
$query .= PHP_EOL . Indent::_(2) .
"\$query->select('a.*');";
// add the category
if ($addCategory)
{
$query .= PHP_EOL . Indent::_(2)
.
"\$query->select(\$db->quoteName('c.title','category_title'));";
}
$query .= PHP_EOL . PHP_EOL . Indent::_(2) . "//" . Line::_(
__LINE__,__CLASS__
) . " From the " .
CFactory::_('Config')->component_code_name . "_"
. $nameSingleCode
. " table";
$query .= PHP_EOL . Indent::_(2) .
"\$query->from(\$db->quoteName('#__"
. CFactory::_('Config')->component_code_name .
"_" . $nameSingleCode . "', 'a'));";
// add the category
if ($addCategory)
{
$query .= PHP_EOL . Indent::_(2)
. "\$query->join('LEFT',
\$db->quoteName('#__categories', 'c') . ' ON
(' . \$db->quoteName('a."
. $categoryCodeName
. "') . ' = ' .
\$db->quoteName('c.id') . ')');";
}
// add custom filtering php
$query .= CFactory::_('Customcode.Dispenser')->get(
'php_getlistquery', $nameSingleCode, PHP_EOL . PHP_EOL
);
// add the custom fields query
$query .= $this->setCustomQuery($nameListCode, $nameSingleCode);
if (StringHelper::check($globalKey) && $key
&& strpos(
(string) $key, '-R>'
) === false
&& strpos((string) $key, '-A>') === false
&& strpos((string) $key, '-OR>') === false
&& $parentKey
&& strpos((string) $parentKey, '-R>') === false
&& strpos((string) $parentKey, '-A>') === false
&& strpos((string) $parentKey, '-OR>') === false)
{
$query .= PHP_EOL . PHP_EOL . Indent::_(2) . "//" . Line::_(
__LINE__,__CLASS__
) . " Filter by " . $globalKey . " global.";
$query .= PHP_EOL . Indent::_(2) . "\$" . $globalKey . "
= \$this->"
. $globalKey . ";";
$query .= PHP_EOL . Indent::_(2) . "if (is_numeric(\$" .
$globalKey
. " ))";
$query .= PHP_EOL . Indent::_(2) . "{";
$query .= PHP_EOL . Indent::_(3) .
"\$query->where('a." . $key
. " = ' . (int) \$" . $globalKey . " );";
$query .= PHP_EOL . Indent::_(2) . "}";
$query .= PHP_EOL . Indent::_(2) . "elseif (is_string(\$"
. $globalKey . "))";
$query .= PHP_EOL . Indent::_(2) . "{";
$query .= PHP_EOL . Indent::_(3) .
"\$query->where('a." . $key
. " = ' . \$db->quote(\$" . $globalKey .
"));";
$query .= PHP_EOL . Indent::_(2) . "}";
$query .= PHP_EOL . Indent::_(2) . "else";
$query .= PHP_EOL . Indent::_(2) . "{";
$query .= PHP_EOL . Indent::_(3) .
"\$query->where('a." . $key
. " = -5');";
$query .= PHP_EOL . Indent::_(2) . "}";
}
elseif (strpos((string) $parentKey, '-OR>') !== false
|| strpos((string) $key, '-OR>') !== false)
{
// get both strings
if (strpos((string) $key, '-OR>') !== false)
{
$ORarray = explode('-OR>', (string) $key);
}
else
{
$ORarray = array($key);
}
// make sure we have an array
if (!ArrayHelper::check($globalKey))
{
$globalKey = array($globalKey);
}
// now load the query (this may be to much... but hey let it write the
code :)
foreach ($globalKey as $_globalKey)
{
// now build the query
$ORquery = array('s' => array(), 'i' =>
array());
foreach ($ORarray as $ORkey)
{
$ORquery['i'][] = "a." . $ORkey . " = '
. (int) \$"
. $_globalKey;
$ORquery['s'][] = "a." . $ORkey . " = '
. \$db->quote(\$"
. $_globalKey . ")";
}
$query .= PHP_EOL . PHP_EOL . Indent::_(2) . "//"
. Line::_(__Line__, __Class__) . " Filter by " .
$_globalKey
. " global.";
$query .= PHP_EOL . Indent::_(2) . "\$" . $_globalKey
. " = \$this->" . $_globalKey . ";";
$query .= PHP_EOL . Indent::_(2) . "if (is_numeric(\$"
. $_globalKey . " ))";
$query .= PHP_EOL . Indent::_(2) . "{";
$query .= PHP_EOL . Indent::_(3) . "\$query->where('"
. implode(
" . ' OR ", $ORquery['i']
) . ", ' OR');";
$query .= PHP_EOL . Indent::_(2) . "}";
$query .= PHP_EOL . Indent::_(2) . "elseif (is_string(\$"
. $_globalKey . "))";
$query .= PHP_EOL . Indent::_(2) . "{";
$query .= PHP_EOL . Indent::_(3) . "\$query->where('"
. implode(
" . ' OR ", $ORquery['s']
) . ", ' OR');";
$query .= PHP_EOL . Indent::_(2) . "}";
$query .= PHP_EOL . Indent::_(2) . "else";
$query .= PHP_EOL . Indent::_(2) . "{";
$query .= PHP_EOL . Indent::_(3) .
"\$query->where('a." . $ORkey
. " = -5');";
$query .= PHP_EOL . Indent::_(2) . "}";
}
}
if
(CFactory::_('Compiler.Builder.Access.Switch')->exists($nameSingleCode))
{
$query .= PHP_EOL . PHP_EOL . Indent::_(2) . "//" . Line::_(
__LINE__,__CLASS__
) . " Join over the asset groups.";
$query .= PHP_EOL . Indent::_(2)
. "\$query->select('ag.title AS
access_level');";
$query .= PHP_EOL . Indent::_(2)
. "\$query->join('LEFT', '#__viewlevels AS ag ON
ag.id = a.access');";
// check if the access field was over ridden
if
(!CFactory::_('Compiler.Builder.Field.Names')->isString($nameSingleCode
. '.access'))
{
// component helper name
$Helper =
CFactory::_('Compiler.Builder.Content.One')->get('Component')
. 'Helper';
// load the access filter query code
$query .= PHP_EOL . Indent::_(2) . "//" . Line::_(
__LINE__,__CLASS__
)
. " Filter by access level.";
$query .= PHP_EOL . Indent::_(2)
. "\$_access =
\$this->getState('filter.access');";
$query .= PHP_EOL . Indent::_(2)
. "if (\$_access && is_numeric(\$_access))";
$query .= PHP_EOL . Indent::_(2) . "{";
$query .= PHP_EOL . Indent::_(3)
. "\$query->where('a.access = ' . (int)
\$_access);";
$query .= PHP_EOL . Indent::_(2) . "}";
$query .= PHP_EOL . Indent::_(2) . "elseif ("
. "Super_" .
"__0a59c65c_9daf_4bc9_baf4_e063ff9e6a8a___Power::check(\$_access))";
$query .= PHP_EOL . Indent::_(2) . "{";
$query .= PHP_EOL . Indent::_(3) . "//"
. Line::_(__Line__, __Class__)
. " Secure the array for the query";
$query .= PHP_EOL . Indent::_(3)
. "\$_access = ArrayHelper::toInteger(\$_access);";
$query .= PHP_EOL . Indent::_(3) . "//"
. Line::_(__Line__, __Class__) . " Filter by the Access
Array.";
$query .= PHP_EOL . Indent::_(3)
. "\$query->where('a.access IN (' .
implode(',', \$_access) . ')');";
$query .= PHP_EOL . Indent::_(2) . "}";
}
// TODO the following will fight against the above access filter
$query .= PHP_EOL . Indent::_(2) . "//" . Line::_(__Line__,
__Class__)
. " Implement View Level Access";
$query .= PHP_EOL . Indent::_(2)
. "if (!\$user->authorise('core.options',
'com_"
. CFactory::_('Config')->component_code_name .
"'))";
$query .= PHP_EOL . Indent::_(2) . "{";
$query .= PHP_EOL . Indent::_(3)
. "\$groups = implode(',',
\$user->getAuthorisedViewLevels());";
$query .= PHP_EOL . Indent::_(3)
. "\$query->where('a.access IN (' . \$groups .
')');";
$query .= PHP_EOL . Indent::_(2) . "}";
}
// add dynamic ordering (Linked view)
if
(CFactory::_('Compiler.Builder.Views.Default.Ordering')->
get("$nameListCode.add_linked_ordering", 0) == 1)
{
foreach
(CFactory::_('Compiler.Builder.Views.Default.Ordering')->
get("$nameListCode.linked_ordering_fields", []) as
$order_field)
{
if (($order_field_name =
CFactory::_('Field.Database.Name')->get(
$nameListCode, $order_field['field']
// We Removed This 'listJoinBuilder' as targetArea
// we will keep an eye on this
)) !== false)
{
// default ordering is by publish and ordering
$query .= PHP_EOL . PHP_EOL . Indent::_(2) . "//"
. Line::_(
__LINE__,__CLASS__
) . " Order the results by ordering";
$query .= PHP_EOL . Indent::_(2)
. "\$query->order('"
. $order_field_name . " " .
$order_field['direction']
. "');";
}
}
}
else
{
// default ordering is by publish and ordering
$query .= PHP_EOL . PHP_EOL . Indent::_(2) . "//" . Line::_(
__LINE__,__CLASS__
) . " Order the results by ordering";
$query .= PHP_EOL . Indent::_(2)
. "\$query->order('a.published ASC');";
$query .= PHP_EOL . Indent::_(2)
. "\$query->order('a.ordering ASC');";
}
$query .= PHP_EOL . PHP_EOL . Indent::_(2) . "//" . Line::_(
__LINE__,__CLASS__
) . " Load the items";
$query .= PHP_EOL . Indent::_(2) .
"\$db->setQuery(\$query);";
$query .= PHP_EOL . Indent::_(2) . "\$db->execute();";
$query .= PHP_EOL . Indent::_(2) . "if
(\$db->getNumRows())";
$query .= PHP_EOL . Indent::_(2) . "{";
$query .= PHP_EOL . Indent::_(3) . "\$items =
\$db->loadObjectList();";
// add the fixing strings method
$query .= $this->setGetItemsMethodStringFix(
$nameSingleCode, $nameListCode,
CFactory::_('Compiler.Builder.Content.One')->get('Component'),
Indent::_(1)
);
// add translations
$query .= $this->setSelectionTranslationFix(
$nameListCode,
CFactory::_('Compiler.Builder.Content.One')->get('Component'),
Indent::_(1)
);
// filter by child repetable field values
if (StringHelper::check($globalKey) && $key
&& strpos(
(string) $key, '-R>'
) !== false
&& strpos((string) $key, '-A>') === false)
{
list($field, $target) = explode('-R>', (string) $key);
$query .= PHP_EOL . PHP_EOL . Indent::_(3) . "//" . Line::_(
__LINE__,__CLASS__
) . " Filter by " . $globalKey . " in this Repetable
Field";
$query .= PHP_EOL . Indent::_(3) . "if ("
. "Super_" .
"__0a59c65c_9daf_4bc9_baf4_e063ff9e6a8a___Power::check(\$items)
&& isset(\$this->"
. $globalKey . "))";
$query .= PHP_EOL . Indent::_(3) . "{";
$query .= PHP_EOL . Indent::_(4)
. "foreach (\$items as \$nr => &\$item)";
$query .= PHP_EOL . Indent::_(4) . "{";
$query .= PHP_EOL . Indent::_(5) . "if (isset(\$item->" .
$field
. ") && Super_" .
"__4b225c51_d293_48e4_b3f6_5136cf5c3f18___Power::check(\$item->"
. $field . "))";
$query .= PHP_EOL . Indent::_(5) . "{";
$query .= PHP_EOL . Indent::_(6)
. "\$tmpArray = json_decode(\$item->" . $field .
",true);";
$query .= PHP_EOL . Indent::_(6) . "if
(!isset(\$tmpArray['"
. $target . "']) || !Super_" .
"__0a59c65c_9daf_4bc9_baf4_e063ff9e6a8a___Power::check(\$tmpArray['"
. $target . "']) || !in_array(\$this->" . $globalKey
. ", \$tmpArray['" . $target . "']))";
$query .= PHP_EOL . Indent::_(6) . "{";
$query .= PHP_EOL . Indent::_(7) . "unset(\$items[\$nr]);";
$query .= PHP_EOL . Indent::_(7) . "continue;";
$query .= PHP_EOL . Indent::_(6) . "}";
$query .= PHP_EOL . Indent::_(5) . "}";
$query .= PHP_EOL . Indent::_(5) . "else";
$query .= PHP_EOL . Indent::_(5) . "{";
$query .= PHP_EOL . Indent::_(6) . "unset(\$items[\$nr]);";
$query .= PHP_EOL . Indent::_(6) . "continue;";
$query .= PHP_EOL . Indent::_(5) . "}";
$query .= PHP_EOL . Indent::_(4) . "}";
$query .= PHP_EOL . Indent::_(3) . "}";
$query .= PHP_EOL . Indent::_(3) . "else";
$query .= PHP_EOL . Indent::_(3) . "{";
$query .= PHP_EOL . Indent::_(4) . "return false;";
$query .= PHP_EOL . Indent::_(3) . "}";
}
// filter by child array field values
if (StringHelper::check($globalKey) && $key
&& strpos(
(string) $key, '-R>'
) === false
&& strpos((string) $key, '-A>') !== false)
{
$query .= PHP_EOL . PHP_EOL . Indent::_(3) . "//" . Line::_(
__LINE__,__CLASS__
) . " Filter by " . $globalKey . " Array Field";
$query .= PHP_EOL . Indent::_(3) . "\$" . $globalKey . "
= \$this->"
. $globalKey . ";";
$query .= PHP_EOL . Indent::_(3) . "if ("
. "Super_" .
"__0a59c65c_9daf_4bc9_baf4_e063ff9e6a8a___Power::check(\$items)
&& \$" . $globalKey
. ")";
$query .= PHP_EOL . Indent::_(3) . "{";
$query .= PHP_EOL . Indent::_(4)
. "foreach (\$items as \$nr => &\$item)";
$query .= PHP_EOL . Indent::_(4) . "{";
list($bin, $target) = explode('-A>', (string) $key);
if (StringHelper::check($target))
{
$query .= PHP_EOL . Indent::_(5) . "if (isset(\$item->" .
$target
. ") && Super_" .
"__4b225c51_d293_48e4_b3f6_5136cf5c3f18___Power::check(\$item->"
. $target . "))";
$query .= PHP_EOL . Indent::_(5) . "{";
$query .= PHP_EOL . Indent::_(6) . "\$item->" . $target
. " = json_decode(\$item->" . $target . ",
true);";
$query .= PHP_EOL . Indent::_(5) . "}";
$query .= PHP_EOL . Indent::_(5) . "elseif
(!isset(\$item->"
. $target . ") || !Super_" .
"__0a59c65c_9daf_4bc9_baf4_e063ff9e6a8a___Power::check(\$item->"
. $target . "))";
$query .= PHP_EOL . Indent::_(5) . "{";
$query .= PHP_EOL . Indent::_(6) . "unset(\$items[\$nr]);";
$query .= PHP_EOL . Indent::_(6) . "continue;";
$query .= PHP_EOL . Indent::_(5) . "}";
$query .= PHP_EOL . Indent::_(5) . "if (!in_array(\$"
. $globalKey . ",\$item->" . $target . "))";
}
else
{
$query .= PHP_EOL . Indent::_(5) . "if (isset(\$item->" .
$_key . ") && "
. "Super_" .
"__4b225c51_d293_48e4_b3f6_5136cf5c3f18___Power::check(\$item->"
. $_key . "))";
$query .= PHP_EOL . Indent::_(5) . "{";
$query .= PHP_EOL . Indent::_(6) . "\$item->" . $_key
. " = json_decode(\$item->" . $_key . ",
true);";
$query .= PHP_EOL . Indent::_(5) . "}";
$query .= PHP_EOL . Indent::_(5) . "elseif
(!isset(\$item->"
. $_key . ") || !Super_" .
"__0a59c65c_9daf_4bc9_baf4_e063ff9e6a8a___Power::check(\$item->"
. $_key . "))";
$query .= PHP_EOL . Indent::_(5) . "{";
$query .= PHP_EOL . Indent::_(6) . "unset(\$items[\$nr]);";
$query .= PHP_EOL . Indent::_(6) . "continue;";
$query .= PHP_EOL . Indent::_(5) . "}";
$query .= PHP_EOL . Indent::_(5) . "if (!in_array(\$"
. $globalKey . ",\$item->" . $_key . "))";
}
$query .= PHP_EOL . Indent::_(5) . "{";
$query .= PHP_EOL . Indent::_(6) . "unset(\$items[\$nr]);";
$query .= PHP_EOL . Indent::_(6) . "continue;";
$query .= PHP_EOL . Indent::_(5) . "}";
$query .= PHP_EOL . Indent::_(4) . "}";
$query .= PHP_EOL . Indent::_(3) . "}";
$query .= PHP_EOL . Indent::_(3) . "else";
$query .= PHP_EOL . Indent::_(3) . "{";
$query .= PHP_EOL . Indent::_(4) . "return false;";
$query .= PHP_EOL . Indent::_(3) . "}";
}
// filter by parent repetable field values
if (StringHelper::check($globalKey) && $key
&& strpos(
(string) $parentKey, '-R>'
) !== false
&& strpos((string) $parentKey, '-A>') === false)
{
list($bin, $target) = explode('-R>', (string) $parentKey);
$query .= PHP_EOL . PHP_EOL . Indent::_(3) . "//" . Line::_(
__LINE__,__CLASS__
) . " Filter by " . $_key . " Repetable Field";
$query .= PHP_EOL . Indent::_(3) . "\$" . $globalKey
. " = json_decode(\$this->" . $globalKey .
",true);";
$query .= PHP_EOL . Indent::_(3) . "if ("
. "Super_" .
"__0a59c65c_9daf_4bc9_baf4_e063ff9e6a8a___Power::check(\$items)
&& isset(\$"
. $globalKey . ") && Super_" .
"__0a59c65c_9daf_4bc9_baf4_e063ff9e6a8a___Power::check(\$"
. $globalKey . "))";
$query .= PHP_EOL . Indent::_(3) . "{";
$query .= PHP_EOL . Indent::_(4)
. "foreach (\$items as \$nr => &\$item)";
$query .= PHP_EOL . Indent::_(4) . "{";
$query .= PHP_EOL . Indent::_(5) . "if (\$item->" . $_key
. " && isset(\$" . $globalKey . "['" .
$target . "']) && "
. "Super_" .
"__0a59c65c_9daf_4bc9_baf4_e063ff9e6a8a___Power::check(\$" .
$globalKey . "['"
. $target . "']))";
$query .= PHP_EOL . Indent::_(5) . "{";
$query .= PHP_EOL . Indent::_(6) . "if (!in_array(\$item->"
. $_key
. ",\$" . $globalKey . "['" . $target .
"']))";
$query .= PHP_EOL . Indent::_(6) . "{";
$query .= PHP_EOL . Indent::_(7) . "unset(\$items[\$nr]);";
$query .= PHP_EOL . Indent::_(7) . "continue;";
$query .= PHP_EOL . Indent::_(6) . "}";
$query .= PHP_EOL . Indent::_(5) . "}";
$query .= PHP_EOL . Indent::_(5) . "else";
$query .= PHP_EOL . Indent::_(5) . "{";
$query .= PHP_EOL . Indent::_(6) . "unset(\$items[\$nr]);";
$query .= PHP_EOL . Indent::_(6) . "continue;";
$query .= PHP_EOL . Indent::_(5) . "}";
$query .= PHP_EOL . Indent::_(4) . "}";
$query .= PHP_EOL . Indent::_(3) . "}";
$query .= PHP_EOL . Indent::_(3) . "else";
$query .= PHP_EOL . Indent::_(3) . "{";
$query .= PHP_EOL . Indent::_(4) . "return false;";
$query .= PHP_EOL . Indent::_(3) . "}";
}
// filter by parent array field values
if (StringHelper::check($globalKey) && $key
&& strpos(
(string) $parentKey, '-R>'
) === false
&& strpos((string) $parentKey, '-A>') !== false)
{
$query .= PHP_EOL . PHP_EOL . Indent::_(3) . "//" . Line::_(
__LINE__,__CLASS__
) . " Filter by " . $globalKey . " Array Field";
$query .= PHP_EOL . Indent::_(3) . "\$" . $globalKey . "
= \$this->"
. $globalKey . ";";
$query .= PHP_EOL . Indent::_(3) . "if ("
. "Super_" .
"__0a59c65c_9daf_4bc9_baf4_e063ff9e6a8a___Power::check(\$items)
&& "
. "Super_" .
"__0a59c65c_9daf_4bc9_baf4_e063ff9e6a8a___Power::check(\$" .
$globalKey . "))";
$query .= PHP_EOL . Indent::_(3) . "{";
$query .= PHP_EOL . Indent::_(4)
. "foreach (\$items as \$nr => &\$item)";
$query .= PHP_EOL . Indent::_(4) . "{";
list($bin, $target) = explode('-A>', (string) $parentKey);
if (StringHelper::check($target))
{
$query .= PHP_EOL . Indent::_(5) . "if (\$item->" . $_key
. " && Super_" .
"__0a59c65c_9daf_4bc9_baf4_e063ff9e6a8a___Power::check(\$" .
$globalKey . "['"
. $target . "']))";
$query .= PHP_EOL . Indent::_(5) . "{";
$query .= PHP_EOL . Indent::_(6) . "if
(!in_array(\$item->"
. $_key . ",\$" . $globalKey . "['" . $target
. "']))";
}
else
{
$query .= PHP_EOL . Indent::_(5) . "if (\$item->" . $_key
. ")";
$query .= PHP_EOL . Indent::_(5) . "{";
$query .= PHP_EOL . Indent::_(6) . "if
(!in_array(\$item->"
. $_key . ",\$" . $globalKey . "))";
}
$query .= PHP_EOL . Indent::_(6) . "{";
$query .= PHP_EOL . Indent::_(7) . "unset(\$items[\$nr]);";
$query .= PHP_EOL . Indent::_(7) . "continue;";
$query .= PHP_EOL . Indent::_(6) . "}";
$query .= PHP_EOL . Indent::_(5) . "}";
$query .= PHP_EOL . Indent::_(5) . "else";
$query .= PHP_EOL . Indent::_(5) . "{";
$query .= PHP_EOL . Indent::_(6) . "unset(\$items[\$nr]);";
$query .= PHP_EOL . Indent::_(6) . "continue;";
$query .= PHP_EOL . Indent::_(5) . "}";
$query .= PHP_EOL . Indent::_(4) . "}";
$query .= PHP_EOL . Indent::_(3) . "}";
$query .= PHP_EOL . Indent::_(3) . "else";
$query .= PHP_EOL . Indent::_(3) . "{";
$query .= PHP_EOL . Indent::_(4) . "return false;";
$query .= PHP_EOL . Indent::_(3) . "}";
}
// add custom php to getitems method after all
$query .= CFactory::_('Customcode.Dispenser')->get(
'php_getitems_after_all', $nameSingleCode,
PHP_EOL . PHP_EOL . Indent::_(1)
);
$query .= PHP_EOL . Indent::_(3) . "return \$items;";
$query .= PHP_EOL . Indent::_(2) . "}";
$query .= PHP_EOL . Indent::_(2) . "return false;";
$query .= PHP_EOL . Indent::_(1) . "}";
// SELECTIONTRANSLATIONFIXFUNC<<<DYNAMIC>>>
$query .= $this->setSelectionTranslationFixFunc(
$nameListCode,
CFactory::_('Compiler.Builder.Content.One')->get('Component')
);
// fixe mothod name clash
$query = str_replace(
'selectionTranslation(',
'selectionTranslation' . $functionName . '(',
$query
);
return $query;
}
/**
* @param $nameListCode
*
* @return array|string
*/
public function setCustomAdminDynamicButton($nameListCode)
{
$buttons = '';
if (isset($this->customAdminDynamicButtons[$nameListCode])
&& ArrayHelper::check(
$this->customAdminDynamicButtons[$nameListCode]
))
{
$buttons = [];
foreach (
$this->customAdminDynamicButtons[$nameListCode] as
$custom_button
)
{
// Load to lang
$keyLang = CFactory::_('Config')->lang_prefix .
'_' . $custom_button['NAME'];
CFactory::_('Language')->set(
CFactory::_('Config')->lang_target, $keyLang,
StringHelper::safe(
$custom_button['name'], 'Ww'
)
);
// add cpanel button
$buttons[] = Indent::_(2) . "if
(\$this->canDo->get('"
. $custom_button['link'] . ".access'))";
$buttons[] = Indent::_(2) . "{";
$buttons[] = Indent::_(3) . "//" . Line::_(__Line__,
__Class__)
. " add " . $custom_button['name'] . "
button.";
$buttons[] = Indent::_(3) . "ToolbarHelper::custom('"
. $nameListCode . ".redirectTo"
. StringHelper::safe(
$custom_button['link'], 'F'
) . "', '" . $custom_button['icon'] .
"', '', '" . $keyLang
. "', true);";
$buttons[] = Indent::_(2) . "}";
}
if (ArrayHelper::check($buttons))
{
return implode(PHP_EOL, $buttons);
}
}
return $buttons;
}
/**
* @param $nameListCode
*
* @return array|string
*/
public function setCustomAdminDynamicButtonController($nameListCode)
{
$method = '';
if (isset($this->customAdminDynamicButtons[$nameListCode])
&& ArrayHelper::check(
$this->customAdminDynamicButtons[$nameListCode]
))
{
$method = [];
foreach (
$this->customAdminDynamicButtons[$nameListCode] as
$custom_button
)
{
// add the custom redirect method
$method[] = PHP_EOL . PHP_EOL . Indent::_(1)
. "public function redirectTo"
. StringHelper::safe(
$custom_button['link'], 'F'
) . "()";
$method[] = Indent::_(1) . "{";
$method[] = Indent::_(2) . "//" . Line::_(__Line__,
__Class__)
. " Check for request forgeries";
$method[] = Indent::_(2)
. "Session::checkToken() or die(Text:"
. ":_('JINVALID_TOKEN'));";
$method[] = Indent::_(2) . "//" . Line::_(__Line__,
__Class__)
. " check if export is allowed for this user.";
if (CFactory::_('Config')->get('joomla_version',
3) == 3)
{
$method[] = Indent::_(2) . "\$user = Factory::getUser();";
}
else
{
$method[] = Indent::_(2) . "\$user =
Factory::getApplication()->getIdentity();";
}
$method[] = Indent::_(2) . "if (\$user->authorise('"
. $custom_button['link'] . ".access',
'com_"
. CFactory::_('Config')->component_code_name .
"'))";
$method[] = Indent::_(2) . "{";
$method[] = Indent::_(3) . "//" . Line::_(__Line__,
__Class__)
. " Get the input";
$method[] = Indent::_(3)
. "\$input = Factory::getApplication()->input;";
$method[] = Indent::_(3)
. "\$pks = \$input->post->get('cid', array(),
'array');";
$method[] = Indent::_(3) . "//" . Line::_(__Line__,
__Class__)
. " Sanitize the input";
$method[] = Indent::_(3)
. "\$pks = ArrayHelper::toInteger(\$pks);";
$method[] = Indent::_(3) . "//" . Line::_(__Line__,
__Class__)
. " convert to string";
$method[] = Indent::_(3) . "\$ids = implode('_',
\$pks);";
$method[] = Indent::_(3)
.
"\$this->setRedirect(Route::_('index.php?option=com_"
. CFactory::_('Config')->component_code_name .
"&view="
. $custom_button['link'] . "&cid='.\$ids,
false));";
$method[] = Indent::_(3) . "return;";
$method[] = Indent::_(2) . "}";
$method[] = Indent::_(2) . "//" . Line::_(__Line__,
__Class__)
. " Redirect to the list screen with error.";
$method[] = Indent::_(2) . "\$message = Text:" .
":_('"
. CFactory::_('Config')->lang_prefix .
"_ACCESS_TO_" . $custom_button['NAME']
. "_FAILED');";
$method[] = Indent::_(2)
.
"\$this->setRedirect(Route::_('index.php?option=com_"
. CFactory::_('Config')->component_code_name .
"&view=" . $nameListCode
. "', false), \$message, 'error');";
$method[] = Indent::_(2) . "return;";
$method[] = Indent::_(1) . "}";
// add to lang array
$lankey = CFactory::_('Config')->lang_prefix .
"_ACCESS_TO_"
. $custom_button['NAME'] . "_FAILED";
CFactory::_('Language')->set(
CFactory::_('Config')->lang_target, $lankey,
'Access to ' . $custom_button['link'] . ' was
denied.'
);
}
return implode(PHP_EOL, $method);
}
return $method;
}
/**
* A function that builds get Items Method for model
*
* @param string $nameSingleCode The single view name
* @param string $nameListCode The list view name
* @param array $config The config details to adapt the
method being build
*
* @return string
*/
public function setGetItemsModelMethod(&$nameSingleCode,
&$nameListCode,
$config
= array('functionName'
=> 'getExportData',
'docDesc' =>
'Method to get list export data.',
'type' =>
'export')
)
{
// start the query string
$query = '';
// check if this is the export method
$isExport = ('export' === $config['type']);
// check if this view has export feature, and or if this is not an export
method
if ((isset($this->eximportView[$nameListCode])
&& $this->eximportView[$nameListCode])
|| !$isExport)
{
$query = PHP_EOL . PHP_EOL . Indent::_(1) . "/**";
$query .= PHP_EOL . Indent::_(1) . " * " .
$config['docDesc'];
$query .= PHP_EOL . Indent::_(1) . " *";
$query .= PHP_EOL . Indent::_(1)
. " * @param array \$pks The ids of the items to get";
$query .= PHP_EOL . Indent::_(1)
. " * @param JUser \$user The user making the request";
$query .= PHP_EOL . Indent::_(1) . " *";
$query .= PHP_EOL . Indent::_(1)
. " * @return mixed An array of data items on success, false on
failure.";
$query .= PHP_EOL . Indent::_(1) . " */";
$query .= PHP_EOL . Indent::_(1) . "public function "
. $config['functionName'] . "(\$pks, \$user =
null)";
$query .= PHP_EOL . Indent::_(1) . "{";
$query .= PHP_EOL . Indent::_(2) . "//" . Line::_(__Line__,
__Class__)
. " setup the query";
$query .= PHP_EOL . Indent::_(2) . "if ((\$pks_size = "
. "Super_" .
"__0a59c65c_9daf_4bc9_baf4_e063ff9e6a8a___Power::check(\$pks)) !==
false || 'bulk' === \$pks)";
$query .= PHP_EOL . Indent::_(2) . "{";
$query .= PHP_EOL . Indent::_(3) . "//" . Line::_(__Line__,
__Class__)
. " Set a value to know this is " .
$config['type']
. " method. (USE IN CUSTOM CODE TO ALTER OUTCOME)";
$query .= PHP_EOL . Indent::_(3) . "\$_" .
$config['type']
. " = true;";
$query .= PHP_EOL . Indent::_(3) . "//" . Line::_(__Line__,
__Class__)
. " Get the user object if not set.";
$query .= PHP_EOL . Indent::_(3) . "if (!isset(\$user) || !"
. "Super_" .
"__91004529_94a9_4590_b842_e7c6b624ecf5___Power::check(\$user))";
$query .= PHP_EOL . Indent::_(3) . "{";
if (CFactory::_('Config')->get('joomla_version',
3) == 3)
{
$query .= PHP_EOL . Indent::_(4) . "\$user =
Factory::getUser();";
}
else
{
$query .= PHP_EOL . Indent::_(4) . "\$user =
\$this->getCurrentUser();";
}
$query .= PHP_EOL . Indent::_(3) . "}";
$query .= PHP_EOL . Indent::_(3) . "//" . Line::_(__Line__,
__Class__)
. " Create a new query object.";
if (CFactory::_('Config')->get('joomla_version',
3) == 3)
{
$query .= PHP_EOL . Indent::_(3) . "\$db =
Factory::getDBO();";
}
else
{
$query .= PHP_EOL . Indent::_(3) . "\$db =
\$this->getDatabase();";
}
$query .= PHP_EOL . Indent::_(3)
. "\$query = \$db->getQuery(true);";
$query .= PHP_EOL . PHP_EOL . Indent::_(3) . "//" . Line::_(
__LINE__,__CLASS__
) . " Select some fields";
$query .= PHP_EOL . Indent::_(3) .
"\$query->select('a.*');";
$query .= PHP_EOL . PHP_EOL . Indent::_(3) . "//" . Line::_(
__LINE__,__CLASS__
) . " From the " .
CFactory::_('Config')->component_code_name . "_"
. $nameSingleCode . " table";
$query .= PHP_EOL . Indent::_(3)
. "\$query->from(\$db->quoteName('#__"
. CFactory::_('Config')->component_code_name .
"_" . $nameSingleCode
. "', 'a'));";
$query .= PHP_EOL . Indent::_(3) . "//" . Line::_(__Line__,
__Class__)
. " The bulk export path";
$query .= PHP_EOL . Indent::_(3) . "if ('bulk' ===
\$pks)";
$query .= PHP_EOL . Indent::_(3)
. "{";
$query .= PHP_EOL . Indent::_(4)
. "\$query->where('a.id > 0');";
$query .= PHP_EOL . Indent::_(3)
. "}";
$query .= PHP_EOL . Indent::_(3) . "//" . Line::_(__Line__,
__Class__)
. " A large array of ID's will not work out well";
$query .= PHP_EOL . Indent::_(3) . "elseif (\$pks_size >
500)";
$query .= PHP_EOL . Indent::_(3)
. "{";
$query .= PHP_EOL . Indent::_(4) . "//" . Line::_(__Line__,
__Class__)
. " Use lowest ID";
$query .= PHP_EOL . Indent::_(4)
. "\$query->where('a.id >= ' . (int)
min(\$pks));";
$query .= PHP_EOL . Indent::_(4) . "//" . Line::_(__Line__,
__Class__)
. " Use highest ID";
$query .= PHP_EOL . Indent::_(4)
. "\$query->where('a.id <= ' . (int)
max(\$pks));";
$query .= PHP_EOL . Indent::_(3)
. "}";
$query .= PHP_EOL . Indent::_(3) . "//" . Line::_(__Line__,
__Class__)
. " The normal default path";
$query .= PHP_EOL . Indent::_(3) . "else";
$query .= PHP_EOL . Indent::_(3)
. "{";
$query .= PHP_EOL . Indent::_(4)
. "\$query->where('a.id IN (' .
implode(',',\$pks) . ')');";
$query .= PHP_EOL . Indent::_(3)
. "}";
// add custom filtering php
$query .= CFactory::_('Customcode.Dispenser')->get(
'php_getlistquery', $nameSingleCode,
PHP_EOL . PHP_EOL . Indent::_(1)
);
// first check if we export of text only is avalable
if
(CFactory::_('Config')->get('export_text_only', 0))
{
// add switch
$query .= PHP_EOL . Indent::_(3) . "//" . Line::_(
__LINE__,__CLASS__
) . " Get global switch to activate text only export";
$query .= PHP_EOL . Indent::_(3)
. "\$export_text_only =
ComponentHelper::getParams('com_"
. CFactory::_('Config')->component_code_name
. "')->get('export_text_only', 0);";
// first check if we have custom queries
$custom_query = $this->setCustomQuery(
$nameListCode, $nameSingleCode, Indent::_(2), true
);
}
// if values were returned add the area
if (isset($custom_query)
&& StringHelper::check(
$custom_query
))
{
$query .= PHP_EOL . Indent::_(3) . "//" . Line::_(
__LINE__,__CLASS__
) . " Add these queries only if text only is required";
$query .= PHP_EOL . Indent::_(3) . "if
(\$export_text_only)";
$query .= PHP_EOL . Indent::_(3) . "{";
// add the custom fields query
$query .= $custom_query;
$query .= PHP_EOL . Indent::_(3) . "}";
}
// add access levels if the view has access set
if
(CFactory::_('Compiler.Builder.Access.Switch')->exists($nameSingleCode))
{
$query .= PHP_EOL . Indent::_(3) . "//" . Line::_(
__LINE__,__CLASS__
) . " Implement View Level Access";
$query .= PHP_EOL . Indent::_(3)
. "if (!\$user->authorise('core.options',
'com_"
. CFactory::_('Config')->component_code_name .
"'))";
$query .= PHP_EOL . Indent::_(3) . "{";
$query .= PHP_EOL . Indent::_(4)
. "\$groups = implode(',',
\$user->getAuthorisedViewLevels());";
$query .= PHP_EOL . Indent::_(4)
. "\$query->where('a.access IN (' . \$groups .
')');";
$query .= PHP_EOL . Indent::_(3) . "}";
}
// add dynamic ordering (Exported data)
if
(CFactory::_('Compiler.Builder.Views.Default.Ordering')->
get("$nameListCode.add_admin_ordering", 0) == 1)
{
foreach
(CFactory::_('Compiler.Builder.Views.Default.Ordering')->
get("$nameListCode.admin_ordering_fields", []) as
$order_field)
{
if (($order_field_name =
CFactory::_('Field.Database.Name')->get(
$nameListCode, $order_field['field']
)) !== false)
{
$query .= PHP_EOL . PHP_EOL . Indent::_(3) . "//"
. Line::_(
__LINE__,__CLASS__
) . " Order the results by ordering";
$query .= PHP_EOL . Indent::_(3)
. "\$query->order('"
. $order_field_name . " "
. $order_field['direction'] . "');";
}
}
}
else
{
$query .= PHP_EOL . PHP_EOL . Indent::_(3) . "//"
. Line::_(
__LINE__,__CLASS__
) . " Order the results by ordering";
$query .= PHP_EOL . Indent::_(3)
. "\$query->order('a.ordering ASC');";
}
$query .= PHP_EOL . PHP_EOL . Indent::_(3) . "//" . Line::_(
__LINE__,__CLASS__
) . " Load the items";
$query .= PHP_EOL . Indent::_(3) .
"\$db->setQuery(\$query);";
$query .= PHP_EOL . Indent::_(3) . "\$db->execute();";
$query .= PHP_EOL . Indent::_(3) . "if
(\$db->getNumRows())";
$query .= PHP_EOL . Indent::_(3) . "{";
$query .= PHP_EOL . Indent::_(4)
. "\$items = \$db->loadObjectList();";
// set the string fixing code
$query .= $this->setGetItemsMethodStringFix(
$nameSingleCode, $nameListCode,
CFactory::_('Compiler.Builder.Content.One')->get('Component'),
Indent::_(2), $isExport, true
);
// first check if we export of text only is avalable
if
(CFactory::_('Config')->get('export_text_only', 0))
{
$query_translations = $this->setSelectionTranslationFix(
$nameListCode,
CFactory::_('Compiler.Builder.Content.One')->get('Component'),
Indent::_(3)
);
}
// add translations
if (isset($query_translations)
&& StringHelper::check($query_translations))
{
$query .= PHP_EOL . Indent::_(3) . "//" . Line::_(
__LINE__,__CLASS__
) . " Add these translation only if text only is required";
$query .= PHP_EOL . Indent::_(3) . "if
(\$export_text_only)";
$query .= PHP_EOL . Indent::_(3) . "{";
$query .= $query_translations;
$query .= PHP_EOL . Indent::_(3) . "}";
}
// add custom php to getItems method after all
$query .= CFactory::_('Customcode.Dispenser')->get(
'php_getitems_after_all', $nameSingleCode,
PHP_EOL . PHP_EOL . Indent::_(2)
);
// in privacy export we must return array of arrays
if ('privacy' === $config['type'])
{
$query .= PHP_EOL . Indent::_(4)
. "return json_decode(json_encode(\$items), true);";
}
else
{
$query .= PHP_EOL . Indent::_(4) . "return \$items;";
}
$query .= PHP_EOL . Indent::_(3) . "}";
$query .= PHP_EOL . Indent::_(2) . "}";
$query .= PHP_EOL . Indent::_(2) . "return false;";
$query .= PHP_EOL . Indent::_(1) . "}";
// get the header script
if ($isExport)
{
$header =
\ComponentbuilderHelper::getDynamicScripts('headers');
// add getExImPortHeaders
$query .= CFactory::_('Customcode.Dispenser')->get(
'php_import_headers', 'import_' . $nameListCode,
PHP_EOL . PHP_EOL, null, true,
// set a default script for those with no custom script
PHP_EOL . PHP_EOL . CFactory::_('Placeholder')->update_(
$header
)
);
}
}
return $query;
}
public function setControllerEximportMethod($nameSingleCode,
$nameListCode
)
{
$method = '';
if (isset($this->eximportView[$nameListCode])
&& $this->eximportView[$nameListCode])
{
$method = [];
// add the export method
$method[] = PHP_EOL . PHP_EOL . Indent::_(1)
. "public function exportData()";
$method[] = Indent::_(1) . "{";
$method[] = Indent::_(2) . "//" . Line::_(__Line__,
__Class__)
. " Check for request forgeries";
$method[] = Indent::_(2) . "Session::checkToken() or
die(Text:"
. ":_('JINVALID_TOKEN'));";
$method[] = Indent::_(2) . "//" . Line::_(__Line__,
__Class__)
. " check if export is allowed for this user.";
if (CFactory::_('Config')->get('joomla_version',
3) == 3)
{
$method[] = Indent::_(2) . "\$user = Factory::getUser();";
}
else
{
$method[] = Indent::_(2) . "\$user =
Factory::getApplication()->getIdentity();";
}
$method[] = Indent::_(2) . "if (\$user->authorise('"
. $nameSingleCode . ".export', 'com_"
. CFactory::_('Config')->component_code_name
. "') &&
\$user->authorise('core.export', 'com_"
. CFactory::_('Config')->component_code_name .
"'))";
$method[] = Indent::_(2) . "{";
$method[] = Indent::_(3) . "//" . Line::_(__Line__,
__Class__)
. " Get the input";
$method[] = Indent::_(3)
. "\$input = Factory::getApplication()->input;";
$method[] = Indent::_(3)
. "\$pks = \$input->post->get('cid', array(),
'array');";
$method[] = Indent::_(3) . "//" . Line::_(__Line__,
__Class__)
. " Sanitize the input";
$method[] = Indent::_(3) . "\$pks =
ArrayHelper::toInteger(\$pks);";
$method[] = Indent::_(3) . "//" . Line::_(__Line__,
__Class__)
. " Get the model";
$method[] = Indent::_(3) . "\$model =
\$this->getModel('"
. StringHelper::safe($nameListCode, 'F')
. "');";
$method[] = Indent::_(3) . "//" . Line::_(__Line__,
__Class__)
. " get the data to export";
$method[] = Indent::_(3)
. "\$data = \$model->getExportData(\$pks);";
$method[] = Indent::_(3) . "if ("
. "Super_" .
"__0a59c65c_9daf_4bc9_baf4_e063ff9e6a8a___Power::check(\$data))";
$method[] = Indent::_(3) . "{";
$method[] = Indent::_(4) . "//" . Line::_(__Line__,
__Class__)
. " now set the data to the spreadsheet";
$method[] = Indent::_(4) . "\$date = Factory::getDate();";
$method[] = Indent::_(4) .
CFactory::_('Compiler.Builder.Content.One')->get('Component')
. "Helper::xls(\$data,'"
. StringHelper::safe($nameListCode, 'F')
. "_'.\$date->format('jS_F_Y'),'"
. StringHelper::safe($nameListCode, 'Ww')
. " exported ('.\$date->format('jS F,
Y').')','"
. StringHelper::safe($nameListCode, 'w')
. "');";
$method[] = Indent::_(3) . "}";
$method[] = Indent::_(2) . "}";
$method[] = Indent::_(2) . "//" . Line::_(__Line__,
__Class__)
. " Redirect to the list screen with error.";
$method[] = Indent::_(2) . "\$message = Text:" .
":_('"
. CFactory::_('Config')->lang_prefix .
"_EXPORT_FAILED');";
$method[] = Indent::_(2)
.
"\$this->setRedirect(Route::_('index.php?option=com_"
. CFactory::_('Config')->component_code_name .
"&view=" . $nameListCode
. "', false), \$message, 'error');";
$method[] = Indent::_(2) . "return;";
$method[] = Indent::_(1) . "}";
// add the import method
$method[] = PHP_EOL . PHP_EOL . Indent::_(1)
. "public function importData()";
$method[] = Indent::_(1) . "{";
$method[] = Indent::_(2) . "//" . Line::_(__Line__,
__Class__)
. " Check for request forgeries";
$method[] = Indent::_(2) . "Session::checkToken() or
die(Text:"
. ":_('JINVALID_TOKEN'));";
$method[] = Indent::_(2) . "//" . Line::_(__Line__,
__Class__)
. " check if import is allowed for this user.";
if (CFactory::_('Config')->get('joomla_version',
3) == 3)
{
$method[] = Indent::_(2) . "\$user = Factory::getUser();";
}
else
{
$method[] = Indent::_(2) . "\$user =
Factory::getApplication()->getIdentity();";
}
$method[] = Indent::_(2) . "if (\$user->authorise('"
. $nameSingleCode . ".import', 'com_"
. CFactory::_('Config')->component_code_name
. "') &&
\$user->authorise('core.import', 'com_"
. CFactory::_('Config')->component_code_name .
"'))";
$method[] = Indent::_(2) . "{";
$method[] = Indent::_(3) . "//" . Line::_(__Line__,
__Class__)
. " Get the import model";
$method[] = Indent::_(3) . "\$model =
\$this->getModel('"
. StringHelper::safe($nameListCode, 'F')
. "');";
$method[] = Indent::_(3) . "//" . Line::_(__Line__,
__Class__)
. " get the headers to import";
$method[] = Indent::_(3)
. "\$headers = \$model->getExImPortHeaders();";
$method[] = Indent::_(3) . "if ("
. "Super_" .
"__91004529_94a9_4590_b842_e7c6b624ecf5___Power::check(\$headers))";
$method[] = Indent::_(3) . "{";
$method[] = Indent::_(4) . "//" . Line::_(__Line__,
__Class__)
. " Load headers to session.";
$method[] = Indent::_(4) . "\$session =
Factory::getSession();";
$method[] = Indent::_(4) . "\$headers =
json_encode(\$headers);";
$method[] = Indent::_(4) . "\$session->set('" .
$nameSingleCode
. "_VDM_IMPORTHEADERS', \$headers);";
$method[] = Indent::_(4) .
"\$session->set('backto_VDM_IMPORT', '"
. $nameListCode . "');";
$method[] = Indent::_(4)
. "\$session->set('dataType_VDM_IMPORTINTO',
'"
. $nameSingleCode . "');";
$method[] = Indent::_(4) . "//" . Line::_(__Line__,
__Class__)
. " Redirect to import view.";
// add to lang array
$selectImportFileNote = CFactory::_('Config')->lang_prefix
. "_IMPORT_SELECT_FILE_FOR_"
. StringHelper::safe($nameListCode, 'U');
CFactory::_('Language')->set(
CFactory::_('Config')->lang_target,
$selectImportFileNote,
'Select the file to import data to ' . $nameListCode .
'.'
);
$method[] = Indent::_(4) . "\$message = Text:" .
":_('"
. $selectImportFileNote . "');";
// if this view has custom script it must have as custom import (model,
veiw, controller)
if (isset($this->importCustomScripts[$nameListCode])
&& $this->importCustomScripts[$nameListCode])
{
$method[] = Indent::_(4)
.
"\$this->setRedirect(Route::_('index.php?option=com_"
. CFactory::_('Config')->component_code_name .
"&view=import_"
. $nameListCode . "', false), \$message);";
}
else
{
$method[] = Indent::_(4)
.
"\$this->setRedirect(Route::_('index.php?option=com_"
. CFactory::_('Config')->component_code_name
. "&view=import', false), \$message);";
}
$method[] = Indent::_(4) . "return;";
$method[] = Indent::_(3) . "}";
$method[] = Indent::_(2) . "}";
$method[] = Indent::_(2) . "//" . Line::_(__Line__,
__Class__)
. " Redirect to the list screen with error.";
$method[] = Indent::_(2) . "\$message = Text:" .
":_('"
. CFactory::_('Config')->lang_prefix .
"_IMPORT_FAILED');";
$method[] = Indent::_(2)
.
"\$this->setRedirect(Route::_('index.php?option=com_"
. CFactory::_('Config')->component_code_name .
"&view=" . $nameListCode
. "', false), \$message, 'error');";
$method[] = Indent::_(2) . "return;";
$method[] = Indent::_(1) . "}";
return implode(PHP_EOL, $method);
}
return $method;
}
public function setExportButton($nameSingleCode, $nameListCode)
{
$button = '';
if (isset($this->eximportView[$nameListCode])
&& $this->eximportView[$nameListCode]
&&
CFactory::_('Config')->get('joomla_version', 3) ==
3) // needs fixing for Joomla 4 and above
{
// main lang prefix
$langExport = CFactory::_('Config')->lang_prefix .
'_'
. StringHelper::safe('Export Data', 'U');
// add to lang array
CFactory::_('Language')->set(CFactory::_('Config')->lang_target,
$langExport, 'Export Data');
$button = [];
$button[] = PHP_EOL . PHP_EOL . Indent::_(3)
. "if (\$this->canDo->get('core.export')
&& \$this->canDo->get('"
. $nameSingleCode . ".export'))";
$button[] = Indent::_(3) . "{";
$button[] = Indent::_(4) . "ToolbarHelper::custom('"
. $nameListCode . ".exportData', 'download',
'', '"
. $langExport . "', true);";
$button[] = Indent::_(3) . "}";
return implode(PHP_EOL, $button);
}
return $button;
}
public function setImportButton($nameSingleCode, $nameListCode)
{
$button = '';
if (isset($this->eximportView[$nameListCode])
&& $this->eximportView[$nameListCode]
&&
CFactory::_('Config')->get('joomla_version', 3) ==
3) // needs fixing for Joomla 4 and above
{
// main lang prefix
$langImport = CFactory::_('Config')->lang_prefix .
'_'
. StringHelper::safe('Import Data', 'U');
// add to lang array
CFactory::_('Language')->set(CFactory::_('Config')->lang_target,
$langImport, 'Import Data');
$button = [];
$button[] = PHP_EOL . PHP_EOL . Indent::_(2)
. "if (\$this->canDo->get('core.import')
&& \$this->canDo->get('"
. $nameSingleCode . ".import'))";
$button[] = Indent::_(2) . "{";
$button[] = Indent::_(3) . "ToolbarHelper::custom('"
. $nameListCode . ".importData', 'upload',
'', '"
. $langImport
. "', false);";
$button[] = Indent::_(2) . "}";
return implode(PHP_EOL, $button);
}
return $button;
}
public function setImportCustomScripts($nameListCode)
{
// setup Ajax files
$target = array('admin' => 'import_' .
$nameListCode);
CFactory::_('Utilities.Structure')->build($target,
'customimport');
// load the custom script to the files
// IMPORT_EXT_METHOD <<<DYNAMIC>>>
CFactory::_('Compiler.Builder.Content.Multi')->set('import_'
. $nameListCode . '|IMPORT_EXT_METHOD',
CFactory::_('Customcode.Dispenser')->get(
'php_import_ext', 'import_' . $nameListCode,
PHP_EOL, null,
true
));
// IMPORT_DISPLAY_METHOD_CUSTOM <<<DYNAMIC>>>
CFactory::_('Compiler.Builder.Content.Multi')->set('import_'
. $nameListCode . '|IMPORT_DISPLAY_METHOD_CUSTOM',
CFactory::_('Customcode.Dispenser')->get(
'php_import_display', 'import_' . $nameListCode,
PHP_EOL,
null,
true
));
// IMPORT_SETDATA_METHOD <<<DYNAMIC>>>
CFactory::_('Compiler.Builder.Content.Multi')->set('import_'
. $nameListCode . '|IMPORT_SETDATA_METHOD',
CFactory::_('Customcode.Dispenser')->get(
'php_import_setdata', 'import_' . $nameListCode,
PHP_EOL,
null,
true
));
// IMPORT_METHOD_CUSTOM <<<DYNAMIC>>>
CFactory::_('Compiler.Builder.Content.Multi')->set('import_'
. $nameListCode . '|IMPORT_METHOD_CUSTOM',
CFactory::_('Customcode.Dispenser')->get(
'php_import', 'import_' . $nameListCode, PHP_EOL,
null,
true
));
// IMPORT_SAVE_METHOD <<<DYNAMIC>>>
CFactory::_('Compiler.Builder.Content.Multi')->set('import_'
. $nameListCode . '|IMPORT_SAVE_METHOD',
CFactory::_('Customcode.Dispenser')->get(
'php_import_save', 'import_' . $nameListCode,
PHP_EOL,
null,
true
));
// IMPORT_DEFAULT_VIEW_CUSTOM <<<DYNAMIC>>>
CFactory::_('Compiler.Builder.Content.Multi')->set('import_'
. $nameListCode . '|IMPORT_DEFAULT_VIEW_CUSTOM',
CFactory::_('Customcode.Dispenser')->get(
'html_import_view', 'import_' . $nameListCode,
PHP_EOL,
null,
true
));
// insure we have the view placeholders setup
CFactory::_('Compiler.Builder.Content.Multi')->set('import_'
. $nameListCode . '|VIEW', 'IMPORT_' .
CFactory::_('Placeholder')->get_h('VIEWS'));
CFactory::_('Compiler.Builder.Content.Multi')->set('import_'
. $nameListCode . '|View', 'Import_' .
CFactory::_('Placeholder')->get_h('views'));
CFactory::_('Compiler.Builder.Content.Multi')->set('import_'
. $nameListCode . '|view', 'import_' .
CFactory::_('Placeholder')->get_h('views'));
CFactory::_('Compiler.Builder.Content.Multi')->set('import_'
. $nameListCode . '|VIEWS', 'IMPORT_' .
CFactory::_('Placeholder')->get_h('VIEWS'));
CFactory::_('Compiler.Builder.Content.Multi')->set('import_'
. $nameListCode . '|Views', 'Import_' .
CFactory::_('Placeholder')->get_h('views'));
CFactory::_('Compiler.Builder.Content.Multi')->set('import_'
. $nameListCode . '|views', 'import_' .
CFactory::_('Placeholder')->get_h('views'));
// IMPORT_CUSTOM_CONTROLLER_HEADER <<<DYNAMIC>>> add
the header details for the controller
CFactory::_('Compiler.Builder.Content.Multi')->set('import_'
. $nameListCode . '|IMPORT_CUSTOM_CONTROLLER_HEADER',
CFactory::_('Header')->get(
'import.custom.controller',
$nameListCode
));
// IMPORT_CUSTOM_MODEL_HEADER <<<DYNAMIC>>> add the
header details for the model
CFactory::_('Compiler.Builder.Content.Multi')->set('import_'
. $nameListCode . '|IMPORT_CUSTOM_MODEL_HEADER',
CFactory::_('Header')->get(
'import.custom.model',
$nameListCode
));
}
public function setListQuery(&$nameSingleCode, &$nameListCode)
{
// check if this view has category added
if
(CFactory::_('Compiler.Builder.Category')->exists("{$nameListCode}.code"))
{
$categoryCodeName =
CFactory::_('Compiler.Builder.Category')->get("{$nameListCode}.code");
$addCategory = true;
$addCategoryFilter
=
CFactory::_('Compiler.Builder.Category')->get("{$nameListCode}.filter",
'error');
}
else
{
$addCategory = false;
$addCategoryFilter = 0;
}
// setup the query
$query = "//" . Line::_(__Line__, __Class__) . " Get the
user object.";
if (CFactory::_('Config')->get('joomla_version',
3) == 3)
{
$query .= PHP_EOL . Indent::_(2) . "\$user =
Factory::getUser();";
}
else
{
$query .= PHP_EOL . Indent::_(2) . "\$user =
\$this->getCurrentUser();";
}
$query .= PHP_EOL . Indent::_(2) . "//" . Line::_(__Line__,
__Class__)
. " Create a new query object.";
if (CFactory::_('Config')->get('joomla_version',
3) == 3)
{
$query .= PHP_EOL . Indent::_(2) . "\$db =
Factory::getDBO();";
}
else
{
$query .= PHP_EOL . Indent::_(2) . "\$db =
\$this->getDatabase();";
}
$query .= PHP_EOL . Indent::_(2) . "\$query =
\$db->getQuery(true);";
$query .= PHP_EOL . PHP_EOL . Indent::_(2) . "//" . Line::_(
__LINE__,__CLASS__
) . " Select some fields";
$query .= PHP_EOL . Indent::_(2) .
"\$query->select('a.*');";
// add the category
if ($addCategory)
{
$query .= PHP_EOL . Indent::_(2)
.
"\$query->select(\$db->quoteName('c.title','category_title'));";
}
$query .= PHP_EOL . PHP_EOL . Indent::_(2) . "//" . Line::_(
__LINE__,__CLASS__
) . " From the " .
CFactory::_('Config')->component_code_name . "_item
table";
$query .= PHP_EOL . Indent::_(2) .
"\$query->from(\$db->quoteName('#__"
. CFactory::_('Config')->component_code_name .
"_" . $nameSingleCode . "', 'a'));";
// add the category
if ($addCategory)
{
$query .= PHP_EOL . Indent::_(2)
. "\$query->join('LEFT',
\$db->quoteName('#__categories', 'c') . ' ON
(' . \$db->quoteName('a."
. $categoryCodeName
. "') . ' = ' .
\$db->quoteName('c.id') . ')');";
}
// add custom filtering php
$query .= CFactory::_('Customcode.Dispenser')->get(
'php_getlistquery', $nameSingleCode, PHP_EOL . PHP_EOL
);
// add the custom fields query
$query .= $this->setCustomQuery($nameListCode, $nameSingleCode);
$query .= PHP_EOL . PHP_EOL . Indent::_(2) . "//" . Line::_(
__LINE__,__CLASS__
) . " Filter by published state";
$query .= PHP_EOL . Indent::_(2)
. "\$published =
\$this->getState('filter.published');";
$query .= PHP_EOL . Indent::_(2) . "if
(is_numeric(\$published))";
$query .= PHP_EOL . Indent::_(2) . "{";
$query .= PHP_EOL . Indent::_(3)
. "\$query->where('a.published = ' . (int)
\$published);";
$query .= PHP_EOL . Indent::_(2) . "}";
$query .= PHP_EOL . Indent::_(2) . "elseif (\$published ===
'')";
$query .= PHP_EOL . Indent::_(2) . "{";
$query .= PHP_EOL . Indent::_(3)
. "\$query->where('(a.published = 0 OR a.published =
1)');";
$query .= PHP_EOL . Indent::_(2) . "}";
if
(CFactory::_('Compiler.Builder.Access.Switch')->exists($nameSingleCode))
{
$query .= PHP_EOL . PHP_EOL . Indent::_(2) . "//" . Line::_(
__LINE__,__CLASS__
) . " Join over the asset groups.";
$query .= PHP_EOL . Indent::_(2)
. "\$query->select('ag.title AS
access_level');";
$query .= PHP_EOL . Indent::_(2)
. "\$query->join('LEFT', '#__viewlevels AS ag ON
ag.id = a.access');";
// check if the access field was over ridden
if
(!CFactory::_('Compiler.Builder.Field.Names')->isString($nameSingleCode
. '.access'))
{
// component helper name
$Helper =
CFactory::_('Compiler.Builder.Content.One')->get('Component')
. 'Helper';
// load the access filter query code
$query .= PHP_EOL . Indent::_(2) . "//" . Line::_(
__LINE__,__CLASS__
)
. " Filter by access level.";
$query .= PHP_EOL . Indent::_(2)
. "\$_access =
\$this->getState('filter.access');";
$query .= PHP_EOL . Indent::_(2)
. "if (\$_access && is_numeric(\$_access))";
$query .= PHP_EOL . Indent::_(2) . "{";
$query .= PHP_EOL . Indent::_(3)
. "\$query->where('a.access = ' . (int)
\$_access);";
$query .= PHP_EOL . Indent::_(2) . "}";
$query .= PHP_EOL . Indent::_(2) . "elseif ("
. "Super_" .
"__0a59c65c_9daf_4bc9_baf4_e063ff9e6a8a___Power::check(\$_access))";
$query .= PHP_EOL . Indent::_(2) . "{";
$query .= PHP_EOL . Indent::_(3) . "//"
. Line::_(__Line__, __Class__)
. " Secure the array for the query";
$query .= PHP_EOL . Indent::_(3)
. "\$_access = ArrayHelper::toInteger(\$_access);";
$query .= PHP_EOL . Indent::_(3) . "//"
. Line::_(__Line__, __Class__) . " Filter by the Access
Array.";
$query .= PHP_EOL . Indent::_(3)
. "\$query->where('a.access IN (' .
implode(',', \$_access) . ')');";
$query .= PHP_EOL . Indent::_(2) . "}";
}
// TODO the following will fight against the above access filter
$query .= PHP_EOL . Indent::_(2) . "//" . Line::_(__Line__,
__Class__)
. " Implement View Level Access";
$query .= PHP_EOL . Indent::_(2)
. "if (!\$user->authorise('core.options',
'com_"
. CFactory::_('Config')->component_code_name .
"'))";
$query .= PHP_EOL . Indent::_(2) . "{";
$query .= PHP_EOL . Indent::_(3)
. "\$groups = implode(',',
\$user->getAuthorisedViewLevels());";
$query .= PHP_EOL . Indent::_(3)
. "\$query->where('a.access IN (' . \$groups .
')');";
$query .= PHP_EOL . Indent::_(2) . "}";
}
// set the search query
$query .= $this->setSearchQuery($nameListCode);
// set other filters
$query .= $this->setFilterQuery($nameListCode);
// add the category
if ($addCategory && $addCategoryFilter >= 1)
{
$query .= PHP_EOL . PHP_EOL . Indent::_(2) . "//" . Line::_(
__LINE__,__CLASS__
) . " Filter by a single or group of categories.";
$query .= PHP_EOL . Indent::_(2) . "\$baselevel = 1;";
$query .= PHP_EOL . Indent::_(2)
. "\$categoryId =
\$this->getState('filter.category_id');";
$query .= PHP_EOL;
$query .= PHP_EOL . Indent::_(2) . "if
(is_numeric(\$categoryId))";
$query .= PHP_EOL . Indent::_(2) . "{";
$query .= PHP_EOL . Indent::_(3)
. "\$cat_tbl = Table::getInstance('Category',
'JTable');";
$query .= PHP_EOL . Indent::_(3) .
"\$cat_tbl->load(\$categoryId);";
$query .= PHP_EOL . Indent::_(3) . "\$rgt =
\$cat_tbl->rgt;";
$query .= PHP_EOL . Indent::_(3) . "\$lft =
\$cat_tbl->lft;";
$query .= PHP_EOL . Indent::_(3)
. "\$baselevel = (int) \$cat_tbl->level;";
$query .= PHP_EOL . Indent::_(3)
. "\$query->where('c.lft >= ' . (int)
\$lft)";
$query .= PHP_EOL . Indent::_(4)
. "->where('c.rgt <= ' . (int) \$rgt);";
$query .= PHP_EOL . Indent::_(2) . "}";
$query .= PHP_EOL . Indent::_(2)
. "elseif (is_array(\$categoryId))";
$query .= PHP_EOL . Indent::_(2) . "{";
$query .= PHP_EOL . Indent::_(3)
. "\$categoryId = ArrayHelper::toInteger(\$categoryId);";
$query .= PHP_EOL . Indent::_(3)
. "\$categoryId = implode(',', \$categoryId);";
$query .= PHP_EOL . Indent::_(3)
. "\$query->where('a." . $categoryCodeName
. " IN (' . \$categoryId . ')');";
$query .= PHP_EOL . Indent::_(2) . "}";
$query .= PHP_EOL;
}
// setup values for the view ordering
// add dynamic ordering (Admin view)
if
(CFactory::_('Compiler.Builder.Views.Default.Ordering')->
get("$nameListCode.add_admin_ordering", 0) == 1)
{
// the first is from the state
$order_first = true;
foreach
(CFactory::_('Compiler.Builder.Views.Default.Ordering')->
get("$nameListCode.admin_ordering_fields", []) as
$order_field)
{
if (($order_field_name =
CFactory::_('Field.Database.Name')->get(
$nameListCode, $order_field['field']
)) !== false)
{
if ($order_first)
{
// just the first field is based on state
$order_first = false;
$query .= PHP_EOL . PHP_EOL . Indent::_(2) . "//"
. Line::_(
__LINE__,__CLASS__
) . " Add the list ordering clause.";
$query .= PHP_EOL . Indent::_(2)
. "\$orderCol = \$this->getState('list.ordering',
'"
. $order_field_name . "');";
$query .= PHP_EOL . Indent::_(2)
. "\$orderDirn =
\$this->getState('list.direction', '"
. $order_field['direction'] . "');";
$query .= PHP_EOL . Indent::_(2)
. "if (\$orderCol != '')";
$query .= PHP_EOL . Indent::_(2) . "{";
$query .= PHP_EOL . Indent::_(3) . "//" .
Line::_(__LINE__,__CLASS__
) . " Check that the order direction is valid encase we have a
field called direction as part of filers.";
$query .= PHP_EOL . Indent::_(3)
. "\$orderDirn = (is_string(\$orderDirn) &&
in_array(strtolower(\$orderDirn), ['asc', 'desc'])) ?
\$orderDirn : '"
. $order_field['direction'] . "';";
$query .= PHP_EOL . Indent::_(3)
. "\$query->order(\$db->escape(\$orderCol . ' '
. \$orderDirn));";
$query .= PHP_EOL . Indent::_(2) . "}";
}
else
{
$query .= PHP_EOL . PHP_EOL . Indent::_(2) . "//"
. Line::_(
__LINE__,__CLASS__
) . " Add a permanent list ordering.";
$query .= PHP_EOL . Indent::_(2)
. "\$query->order(\$db->escape('"
. $order_field_name . " "
. $order_field['direction'] . "'));";
}
}
}
}
else
{
$query .= PHP_EOL . PHP_EOL . Indent::_(2) . "//" . Line::_(
__LINE__,__CLASS__
) . " Add the list ordering clause.";
$query .= PHP_EOL . Indent::_(2)
. "\$orderCol = \$this->getState('list.ordering',
'a.id');";
$query .= PHP_EOL . Indent::_(2)
. "\$orderDirn = \$this->getState('list.direction',
'desc');";
$query .= PHP_EOL . Indent::_(2) . "if (\$orderCol !=
'')";
$query .= PHP_EOL . Indent::_(2) . "{";
$query .= PHP_EOL . Indent::_(3) . "//" .
Line::_(__LINE__,__CLASS__
) . " Check that the order direction is valid encase we have a
field called direction as part of filers.";
$query .= PHP_EOL . Indent::_(3)
. "\$orderDirn = (is_string(\$orderDirn) &&
in_array(strtolower(\$orderDirn), ['asc', 'desc'])) ?
\$orderDirn : 'desc';";
$query .= PHP_EOL . Indent::_(3)
. "\$query->order(\$db->escape(\$orderCol . ' ' .
\$orderDirn));";
$query .= PHP_EOL . Indent::_(2) . "}";
}
$query .= PHP_EOL;
$query .= PHP_EOL . Indent::_(2) . "return \$query;";
return $query;
}
public function setSearchQuery($nameListCode)
{
if
(CFactory::_('Compiler.Builder.Search')->exists($nameListCode))
{
// setup the searh options
$search = "'(";
foreach
(CFactory::_('Compiler.Builder.Search')->get($nameListCode) as
$nr => $array)
{
// array( 'type' => $typeName, 'code' =>
$name, 'custom' => $custom, 'list' =>
$field['list']);
if ($nr == 0)
{
$search .= "a." . $array['code'] . " LIKE
'.\$search.'";
if (ArrayHelper::check($array['custom'])
&& 1 == $array['list'])
{
$search .= " OR " .
$array['custom']['db'] . "."
. $array['custom']['text'] . " LIKE
'.\$search.'";
}
}
else
{
$search .= " OR a." . $array['code'] . " LIKE
'.\$search.'";
if (ArrayHelper::check($array['custom'])
&& 1 == $array['list'])
{
$search .= " OR " .
$array['custom']['db'] . "."
. $array['custom']['text'] . " LIKE
'.\$search.'";
}
}
}
$search .= ")'";
// now setup query
$query = PHP_EOL . Indent::_(2) . "//" . Line::_(__Line__,
__Class__)
. " Filter by search.";
$query .= PHP_EOL . Indent::_(2)
. "\$search =
\$this->getState('filter.search');";
$query .= PHP_EOL . Indent::_(2) . "if (!empty(\$search))";
$query .= PHP_EOL . Indent::_(2) . "{";
$query .= PHP_EOL . Indent::_(3)
. "if (stripos(\$search, 'id:') === 0)";
$query .= PHP_EOL . Indent::_(3) . "{";
$query .= PHP_EOL . Indent::_(4)
. "\$query->where('a.id = ' . (int) substr(\$search,
3));";
$query .= PHP_EOL . Indent::_(3) . "}";
$query .= PHP_EOL . Indent::_(3) . "else";
$query .= PHP_EOL . Indent::_(3) . "{";
$query .= PHP_EOL . Indent::_(4)
. "\$search = \$db->quote('%' .
\$db->escape(\$search) . '%');";
$query .= PHP_EOL . Indent::_(4) . "\$query->where(" .
$search
. ");";
$query .= PHP_EOL . Indent::_(3) . "}";
$query .= PHP_EOL . Indent::_(2) . "}";
$query .= PHP_EOL;
return $query;
}
return '';
}
public function setCustomQuery($nameListCode, $nameSingleCode,
$tab = '',
$just_text = false
)
{
if
(CFactory::_('Compiler.Builder.Custom.Field')->exists($nameListCode))
{
$query = "";
foreach
(CFactory::_('Compiler.Builder.Custom.Field')->get($nameListCode)
as $filter)
{
// only load this if table is set
if
((CFactory::_('Compiler.Builder.Custom.List')->exists($nameSingleCode
. '.' . $filter['code'])
&& isset($filter['custom']['table'])
&&
StringHelper::check($filter['custom']['table'])
&& $filter['method'] == 0)
|| ($just_text &&
isset($filter['custom']['table'])
&&
StringHelper::check($filter['custom']['table'])
&& $filter['method'] == 0))
{
$query .= PHP_EOL . PHP_EOL . Indent::_(2) . $tab . "//"
. Line::_(__Line__, __Class__) . " From the "
. StringHelper::safe(
StringHelper::safe(
$filter['custom']['table'], 'w'
)
) . " table.";
// we must add some fix for none ID keys (I know this is horrible...
but we need it)
// TODO we assume that all tables in admin has ids
if ($filter['custom']['id'] !== 'id')
{
// we want to at times just have the words and not the ids as well
if ($just_text)
{
$query .= PHP_EOL . Indent::_(2) . $tab
. "\$query->select(\$db->quoteName(['"
. $filter['custom']['db'] . "."
. $filter['custom']['text'] .
"','"
. $filter['custom']['db'] .
".id'],['"
. $filter['code'] . "','"
. $filter['code'] . "_id']));";
}
else
{
$query .= PHP_EOL . Indent::_(2) . $tab
. "\$query->select(\$db->quoteName(['"
. $filter['custom']['db'] . "."
. $filter['custom']['text'] .
"','"
. $filter['custom']['db'] .
".id'],['"
. $filter['code'] . "_" .
$filter['custom']['text']
. "','" . $filter['code'] .
"_id']));";
}
}
else
{
// we want to at times just have the words and not the ids as well
if ($just_text)
{
$query .= PHP_EOL . Indent::_(2) . $tab
. "\$query->select(\$db->quoteName('"
. $filter['custom']['db'] . "."
. $filter['custom']['text'] .
"','"
. $filter['code'] . "'));";
}
else
{
$query .= PHP_EOL . Indent::_(2) . $tab
. "\$query->select(\$db->quoteName('"
. $filter['custom']['db'] . "."
. $filter['custom']['text'] .
"','"
. $filter['code'] . "_" .
$filter['custom']['text']
. "'));";
}
}
$query .= PHP_EOL . Indent::_(2) . $tab
. "\$query->join('LEFT',
\$db->quoteName('"
. $filter['custom']['table'] . "',
'"
. $filter['custom']['db']
. "') . ' ON (' .
\$db->quoteName('a." . $filter['code']
. "') . ' = ' . \$db->quoteName('"
. $filter['custom']['db'] . "."
. $filter['custom']['id'] . "') .
')');";
}
// build the field type file
CFactory::_('Compiler.Creator.Custom.Field.Type.File')->set(
$filter, $nameListCode, $nameSingleCode
);
}
return $query;
}
}
/**
* build model filter per/field in the list view
*
* @param string $nameListCode The list view name
*
* @return string The php to place in model to filter
*
*/
public function setFilterQuery($nameListCode)
{
if
(CFactory::_('Compiler.Builder.Filter')->exists($nameListCode))
{
// component helper name
$Helper =
CFactory::_('Compiler.Builder.Content.One')->get('Component')
. 'Helper';
// start building the filter query
$filterQuery = "";
foreach
(CFactory::_('Compiler.Builder.Filter')->get($nameListCode) as
$filter)
{
// only add for none category fields
if ($filter['type'] != 'category')
{
$filterQuery .= PHP_EOL . Indent::_(2) . "//"
. Line::_(__Line__, __Class__) . " Filter by "
. ucwords((string) $filter['code']) . ".";
// we only add multi filter option if new filter type
// and we have multi filter set for this field (2 = topbar)
if
(CFactory::_('Compiler.Builder.Admin.Filter.Type')->get($nameListCode,
1) == 2
&& isset($filter['multi'])
&& $filter['multi'] == 2)
{
$filterQuery .= $this->setMultiFilterQuery(
$filter, $Helper
);
}
else
{
$filterQuery .= $this->setSingleFilterQuery(
$filter, $Helper
);
}
}
}
return $filterQuery;
}
return '';
}
/**
* build single filter query
*
* @param array $filter The field/filter
* @param string $Helper The helper name of the component being build
* @param string $a The db table target name (a)
*
* @return string The php to place in model to filter this field
*
*/
protected function setSingleFilterQuery($filter, $Helper, $a =
"a")
{
$filterQuery = PHP_EOL . Indent::_(2) . "\$_"
. $filter['code'] . " =
\$this->getState('filter."
. $filter['code'] . "');";
$filterQuery .= PHP_EOL . Indent::_(2) . "if (is_numeric(\$_"
. $filter['code'] . "))";
$filterQuery .= PHP_EOL . Indent::_(2) . "{";
$filterQuery .= PHP_EOL . Indent::_(3) . "if (is_float(\$_"
. $filter['code'] . "))";
$filterQuery .= PHP_EOL . Indent::_(3) . "{";
$filterQuery .= PHP_EOL . Indent::_(4)
. "\$query->where('" . $a . "." .
$filter['code']
. " = ' . (float) \$_" . $filter['code'] .
");";
$filterQuery .= PHP_EOL . Indent::_(3) . "}";
$filterQuery .= PHP_EOL . Indent::_(3) . "else";
$filterQuery .= PHP_EOL . Indent::_(3) . "{";
$filterQuery .= PHP_EOL . Indent::_(4)
. "\$query->where('" . $a . "." .
$filter['code']
. " = ' . (int) \$_" . $filter['code'] .
");";
$filterQuery .= PHP_EOL . Indent::_(3) . "}";
$filterQuery .= PHP_EOL . Indent::_(2) . "}";
$filterQuery .= PHP_EOL . Indent::_(2) . "elseif ("
. "Super_" .
"__1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::check(\$_" .
$filter['code'] . "))";
$filterQuery .= PHP_EOL . Indent::_(2) . "{";
$filterQuery .= PHP_EOL . Indent::_(3)
. "\$query->where('" . $a . "." .
$filter['code']
. " = ' . \$db->quote(\$db->escape(\$_" .
$filter['code']
. ")));";
$filterQuery .= PHP_EOL . Indent::_(2) . "}";
return $filterQuery;
}
/**
* build multiple filter query
*
* @param array $filter The field/filter
* @param string $Helper The helper name of the component being build
* @param string $a The db table target name (a)
*
* @return string The php to place in model to filter this field
*
*/
protected function setMultiFilterQuery($filter, $Helper, $a =
"a")
{
$filterQuery = PHP_EOL . Indent::_(2) . "\$_"
. $filter['code'] . " =
\$this->getState('filter."
. $filter['code'] . "');";
$filterQuery .= PHP_EOL . Indent::_(2) . "if (is_numeric(\$_"
. $filter['code'] . "))";
$filterQuery .= PHP_EOL . Indent::_(2) . "{";
$filterQuery .= PHP_EOL . Indent::_(3) . "if (is_float(\$_"
. $filter['code'] . "))";
$filterQuery .= PHP_EOL . Indent::_(3) . "{";
$filterQuery .= PHP_EOL . Indent::_(4)
. "\$query->where('" . $a . "." .
$filter['code']
. " = ' . (float) \$_" . $filter['code'] .
");";
$filterQuery .= PHP_EOL . Indent::_(3) . "}";
$filterQuery .= PHP_EOL . Indent::_(3) . "else";
$filterQuery .= PHP_EOL . Indent::_(3) . "{";
$filterQuery .= PHP_EOL . Indent::_(4)
. "\$query->where('" . $a . "." .
$filter['code']
. " = ' . (int) \$_" . $filter['code'] .
");";
$filterQuery .= PHP_EOL . Indent::_(3) . "}";
$filterQuery .= PHP_EOL . Indent::_(2) . "}";
$filterQuery .= PHP_EOL . Indent::_(2) . "elseif ("
. "Super_" .
"__1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::check(\$_" .
$filter['code'] . "))";
$filterQuery .= PHP_EOL . Indent::_(2) . "{";
$filterQuery .= PHP_EOL . Indent::_(3)
. "\$query->where('" . $a . "." .
$filter['code']
. " = ' . \$db->quote(\$db->escape(\$_" .
$filter['code']
. ")));";
$filterQuery .= PHP_EOL . Indent::_(2) . "}";
$filterQuery .= PHP_EOL . Indent::_(2) . "elseif ("
. "Super_" .
"__0a59c65c_9daf_4bc9_baf4_e063ff9e6a8a___Power::check(\$_" .
$filter['code'] . "))";
$filterQuery .= PHP_EOL . Indent::_(2) . "{";
$filterQuery .= PHP_EOL . Indent::_(3) . "//"
. Line::_(__Line__, __Class__) . " Secure the array for the
query";
$filterQuery .= PHP_EOL . Indent::_(3) . "\$_" .
$filter['code']
. " = array_map( function (\$val) use(&\$db) {";
$filterQuery .= PHP_EOL . Indent::_(4) . "if
(is_numeric(\$val))";
$filterQuery .= PHP_EOL . Indent::_(4) . "{";
$filterQuery .= PHP_EOL . Indent::_(5) . "if
(is_float(\$val))";
$filterQuery .= PHP_EOL . Indent::_(5) . "{";
$filterQuery .= PHP_EOL . Indent::_(6) . "return (float)
\$val;";
$filterQuery .= PHP_EOL . Indent::_(5) . "}";
$filterQuery .= PHP_EOL . Indent::_(5) . "else";
$filterQuery .= PHP_EOL . Indent::_(5) . "{";
$filterQuery .= PHP_EOL . Indent::_(6) . "return (int)
\$val;";
$filterQuery .= PHP_EOL . Indent::_(5) . "}";
$filterQuery .= PHP_EOL . Indent::_(4) . "}";
$filterQuery .= PHP_EOL . Indent::_(4) . "elseif ("
. "Super_" .
"__1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::check(\$val))";
$filterQuery .= PHP_EOL . Indent::_(4) . "{";
$filterQuery .= PHP_EOL . Indent::_(5)
. "return \$db->quote(\$db->escape(\$val));";
$filterQuery .= PHP_EOL . Indent::_(4) . "}";
$filterQuery .= PHP_EOL . Indent::_(3) . "}, \$_"
. $filter['code'] . ");";
$filterQuery .= PHP_EOL . Indent::_(3) . "//"
. Line::_(__Line__, __Class__) . " Filter by the "
. ucwords((string) $filter['code']) . " Array.";
$filterQuery .= PHP_EOL . Indent::_(3)
. "\$query->where('" . $a . "." .
$filter['code']
. " IN (' . implode(',', \$_" .
$filter['code'] . ") . ')');";
$filterQuery .= PHP_EOL . Indent::_(2) . "}";
return $filterQuery;
}
public function buildTheViewScript($viewArray)
{
// set the view name
$nameSingleCode = $viewArray['settings']->name_single_code;
// add conditions to this view
if (isset($viewArray['settings']->conditions)
&& ArrayHelper::check(
$viewArray['settings']->conditions
))
{
// reset defaults
$getValue = [];
$ifValue = [];
$targetControls = [];
$functions = [];
foreach ($viewArray['settings']->conditions as $condition)
{
if (isset($condition['match_name'])
&& StringHelper::check(
$condition['match_name']
))
{
$uniqueVar = $this->uniquekey(7);
$matchName = $condition['match_name'] . '_'
. $uniqueVar;
$targetBehavior = ($condition['target_behavior'] == 1
|| $condition['target_behavior'] == 3) ? 'show'
: 'hide';
$targetDefault = ($condition['target_behavior'] == 1
|| $condition['target_behavior'] == 3) ? 'hide'
: 'show';
// set the realtation if any
if ($condition['target_relation'])
{
// chain to other items of the same target
$relations = $this->getTargetRelationScript(
$viewArray['settings']->conditions, $condition,
$nameSingleCode
);
if (ArrayHelper::check($relations))
{
// set behavior and default array
$behaviors[$matchName] = $targetBehavior;
$defaults[$matchName] = $targetDefault;
$toggleSwitch[$matchName]
= ($condition['target_behavior']
== 1
|| $condition['target_behavior'] == 2) ? true
: false;
// set the type buket
$typeBuket[$matchName] = $condition['match_type'];
// set function array
$functions[$uniqueVar][0] = $matchName;
$matchNames[$matchName]
= $condition['match_name'];
// get the select value
$getValue[$matchName] = $this->getValueScript(
$condition['match_type'],
$condition['match_name'],
$condition['match_extends'], $uniqueVar
);
// get the options
$options = $this->getOptionsScript(
$condition['match_type'],
$condition['match_options']
);
// set the if values
$ifValue[$matchName] = $this->ifValueScript(
$matchName, $condition['match_behavior'],
$condition['match_type'], $options
);
// set the target controls
$targetControls[$matchName]
= $this->setTargetControlsScript(
$toggleSwitch[$matchName],
$condition['target_field'], $targetBehavior,
$targetDefault, $uniqueVar, $nameSingleCode
);
foreach ($relations as $relation)
{
if (StringHelper::check(
$relation['match_name']
))
{
$relationName = $relation['match_name']
. '_' . $uniqueVar;
// set the type buket
$typeBuket[$relationName]
= $relation['match_type'];
// set function array
$functions[$uniqueVar][] = $relationName;
$matchNames[$relationName]
= $relation['match_name'];
// get the relation option
$relationOptions = $this->getOptionsScript(
$relation['match_type'],
$relation['match_options']
);
$getValue[$relationName]
= $this->getValueScript(
$relation['match_type'],
$relation['match_name'],
$condition['match_extends'], $uniqueVar
);
$ifValue[$relationName]
= $this->ifValueScript(
$relationName,
$relation['match_behavior'],
$relation['match_type'],
$relationOptions
);
}
}
}
}
else
{
// set behavior and default array
$behaviors[$matchName] = $targetBehavior;
$defaults[$matchName] = $targetDefault;
$toggleSwitch[$matchName]
= ($condition['target_behavior']
== 1
|| $condition['target_behavior'] == 2) ? true
: false;
// set the type buket
$typeBuket[$matchName] = $condition['match_type'];
// set function array
$functions[$uniqueVar][0] = $matchName;
$matchNames[$matchName] = $condition['match_name'];
// get the select value
$getValue[$matchName] = $this->getValueScript(
$condition['match_type'],
$condition['match_name'],
$condition['match_extends'], $uniqueVar
);
// get the options
$options = $this->getOptionsScript(
$condition['match_type'],
$condition['match_options']
);
// set the if values
$ifValue[$matchName] = $this->ifValueScript(
$matchName, $condition['match_behavior'],
$condition['match_type'], $options
);
// set the target controls
$targetControls[$matchName]
= $this->setTargetControlsScript(
$toggleSwitch[$matchName],
$condition['target_field'], $targetBehavior,
$targetDefault, $uniqueVar, $nameSingleCode
);
}
}
}
// reset buckets
$initial = '';
$func = '';
$validation = '';
$isSet = '';
$listener = '';
if (ArrayHelper::check($functions))
{
// now build the initial script
$initial .= "//" . Line::_(__Line__, __Class__) . "
Initial Script"
. PHP_EOL .
"document.addEventListener('DOMContentLoaded',
function()";
$initial .= PHP_EOL . "{";
foreach ($functions as $function => $matchKeys)
{
$func_call = $this->buildFunctionCall(
$function, $matchKeys, $getValue
);
$initial .= $func_call['code'];
}
$initial .= "});" . PHP_EOL;
// for modal fields
$modal = '';
// now build the listener scripts
foreach ($functions as $l_function => $l_matchKeys)
{
$funcCall = '';
foreach ($l_matchKeys as $l_matchKey)
{
$name = $matchNames[$l_matchKey];
$matchTypeKey = $typeBuket[$l_matchKey];
$funcCall = $this->buildFunctionCall(
$l_function, $l_matchKeys, $getValue
);
if
(CFactory::_('Compiler.Builder.Script.Media.Switch')->inArray($matchTypeKey))
{
$modal .= $funcCall['code'];
}
else
{
if
(CFactory::_('Compiler.Builder.Script.User.Switch')->inArray($matchTypeKey))
{
$name = $name . '_id';
}
$listener .= PHP_EOL . "//" . Line::_(
__LINE__,__CLASS__
) . " #jform_" . $name . " listeners for "
. $l_matchKey . " function";
$listener .= PHP_EOL . "jQuery('#jform_" . $name
. "').on('keyup',function()";
$listener .= PHP_EOL . "{";
$listener .= $funcCall['code'];
$listener .= PHP_EOL . "});";
$listener .= PHP_EOL
. "jQuery('#adminForm').on('change',
'#jform_"
. $name . "',function (e)";
$listener .= PHP_EOL . "{";
$listener .= PHP_EOL . Indent::_(1)
. "e.preventDefault();";
$listener .= $funcCall['code'];
$listener .= PHP_EOL . "});" . PHP_EOL;
}
}
}
if (StringHelper::check($modal))
{
$listener .= PHP_EOL . "window.SqueezeBox.initialize({";
$listener .= PHP_EOL . Indent::_(1) .
"onClose:function(){";
$listener .= $modal;
$listener .= PHP_EOL . Indent::_(1) . "}";
$listener .= PHP_EOL . "});" . PHP_EOL;
}
// now build the function
$func = '';
$head = '';
foreach ($functions as $f_function => $f_matchKeys)
{
$map = '';
// does this function require an array
$addArray = false;
$func_ = $this->buildFunctionCall(
$f_function, $f_matchKeys, $getValue
);
// set array switch
if ($func_['array'])
{
$addArray = true;
}
$func .= PHP_EOL . "//" . Line::_(__Line__, __Class__)
. " the " . $f_function . " function";
$func .= PHP_EOL . "function " . $f_function .
"(";
$fucounter = 0;
foreach ($f_matchKeys as $fu_matchKey)
{
if (StringHelper::check($fu_matchKey))
{
if ($fucounter == 0)
{
$func .= $fu_matchKey;
}
else
{
$func .= ',' . $fu_matchKey;
}
$fucounter++;
}
}
$func .= ")";
$func .= PHP_EOL . "{";
if ($addArray)
{
foreach ($f_matchKeys as $a_matchKey)
{
$name = $matchNames[$a_matchKey];
$func .= PHP_EOL . Indent::_(1) . "if (isSet("
. $a_matchKey . ") && " . $a_matchKey
. ".constructor !== Array)" . PHP_EOL
. Indent::_(1) . "{" . PHP_EOL . Indent::_(2)
. "var temp_" . $f_function . " = "
. $a_matchKey . ";" . PHP_EOL . Indent::_(2)
. "var " . $a_matchKey . " = [];" . PHP_EOL
. Indent::_(2) . $a_matchKey . ".push(temp_"
. $f_function . ");" . PHP_EOL . Indent::_(1)
. "}";
$func .= PHP_EOL . Indent::_(1) . "else if (!isSet("
. $a_matchKey . "))" . PHP_EOL . Indent::_(1)
. "{";
$func .= PHP_EOL . Indent::_(2) . "var "
. $a_matchKey . " = [];";
$func .= PHP_EOL . Indent::_(1) . "}";
$func .= PHP_EOL . Indent::_(1) . "var " . $name
. " = " . $a_matchKey . ".some(" . $a_matchKey
. "_SomeFunc);" . PHP_EOL;
// setup the map function
$map .= PHP_EOL . "//" . Line::_(__Line__, __Class__)
. " the " . $f_function . " Some function";
$map .= PHP_EOL . "function " . $a_matchKey
. "_SomeFunc(" . $a_matchKey . ")";
$map .= PHP_EOL . "{";
$map .= PHP_EOL . Indent::_(1) . "//"
. Line::_(__Line__, __Class__)
. " set the function logic";
$map .= PHP_EOL . Indent::_(1) . "if (";
$if = $ifValue[$a_matchKey];
if (StringHelper::check($if))
{
$map .= $if;
}
$map .= ")";
$map .= PHP_EOL . Indent::_(1) . "{";
$map .= PHP_EOL . Indent::_(2) . "return true;";
$map .= PHP_EOL . Indent::_(1) . "}" . PHP_EOL
. Indent::_(1) . "return false;";
$map .= PHP_EOL . "}" . PHP_EOL;
}
$func .= PHP_EOL . PHP_EOL . Indent::_(1) . "//"
. Line::_(__Line__, __Class__)
. " set this function logic";
$func .= PHP_EOL . Indent::_(1) . "if (";
// set if counter
$aifcounter = 0;
foreach ($f_matchKeys as $af_matchKey)
{
$name = $matchNames[$af_matchKey];
if ($aifcounter == 0)
{
$func .= $name;
}
else
{
$func .= ' && ' . $name;
}
$aifcounter++;
}
$func .= ")" . PHP_EOL . Indent::_(1) . "{";
}
else
{
$func .= PHP_EOL . Indent::_(1) . "//" . Line::_(
__LINE__,__CLASS__
) . " set the function logic";
$func .= PHP_EOL . Indent::_(1) . "if (";
// set if counter
$ifcounter = 0;
foreach ($f_matchKeys as $f_matchKey)
{
$if = $ifValue[$f_matchKey];
if (StringHelper::check($if))
{
if ($ifcounter == 0)
{
$func .= $if;
}
else
{
$func .= ' && ' . $if;
}
$ifcounter++;
}
}
$func .= ")" . PHP_EOL . Indent::_(1) . "{";
}
// get the controles
$controls = $targetControls[$f_matchKeys[0]];
// get target behavior and default
$targetBehavior = $behaviors[$f_matchKeys[0]];
$targetDefault = $defaults[$f_matchKeys[0]];
// load the target behavior
foreach ($controls as $target => $action)
{
$func .= $action['behavior'];
if (StringHelper::check(
$action[$targetBehavior]
))
{
$func .= $action[$targetBehavior];
$head .= $action['requiredVar'];
}
}
// check if this is a toggle switch
if ($toggleSwitch[$f_matchKeys[0]])
{
$func .= PHP_EOL . Indent::_(1) . "}" . PHP_EOL
. Indent::_(1) . "else" . PHP_EOL . Indent::_(1)
. "{";
// load the default behavior
foreach ($controls as $target => $action)
{
$func .= $action['default'];
if (StringHelper::check(
$action[$targetDefault]
))
{
$func .= $action[$targetDefault];
}
}
}
$func .= PHP_EOL . Indent::_(1) . "}" . PHP_EOL .
"}"
. PHP_EOL . $map;
}
// add the needed validation to file
if (isset($this->validationFixBuilder[$nameSingleCode])
&& ArrayHelper::check(
$this->validationFixBuilder[$nameSingleCode]
))
{
$validation .= PHP_EOL . "// update fields required";
$validation .= PHP_EOL
. "function updateFieldRequired(name, status) {";
$validation .= PHP_EOL . Indent::_(1)
. "// check if not_required exist";
$validation .= PHP_EOL . Indent::_(1)
. "if (document.getElementById('jform_not_required'))
{";
$validation .= PHP_EOL . Indent::_(2)
. "var not_required =
jQuery('#jform_not_required').val().split(\",\");";
$validation .= PHP_EOL . PHP_EOL . Indent::_(2)
. "if(status == 1)";
$validation .= PHP_EOL . Indent::_(2) . "{";
$validation .= PHP_EOL . Indent::_(3)
. "not_required.push(name);";
$validation .= PHP_EOL . Indent::_(2) . "}";
$validation .= PHP_EOL . Indent::_(2) . "else";
$validation .= PHP_EOL . Indent::_(2) . "{";
$validation .= PHP_EOL . Indent::_(3)
. "not_required = removeFieldFromNotRequired(not_required,
name);";
$validation .= PHP_EOL . Indent::_(2) . "}";
$validation .= PHP_EOL . PHP_EOL . Indent::_(2)
.
"jQuery('#jform_not_required').val(fixNotRequiredArray(not_required).toString());";
$validation .= PHP_EOL . Indent::_(1) . "}";
$validation .= PHP_EOL . "}" . PHP_EOL;
$validation .= PHP_EOL
. "// remove field from not_required";
$validation .= PHP_EOL
. "function removeFieldFromNotRequired(array, what) {";
$validation .= PHP_EOL . Indent::_(1)
. "return array.filter(function(element){";
$validation .= PHP_EOL . Indent::_(2)
. "return element !== what;";
$validation .= PHP_EOL . Indent::_(1) . "});";
$validation .= PHP_EOL . "}" . PHP_EOL;
$validation .= PHP_EOL . "// fix not required array";
$validation .= PHP_EOL
. "function fixNotRequiredArray(array) {";
$validation .= PHP_EOL . Indent::_(1) . "var seen = {};";
$validation .= PHP_EOL . Indent::_(1)
. "return
removeEmptyFromNotRequiredArray(array).filter(function(item) {";
$validation .= PHP_EOL . Indent::_(2)
. "return seen.hasOwnProperty(item) ? false : (seen[item] =
true);";
$validation .= PHP_EOL . Indent::_(1) . "});";
$validation .= PHP_EOL . "}" . PHP_EOL;
$validation .= PHP_EOL
. "// remove empty from not_required array";
$validation .= PHP_EOL
. "function removeEmptyFromNotRequiredArray(array) {";
$validation .= PHP_EOL . Indent::_(1)
. "return array.filter(function (el) {";
$validation .= PHP_EOL . Indent::_(2)
. "// remove ( 一_一) as well - lol";
$validation .= PHP_EOL . Indent::_(2)
. "return (el.length > 0 && '一_一' !==
el);";
$validation .= PHP_EOL . Indent::_(1) . "});";
$validation .= PHP_EOL . "}" . PHP_EOL;
}
// set the isSet function
$isSet = PHP_EOL . "// the isSet function";
$isSet .= PHP_EOL . "function isSet(val)";
$isSet .= PHP_EOL . "{";
$isSet .= PHP_EOL . Indent::_(1)
. "if ((val != undefined) && (val != null) && 0
!== val.length){";
$isSet .= PHP_EOL . Indent::_(2) . "return true;";
$isSet .= PHP_EOL . Indent::_(1) . "}";
$isSet .= PHP_EOL . Indent::_(1) . "return false;";
$isSet .= PHP_EOL . "}";
}
// load to this buket
$fileScript = $initial . $func . $validation . $isSet;
$footerScript = $listener;
}
// add custom script to edit form JS file
if (!isset($fileScript))
{
$fileScript = '';
}
$fileScript .= CFactory::_('Customcode.Dispenser')->get(
'view_file', $nameSingleCode, PHP_EOL . PHP_EOL, null, true,
''
);
// add custom script to footer
if
(isset(CFactory::_('Customcode.Dispenser')->hub['view_footer'][$nameSingleCode])
&& StringHelper::check(
CFactory::_('Customcode.Dispenser')->hub['view_footer'][$nameSingleCode]
))
{
$customFooterScript = PHP_EOL . PHP_EOL .
CFactory::_('Placeholder')->update_(
CFactory::_('Customcode.Dispenser')->hub['view_footer'][$nameSingleCode]
);
if (strpos($customFooterScript, '<?php') === false)
{
// only add now if no php is added to the footer script
if (!isset($footerScript))
{
$footerScript = '';
}
$footerScript .= $customFooterScript;
unset($customFooterScript);
}
}
// set view listname
$nameListCode = $viewArray['settings']->name_list_code;
// add custom script to list view JS file
if (($list_fileScript =
CFactory::_('Customcode.Dispenser')->get(
'views_file', $nameSingleCode, PHP_EOL . PHP_EOL, null,
true,
false
)) !== false
&& StringHelper::check($list_fileScript))
{
// get dates
$_created =
CFactory::_('Model.Createdate')->get($viewArray);
$_modified =
CFactory::_('Model.Modifieddate')->get($viewArray);
// add file to view
$_target = array(CFactory::_('Config')->build_target =>
$nameListCode);
$_config = array(Placefix::_h('CREATIONDATE') =>
$_created,
Placefix::_h('BUILDDATE') => $_modified,
Placefix::_h('VERSION') =>
$viewArray['settings']->version);
CFactory::_('Utilities.Structure')->build($_target,
'javascript_file', false, $_config);
// set path
$_path = '/administrator/components/com_' .
CFactory::_('Config')->component_code_name
. '/assets/js/' . $nameListCode . '.js';
// load the file to the list view
CFactory::_('Compiler.Builder.Content.Multi')->set($nameListCode
. '|ADMIN_ADD_JAVASCRIPT_FILE', PHP_EOL . PHP_EOL . Indent::_(2)
. "//" . Line::_(
__LINE__,__CLASS__
) . " Add List View JavaScript File" . PHP_EOL .
Indent::_(2)
. $this->setIncludeLibScript($_path)
);
}
else
{
$list_fileScript = '';
CFactory::_('Compiler.Builder.Content.Multi')->set($nameListCode
. '|ADMIN_ADD_JAVASCRIPT_FILE', '');
}
// minify the script
if (CFactory::_('Config')->get('minify', 0)
&& isset($list_fileScript)
&& StringHelper::check($list_fileScript))
{
// minify the fileScript javascript
$list_fileScript = Minify::js($list_fileScript);
}
// minify the script
if (CFactory::_('Config')->get('minify', 0)
&& isset($fileScript)
&& StringHelper::check($fileScript))
{
// minify the fileScript javascript
$fileScript = Minify::js($fileScript);
}
// minify the script
if (CFactory::_('Config')->get('minify', 0)
&& isset($footerScript)
&& StringHelper::check($footerScript))
{
// minify the footerScript javascript
$footerScript = Minify::js($footerScript);
}
// make sure there is script to add
if (isset($list_fileScript)
&& StringHelper::check(
$list_fileScript
))
{
// load the script
$this->viewScriptBuilder[$nameListCode]['list_fileScript']
= $list_fileScript;
}
// make sure there is script to add
if (isset($fileScript)
&& StringHelper::check(
$fileScript
))
{
// add the head script if set
if (isset($head) && StringHelper::check($head))
{
$fileScript = "// Some Global Values" . PHP_EOL . $head
. PHP_EOL . $fileScript;
}
// load the script
$this->viewScriptBuilder[$nameSingleCode]['fileScript']
= $fileScript;
}
// make sure to add custom footer script if php was found in it, since we
canot minfy it with php
if (isset($customFooterScript)
&& StringHelper::check(
$customFooterScript
))
{
if (!isset($footerScript))
{
$footerScript = '';
}
$footerScript .= $customFooterScript;
}
// make sure there is script to add
if (isset($footerScript)
&& StringHelper::check(
$footerScript
))
{
// add the needed script tags
$footerScript = PHP_EOL
. PHP_EOL . '<script type="text/javascript">'
. PHP_EOL
. $footerScript . PHP_EOL . "</script>";
$this->viewScriptBuilder[$nameSingleCode]['footerScript']
= $footerScript;
}
}
public function buildFunctionCall($function, $matchKeys, $getValue)
{
$initial = '';
$funcsets = [];
$array = false;
foreach ($matchKeys as $matchKey)
{
$value = $getValue[$matchKey];
if ($value['isArray'])
{
$initial .= PHP_EOL . Indent::_(1) . $value['get'];
$funcsets[] = $matchKey;
$array = true;
}
else
{
$initial .= PHP_EOL . Indent::_(1) . $value['get'];
$funcsets[] = $matchKey;
}
}
// make sure that the function is loaded only once
if (ArrayHelper::check($funcsets))
{
$initial .= PHP_EOL . Indent::_(1) . $function . "(";
$initial .= implode(',', $funcsets);
$initial .= ");" . PHP_EOL;
}
return array('code' => $initial, 'array' =>
$array);
}
public function getTargetRelationScript($relations, $condition, $view)
{
// reset the buket
$buket = [];
// convert to name array
foreach ($condition['target_field'] as $targetField)
{
if (ArrayHelper::check($targetField)
&& isset($targetField['name']))
{
$currentTargets[] = $targetField['name'];
}
}
// start the search
foreach ($relations as $relation)
{
// reset found
$found = false;
// chain only none matching fields
if ($relation['match_field'] !==
$condition['match_field']
&& $relation['target_relation']) // Made this change
to see if it improves the expected result (TODO)
{
if (ArrayHelper::check(
$relation['target_field']
))
{
foreach ($relation['target_field'] as $target)
{
if (ArrayHelper::check($target)
&& $this->checkRelationControl(
$target['name'], $relation['match_name'],
$condition['match_name'], $view
))
{
if (in_array($target['name'], $currentTargets))
{
$this->targetRelationControl[$view][$target['name']]
= array($relation['match_name'],
$condition['match_name']);
$found = true;
break;
}
}
}
if ($found)
{
$buket[] = $relation;
}
}
}
}
return $buket;
}
public function checkRelationControl($targetName, $relationMatchName,
$conditionMatchName, $view
)
{
if (isset($this->targetRelationControl[$view])
&& ArrayHelper::check(
$this->targetRelationControl[$view]
))
{
if (isset($this->targetRelationControl[$view][$targetName])
&& ArrayHelper::check(
$this->targetRelationControl[$view][$targetName]
))
{
if (!in_array(
$relationMatchName,
$this->targetRelationControl[$view][$targetName]
)
|| !in_array(
$conditionMatchName,
$this->targetRelationControl[$view][$targetName]
))
{
return true;
}
}
else
{
return true;
}
}
elseif (!isset($this->targetRelationControl[$view])
|| !ArrayHelper::check(
$this->targetRelationControl[$view]
))
{
return true;
}
return false;
}
public function setTargetControlsScript($toggleSwitch, $targets,
$targetBehavior, $targetDefault,
$uniqueVar, $nameSingleCode
)
{
$bucket = [];
if (ArrayHelper::check($targets)
&& !in_array(
$uniqueVar, $this->targetControlsScriptChecker
))
{
foreach ($targets as $target)
{
if (ArrayHelper::check($target))
{
// set the required var
if ($target['required'] === 'yes')
{
$unique = $uniqueVar
. $this->uniquekey(3);
$bucket[$target['name']]['requiredVar'] =
"jform_"
. $unique . "_required = false;" . PHP_EOL;
}
else
{
$bucket[$target['name']]['requiredVar'] =
'';
}
// set target type
$targetTypeSufix = "";
if (CFactory::_('Field.Groups')->check(
$target['type'], 'spacer'
))
{
// target a class if this is a note or spacer
$targetType = ".";
}
elseif ($target['type'] === 'editor'
|| $target['type'] === 'subform')
{
// target the label if editor field
$targetType = "#jform_";
// since the id is not alway accessable we use the lable TODO (not
best way)
$targetTypeSufix = "-lbl";
}
else
{
// target an id if this is a field
$targetType = "#jform_";
}
// set the target behavior
$bucket[$target['name']]['behavior'] = PHP_EOL .
Indent::_(
2
) . "jQuery('" . $targetType .
$target['name']
. $targetTypeSufix .
"').closest('.control-group')."
. $targetBehavior . "();";
// set the target default
$bucket[$target['name']]['default'] = PHP_EOL .
Indent::_(2)
. "jQuery('" . $targetType .
$target['name']
. $targetTypeSufix .
"').closest('.control-group')."
. $targetDefault . "();";
// the hide required function
if ($target['required'] === 'yes')
{
if ($toggleSwitch)
{
$hide = PHP_EOL
. Indent::_(2) . "//" . Line::_(__Line__, __Class__)
. " remove required attribute from "
. $target['name'] . " field";
$hide .= PHP_EOL
. Indent::_(2) . "if (!jform_" . $unique
. "_required)";
$hide .= PHP_EOL
. Indent::_(2) . "{";
$hide .= PHP_EOL
. Indent::_(3) . "updateFieldRequired('"
. $target['name'] . "',1);";
$hide .= PHP_EOL
. Indent::_(3) . "jQuery('#jform_"
. $target['name']
. "').removeAttr('required');";
$hide .= PHP_EOL
. Indent::_(3) . "jQuery('#jform_"
. $target['name']
. "').removeAttr('aria-required');";
$hide .= PHP_EOL
. Indent::_(3) . "jQuery('#jform_"
. $target['name']
. "').removeClass('required');";
$hide .= PHP_EOL
. Indent::_(3) . "jform_" . $unique
. "_required = true;";
$hide .= PHP_EOL
. Indent::_(2) . "}";
$bucket[$target['name']]['hide'] = $hide;
// the show required function
$show = PHP_EOL
. Indent::_(2) . "//" . Line::_(__Line__, __Class__)
. " add required attribute to "
. $target['name'] . " field";
$show .= PHP_EOL
. Indent::_(2) . "if (jform_" . $unique
. "_required)";
$show .= PHP_EOL
. Indent::_(2) . "{";
$show .= PHP_EOL
. Indent::_(3) . "updateFieldRequired('"
. $target['name'] . "',0);";
$show .= PHP_EOL
. Indent::_(3) . "jQuery('#jform_"
. $target['name']
.
"').prop('required','required');";
$show .= PHP_EOL
. Indent::_(3) . "jQuery('#jform_"
. $target['name']
. "').attr('aria-required',true);";
$show .= PHP_EOL
. Indent::_(3) . "jQuery('#jform_"
. $target['name'] .
"').addClass('required');";
$show .= PHP_EOL
. Indent::_(3) . "jform_" . $unique
. "_required = false;";
$show .= PHP_EOL
. Indent::_(2) . "}";
$bucket[$target['name']]['show'] = $show;
}
else
{
$hide = PHP_EOL
. Indent::_(2) . "//" . Line::_(__Line__, __Class__)
. " remove required attribute from "
. $target['name'] . " field";
$hide .= PHP_EOL
. Indent::_(2) . "updateFieldRequired('"
. $target['name'] . "',1);";
$hide .= PHP_EOL
. Indent::_(2) . "jQuery('#jform_"
. $target['name']
. "').removeAttr('required');";
$hide .= PHP_EOL
. Indent::_(2) . "jQuery('#jform_"
. $target['name']
. "').removeAttr('aria-required');";
$hide .= PHP_EOL
. Indent::_(2) . "jQuery('#jform_"
. $target['name']
. "').removeClass('required');";
$hide .= PHP_EOL
. Indent::_(2) . "jform_" . $unique
. "_required = true;" . PHP_EOL;
$bucket[$target['name']]['hide'] = $hide;
// the show required function
$show = PHP_EOL
. Indent::_(2) . "//" . Line::_(__Line__, __Class__)
. " add required attribute to "
. $target['name'] . " field";
$show .= PHP_EOL
. Indent::_(2) . "updateFieldRequired('"
. $target['name'] . "',0);";
$show .= PHP_EOL
. Indent::_(2) . "jQuery('#jform_"
. $target['name']
.
"').prop('required','required');";
$show .= PHP_EOL
. Indent::_(2) . "jQuery('#jform_"
. $target['name']
. "').attr('aria-required',true);";
$show .= PHP_EOL
. Indent::_(2) . "jQuery('#jform_"
. $target['name'] .
"').addClass('required');";
$show .= PHP_EOL
. Indent::_(2) . "jform_" . $unique
. "_required = false;" . PHP_EOL;
$bucket[$target['name']]['show'] = $show;
}
// make sure that the axaj and other needed things for this view is
loaded
$this->validationFixBuilder[$nameSingleCode][]
= $target['name'];
}
else
{
$bucket[$target['name']]['hide'] = '';
$bucket[$target['name']]['show'] = '';
}
}
}
$this->targetControlsScriptChecker[] = $uniqueVar;
}
return $bucket;
}
public function ifValueScript($value, $behavior, $type, $options)
{
// reset string
$string = '';
switch ($behavior)
{
case 1: // Is
// only 4 list/radio/checkboxes
if (CFactory::_('Field.Groups')->check($type,
'list')
|| CFactory::_('Field.Groups')->check($type,
'dynamic')
|| !CFactory::_('Field.Groups')->check($type))
{
if (ArrayHelper::check($options))
{
foreach ($options as $option)
{
if (!is_numeric($option))
{
if ($option != 'true' && $option !=
'false')
{
$option = "'" . $option . "'";
}
}
if (StringHelper::check($string))
{
$string .= ' || ' . $value . ' == ' . $option;
}
else
{
$string .= $value . ' == ' . $option;
}
}
}
else
{
$string .= 'isSet(' . $value . ')';
}
}
break;
case 2: // Is Not
// only 4 list/radio/checkboxes
if (CFactory::_('Field.Groups')->check($type,
'list')
|| CFactory::_('Field.Groups')->check($type,
'dynamic')
|| !CFactory::_('Field.Groups')->check($type))
{
if (ArrayHelper::check($options))
{
foreach ($options as $option)
{
if (!is_numeric($option))
{
if ($option != 'true' && $option !=
'false')
{
$option = "'" . $option . "'";
}
}
if (StringHelper::check($string))
{
$string .= ' || ' . $value . ' != ' . $option;
}
else
{
$string .= $value . ' != ' . $option;
}
}
}
else
{
$string .= '!isSet(' . $value . ')';
}
}
break;
case 3: // Any Selection
// only 4 list/radio/checkboxes/dynamic_list
if (CFactory::_('Field.Groups')->check($type,
'list')
|| CFactory::_('Field.Groups')->check($type,
'dynamic')
|| !CFactory::_('Field.Groups')->check($type))
{
if (ArrayHelper::check($options))
{
foreach ($options as $option)
{
if (!is_numeric($option))
{
if ($option != 'true' && $option !=
'false')
{
$option = "'" . $option . "'";
}
}
if (StringHelper::check($string))
{
$string .= ' || ' . $value . ' == ' . $option;
}
else
{
$string .= $value . ' == ' . $option;
}
}
}
else
{
$userFix = '';
if
(CFactory::_('Compiler.Builder.Script.User.Switch')->inArray($type))
{
// TODO this needs a closer look, a bit buggy
$userFix = " && " . $value . " != 0";
}
$string .= 'isSet(' . $value . ')' . $userFix;
}
}
break;
case 4: // Active (not empty)
// only 4 text_field
if (CFactory::_('Field.Groups')->check($type,
'text'))
{
$string .= 'isSet(' . $value . ')';
}
break;
case 5: // Unactive (empty)
// only 4 text_field
if (CFactory::_('Field.Groups')->check($type,
'text'))
{
$string .= '!isSet(' . $value . ')';
}
break;
case 6: // Key Word All (case-sensitive)
// only 4 text_field
if (CFactory::_('Field.Groups')->check($type,
'text'))
{
if (ArrayHelper::check(
$options['keywords']
))
{
foreach ($options['keywords'] as $keyword)
{
if (StringHelper::check($string))
{
$string .= ' && ' . $value .
'.indexOf("'
. $keyword . '") >= 0';
}
else
{
$string .= $value . '.indexOf("' . $keyword
. '") >= 0';
}
}
}
if (!StringHelper::check($string))
{
$string .= $value . ' == "error"';
}
}
break;
case 7: // Key Word Any (case-sensitive)
// only 4 text_field
if (CFactory::_('Field.Groups')->check($type,
'text'))
{
if (ArrayHelper::check(
$options['keywords']
))
{
foreach ($options['keywords'] as $keyword)
{
if (StringHelper::check($string))
{
$string .= ' || ' . $value . '.indexOf("'
. $keyword . '") >= 0';
}
else
{
$string .= $value . '.indexOf("' . $keyword
. '") >= 0';
}
}
}
if (!StringHelper::check($string))
{
$string .= $value . ' == "error"';
}
}
break;
case 8: // Key Word All (case-insensitive)
// only 4 text_field
if (CFactory::_('Field.Groups')->check($type,
'text'))
{
if (ArrayHelper::check(
$options['keywords']
))
{
foreach ($options['keywords'] as $keyword)
{
$keyword = StringHelper::safe(
$keyword, 'w'
);
if (StringHelper::check($string))
{
$string .= ' && ' . $value
. '.toLowerCase().indexOf("' . $keyword
. '") >= 0';
}
else
{
$string .= $value . '.toLowerCase().indexOf("'
. $keyword . '") >= 0';
}
}
}
if (!StringHelper::check($string))
{
$string .= $value . ' == "error"';
}
}
break;
case 9: // Key Word Any (case-insensitive)
// only 4 text_field
if (CFactory::_('Field.Groups')->check($type,
'text'))
{
if (ArrayHelper::check(
$options['keywords']
))
{
foreach ($options['keywords'] as $keyword)
{
$keyword = StringHelper::safe(
$keyword, 'w'
);
if (StringHelper::check($string))
{
$string .= ' || ' . $value
. '.toLowerCase().indexOf("' . $keyword
. '") >= 0';
}
else
{
$string .= $value . '.toLowerCase().indexOf("'
. $keyword . '") >= 0';
}
}
}
if (!StringHelper::check($string))
{
$string .= $value . ' == "error"';
}
}
break;
case 10: // Min Length
// only 4 text_field
if (CFactory::_('Field.Groups')->check($type,
'text'))
{
if (ArrayHelper::check($options))
{
if ($options['length'])
{
$string .= $value . '.length >= '
. (int) $options['length'];
}
}
if (!StringHelper::check($string))
{
$string .= $value . '.length >= 5';
}
}
break;
case 11: // Max Length
// only 4 text_field
if (CFactory::_('Field.Groups')->check($type,
'text'))
{
if (ArrayHelper::check($options))
{
if ($options['length'])
{
$string .= $value . '.length <= '
. (int) $options['length'];
}
}
if (!StringHelper::check($string))
{
$string .= $value . '.length <= 5';
}
}
break;
case 12: // Exact Length
// only 4 text_field
if (CFactory::_('Field.Groups')->check($type,
'text'))
{
if (ArrayHelper::check($options))
{
if ($options['length'])
{
$string .= $value . '.length == '
. (int) $options['length'];
}
}
if (!StringHelper::check($string))
{
$string .= $value . '.length == 5';
}
}
break;
}
if (!StringHelper::check($string))
{
$string = 0;
}
return $string;
}
public function getOptionsScript($type, $options)
{
$buket = [];
if (StringHelper::check($options))
{
if (CFactory::_('Field.Groups')->check($type,
'list')
|| CFactory::_('Field.Groups')->check($type,
'dynamic')
|| !CFactory::_('Field.Groups')->check($type))
{
$optionsArray = array_map(
'trim', (array) explode(PHP_EOL, (string) $options)
);
if (!ArrayHelper::check($optionsArray))
{
$optionsArray[] = $optionsArray;
}
foreach ($optionsArray as $option)
{
if (strpos($option, '|') !== false)
{
list($option) = array_map(
'trim', (array) explode('|', $option)
);
}
if ($option != 'dynamic_list')
{
// add option to return buket
$buket[] = $option;
}
}
}
elseif (CFactory::_('Field.Groups')->check($type,
'text'))
{
// check to get the key words if set
$keywords = GetHelper::between(
$options, 'keywords="', '"'
);
if (StringHelper::check($keywords))
{
if (strpos((string) $keywords, ',') !== false)
{
$keywords = array_map(
'trim', (array) explode(',', (string)
$keywords)
);
foreach ($keywords as $keyword)
{
$buket['keywords'][] = trim($keyword);
}
}
else
{
$buket['keywords'][] = trim((string) $keywords);
}
}
// check to ket string length if set
$length = GetHelper::between(
$options, 'length="', '"'
);
if (StringHelper::check($length))
{
$buket['length'] = $length;
}
else
{
$buket['length'] = false;
}
}
}
return $buket;
}
public function getValueScript($type, $name, $extends, $unique)
{
$select = '';
$isArray = false;
$keyName = $name . '_' . $unique;
if ($type === 'checkboxes' || $extends ===
'checkboxes')
{
$select = "var " . $keyName . " = [];" . PHP_EOL .
Indent::_(1)
. "jQuery('#jform_" . $name
. " input[type=checkbox]').each(function()" . PHP_EOL
. Indent::_(1) . "{" . PHP_EOL . Indent::_(2)
. "if (jQuery(this).is(':checked'))" . PHP_EOL .
Indent::_(2)
. "{" . PHP_EOL . Indent::_(3) . $keyName
. ".push(jQuery(this).prop('value'));" . PHP_EOL .
Indent::_(2)
. "}" . PHP_EOL . Indent::_(1) . "});";
$isArray = true;
}
elseif ($type === 'checkbox')
{
$select = 'var ' . $keyName . ' =
jQuery("#jform_' . $name
. '").prop(\'checked\');';
}
elseif ($type === 'radio')
{
$select = 'var ' . $keyName . ' =
jQuery("#jform_' . $name
. ' input[type=\'radio\']:checked").val();';
}
elseif
(CFactory::_('Compiler.Builder.Script.User.Switch')->inArray($type))
{
// this is only since 3.3.4
$select = 'var ' . $keyName . ' =
jQuery("#jform_' . $name
. '_id").val();';
}
elseif ($type === 'list'
|| CFactory::_('Field.Groups')->check(
$type, 'dynamic'
)
|| !CFactory::_('Field.Groups')->check($type))
{
$select = 'var ' . $keyName . ' =
jQuery("#jform_' . $name
. '").val();';
$isArray = true;
}
elseif (CFactory::_('Field.Groups')->check($type,
'text'))
{
$select = 'var ' . $keyName . ' =
jQuery("#jform_' . $name
. '").val();';
}
return array('get' => $select, 'isArray' =>
$isArray);
}
public function clearValueScript($type, $name, $unique)
{
$clear = '';
$isArray = false;
$keyName = $name . '_' . $unique;
if ($type === 'text' || $type === 'password' || $type
=== 'textarea')
{
$clear = "jQuery('#jform_" . $name . "').value
= '';";
}
elseif ($type === 'radio')
{
$clear = "jQuery('#jform_" . $name .
"').checked = false;";
}
elseif ($type === 'checkboxes' || $type ===
'checkbox'
|| $type === 'checkbox')
{
$clear = "jQuery('#jform_" . $name .
"').selectedIndex = -1;";
}
return $clear;
}
public function setViewScript(&$view, $type)
{
if (isset($this->viewScriptBuilder[$view])
&& isset($this->viewScriptBuilder[$view][$type]))
{
return $this->viewScriptBuilder[$view][$type];
}
return '';
}
public function setValidationFix($view, $Component)
{
$fix = '';
if (isset($this->validationFixBuilder[$view])
&& ArrayHelper::check(
$this->validationFixBuilder[$view]
))
{
$fix .= PHP_EOL . PHP_EOL . Indent::_(1) . "/**";
$fix .= PHP_EOL . Indent::_(1)
. " * Method to validate the form data.";
$fix .= PHP_EOL . Indent::_(1) . " *";
$fix .= PHP_EOL . Indent::_(1)
. " * @param JForm \$form The form to validate
against.";
$fix .= PHP_EOL . Indent::_(1)
. " * @param array \$data The data to validate.";
$fix .= PHP_EOL . Indent::_(1)
. " * @param string \$group The name of the field group to
validate.";
$fix .= PHP_EOL . Indent::_(1) . " *";
$fix .= PHP_EOL . Indent::_(1)
. " * @return mixed Array of filtered data if valid, false
otherwise.";
$fix .= PHP_EOL . Indent::_(1) . " *";
$fix .= PHP_EOL . Indent::_(1) . " * @see JFormRule";
$fix .= PHP_EOL . Indent::_(1) . " * @see JFilterInput";
$fix .= PHP_EOL . Indent::_(1) . " * @since 12.2";
$fix .= PHP_EOL . Indent::_(1) . " */";
$fix .= PHP_EOL . Indent::_(1)
. "public function validate(\$form, \$data, \$group =
null)";
$fix .= PHP_EOL . Indent::_(1) . "{";
$fix .= PHP_EOL . Indent::_(2) . "//" . Line::_(__Line__,
__Class__)
. " check if the not_required field is set";
$fix .= PHP_EOL . Indent::_(2)
. "if (isset(\$data['not_required']) && "
. "Super_" .
"__1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::check(\$data['not_required']))";
$fix .= PHP_EOL . Indent::_(2) . "{";
$fix .= PHP_EOL . Indent::_(3)
. "\$requiredFields = (array) explode(',',(string)
\$data['not_required']);";
$fix .= PHP_EOL . Indent::_(3)
. "\$requiredFields = array_unique(\$requiredFields);";
$fix .= PHP_EOL . Indent::_(3) . "//" . Line::_(__Line__,
__Class__)
. " now change the required field attributes value";
$fix .= PHP_EOL . Indent::_(3)
. "foreach (\$requiredFields as \$requiredField)";
$fix .= PHP_EOL . Indent::_(3) . "{";
$fix .= PHP_EOL . Indent::_(4) . "//" . Line::_(__Line__,
__Class__)
. " make sure there is a string value";
$fix .= PHP_EOL . Indent::_(4) . "if ("
. "Super_" .
"__1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::check(\$requiredField))";
$fix .= PHP_EOL . Indent::_(4) . "{";
$fix .= PHP_EOL . Indent::_(5) . "//" . Line::_(__Line__,
__Class__)
. " change to false";
$fix .= PHP_EOL . Indent::_(5)
. "\$form->setFieldAttribute(\$requiredField,
'required', 'false');";
$fix .= PHP_EOL . Indent::_(5) . "//" . Line::_(__Line__,
__Class__)
. " also clear the data set";
$fix .= PHP_EOL . Indent::_(5) . "\$data[\$requiredField] =
'';";
$fix .= PHP_EOL . Indent::_(4) . "}";
$fix .= PHP_EOL . Indent::_(3) . "}";
$fix .= PHP_EOL . Indent::_(2) . "}";
$fix .= PHP_EOL . Indent::_(2)
. "return parent::validate(\$form, \$data, \$group);";
$fix .= PHP_EOL . Indent::_(1) . "}";
}
return $fix;
}
public function setAjaxToke(&$view)
{
$fix = '';
if
(isset(CFactory::_('Customcode.Dispenser')->hub['token'][$view])
&&
CFactory::_('Customcode.Dispenser')->hub['token'][$view])
{
$fix .= PHP_EOL . Indent::_(2) . "//" . Line::_(__Line__,
__Class__)
. " Add Ajax Token";
$fix .= PHP_EOL . Indent::_(2)
. "\$this->getDocument()->addScriptDeclaration(\"var
token = '\" . Session::getFormToken() .
\"';\");";
}
return $fix;
}
public function setRegisterAjaxTask($target)
{
$tasks = '';
if
(isset(CFactory::_('Customcode.Dispenser')->hub[$target]['ajax_controller'])
&& ArrayHelper::check(
CFactory::_('Customcode.Dispenser')->hub[$target]['ajax_controller']
))
{
$taskArray = [];
foreach (
CFactory::_('Customcode.Dispenser')->hub[$target]['ajax_controller']
as $view
)
{
foreach ($view as $task)
{
$taskArray[$task['task_name']] =
$task['task_name'];
}
}
if (ArrayHelper::check($taskArray))
{
foreach ($taskArray as $name)
{
$tasks .= PHP_EOL . Indent::_(2) .
"\$this->registerTask('"
. $name . "', 'ajax');";
}
}
}
return $tasks;
}
public function setAjaxInputReturn($target)
{
$cases = '';
if
(isset(CFactory::_('Customcode.Dispenser')->hub[$target]['ajax_controller'])
&& ArrayHelper::check(
CFactory::_('Customcode.Dispenser')->hub[$target]['ajax_controller']
))
{
$input = [];
$valueArray = [];
$ifArray = [];
$getModel = [];
$userCheck = [];
$prefix = ($target == 'site') ?
'Site':'Administrator';
$isJoomla3 =
(CFactory::_('Config')->get('joomla_version', 3) ==
3);
$failed = "false";
if (!$isJoomla3)
{
$failed = "['error' => 'There was an error!
[149]']";
}
foreach (
CFactory::_('Customcode.Dispenser')->hub[$target]['ajax_controller']
as $view
)
{
foreach ($view as $task)
{
$input[$task['task_name']][] = "\$"
. $task['value_name'] . "Value =
\$jinput->get('"
. $task['value_name'] . "', " .
$task['input_default']
. ", '" . $task['input_filter'] .
"');";
$valueArray[$task['task_name']][] = "\$"
. $task['value_name'] . "Value";
$getModel[$task['task_name']] =
"\$result = \$ajaxModule->"
. $task['method_name'] . "(" .
Placefix::_("valueArray") . ");";
// check if null or zero is allowed
if (!isset($task['allow_zero']) || 1 !=
$task['allow_zero'])
{
$ifArray[$task['task_name']][] = "\$"
. $task['value_name'] . "Value";
}
// see user check is needed
if (!isset($userCheck[$task['task_name']])
&& isset($task['user_check'])
&& 1 == $task['user_check'])
{
// add it since this means it was not set, and in the old method we
assumed it was inplace
// or it is set and 1 means we still want it inplace
$ifArray[$task['task_name']][] = '$user->id !=
0';
// add it only once
$userCheck[$task['task_name']] = true;
}
}
}
if (ArrayHelper::check($getModel))
{
foreach ($getModel as $task => $getMethod)
{
$cases .= PHP_EOL . Indent::_(4) . "case '" . $task .
"':";
$cases .= PHP_EOL . Indent::_(5) . "try";
$cases .= PHP_EOL . Indent::_(5) . "{";
foreach ($input[$task] as $string)
{
$cases .= PHP_EOL . Indent::_(6) . $string;
}
// set the values
$values = implode(', ', $valueArray[$task]);
// set the values to method
$getMethod = str_replace(
Placefix::_('valueArray'), $values,
$getMethod
);
// check if we have some values to check
if (isset($ifArray[$task])
&& ArrayHelper::check($ifArray[$task]))
{
// set if string
$ifvalues = implode(' && ', $ifArray[$task]);
// add to case
$cases .= PHP_EOL . Indent::_(6) . "if(" . $ifvalues
. ")";
$cases .= PHP_EOL . Indent::_(6) . "{";
if ($isJoomla3)
{
$cases .= PHP_EOL . Indent::_(7) . "\$ajaxModule =
\$this->getModel('ajax');";
}
else
{
$cases .= PHP_EOL . Indent::_(7) . "\$ajaxModule =
\$this->getModel('ajax', '$prefix');";
}
$cases .= PHP_EOL . Indent::_(7) . "if (\$ajaxModule)";
$cases .= PHP_EOL . Indent::_(7) . "{";
$cases .= PHP_EOL . Indent::_(8) . $getMethod;
$cases .= PHP_EOL . Indent::_(7) . "}";
$cases .= PHP_EOL . Indent::_(7) . "else";
$cases .= PHP_EOL . Indent::_(7) . "{";
$cases .= PHP_EOL . Indent::_(8) . "\$result = $failed;";
$cases .= PHP_EOL . Indent::_(7) . "}";
$cases .= PHP_EOL . Indent::_(6) . "}";
$cases .= PHP_EOL . Indent::_(6) . "else";
$cases .= PHP_EOL . Indent::_(6) . "{";
$cases .= PHP_EOL . Indent::_(7) . "\$result = $failed;";
$cases .= PHP_EOL . Indent::_(6) . "}";
}
else
{
if ($isJoomla3)
{
$cases .= PHP_EOL . Indent::_(6) . "\$ajaxModule =
\$this->getModel('ajax');";
}
else
{
$cases .= PHP_EOL . Indent::_(6) . "\$ajaxModule =
\$this->getModel('ajax', '$prefix');";
}
$cases .= PHP_EOL . Indent::_(6) . "if (\$ajaxModule)";
$cases .= PHP_EOL . Indent::_(6) . "{";
$cases .= PHP_EOL . Indent::_(7) . $getMethod;
$cases .= PHP_EOL . Indent::_(6) . "}";
$cases .= PHP_EOL . Indent::_(6) . "else";
$cases .= PHP_EOL . Indent::_(6) . "{";
$cases .= PHP_EOL . Indent::_(7) . "\$result = $failed;";
$cases .= PHP_EOL . Indent::_(6) . "}";
}
// continue the build
$cases .= PHP_EOL . Indent::_(6)
. "if(\$callback)";
$cases .= PHP_EOL . Indent::_(6) . "{";
$cases .= PHP_EOL . Indent::_(7)
. "echo \$callback .
\"(\".json_encode(\$result).\");\";";
$cases .= PHP_EOL . Indent::_(6) . "}";
$cases .= PHP_EOL . Indent::_(6) . "elseif(\$returnRaw)";
$cases .= PHP_EOL . Indent::_(6) . "{";
$cases .= PHP_EOL . Indent::_(7)
. "echo json_encode(\$result);";
$cases .= PHP_EOL . Indent::_(6) . "}";
$cases .= PHP_EOL . Indent::_(6) . "else";
$cases .= PHP_EOL . Indent::_(6) . "{";
$cases .= PHP_EOL . Indent::_(7)
. "echo
\"(\".json_encode(\$result).\");\";";
$cases .= PHP_EOL . Indent::_(6) . "}";
$cases .= PHP_EOL . Indent::_(5) . "}";
$cases .= PHP_EOL . Indent::_(5) . "catch(\Exception \$e)";
$cases .= PHP_EOL . Indent::_(5) . "{";
$cases .= PHP_EOL . Indent::_(6)
. "if(\$callback)";
$cases .= PHP_EOL . Indent::_(6) . "{";
$cases .= PHP_EOL . Indent::_(7)
. "echo
\$callback.\"(\".json_encode(\$e).\");\";";
$cases .= PHP_EOL . Indent::_(6) . "}";
$cases .= PHP_EOL . Indent::_(6)
. "elseif(\$returnRaw)";
$cases .= PHP_EOL . Indent::_(6) . "{";
$cases .= PHP_EOL . Indent::_(7)
. "echo json_encode(\$e);";
$cases .= PHP_EOL . Indent::_(6) . "}";
$cases .= PHP_EOL . Indent::_(6) . "else";
$cases .= PHP_EOL . Indent::_(6) . "{";
$cases .= PHP_EOL . Indent::_(7)
. "echo
\"(\".json_encode(\$e).\");\";";
$cases .= PHP_EOL . Indent::_(6) . "}";
$cases .= PHP_EOL . Indent::_(5) . "}";
$cases .= PHP_EOL . Indent::_(4) . "break;";
}
}
}
return $cases;
}
public function setAjaxModelMethods($target)
{
$methods = '';
if
(isset(CFactory::_('Customcode.Dispenser')->hub[$target]['ajax_model'])
&& ArrayHelper::check(
CFactory::_('Customcode.Dispenser')->hub[$target]['ajax_model']
))
{
foreach (
CFactory::_('Customcode.Dispenser')->hub[$target]['ajax_model']
as $view =>
$method
)
{
$methods .= PHP_EOL . PHP_EOL . Indent::_(1) . "//"
. Line::_(__Line__, __Class__) . " Used in " . $view .
PHP_EOL;
$methods .= CFactory::_('Placeholder')->update_(
$method
);
}
}
return $methods;
}
public function setJquery(&$view)
{
$addJQuery = '';
if (true) // TODO we just add it everywhere for now.
{
$addJQuery .= PHP_EOL . Indent::_(2) . "//" .
Line::_(__Line__, __Class__)
. " Load jQuery";
$addJQuery .= PHP_EOL . Indent::_(2) .
"Html::_('jquery.framework');";
}
return $addJQuery;
}
/**
* build filter functions
*
* @param string $nameSingleCode The single view name
* @param string $nameListCode The list view name
*
* @return string The php to place in view.html.php
*
*/
public function setFilterFieldHelper(&$nameSingleCode,
&$nameListCode)
{
// the old filter type uses these functions
if
(CFactory::_('Compiler.Builder.Filter')->exists($nameListCode))
{
// set the function or file path (2 = topbar)
$funtion_path = true;
if
(CFactory::_('Compiler.Builder.Admin.Filter.Type')->get($nameListCode,
1) == 2)
{
$funtion_path = false;
}
$function = [];
// set component name
$component = CFactory::_('Config')->component_code_name;
$Component = ucfirst((string) $component);
foreach
(CFactory::_('Compiler.Builder.Filter')->get($nameListCode) as
$filter)
{
if ($filter['type'] != 'category'
&& ArrayHelper::check($filter['custom'])
&& $filter['custom']['extends'] ===
'user')
{
// add if this is a function path
if ($funtion_path)
{
$function[] = PHP_EOL . Indent::_(1)
. "protected function getThe" .
$filter['function']
. StringHelper::safe(
$filter['custom']['text'], 'F'
) . "Selections()";
$function[] = Indent::_(1) . "{";
}
$function[] = Indent::_(2) . "//" . Line::_(__Line__,
__Class__)
. " Get a db connection.";
if
(CFactory::_('Config')->get('joomla_version', 3) ==
3)
{
$function[] = Indent::_(2) . "\$db = Factory::getDbo();";
}
else
{
$function[] = Indent::_(2) . "\$db =
Factory::getContainer()->get(\Joomla\Database\DatabaseInterface::class);";
}
$function[] = PHP_EOL . Indent::_(2) . "//"
. Line::_(__Line__, __Class__)
. " Create a new query object.";
$function[] = Indent::_(2)
. "\$query = \$db->getQuery(true);";
$function[] = PHP_EOL . Indent::_(2) . "//"
. Line::_(__Line__, __Class__) . " Select the text.";
$function[] = Indent::_(2)
. "\$query->select(\$db->quoteName(array('a."
. $filter['custom']['id'] .
"','a."
. $filter['custom']['text'] .
"')));";
$function[] = Indent::_(2)
. "\$query->from(\$db->quoteName('"
. $filter['custom']['table'] . "',
'a'));";
$function[] = Indent::_(2) . "//" . Line::_(__Line__,
__Class__)
. " get the targeted groups";
$function[] = Indent::_(2)
. "\$groups= ComponentHelper::getParams('com_"
. $component . "')->get('" .
$filter['type'] . "');";
$function[] = Indent::_(2)
. "if (!empty(\$groups) && count((array) \$groups) >
0)";
$function[] = Indent::_(2) . "{";
$function[] = Indent::_(3)
. "\$query->join('LEFT',
\$db->quoteName('#__user_usergroup_map', 'group') .
' ON (' . \$db->quoteName('group.user_id') . '
= ' . \$db->quoteName('a.id') . ')');";
$function[] = Indent::_(3)
. "\$query->where('group.group_id IN (' .
implode(',', \$groups) . ')');";
$function[] = Indent::_(2) . "}";
$function[] = Indent::_(2) . "\$query->order('a."
. $filter['custom']['text'] . "
ASC');";
$function[] = PHP_EOL . Indent::_(2) . "//"
. Line::_(__Line__, __Class__)
. " Reset the query using our newly populated query
object.";
$function[] = Indent::_(2) . "\$db->setQuery(\$query);";
$function[] = PHP_EOL . Indent::_(2)
. "\$results = \$db->loadObjectList();";
$function[] = Indent::_(2) . "\$_filter = [];";
// if this is not a multi field
if (!$funtion_path && $filter['multi'] == 1)
{
$function[] = Indent::_(2)
. "\$_filter[] = Html::_('select.option',
'', '- Select ' . Text:"
. ":_('" . $filter['lang'] . "')
. ' -');";
}
$function[] = Indent::_(2) . "if (\$results)";
$function[] = Indent::_(2) . "{";
$function[] = Indent::_(3)
. "foreach (\$results as \$result)";
$function[] = Indent::_(3) . "{";
$function[] = Indent::_(4)
. "\$_filter[] = Html::_('select.option',
\$result->"
. $filter['custom']['id'] . ",
\$result->"
. $filter['custom']['text'] . ");";
$function[] = Indent::_(3) . "}";
$function[] = Indent::_(2) . "}";
$function[] = Indent::_(2) . "return \$_filter;";
// add if this is a function path
if ($funtion_path)
{
$function[] = Indent::_(1) . "}";
}
/* else
{
$function[] = PHP_EOL.Indent::_(1) . "protected function
getThe".$filter['function'].StringHelper::safe($filter['custom']['text'],'F')."Selections()";
$function[] = Indent::_(1) . "{";
$function[] = Indent::_(2) . "//".Line::_(__Line__,
__Class__)." Get a db connection.";
$function[] = Indent::_(2) . "\$db = Factory::getDbo();";
$function[] = PHP_EOL.Indent::_(2) .
"//".Line::_(__Line__, __Class__)." Select the text.";
$function[] = Indent::_(2) . "\$query =
\$db->getQuery(true);";
$function[] = PHP_EOL.Indent::_(2) .
"//".Line::_(__Line__, __Class__)." Select the text.";
$function[] = Indent::_(2) .
"\$query->select(\$db->quoteName(array('".$filter['custom']['id']."','".$filter['custom']['text']."')));";
$function[] = Indent::_(2) .
"\$query->from(\$db->quoteName('".$filter['custom']['table']."'));";
$function[] = Indent::_(2) .
"\$query->where(\$db->quoteName('published') . '
= 1');";
$function[] = Indent::_(2) .
"\$query->order(\$db->quoteName('".$filter['custom']['text']."')
. ' ASC');";
$function[] = PHP_EOL.Indent::_(2) .
"//".Line::_(__Line__, __Class__)." Reset the query using
our newly populated query object.";
$function[] = Indent::_(2) .
"\$db->setQuery(\$query);";
$function[] = PHP_EOL.Indent::_(2) . "\$results =
\$db->loadObjectList();";
$function[] = PHP_EOL.Indent::_(2) . "if (\$results)";
$function[] = Indent::_(2) . "{";
$function[] = Indent::_(3) . "\$filter = [];";
$function[] = Indent::_(3) . "\$batch = [];";
$function[] = Indent::_(3) . "foreach (\$results as
\$result)";
$function[] = Indent::_(3) . "{";
if ($filter['custom']['text'] ===
'user')
{
$function[] = Indent::_(4) . "\$filter[] =
Html::_('select.option',
\$result->".$filter['custom']['text'].",
Factory::getUser(\$result->".$filter['custom']['text'].")->name);";
$function[] = Indent::_(4) . "\$batch[] =
Html::_('select.option',
\$result->".$filter['custom']['id'].",
Factory::getUser(\$result->".$filter['custom']['text'].")->name);";
}
else
{
$function[] = Indent::_(4) . "\$filter[] =
Html::_('select.option',
\$result->".$filter['custom']['text'].",
\$result->".$filter['custom']['text'].");";
$function[] = Indent::_(4) . "\$batch[] =
Html::_('select.option',
\$result->".$filter['custom']['id'].",
\$result->".$filter['custom']['text'].");";
}
$function[] = Indent::_(3) . "}";
$function[] = Indent::_(3) . "return array('filter'
=> \$filter, 'batch' => \$batch);";
$function[] = Indent::_(2) . "}";
$function[] = Indent::_(2) . "return false;";
$function[] = Indent::_(1) . "}";
} */
}
elseif ($filter['type'] != 'category'
&& !ArrayHelper::check($filter['custom']))
{
$translation = false;
if
(CFactory::_('Compiler.Builder.Selection.Translation')->
exists($nameListCode . '.' . $filter['code']))
{
$translation = true;
}
// add if this is a function path
if ($funtion_path)
{
$function[] = PHP_EOL . Indent::_(1)
. "protected function getThe" .
$filter['function']
. "Selections()";
$function[] = Indent::_(1) . "{";
$function[] = Indent::_(2) . "//" . Line::_(
__LINE__,__CLASS__
)
. " Get a db connection.";
}
else
{
$function[] = "//" . Line::_(__Line__, __Class__)
. " Get a db connection.";
}
if
(CFactory::_('Config')->get('joomla_version', 3) ==
3)
{
$function[] = Indent::_(2) . "\$db = Factory::getDbo();";
}
else
{
$function[] = Indent::_(2) . "\$db =
Factory::getContainer()->get(\Joomla\Database\DatabaseInterface::class);";
}
$function[] = PHP_EOL . Indent::_(2) . "//"
. Line::_(__Line__, __Class__)
. " Create a new query object.";
$function[] = Indent::_(2)
. "\$query = \$db->getQuery(true);";
// check if usergroup as we change to an object query
if ($filter['type'] === 'usergroup' ||
$filter['type'] === 'usergrouplist')
{
$function[] = PHP_EOL . Indent::_(2) . "//"
. Line::_(__Line__, __Class__) . " Select the text.";
$function[] = Indent::_(2)
. "\$query->select(\$db->quoteName('g."
. $filter['code'] . "',
'id'));";
$function[] = Indent::_(2)
. "\$query->select(\$db->quoteName('ug.title',
'title'));";
$function[] = Indent::_(2)
. "\$query->from(\$db->quoteName('#__" .
$component
. "_" . $filter['database'] . "',
'g'));";
$function[] = Indent::_(2)
. "\$query->join('LEFT',
\$db->quoteName('#__usergroups', 'ug') . ' ON
(' . (\$db->quoteName('g."
. $filter['code']
. "') . ' = ' .
\$db->quoteName('ug.id') . ')'));";
$function[] = Indent::_(2)
. "\$query->order(\$db->quoteName('title') .
' ASC');";
$function[] = Indent::_(2)
.
"\$query->group(\$db->quoteName('ug.id'));";
$function[] = PHP_EOL . Indent::_(2) . "//"
. Line::_(__Line__, __Class__)
. " Reset the query using our newly populated query
object.";
$function[] = Indent::_(2) .
"\$db->setQuery(\$query);";
$function[] = PHP_EOL . Indent::_(2)
. "\$_results = \$db->loadObjectList();";
}
else
{
$function[] = PHP_EOL . Indent::_(2) . "//"
. Line::_(__Line__, __Class__) . " Select the text.";
$function[] = Indent::_(2)
. "\$query->select(\$db->quoteName('"
. $filter['code'] . "'));";
$function[] = Indent::_(2)
. "\$query->from(\$db->quoteName('#__" .
$component
. "_" . $filter['database'] .
"'));";
$function[] = Indent::_(2)
. "\$query->order(\$db->quoteName('"
. $filter['code'] . "') . '
ASC');";
$function[] = PHP_EOL . Indent::_(2) . "//"
. Line::_(__Line__, __Class__)
. " Reset the query using our newly populated query
object.";
$function[] = Indent::_(2) .
"\$db->setQuery(\$query);";
$function[] = PHP_EOL . Indent::_(2)
. "\$_results = \$db->loadColumn();";
}
$function[] = Indent::_(2) . "\$_filter = [];";
// if this is not a multi field
if (!$funtion_path && $filter['multi'] == 1)
{
$function[] = Indent::_(2)
. "\$_filter[] = Html::_('select.option',
'', '- ' . Text:"
. ":_('" . $filter['lang_select'] .
"') . ' -');";
}
$function[] = PHP_EOL . Indent::_(2) . "if (\$_results)";
$function[] = Indent::_(2) . "{";
// check if translated value is used
if ($funtion_path && $translation)
{
$function[] = Indent::_(3) . "//" . Line::_(
__LINE__,__CLASS__
) . " get model";
$function[] = Indent::_(3)
. "\$_model = \$this->getModel();";
}
elseif ($translation)
{
$function[] = Indent::_(3) . "//" . Line::_(
__LINE__,__CLASS__
) . " get " . $nameListCode . "model";
$function[] = Indent::_(3)
. "\$_model = " . $Component .
"Helper::getModel('"
. $nameListCode . "');";
}
// check if usergroup as we change to an object query
if ($filter['type'] !== 'usergroup' &&
$filter['type'] !== 'usergrouplist')
{
$function[] = Indent::_(3)
. "\$_results = array_unique(\$_results);";
}
$function[] = Indent::_(3) . "foreach (\$_results as \$"
. $filter['code'] . ")";
$function[] = Indent::_(3) . "{";
// check if translated value is used
if ($translation)
{
$function[] = Indent::_(4) . "//" . Line::_(
__LINE__,__CLASS__
) . " Translate the " . $filter['code']
. " selection";
$function[] = Indent::_(4)
. "\$_text = \$_model->selectionTranslation(\$"
. $filter['code'] . ",'" .
$filter['code'] . "');";
$function[] = Indent::_(4) . "//" . Line::_(
__LINE__,__CLASS__
) . " Now add the " . $filter['code']
. " and its text to the options array";
$function[] = Indent::_(4)
. "\$_filter[] = Html::_('select.option', \$"
. $filter['code'] . ", Text:" .
":_(\$_text));";
}
elseif ($filter['type'] === 'user')
{
$function[] = Indent::_(4) . "//" . Line::_(
__LINE__,__CLASS__
) . " Now add the " . $filter['code']
. " and its text to the options array";
if
(CFactory::_('Config')->get('joomla_version', 3) ==
3)
{
$function[] = Indent::_(4)
. "\$_filter[] = Html::_('select.option', \$"
. $filter['code'] . ", Factory::getUser(\$"
. $filter['code'] . ")->name);";
}
else
{
$function[] = Indent::_(4)
. "\$_filter[] = Html::_('select.option', \$"
. $filter['code'] . ",";
$function[] = Indent::_(5)
. "Factory::getContainer()->";
$function[] = Indent::_(5)
.
"get(\Joomla\CMS\User\UserFactoryInterface::class)->";
$function[] = Indent::_(5)
. "loadUserById(\$"
. $filter['code'] . ")->name";
$function[] = Indent::_(5)
. ");";
}
}
else
{
if ($filter['type'] === 'usergroup' ||
$filter['type'] === 'usergrouplist')
{
$function[] = Indent::_(4) . "//" . Line::_(
__LINE__,__CLASS__
) . " Now add the " . $filter['code']
. " and its text to the options array";
$function[] = Indent::_(4)
. "\$_filter[] = Html::_('select.option', \$"
. $filter['code'] . "->id, \$" .
$filter['code']
. "->title);";
}
else
{
$function[] = Indent::_(4) . "//" . Line::_(
__LINE__,__CLASS__
) . " Now add the " . $filter['code']
. " and its text to the options array";
$function[] = Indent::_(4)
. "\$_filter[] = Html::_('select.option', \$"
. $filter['code'] . ", \$" .
$filter['code']
. ");";
}
}
$function[] = Indent::_(3) . "}";
$function[] = Indent::_(2) . "}";
$function[] = Indent::_(2) . "return \$_filter;";
// add if this is a function path
if ($funtion_path)
{
$function[] = Indent::_(1) . "}";
}
}
// we check if this is a multi field
// and if there is a blank option
// and give a notice that this will cause an issue
elseif (!$funtion_path && $filter['type'] !=
'category'
&& $filter['multi'] == 2
&& ArrayHelper::check($filter['custom']))
{
// get the field code
$field_code = $this->getCustomFieldCode(
$filter['custom']
)['JFORM_TYPE_PHP'];
// check for the [Html::_('select.option', '',]
code
if (strpos((string) $field_code,
"Html::_('select.option', '',")
!== false
&& strpos((string) $field_code, '($this->multiple ===
false)')
=== false)
{
// for now we just give an error message (don't fix it)
$this->app->enqueueMessage(
Text::_('COM_COMPONENTBUILDER_HR_HTHREEMULTI_FILTER_ERRORHTHREE'),
'Error'
);
$field_url
=
'"index.php?option=com_componentbuilder&view=fields&task=field.edit&id='
. $filter['id'] . '"
target="_blank"';
$field_fix
= "<pre>if (\$this->multiple === false) { // <--
this if statement is needed";
$field_fix .= PHP_EOL . Indent::_(1)
. "\$options[] = Html::_('select.option',
'', 'Select an option'); // <-- the empty
option";
$field_fix .= PHP_EOL . "}</pre>";
$this->app->enqueueMessage(
Text::sprintf(
'We detected that you have an empty option in a <a
href=%s>custom field (%s)</a> that is used in a multi
filter.<br />This will cause a problem, you will need to add the
following code to it.<br />%s',
$field_url,
$filter['code'],
$field_fix
), 'Error'
);
}
}
// divert the code to a file if this is not a funtion path
if (!$funtion_path
&& ArrayHelper::check(
$function
))
{
// set the filter file
$this->setFilterFieldFile(
implode(PHP_EOL, $function), $filter
);
// clear the filter out
$function = [];
}
}
// if this is a function path, return the function if set
if ($funtion_path && ArrayHelper::check($function))
{
// return the function
return PHP_EOL . implode(PHP_EOL, $function);
}
}
return '';
}
public function setUniqueFields(&$view)
{
$fields = [];
$fields[] = PHP_EOL . PHP_EOL . Indent::_(1) . "/**";
$fields[] = Indent::_(1)
. " * Method to get the unique fields of this table.";
$fields[] = Indent::_(1) . " *";
$fields[] = Indent::_(1)
. " * @return mixed An array of field names, boolean false if
none is set.";
$fields[] = Indent::_(1) . " *";
$fields[] = Indent::_(1) . " * @since 3.0";
$fields[] = Indent::_(1) . " */";
$fields[] = Indent::_(1) . "protected function
getUniqueFields()";
$fields[] = Indent::_(1) . "{";
if
(CFactory::_('Compiler.Builder.Database.Unique.Keys')->exists($view))
{
// if guid should also be added
if
(CFactory::_('Compiler.Builder.Database.Unique.Guid')->exists($view))
{
$fields[] = Indent::_(2) . "return array('" . implode(
"','",
CFactory::_('Compiler.Builder.Database.Unique.Keys')->get($view)
) . "', 'guid');";
}
else
{
$fields[] = Indent::_(2) . "return array('" . implode(
"','",
CFactory::_('Compiler.Builder.Database.Unique.Keys')->get($view)
) . "');";
}
}
// if only GUID is found
elseif
(CFactory::_('Compiler.Builder.Database.Unique.Guid')->exists($view))
{
$fields[] = Indent::_(2) . "return array('guid');";
}
else
{
$fields[] = Indent::_(2) . "return false;";
}
$fields[] = Indent::_(1) . "}";
// return the unique fields
return implode(PHP_EOL, $fields);
}
/**
* build sidebar filter loading scripts
*
* @param string $nameSingleCode The single view name
* @param string $nameListCode The list view name
*
* @return string The php to place in view.html.php
*
*/
public function setFilterFieldSidebarDisplayHelper(&$nameSingleCode,
&$nameListCode
)
{
// start the filter bucket
$fieldFilters = [];
// add the default filter
$this->setDefaultSidebarFilterHelper(
$fieldFilters, $nameSingleCode, $nameListCode
);
// add the category filter stuff
$this->setCategorySidebarFilterHelper($fieldFilters, $nameListCode);
// check if filter fields are added (1 = sidebar)
if
(CFactory::_('Compiler.Builder.Admin.Filter.Type')->get($nameListCode,
1) == 1
&&
CFactory::_('Compiler.Builder.Filter')->exists($nameListCode))
{
// get component name
$Component =
CFactory::_('Compiler.Builder.Content.One')->get('Component');
// load the rest of the filters
foreach
(CFactory::_('Compiler.Builder.Filter')->get($nameListCode) as
$filter)
{
if ($filter['type'] != 'category'
&& ArrayHelper::check($filter['custom'])
&& $filter['custom']['extends'] !==
'user')
{
$CodeName = StringHelper::safe(
$filter['code'] . ' ' .
$filter['custom']['text'], 'W'
);
$codeName = $filter['code']
. StringHelper::safe(
$filter['custom']['text'], 'F'
);
$type = StringHelper::safe(
$filter['custom']['type'], 'F'
);
$fieldFilters[] = PHP_EOL . Indent::_(2) . "//"
. Line::_(__Line__, __Class__) . " Set " . $CodeName
. " Selection";
$fieldFilters[] = Indent::_(2) . "\$this->" . $codeName
. "Options = FormHelper::loadFieldType('" . $type
. "')->options;";
$fieldFilters[] = Indent::_(2) . "//" . Line::_(
__LINE__,__CLASS__
) . " We do some sanitation for " . $CodeName
. " filter";
$fieldFilters[] = Indent::_(2) . "if ("
. "Super_" .
"__0a59c65c_9daf_4bc9_baf4_e063ff9e6a8a___Power::check(\$this->"
. $codeName
. "Options) &&";
$fieldFilters[] = Indent::_(3) . "isset(\$this->"
. $codeName
. "Options[0]->value) &&";
$fieldFilters[] = Indent::_(3) . "!"
. "Super_" .
"__1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::check(\$this->"
. $codeName
. "Options[0]->value))";
$fieldFilters[] = Indent::_(2) . "{";
$fieldFilters[] = Indent::_(3) . "unset(\$this->"
. $codeName
. "Options[0]);";
$fieldFilters[] = Indent::_(2) . "}";
$fieldFilters[] = Indent::_(2) . "//" . Line::_(
__LINE__,__CLASS__
) . " Only load " . $CodeName
. " filter if it has values";
$fieldFilters[] = Indent::_(2) . "if ("
. "Super_" .
"__0a59c65c_9daf_4bc9_baf4_e063ff9e6a8a___Power::check(\$this->"
. $codeName
. "Options))";
$fieldFilters[] = Indent::_(2) . "{";
$fieldFilters[] = Indent::_(3) . "//" . Line::_(
__LINE__,__CLASS__
) . " " . $CodeName . " Filter";
$fieldFilters[] = Indent::_(3) .
"\JHtmlSidebar::addFilter(";
$fieldFilters[] = Indent::_(4) . "'- Select ' .
Text:"
. ":_('" . $filter['lang'] . "') .
' -',";
$fieldFilters[] = Indent::_(4) . "'filter_"
. $filter['code']
. "',";
$fieldFilters[] = Indent::_(4)
. "Html::_('select.options', \$this->" .
$codeName
. "Options, 'value', 'text',
\$this->state->get('filter."
. $filter['code'] . "'))";
$fieldFilters[] = Indent::_(3) . ");";
$fieldFilters[] = Indent::_(2) . "}";
}
elseif ($filter['type'] != 'category')
{
$Codename = StringHelper::safe(
$filter['code'], 'W'
);
if (isset($filter['custom'])
&& ArrayHelper::check($filter['custom'])
&& $filter['custom']['extends'] ===
'user')
{
$functionName = "\$this->getThe" .
$filter['function']
. StringHelper::safe(
$filter['custom']['text'], 'F'
) . "Selections();";
}
else
{
$functionName = "\$this->getThe" .
$filter['function']
. "Selections();";
}
$fieldFilters[] = PHP_EOL . Indent::_(2) . "//"
. Line::_(__Line__, __Class__) . " Set " . $Codename
. " Selection";
$fieldFilters[] = Indent::_(2) . "\$this->"
. $filter['code']
. "Options = " . $functionName;
$fieldFilters[] = Indent::_(2) . "//" . Line::_(
__LINE__,__CLASS__
) . " We do some sanitation for " . $Codename
. " filter";
$fieldFilters[] = Indent::_(2) . "if ("
. "Super_" .
"__0a59c65c_9daf_4bc9_baf4_e063ff9e6a8a___Power::check(\$this->"
. $filter['code']
. "Options) &&";
$fieldFilters[] = Indent::_(3) . "isset(\$this->"
. $filter['code'] . "Options[0]->value)
&&";
$fieldFilters[] = Indent::_(3) . "!"
. "Super_" .
"__1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::check(\$this->"
. $filter['code']
. "Options[0]->value))";
$fieldFilters[] = Indent::_(2) . "{";
$fieldFilters[] = Indent::_(3) . "unset(\$this->"
. $filter['code'] . "Options[0]);";
$fieldFilters[] = Indent::_(2) . "}";
$fieldFilters[] = Indent::_(2) . "//" . Line::_(
__LINE__,__CLASS__
) . " Only load " . $Codename
. " filter if it has values";
$fieldFilters[] = Indent::_(2) . "if ("
. "Super_" .
"__0a59c65c_9daf_4bc9_baf4_e063ff9e6a8a___Power::check(\$this->"
. $filter['code']
. "Options))";
$fieldFilters[] = Indent::_(2) . "{";
$fieldFilters[] = Indent::_(3) . "//" . Line::_(
__LINE__,__CLASS__
) . " " . $Codename . " Filter";
$fieldFilters[] = Indent::_(3) .
"\JHtmlSidebar::addFilter(";
$fieldFilters[] = Indent::_(4) . "'- Select
'.Text:"
. ":_('" . $filter['lang'] .
"').' -',";
$fieldFilters[] = Indent::_(4) . "'filter_"
. $filter['code']
. "',";
$fieldFilters[] = Indent::_(4)
. "Html::_('select.options', \$this->"
. $filter['code']
. "Options, 'value', 'text',
\$this->state->get('filter."
. $filter['code'] . "'))";
$fieldFilters[] = Indent::_(3) . ");";
$fieldFilters[] = Indent::_(2) . "}";
}
}
}
// did we find filters
if (ArrayHelper::check($fieldFilters))
{
// return the filter
return PHP_EOL . implode(PHP_EOL, $fieldFilters);
}
return '';
}
/**
* add default filter helper
*
* @param array $filter The batch code array
* @param string $nameSingleCode The single view name
* @param string $nameListCode The list view name
*
* @return void
*
*/
protected function setDefaultSidebarFilterHelper(&$filter,
&$nameSingleCode,
&$nameListCode
)
{
// add the default filters if we are on the old filter paths (1 =
sidebar)
if
(CFactory::_('Compiler.Builder.Admin.Filter.Type')->get($nameListCode,
1) == 1)
{
// set batch
$filter[] = PHP_EOL . Indent::_(2)
. "//" . Line::_(__Line__, __Class__)
. " Only load publish filter if state change is allowed";
$filter[] = Indent::_(2)
. "if (\$this->canState)";
$filter[] = Indent::_(2) . "{";
$filter[] = Indent::_(3) . "\JHtmlSidebar::addFilter(";
$filter[] = Indent::_(4) . "Text:"
. ":_('JOPTION_SELECT_PUBLISHED'),";
$filter[] = Indent::_(4) . "'filter_published',";
$filter[] = Indent::_(4)
. "Html::_('select.options',
Html::_('jgrid.publishedOptions'), 'value',
'text', \$this->state->get('filter.published'),
true)";
$filter[] = Indent::_(3) . ");";
$filter[] = Indent::_(2) . "}";
// check if view has access
if
(CFactory::_('Compiler.Builder.Access.Switch')->exists($nameSingleCode)
&&
!CFactory::_('Compiler.Builder.Field.Names')->isString($nameSingleCode
. '.access'))
{
$filter[] = PHP_EOL . Indent::_(2) .
"\JHtmlSidebar::addFilter(";
$filter[] = Indent::_(3) . "Text:"
. ":_('JOPTION_SELECT_ACCESS'),";
$filter[] = Indent::_(3) . "'filter_access',";
$filter[] = Indent::_(3)
. "Html::_('select.options',
Html::_('access.assetgroups'), 'value',
'text',
\$this->state->get('filter.access'))";
$filter[] = Indent::_(2) . ");";
}
}
}
/**
* build category sidebar display filter helper
*
* @param array $filter The filter code array
* @param string $nameListCode The list view name
*
* @return void
*
*/
protected function setCategorySidebarFilterHelper(&$filter,
&$nameListCode)
{
// add the category filter if we are on the old filter paths (1 =
sidebar)
if
(CFactory::_('Compiler.Builder.Admin.Filter.Type')->get($nameListCode,
1) == 1
&&
CFactory::_('Compiler.Builder.Category')->exists("{$nameListCode}.extension")
&&
CFactory::_('Compiler.Builder.Category')->get("{$nameListCode}.filter",
0) >= 1)
{
// set filter
$filter[] = PHP_EOL . Indent::_(2) . "//"
. Line::_(__Line__, __Class__) . " Category Filter.";
$filter[] = Indent::_(2) . "\JHtmlSidebar::addFilter(";
$filter[] = Indent::_(3) . "Text:"
. ":_('JOPTION_SELECT_CATEGORY'),";
$filter[] = Indent::_(3) . "'filter_category_id',";
$filter[] = Indent::_(3)
. "Html::_('select.options',
Html::_('category.options', '"
.
CFactory::_('Compiler.Builder.Category')->get("{$nameListCode}.extension")
. "'), 'value', 'text',
\$this->state->get('filter.category_id'))";
$filter[] = Indent::_(2) . ");";
}
}
/**
* build batch loading helper scripts
*
* @param string $nameSingleCode The single view name
* @param string $nameListCode The list view name
*
* @return string The php to place in view.html.php
*
*/
public function setBatchDisplayHelper(&$nameSingleCode,
&$nameListCode)
{
// temp fix
if (CFactory::_('Config')->get('joomla_version',
3) != 3)
{
return '';
}
// start the batch bucket
$fieldBatch = [];
// add the default batch
$this->setDefaultBatchHelper($fieldBatch, $nameSingleCode);
// add the category filter stuff
$this->setCategoryBatchHelper($fieldBatch, $nameListCode);
// check if we have other batch options to add
if
(CFactory::_('Compiler.Builder.Filter')->exists($nameListCode))
{
// check if we should add some help to get the values (2 = topbar)
$get_values = false;
if
(CFactory::_('Compiler.Builder.Admin.Filter.Type')->get($nameListCode,
1) == 2)
{
// since the old path is not used, we need to add those values here
$get_values = true;
}
// get component name
$Component =
CFactory::_('Compiler.Builder.Content.One')->get('Component');
// load the rest of the batch options
foreach
(CFactory::_('Compiler.Builder.Filter')->get($nameListCode) as
$filter)
{
if ($filter['type'] != 'category'
&& ArrayHelper::check($filter['custom'])
&& $filter['custom']['extends'] !==
'user')
{
$CodeName = StringHelper::safe(
$filter['code'] . ' ' .
$filter['custom']['text'], 'W'
);
$codeName = $filter['code']
. StringHelper::safe(
$filter['custom']['text'], 'F'
);
$fieldBatch[] = PHP_EOL . Indent::_(2)
. "//" . Line::_(__Line__, __Class__)
. " Only load " . $CodeName
. " batch if create, edit, and batch is allowed";
$fieldBatch[] = Indent::_(2)
. "if (\$this->canBatch && \$this->canCreate
&& \$this->canEdit)";
$fieldBatch[] = Indent::_(2) . "{";
// add the get values here
if ($get_values)
{
$type = StringHelper::safe(
$filter['custom']['type'], 'F'
);
$fieldBatch[] = Indent::_(3) . "//"
. Line::_(__Line__, __Class__) . " Set " . $CodeName
. " Selection";
$fieldBatch[] = Indent::_(3) . "\$this->" . $codeName
. "Options = FormHelper::loadFieldType('" . $type
. "')->options;";
$fieldBatch[] = Indent::_(3) . "//" . Line::_(
__LINE__,__CLASS__
) . " We do some sanitation for " . $CodeName
. " filter";
$fieldBatch[] = Indent::_(3) . "if ("
. "Super_" .
"__0a59c65c_9daf_4bc9_baf4_e063ff9e6a8a___Power::check(\$this->"
. $codeName
. "Options) &&";
$fieldBatch[] = Indent::_(4) . "isset(\$this->"
. $codeName
. "Options[0]->value) &&";
$fieldBatch[] = Indent::_(4) . "!"
. "Super_" .
"__1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::check(\$this->"
. $codeName
. "Options[0]->value))";
$fieldBatch[] = Indent::_(3) . "{";
$fieldBatch[] = Indent::_(4) . "unset(\$this->"
. $codeName
. "Options[0]);";
$fieldBatch[] = Indent::_(3) . "}";
}
$fieldBatch[] = Indent::_(3) . "//" . Line::_(
__LINE__,__CLASS__
) . " " . $CodeName . " Batch Selection";
$fieldBatch[] = Indent::_(3)
. "JHtmlBatch_::addListSelection(";
$fieldBatch[] = Indent::_(4) . "'- Keep Original
'.Text:"
. ":_('" . $filter['lang'] .
"').' -',";
$fieldBatch[] = Indent::_(4) . "'batch[" .
$filter['code']
. "]',";
$fieldBatch[] = Indent::_(4)
. "Html::_('select.options', \$this->" .
$codeName
. "Options, 'value', 'text')";
$fieldBatch[] = Indent::_(3) . ");";
$fieldBatch[] = Indent::_(2) . "}";
}
elseif ($filter['type'] != 'category')
{
$CodeName = StringHelper::safe(
$filter['code'], 'W'
);
$fieldBatch[] = PHP_EOL . Indent::_(2)
. "//" . Line::_(__Line__, __Class__)
. " Only load " . $CodeName
. " batch if create, edit, and batch is allowed";
$fieldBatch[] = Indent::_(2)
. "if (\$this->canBatch && \$this->canCreate
&& \$this->canEdit)";
$fieldBatch[] = Indent::_(2) . "{";
// add the get values here
if ($get_values)
{
$fieldBatch[] = Indent::_(3) . "//"
. Line::_(__Line__, __Class__) . " Set " . $CodeName
. " Selection";
$fieldBatch[] = Indent::_(3) . "\$this->"
. $filter['code']
. "Options = FormHelper::loadFieldType('"
. $filter['filter_type']
. "')->options;";
$fieldBatch[] = Indent::_(3) . "//" . Line::_(
__LINE__,__CLASS__
) . " We do some sanitation for " . $CodeName
. " filter";
$fieldBatch[] = Indent::_(3) . "if ("
. "Super_" .
"__0a59c65c_9daf_4bc9_baf4_e063ff9e6a8a___Power::check(\$this->"
. $filter['code']
. "Options) &&";
$fieldBatch[] = Indent::_(4) . "isset(\$this->"
. $filter['code'] . "Options[0]->value)
&&";
$fieldBatch[] = Indent::_(4) . "!"
. "Super_" .
"__1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::check(\$this->"
. $filter['code']
. "Options[0]->value))";
$fieldBatch[] = Indent::_(3) . "{";
$fieldBatch[] = Indent::_(4) . "unset(\$this->"
. $filter['code'] . "Options[0]);";
$fieldBatch[] = Indent::_(3) . "}";
}
$fieldBatch[] = Indent::_(3) . "//" . Line::_(
__LINE__,__CLASS__
) . " " . $CodeName . " Batch Selection";
$fieldBatch[] = Indent::_(3)
. "JHtmlBatch_::addListSelection(";
$fieldBatch[] = Indent::_(4) . "'- Keep Original
'.Text:"
. ":_('" . $filter['lang'] .
"').' -',";
$fieldBatch[] = Indent::_(4) . "'batch[" .
$filter['code']
. "]',";
$fieldBatch[] = Indent::_(4)
. "Html::_('select.options', \$this->"
. $filter['code'] . "Options, 'value',
'text')";
$fieldBatch[] = Indent::_(3) . ");";
$fieldBatch[] = Indent::_(2) . "}";
}
}
}
// did we find batch options
if (ArrayHelper::check($fieldBatch))
{
// return the batch
return PHP_EOL . implode(PHP_EOL, $fieldBatch);
}
return '';
}
/**
* add default batch helper
*
* @param array $batch The batch code array
* @param string $nameSingleCode The single view name
*
* @return void
*
*/
protected function setDefaultBatchHelper(&$batch,
&$nameSingleCode)
{
// set component name
$COPMONENT =
CFactory::_('Component')->get('name_code');
$COPMONENT = StringHelper::safe(
$COPMONENT, 'U'
);
// set batch
$batch[] = PHP_EOL . Indent::_(2)
. "//" . Line::_(__Line__, __Class__)
. " Only load published batch if state and batch is allowed";
$batch[] = Indent::_(2)
. "if (\$this->canState && \$this->canBatch)";
$batch[] = Indent::_(2) . "{";
$batch[] = Indent::_(3) . "JHtmlBatch_::addListSelection(";
$batch[] = Indent::_(4) . "Text:" . ":_('COM_" .
$COPMONENT
. "_KEEP_ORIGINAL_STATE'),";
$batch[] = Indent::_(4) . "'batch[published]',";
$batch[] = Indent::_(4)
. "Html::_('select.options',
Html::_('jgrid.publishedOptions', array('all' =>
false)), 'value', 'text', '', true)";
$batch[] = Indent::_(3) . ");";
$batch[] = Indent::_(2) . "}";
// check if view has access
if
(CFactory::_('Compiler.Builder.Access.Switch')->exists($nameSingleCode)
&&
!CFactory::_('Compiler.Builder.Field.Names')->isString($nameSingleCode
. '.access'))
{
$batch[] = PHP_EOL . Indent::_(2)
. "//" . Line::_(__Line__, __Class__)
. " Only load access batch if create, edit and batch is
allowed";
$batch[] = Indent::_(2)
. "if (\$this->canBatch && \$this->canCreate
&& \$this->canEdit)";
$batch[] = Indent::_(2) . "{";
$batch[] = Indent::_(3) . "JHtmlBatch_::addListSelection(";
$batch[] = Indent::_(4) . "Text:" . ":_('COM_"
. $COPMONENT
. "_KEEP_ORIGINAL_ACCESS'),";
$batch[] = Indent::_(4) . "'batch[access]',";
$batch[] = Indent::_(4)
. "Html::_('select.options',
Html::_('access.assetgroups'), 'value',
'text')";
$batch[] = Indent::_(3) . ");";
$batch[] = Indent::_(2) . "}";
}
}
/**
* build category batch helper
*
* @param array $batch The batch code array
* @param string $nameListCode The list view name
*
* @return mixed The php to place in view.html.php
*
*/
protected function setCategoryBatchHelper(&$batch,
&$nameListCode)
{
if
(CFactory::_('Compiler.Builder.Category')->exists("{$nameListCode}.extension"))
{
// set component name
$COPMONENT =
CFactory::_('Component')->get('name_code');
$COPMONENT = StringHelper::safe($COPMONENT, 'U');
// set filter
$batch[] = PHP_EOL . Indent::_(2)
. "if (\$this->canBatch && \$this->canCreate
&& \$this->canEdit)";
$batch[] = Indent::_(2) . "{";
$batch[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__)
. " Category Batch selection.";
$batch[] = Indent::_(3) . "JHtmlBatch_::addListSelection(";
$batch[] = Indent::_(4) . "Text:" . ":_('COM_"
. $COPMONENT
. "_KEEP_ORIGINAL_CATEGORY'),";
$batch[] = Indent::_(4) . "'batch[category]',";
$batch[] = Indent::_(4)
. "Html::_('select.options',
Html::_('category.options', '"
.
CFactory::_('Compiler.Builder.Category')->get("{$nameListCode}.extension")
. "'), 'value', 'text')";
$batch[] = Indent::_(3) . ");";
$batch[] = Indent::_(2) . "}";
}
}
public function setRouterCategoryViews($nameSingleCode, $nameListCode)
{
if
(CFactory::_('Compiler.Builder.Category')->exists("{$nameListCode}.extension"))
{
// get the actual extension
$_extension =
CFactory::_('Compiler.Builder.Category')->get("{$nameListCode}.extension");
$_extension = explode('.', (string) $_extension);
// set component name
if (ArrayHelper::check($_extension))
{
$component = str_replace('com_', '',
$_extension[0]);
}
else
{
$component = CFactory::_('Config')->component_code_name;
}
// check if category has another name
$otherViews =
CFactory::_('Compiler.Builder.Category.Other.Name')->
get($nameListCode . '.views', $nameListCode);
$otherView =
CFactory::_('Compiler.Builder.Category.Other.Name')->
get($nameListCode . '.view', $nameSingleCode);
// set the OtherView value
CFactory::_('Compiler.Builder.Content.Multi')->set('category'
. $otherView . '|otherview', $otherView);
// load the category helper details in not already loaded
if
(!CFactory::_('Compiler.Builder.Content.Multi')->exists('category'
. $otherView . '|view'))
{
// lets also set the category helper for this view
$target = array('site' => 'category' .
$otherView);
CFactory::_('Utilities.Structure')->build($target,
'category');
// insure the file gets updated
CFactory::_('Compiler.Builder.Content.Multi')->set('category'
. $otherView . '|view', $otherView);
CFactory::_('Compiler.Builder.Content.Multi')->set('category'
. $otherView . '|View', ucfirst((string) $otherView));
CFactory::_('Compiler.Builder.Content.Multi')->set('category'
. $otherView . '|views', $otherViews);
CFactory::_('Compiler.Builder.Content.Multi')->set('category'
. $otherView . '|Views', ucfirst((string) $otherViews));
// set script to global helper file
$includeHelper = [];
$includeHelper[] = "\n//" . Line::_(__Line__, __Class__)
. "Insure this view category file is loaded.";
$includeHelper[] = "\$classname = '" . ucfirst((string)
$component)
. ucfirst((string) $otherView) . "Categories';";
$includeHelper[] = "if (!class_exists(\$classname))";
$includeHelper[] = "{";
$includeHelper[] = Indent::_(1)
. "\$path = JPATH_SITE . '/components/com_" .
$component
. "/helpers/category" . $otherView .
".php';";
$includeHelper[] = Indent::_(1) . "if (is_file(\$path))";
$includeHelper[] = Indent::_(1) . "{";
$includeHelper[] = Indent::_(2) . "include_once \$path;";
$includeHelper[] = Indent::_(1) . "}";
$includeHelper[] = "}";
CFactory::_('Compiler.Builder.Content.One')->add('CATEGORY_CLASS_TREES',
implode("\n", $includeHelper));
}
// return category view string
if
(CFactory::_('Compiler.Builder.Content.One')->exists('ROUTER_CATEGORY_VIEWS')
&& StringHelper::check(
CFactory::_('Compiler.Builder.Content.One')->get('ROUTER_CATEGORY_VIEWS')
))
{
return "," . PHP_EOL . Indent::_(3) . '"'
.
CFactory::_('Compiler.Builder.Category')->get("{$nameListCode}.extension")
. '" => "' . $otherView . '"';
}
else
{
return PHP_EOL . Indent::_(3) . '"'
.
CFactory::_('Compiler.Builder.Category')->get("{$nameListCode}.extension")
. '" => "' . $otherView . '"';
}
}
return '';
}
/**
* Get Admin Controller Allow Add
*
* @param string $nameSingleCode The view edit or single name
* @param string $nameListCode The view list name
*
* @return string The method code
* @deprecated 3.3 Use
CFactory::_('Architecture.Controller.AllowAdd')->get($nameSingleCode);
*/
public function setJcontrollerAllowAdd($nameSingleCode, $nameListCode)
{
return
CFactory::_('Architecture.Controller.AllowAdd')->get($nameSingleCode);
}
/**
* Get Admin Controller Allow Edit
*
* @param string $nameSingleCode The view edit or single name
* @param string $nameListCode The view list name
*
* @return string The method code
* @deprecated 3.3 Use
CFactory::_('Architecture.Controller.AllowEdit')->get($nameSingleCode,
$nameListCode);
*/
public function setJcontrollerAllowEdit($nameSingleCode, $nameListCode)
{
return
CFactory::_('Architecture.Controller.AllowEdit')->get($nameSingleCode,
$nameListCode);
}
public function setJmodelAdminGetForm($nameSingleCode, $nameListCode)
{
// set component name
$component = CFactory::_('Config')->component_code_name;
// allways load these
$getForm = [];
$getForm[] = PHP_EOL . Indent::_(2) . "//" . Line::_(__Line__,
__Class__)
. " check if xpath was set in options";
$getForm[] = Indent::_(2) . "\$xpath = false;";
$getForm[] = Indent::_(2) . "if
(isset(\$options['xpath']))";
$getForm[] = Indent::_(2) . "{";
$getForm[] = Indent::_(3) . "\$xpath =
\$options['xpath'];";
$getForm[] = Indent::_(3) .
"unset(\$options['xpath']);";
$getForm[] = Indent::_(2) . "}";
$getForm[] = Indent::_(2) . "//" . Line::_(__Line__,
__Class__)
. " check if clear form was set in options";
$getForm[] = Indent::_(2) . "\$clear = false;";
$getForm[] = Indent::_(2) . "if
(isset(\$options['clear']))";
$getForm[] = Indent::_(2) . "{";
$getForm[] = Indent::_(3) . "\$clear =
\$options['clear'];";
$getForm[] = Indent::_(3) .
"unset(\$options['clear']);";
$getForm[] = Indent::_(2) . "}";
$getForm[] = PHP_EOL . Indent::_(2) . "//" . Line::_(__Line__,
__Class__)
. " Get the form.";
$getForm[] = Indent::_(2) . "\$form =
\$this->loadForm('com_"
. $component . "." . $nameSingleCode . "',
'" . $nameSingleCode
. "', \$options, \$clear, \$xpath);";
$getForm[] = PHP_EOL . Indent::_(2) . "if (empty(\$form))";
$getForm[] = Indent::_(2) . "{";
$getForm[] = Indent::_(3) . "return false;";
$getForm[] = Indent::_(2) . "}";
// load license locker
if (CFactory::_('Component')->get('add_license')
&&
CFactory::_('Component')->get('license_type') == 3
&&
CFactory::_('Compiler.Builder.Content.Multi')->exists($nameSingleCode
. '|BOOLMETHOD'))
{
$getForm[] = $this->checkStatmentLicenseLocked(
CFactory::_('Compiler.Builder.Content.Multi')->get($nameSingleCode
. '|BOOLMETHOD', '')
);
}
if (0)
//CFactory::_('Compiler.Builder.Category')->exists("{$nameListCode}"))
<-- remove category from check
{
// check if category has another name
$otherViews =
CFactory::_('Compiler.Builder.Category.Other.Name')->
get($nameListCode . '.views', $nameListCode);
$otherView =
CFactory::_('Compiler.Builder.Category.Other.Name')->
get($nameListCode . '.view', $nameSingleCode);
// setup the category script
$getForm[] = PHP_EOL . Indent::_(2)
. "\$jinput = Factory::getApplication()->input;";
$getForm[] = PHP_EOL . Indent::_(2) . "//" . Line::_(
__LINE__,__CLASS__
)
. " The front end calls this model and uses a_id to avoid id
clashes so we need to check for that first.";
$getForm[] = Indent::_(2) . "if
(\$jinput->get('a_id'))";
$getForm[] = Indent::_(2) . "{";
$getForm[] = Indent::_(3)
. "\$id = \$jinput->get('a_id', 0,
'INT');";
$getForm[] = Indent::_(2) . "}";
$getForm[] = Indent::_(2) . "//" . Line::_(__Line__,
__Class__)
. " The back end uses id so we use that the rest of the time and
set it to 0 by default.";
$getForm[] = Indent::_(2) . "else";
$getForm[] = Indent::_(2) . "{";
$getForm[] = Indent::_(3) . "\$id =
\$jinput->get('id', 0, 'INT');";
$getForm[] = Indent::_(2) . "}";
$getForm[] = Indent::_(2) . "//" . Line::_(__Line__,
__Class__)
. " Determine correct permissions to check.";
$getForm[] = Indent::_(2) . "if (\$this->getState('"
. $nameSingleCode . ".id'))";
$getForm[] = Indent::_(2) . "{";
$getForm[] = Indent::_(3) . "\$id =
\$this->getState('"
. $nameSingleCode . ".id');";
$getForm[] = PHP_EOL . Indent::_(3) . "\$catid = 0;";
$getForm[] = Indent::_(3)
. "if (isset(\$this->getItem(\$id)->catid))";
$getForm[] = Indent::_(3) . "{";
$getForm[] = Indent::_(4) . "//" . Line::_(__Line__,
__Class__)
. " set category id";
$getForm[] = Indent::_(4)
. "\$catid = \$this->getItem(\$id)->catid;";
$getForm[] = PHP_EOL . Indent::_(4) . "//" . Line::_(
__LINE__,__CLASS__
) . " Existing record. Can only edit in selected
categories.";
$getForm[] = Indent::_(4)
. "\$form->setFieldAttribute('catid',
'action', 'core.edit');";
$getForm[] = PHP_EOL . Indent::_(4) . "//" . Line::_(
__LINE__,__CLASS__
)
. " Existing record. Can only edit own items in selected
categories.";
$getForm[] = Indent::_(4)
. "\$form->setFieldAttribute('catid',
'action', 'core.edit.own');";
$getForm[] = Indent::_(3) . "}";
$getForm[] = Indent::_(2) . "}";
$getForm[] = Indent::_(2) . "else";
$getForm[] = Indent::_(2) . "{";
$getForm[] = Indent::_(3) . "//" . Line::_(__Line__,
__Class__)
. " New record. Can only create in selected categories.";
$getForm[] = Indent::_(3)
. "\$form->setFieldAttribute('catid',
'action', 'core.create');";
$getForm[] = Indent::_(2) . "}";
if (CFactory::_('Config')->get('joomla_version',
3) == 3)
{
$getForm[] = PHP_EOL . Indent::_(2)
. "\$user = Factory::getUser();";
}
else
{
$getForm[] = PHP_EOL . Indent::_(2)
. "\$user = Factory::getApplication()->getIdentity();";
}
$getForm[] = PHP_EOL . Indent::_(2) . "//" . Line::_(
__LINE__,__CLASS__
) . " Check for existing item.";
$getForm[] = Indent::_(2) . "//" . Line::_(__Line__,
__Class__)
. " Modify the form based on Edit State access controls.";
// get the other view
$otherView =
CFactory::_('Compiler.Builder.Category.Code')->getString("{$nameSingleCode}.view",
'error');
// check if the item has permissions.
$getForm[] = Indent::_(2)
. "if (\$id != 0 && (!\$user->authorise('"
.
CFactory::_('Compiler.Creator.Permission')->getAction($nameSingleCode,
'core.edit.state')
. "', 'com_" . $component . "."
. $nameSingleCode . ".' . (int) \$id))";
$getForm[] = Indent::_(3)
. "|| (isset(\$catid) && \$catid != 0 &&
!\$user->authorise('core.edit.state', 'com_"
. $component . "." . $otherView
. ".category.' . (int) \$catid))";
$getForm[] = Indent::_(3)
. "|| (\$id == 0 && !\$user->authorise('"
.
CFactory::_('Compiler.Creator.Permission')->getAction($nameSingleCode,
'core.edit.state')
. "', 'com_" . $component . "')))";
$getForm[] = Indent::_(2) . "{";
$getForm[] = Indent::_(3) . "//" . Line::_(__Line__,
__Class__)
. " Disable fields for display.";
$getForm[] = Indent::_(3)
. "\$form->setFieldAttribute('ordering',
'disabled', 'true');";
$getForm[] = Indent::_(3)
. "\$form->setFieldAttribute('published',
'disabled', 'true');";
$getForm[] = PHP_EOL . Indent::_(3) . "//" . Line::_(
__LINE__,__CLASS__
) . " Disable fields while saving.";
$getForm[] = Indent::_(3)
. "\$form->setFieldAttribute('ordering',
'filter', 'unset');";
$getForm[] = Indent::_(3)
. "\$form->setFieldAttribute('published',
'filter', 'unset');";
$getForm[] = Indent::_(2) . "}";
}
else
{
$getForm[] = PHP_EOL . Indent::_(2)
. "\$jinput = Factory::getApplication()->input;";
$getForm[] = PHP_EOL . Indent::_(2) . "//" . Line::_(
__LINE__,__CLASS__
)
. " The front end calls this model and uses a_id to avoid id
clashes so we need to check for that first.";
$getForm[] = Indent::_(2) . "if
(\$jinput->get('a_id'))";
$getForm[] = Indent::_(2) . "{";
$getForm[] = Indent::_(3)
. "\$id = \$jinput->get('a_id', 0,
'INT');";
$getForm[] = Indent::_(2) . "}";
$getForm[] = Indent::_(2) . "//" . Line::_(__Line__,
__Class__)
. " The back end uses id so we use that the rest of the time and
set it to 0 by default.";
$getForm[] = Indent::_(2) . "else";
$getForm[] = Indent::_(2) . "{";
$getForm[] = Indent::_(3) . "\$id =
\$jinput->get('id', 0, 'INT');";
$getForm[] = Indent::_(2) . "}";
if (CFactory::_('Config')->get('joomla_version',
3) == 3)
{
$getForm[] = PHP_EOL . Indent::_(2)
. "\$user = Factory::getUser();";
}
else
{
$getForm[] = PHP_EOL . Indent::_(2)
. "\$user = Factory::getApplication()->getIdentity();";
}
$getForm[] = PHP_EOL . Indent::_(2) . "//" . Line::_(
__LINE__,__CLASS__
) . " Check for existing item.";
$getForm[] = Indent::_(2) . "//" . Line::_(__Line__,
__Class__)
. " Modify the form based on Edit State access controls.";
// check if the item has permissions.
$getForm[] = Indent::_(2)
. "if (\$id != 0 && (!\$user->authorise('"
.
CFactory::_('Compiler.Creator.Permission')->getAction($nameSingleCode,
'core.edit.state') . "', 'com_" . $component
. "."
. $nameSingleCode . ".' . (int) \$id))";
$getForm[] = Indent::_(3)
. "|| (\$id == 0 && !\$user->authorise('"
.
CFactory::_('Compiler.Creator.Permission')->getAction($nameSingleCode,
'core.edit.state') . "', 'com_" . $component
. "')))";
$getForm[] = Indent::_(2) . "{";
$getForm[] = Indent::_(3) . "//" . Line::_(__Line__,
__Class__)
. " Disable fields for display.";
$getForm[] = Indent::_(3)
. "\$form->setFieldAttribute('ordering',
'disabled', 'true');";
$getForm[] = Indent::_(3)
. "\$form->setFieldAttribute('published',
'disabled', 'true');";
$getForm[] = Indent::_(3) . "//" . Line::_(__Line__,
__Class__)
. " Disable fields while saving.";
$getForm[] = Indent::_(3)
. "\$form->setFieldAttribute('ordering',
'filter', 'unset');";
$getForm[] = Indent::_(3)
. "\$form->setFieldAttribute('published',
'filter', 'unset');";
$getForm[] = Indent::_(2) . "}";
}
$getForm[] = Indent::_(2) . "//" . Line::_(__Line__,
__Class__)
. " If this is a new item insure the greated by is set.";
$getForm[] = Indent::_(2) . "if (0 == \$id)";
$getForm[] = Indent::_(2) . "{";
$getForm[] = Indent::_(3) . "//" . Line::_(__Line__,
__Class__)
. " Set the created_by to this user";
$getForm[] = Indent::_(3)
. "\$form->setValue('created_by', null,
\$user->id);";
$getForm[] = Indent::_(2) . "}";
$getForm[] = Indent::_(2) . "//" . Line::_(__Line__,
__Class__)
. " Modify the form based on Edit Creaded By access
controls.";
// check if the item has permissions.
if
(CFactory::_('Compiler.Creator.Permission')->actionExist($nameSingleCode,
'core.edit.created_by'))
{
$getForm[] = Indent::_(2) . "if (\$id != 0 &&
(!\$user->authorise('"
.
CFactory::_('Compiler.Creator.Permission')->getAction($nameSingleCode,
'core.edit.created_by')
. "', 'com_" . $component . "." .
$nameSingleCode . ".' . (int) \$id))";
$getForm[] = Indent::_(3) . "|| (\$id == 0 &&
!\$user->authorise('"
.
CFactory::_('Compiler.Creator.Permission')->getAction($nameSingleCode,
'core.edit.created_by')
. "', 'com_" . $component . "')))";
}
else
{
$getForm[] = Indent::_(2)
. "if (!\$user->authorise('core.edit.created_by',
'com_" . $component . "'))";
}
$getForm[] = Indent::_(2) . "{";
$getForm[] = Indent::_(3) . "//" . Line::_(__Line__,
__Class__)
. " Disable fields for display.";
$getForm[] = Indent::_(3)
. "\$form->setFieldAttribute('created_by',
'disabled', 'true');";
$getForm[] = Indent::_(3) . "//" . Line::_(__Line__,
__Class__)
. " Disable fields for display.";
$getForm[] = Indent::_(3)
. "\$form->setFieldAttribute('created_by',
'readonly', 'true');";
$getForm[] = Indent::_(3) . "//" . Line::_(__Line__,
__Class__)
. " Disable fields while saving.";
$getForm[] = Indent::_(3)
. "\$form->setFieldAttribute('created_by',
'filter', 'unset');";
$getForm[] = Indent::_(2) . "}";
$getForm[] = Indent::_(2) . "//" . Line::_(__Line__,
__Class__)
. " Modify the form based on Edit Creaded Date access
controls.";
// check if the item has permissions.
if
(CFactory::_('Compiler.Creator.Permission')->actionExist($nameSingleCode,
'core.edit.created'))
{
$getForm[] = Indent::_(2) . "if (\$id != 0 &&
(!\$user->authorise('"
.
CFactory::_('Compiler.Creator.Permission')->getAction($nameSingleCode,
'core.edit.created')
. "', 'com_" . $component . "." .
$nameSingleCode . ".' . (int) \$id))";
$getForm[] = Indent::_(3) . "|| (\$id == 0 &&
!\$user->authorise('"
.
CFactory::_('Compiler.Creator.Permission')->getAction($nameSingleCode,
'core.edit.created')
. "', 'com_" . $component . "')))";
}
else
{
$getForm[] = Indent::_(2)
. "if (!\$user->authorise('core.edit.created',
'com_"
. $component . "'))";
}
$getForm[] = Indent::_(2) . "{";
$getForm[] = Indent::_(3) . "//" . Line::_(__Line__,
__Class__)
. " Disable fields for display.";
$getForm[] = Indent::_(3)
. "\$form->setFieldAttribute('created',
'disabled', 'true');";
$getForm[] = Indent::_(3) . "//" . Line::_(__Line__,
__Class__)
. " Disable fields while saving.";
$getForm[] = Indent::_(3)
. "\$form->setFieldAttribute('created',
'filter', 'unset');";
$getForm[] = Indent::_(2) . "}";
// check if the item has access permissions.
if
(CFactory::_('Compiler.Creator.Permission')->actionExist($nameSingleCode,
'core.edit.access'))
{
$getForm[] = Indent::_(2) . "//" . Line::_(__Line__,
__Class__)
. " Modify the form based on Edit Access 'access'
controls.";
$getForm[] = Indent::_(2) . "if (\$id != 0 &&
(!\$user->authorise('"
.
CFactory::_('Compiler.Creator.Permission')->getAction($nameSingleCode,
'core.edit.access')
. "', 'com_" . $component . "." .
$nameSingleCode . ".' . (int) \$id))";
$getForm[] = Indent::_(3) . "|| (\$id == 0 &&
!\$user->authorise('"
.
CFactory::_('Compiler.Creator.Permission')->getAction($nameSingleCode,
'core.edit.access')
. "', 'com_" . $component . "')))";
$getForm[] = Indent::_(2) . "{";
$getForm[] = Indent::_(3) . "//" . Line::_(__Line__,
__Class__)
. " Disable fields for display.";
$getForm[] = Indent::_(3)
. "\$form->setFieldAttribute('access',
'disabled', 'true');";
$getForm[] = Indent::_(3) . "//" . Line::_(__Line__,
__Class__)
. " Disable fields while saving.";
$getForm[] = Indent::_(3)
. "\$form->setFieldAttribute('access',
'filter', 'unset');";
$getForm[] = Indent::_(2) . "}";
}
// handel the fields permissions
if
(CFactory::_('Compiler.Builder.Permission.Fields')->isArray($nameSingleCode))
{
foreach
(CFactory::_('Compiler.Builder.Permission.Fields')->get($nameSingleCode)
as $fieldName => $permission_options)
{
foreach ($permission_options as $permission_option => $fieldType)
{
switch ($permission_option)
{
case 'edit':
$this->setPermissionEditFields(
$getForm, $nameSingleCode, $fieldName,
$fieldType, $component
);
break;
case 'access':
$this->setPermissionAccessFields(
$getForm, $nameSingleCode, $fieldName,
$fieldType, $component
);
break;
case 'view':
$this->setPermissionViewFields(
$getForm, $nameSingleCode, $fieldName,
$fieldType, $component
);
break;
case 'edit.own':
case 'access.own':
// this must still be build (TODO)
break;
}
}
}
}
// add the redirect trick to set the field of origin
$getForm[] = Indent::_(2) . "//" . Line::_(__Line__,
__Class__)
. " Only load these values if no id is found";
$getForm[] = Indent::_(2) . "if (0 == \$id)";
$getForm[] = Indent::_(2) . "{";
$getForm[] = Indent::_(3) . "//" . Line::_(__Line__,
__Class__)
. " Set redirected view name";
$getForm[] = Indent::_(3)
. "\$redirectedView = \$jinput->get('ref', null,
'STRING');";
$getForm[] = Indent::_(3) . "//" . Line::_(__Line__,
__Class__)
. " Set field name (or fall back to view name)";
$getForm[] = Indent::_(3)
. "\$redirectedField = \$jinput->get('field',
\$redirectedView, 'STRING');";
$getForm[] = Indent::_(3) . "//" . Line::_(__Line__,
__Class__)
. " Set redirected view id";
$getForm[] = Indent::_(3)
. "\$redirectedId = \$jinput->get('refid', 0,
'INT');";
$getForm[] = Indent::_(3) . "//" . Line::_(__Line__,
__Class__)
. " Set field id (or fall back to redirected view id)";
$getForm[] = Indent::_(3)
. "\$redirectedValue = \$jinput->get('field_id',
\$redirectedId, 'INT');";
$getForm[] = Indent::_(3)
. "if (0 != \$redirectedValue && \$redirectedField)";
$getForm[] = Indent::_(3) . "{";
$getForm[] = Indent::_(4) . "//" . Line::_(__Line__,
__Class__)
. " Now set the local-redirected field default value";
$getForm[] = Indent::_(4)
. "\$form->setValue(\$redirectedField, null,
\$redirectedValue);";
$getForm[] = Indent::_(3) . "}";
// load custom script if found
$getForm[] = Indent::_(2) . "}" .
CFactory::_('Customcode.Dispenser')->get(
'php_getform', $nameSingleCode, PHP_EOL
);
// setup the default script
$getForm[] = Indent::_(2) . "return \$form;";
return implode(PHP_EOL, $getForm);
}
protected function setPermissionEditFields(&$allow, $nameSingleCode,
$fieldName, $fieldType,
$component
)
{
// only for fields that can be edited
if (!CFactory::_('Field.Groups')->check($fieldType,
'spacer'))
{
$allow[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__)
. " Modify the form based on Edit "
. StringHelper::safe($fieldName, 'W')
. " access controls.";
$allow[] = Indent::_(2) . "if (\$id != 0 &&
(!\$user->authorise('"
. $nameSingleCode . ".edit." . $fieldName . "',
'com_"
. $component . "." . $nameSingleCode . ".' . (int)
\$id))";
$allow[] = Indent::_(3) . "|| (\$id == 0 &&
!\$user->authorise('"
. $nameSingleCode . ".edit." . $fieldName . "',
'com_"
. $component . "')))";
$allow[] = Indent::_(2) . "{";
$allow[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__)
. " Disable fields for display.";
$allow[] = Indent::_(3) .
"\$form->setFieldAttribute('" . $fieldName
. "', 'disabled', 'true');";
$allow[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__)
. " Disable fields for display.";
$allow[] = Indent::_(3) .
"\$form->setFieldAttribute('" . $fieldName
. "', 'readonly', 'true');";
if ('radio' === $fieldType || 'repeatable' ===
$fieldType)
{
$allow[] = Indent::_(3) . "//" . Line::_(__Line__,
__Class__)
. " Disable radio button for display.";
$allow[] = Indent::_(3)
. "\$class = \$form->getFieldAttribute('" .
$fieldName
. "', 'class', '');";
$allow[] = Indent::_(3) .
"\$form->setFieldAttribute('"
. $fieldName . "', 'class', \$class.'
disabled no-click');";
}
$allow[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__)
. " If there is no value continue.";
$allow[] = Indent::_(3) . "if (!\$form->getValue('" .
$fieldName
. "'))";
$allow[] = Indent::_(3) . "{";
$allow[] = Indent::_(4) . "//" . Line::_(__Line__, __Class__)
. " Disable fields while saving.";
$allow[] = Indent::_(4) .
"\$form->setFieldAttribute('" . $fieldName
. "', 'filter', 'unset');";
$allow[] = Indent::_(4) . "//" . Line::_(__Line__, __Class__)
. " Disable fields while saving.";
$allow[] = Indent::_(4) .
"\$form->setFieldAttribute('" . $fieldName
. "', 'required', 'false');";
$allow[] = Indent::_(3) . "}";
$allow[] = Indent::_(2) . "}";
}
}
protected function setPermissionAccessFields(&$allow,
$nameSingleCode,
$fieldName, $fieldType,
$component
)
{
$allow[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__)
. " Modify the from the form based on "
. StringHelper::safe($fieldName, 'W')
. " access controls.";
$allow[] = Indent::_(2) . "if (\$id != 0 &&
(!\$user->authorise('"
. $nameSingleCode . ".access." . $fieldName . "',
'com_"
. $component . "." . $nameSingleCode . ".' . (int)
\$id))";
$allow[] = Indent::_(3) . "|| (\$id == 0 &&
!\$user->authorise('"
. $nameSingleCode . ".access." . $fieldName . "',
'com_"
. $component . "')))";
$allow[] = Indent::_(2) . "{";
$allow[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__)
. " Remove the field";
$allow[] = Indent::_(3) . "\$form->removeField('" .
$fieldName . "');";
$allow[] = Indent::_(2) . "}";
}
protected function setPermissionViewFields(&$allow, $nameSingleCode,
$fieldName, $fieldType,
$component
)
{
if (CFactory::_('Field.Groups')->check($fieldType,
'spacer'))
{
$allow[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__)
. " Modify the form based on View "
. StringHelper::safe($fieldName, 'W')
. " access controls.";
$allow[] = Indent::_(2) . "if (\$id != 0 &&
(!\$user->authorise('"
. $nameSingleCode . ".view." . $fieldName . "',
'com_"
. $component . "." . $nameSingleCode . ".' . (int)
\$id))";
$allow[] = Indent::_(3) . "|| (\$id == 0 &&
!\$user->authorise('"
. $nameSingleCode . ".view." . $fieldName . "',
'com_"
. $component . "')))";
$allow[] = Indent::_(2) . "{";
$allow[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__)
. " Remove the field";
$allow[] = Indent::_(3) . "\$form->removeField('" .
$fieldName
. "');";
$allow[] = Indent::_(2) . "}";
}
else
{
$allow[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__)
. " Modify the form based on View "
. StringHelper::safe($fieldName, 'W')
. " access controls.";
$allow[] = Indent::_(2) . "if (\$id != 0 &&
(!\$user->authorise('"
. $nameSingleCode . ".view." . $fieldName . "',
'com_"
. $component . "." . $nameSingleCode . ".' . (int)
\$id))";
$allow[] = Indent::_(3) . "|| (\$id == 0 &&
!\$user->authorise('"
. $nameSingleCode . ".view." . $fieldName . "',
'com_"
. $component . "')))";
$allow[] = Indent::_(2) . "{";
$allow[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__)
. " Make the field hidded.";
$allow[] = Indent::_(3) .
"\$form->setFieldAttribute('" . $fieldName
. "', 'type', 'hidden');";
$allow[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__)
. " If there is no value continue.";
$allow[] = Indent::_(3) . "if (!(\$val =
\$form->getValue('"
. $fieldName . "')))";
$allow[] = Indent::_(3) . "{";
$allow[] = Indent::_(4) . "//" . Line::_(__Line__, __Class__)
. " Disable fields while saving.";
$allow[] = Indent::_(4) .
"\$form->setFieldAttribute('" . $fieldName
. "', 'filter', 'unset');";
$allow[] = Indent::_(4) . "//" . Line::_(__Line__, __Class__)
. " Disable fields while saving.";
$allow[] = Indent::_(4) .
"\$form->setFieldAttribute('" . $fieldName
. "', 'required', 'false');";
$allow[] = Indent::_(4) . "//" . Line::_(__Line__, __Class__)
. " Make sure";
$allow[] = Indent::_(4) . "\$form->setValue('" .
$fieldName
. "', null, '');";
$allow[] = Indent::_(3) . "}";
$allow[] = Indent::_(3) . "elseif ("
. "Super_" .
"__0a59c65c_9daf_4bc9_baf4_e063ff9e6a8a___Power::check(\$val))";
$allow[] = Indent::_(3) . "{";
$allow[] = Indent::_(4) . "//" . Line::_(__Line__, __Class__)
. " We have to unset then (TODO)";
$allow[] = Indent::_(4) . "//" . Line::_(__Line__, __Class__)
. " Hiddend field can not handel array value";
$allow[] = Indent::_(4) . "//" . Line::_(__Line__, __Class__)
. " Even if we convert to json we get an error";
$allow[] = Indent::_(4) . "\$form->removeField('" .
$fieldName
. "');";
$allow[] = Indent::_(3) . "}";
$allow[] = Indent::_(2) . "}";
}
}
public function setJmodelAdminAllowEdit($nameSingleCode, $nameListCode)
{
$allow = [];
// set component name
$component = CFactory::_('Config')->component_code_name;
// prepare custom permission script
$customAllow = CFactory::_('Customcode.Dispenser')->get(
'php_allowedit', $nameSingleCode, Indent::_(2)
. "\$recordId = (int) isset(\$data[\$key]) ? \$data[\$key] :
0;"
. PHP_EOL
);
// check if the item has permissions.
if
(CFactory::_('Compiler.Creator.Permission')->actionExist($nameSingleCode,
'core.edit'))
{
$allow[] = PHP_EOL . Indent::_(2) . "//" . Line::_(__Line__,
__Class__)
. " Check specific edit permission then general edit
permission.";
if (CFactory::_('Config')->get('joomla_version',
3) == 3)
{
$allow[] = Indent::_(2) . "\$user = Factory::getUser();";
}
else
{
$allow[] = Indent::_(2) . "\$user =
Factory::getApplication()->getIdentity();";
}
// load custom permission script
$allow[] = $customAllow;
$allow[] = Indent::_(2) . "return
\$user->authorise('"
.
CFactory::_('Compiler.Creator.Permission')->getAction($nameSingleCode,
'core.edit')
. "', 'com_" . $component . "." .
$nameSingleCode
. ".'. ((int) isset(\$data[\$key]) ? \$data[\$key] : 0)) or
\$user->authorise('"
.
CFactory::_('Compiler.Creator.Permission')->getAction($nameSingleCode,
'core.edit')
. "', 'com_" . $component . "');";
}
else
{
$allow[] = PHP_EOL . Indent::_(2) . "//" . Line::_(__Line__,
__Class__)
. " Check specific edit permission then general edit
permission.";
if (StringHelper::check($customAllow))
{
if (CFactory::_('Config')->get('joomla_version',
3) == 3)
{
$allow[] = Indent::_(2) . "\$user = Factory::getUser();";
}
else
{
$allow[] = Indent::_(2) . "\$user =
Factory::getApplication()->getIdentity();";
}
}
// load custom permission script
$allow[] = $customAllow;
if (CFactory::_('Config')->get('joomla_version',
3) == 3)
{
$allow[] = Indent::_(2)
. "return Factory::getUser()->authorise('core.edit',
'com_"
. $component . "." . $nameSingleCode
. ".'. ((int) isset(\$data[\$key]) ? \$data[\$key] : 0)) or
parent::allowEdit(\$data, \$key);";
}
else
{
$allow[] = Indent::_(2)
. "return
Factory::getApplication()->getIdentity()->authorise('core.edit',
'com_"
. $component . "." . $nameSingleCode
. ".'. ((int) isset(\$data[\$key]) ? \$data[\$key] : 0)) or
parent::allowEdit(\$data, \$key);";
}
}
return implode(PHP_EOL, $allow);
}
/**
* Get Admin Module Can Delete
*
* @param string $nameSingleCode The view edit or single name
* @param string $nameListCode The view list name
*
* @return string The method code
* @deprecated 3.3 Use
CFactory::_('Architecture.Model.CanDelete')->get($nameSingleCode);
*/
public function setJmodelAdminCanDelete($nameSingleCode, $nameListCode)
{
return
CFactory::_('Architecture.Model.CanDelete')->get($nameSingleCode);
}
/**
* Get Admin Module Can Delete
*
* @param string $nameSingleCode The view edit or single name
* @param string $nameListCode The view list name
*
* @return string The method code
* @deprecated 3.3 Use
CFactory::_('Architecture.Model.CanEditState')->get($nameSingleCode);
*/
public function setJmodelAdminCanEditState($nameSingleCode,
$nameListCode)
{
return
CFactory::_('Architecture.Model.CanEditState')->get($nameSingleCode);
}
public function setJviewListCanDo($nameSingleCode, $nameListCode)
{
$allow = [];
// set component name
$component = CFactory::_('Config')->component_code_name;
// check if the item has permissions for edit.
$allow[] = PHP_EOL . Indent::_(2)
. "\$this->canEdit = \$this->canDo->get('"
.
CFactory::_('Compiler.Creator.Permission')->getGlobal($nameSingleCode,
'core.edit')
. "');";
// check if the item has permissions for edit state.
$allow[] = Indent::_(2) . "\$this->canState =
\$this->canDo->get('"
.
CFactory::_('Compiler.Creator.Permission')->getGlobal($nameSingleCode,
'core.edit.state')
. "');";
// check if the item has permissions for create.
$allow[] = Indent::_(2) . "\$this->canCreate =
\$this->canDo->get('"
.
CFactory::_('Compiler.Creator.Permission')->getGlobal($nameSingleCode,
'core.create') . "');";
// check if the item has permissions for delete.
$allow[] = Indent::_(2) . "\$this->canDelete =
\$this->canDo->get('"
.
CFactory::_('Compiler.Creator.Permission')->getGlobal($nameSingleCode,
'core.delete') . "');";
// check if the item has permissions for batch.
if
(CFactory::_('Compiler.Creator.Permission')->globalExist($nameSingleCode,
'core.batch'))
{
$allow[] = Indent::_(2) . "\$this->canBatch =
(\$this->canDo->get('"
.
CFactory::_('Compiler.Creator.Permission')->getGlobal($nameSingleCode,
'core.batch')
. "') &&
\$this->canDo->get('core.batch'));";
}
else
{
$allow[] = Indent::_(2)
. "\$this->canBatch =
\$this->canDo->get('core.batch');";
}
return implode(PHP_EOL, $allow);
}
public function setFieldSetAccessControl(&$view)
{
$access = '';
if ($view != 'component')
{
// set component name
$component = CFactory::_('Config')->component_code_name;
// set label
$label = 'Permissions in relation to this ' . $view;
// set the access fieldset
$access = "<!--" . Line::_(__Line__, __Class__)
. " Access Control Fields. -->";
$access .= PHP_EOL . Indent::_(1)
. '<fieldset name="accesscontrol">';
$access .= PHP_EOL . Indent::_(2) . "<!--" . Line::_(
__LINE__,__CLASS__
) . " Asset Id Field. Type: Hidden (joomla) -->";
$access .= PHP_EOL . Indent::_(2) . '<field';
$access .= PHP_EOL . Indent::_(3) .
'name="asset_id"';
$access .= PHP_EOL . Indent::_(3) .
'type="hidden"';
$access .= PHP_EOL . Indent::_(3) .
'filter="unset"';
$access .= PHP_EOL . Indent::_(2) . '/>';
$access .= PHP_EOL . Indent::_(2) . "<!--" . Line::_(
__LINE__,__CLASS__
) . " Rules Field. Type: Rules (joomla) -->";
$access .= PHP_EOL . Indent::_(2) . '<field';
$access .= PHP_EOL . Indent::_(3) . 'name="rules"';
$access .= PHP_EOL . Indent::_(3) . 'type="rules"';
$access .= PHP_EOL . Indent::_(3) . 'label="' . $label .
'"';
$access .= PHP_EOL . Indent::_(3) .
'translate_label="false"';
$access .= PHP_EOL . Indent::_(3) .
'filter="rules"';
$access .= PHP_EOL . Indent::_(3) .
'validate="rules"';
$access .= PHP_EOL . Indent::_(3) .
'class="inputbox"';
$access .= PHP_EOL . Indent::_(3) . 'component="com_' .
$component
. '"';
$access .= PHP_EOL . Indent::_(3) . 'section="' . $view .
'"';
$access .= PHP_EOL . Indent::_(2) . '/>';
$access .= PHP_EOL . Indent::_(1) . '</fieldset>';
}
// return access field set
return $access;
}
/**
* set the filter fields
*
* @param string $nameSingleCode The single view name
* @param string $nameListCode The list view name
*
* @return string The code for the filter fields array
*
*/
public function setFilterFieldsArray(&$nameSingleCode,
&$nameListCode)
{
// keep track of all fields already added
$donelist = array('id' => true, 'search'
=> true,
'published' => true, 'access' => true,
'created_by' => true, 'modified_by' => true);
// default filter fields
$fields = "'a.id','id'";
$fields .= "," . PHP_EOL . Indent::_(4) .
"'a.published','published'";
if
(CFactory::_('Compiler.Builder.Access.Switch')->exists($nameSingleCode))
{
$fields .= "," . PHP_EOL . Indent::_(4) .
"'a.access','access'";
}
$fields .= "," . PHP_EOL . Indent::_(4) .
"'a.ordering','ordering'";
$fields .= "," . PHP_EOL . Indent::_(4) .
"'a.created_by','created_by'";
$fields .= "," . PHP_EOL . Indent::_(4)
. "'a.modified_by','modified_by'";
// add the rest of the set filters
if
(CFactory::_('Compiler.Builder.Filter')->exists($nameListCode))
{
foreach
(CFactory::_('Compiler.Builder.Filter')->get($nameListCode) as
$filter)
{
if (!isset($donelist[$filter['code']]))
{
$fields .= $this->getFilterFieldCode(
$filter
);
$donelist[$filter['code']] = true;
}
}
}
// add the rest of the set filters
if
(CFactory::_('Compiler.Builder.Sort')->exists($nameListCode))
{
foreach
(CFactory::_('Compiler.Builder.Sort')->get($nameListCode) as
$filter)
{
if (!isset($donelist[$filter['code']]))
{
$fields .= $this->getFilterFieldCode(
$filter
);
$donelist[$filter['code']] = true;
}
}
}
return $fields;
}
/**
* Add the code of the filter field array
*
* @param array $filter The field/filter array
*
* @return string The code for the filter array
*
*/
protected function getFilterFieldCode(&$filter)
{
// add the category stuff (may still remove these) TODO
if ($filter['type'] === 'category')
{
$field = "," . PHP_EOL . Indent::_(4)
. "'c.title','category_title'";
$field .= "," . PHP_EOL . Indent::_(4)
. "'c.id', 'category_id'";
if ($filter['code'] != 'category')
{
$field .= "," . PHP_EOL . Indent::_(4) .
"'a."
. $filter['code'] . "','" .
$filter['code']
. "'";
}
}
else
{
// check if custom field is set
if (ArrayHelper::check(
$filter['custom']
)
&& isset($filter['custom']['db'])
&& StringHelper::check(
$filter['custom']['db']
)
&& isset($filter['custom']['text'])
&& StringHelper::check(
$filter['custom']['text']
))
{
$field = "," . PHP_EOL . Indent::_(4) . "'"
. $filter['custom']['db'] . "."
. $filter['custom']['text'] .
"','" . $filter['code']
. "'";
}
else
{
$field = "," . PHP_EOL . Indent::_(4) . "'a."
. $filter['code'] . "','" .
$filter['code']
. "'";
}
}
return $field;
}
/**
* set the sotred ids
*
* @param string $nameSingleCode The single view name
* @param string $nameListCode The list view name
*
* @return string The code for the populate state
*
*/
public function setStoredId(&$nameSingleCode, &$nameListCode)
{
// set component name
$Component = ucwords((string)
CFactory::_('Config')->component_code_name);
// keep track of all fields already added
$donelist = array('id' => true, 'search'
=> true,
'published' => true, 'access' => true,
'created_by' => true, 'modified_by' => true);
// set the defaults first
$stored = "//" . Line::_(__Line__, __Class__) . " Compile
the store id.";
$stored .= PHP_EOL . Indent::_(2)
. "\$id .= ':' .
\$this->getState('filter.id');";
$stored .= PHP_EOL . Indent::_(2)
. "\$id .= ':' .
\$this->getState('filter.search');";
// add this if not already added
if
(!CFactory::_('Compiler.Builder.Field.Names')->isString($nameSingleCode
. '.published'))
{
$stored .= PHP_EOL . Indent::_(2)
. "\$id .= ':' .
\$this->getState('filter.published');";
}
// add if view calls for it, and not already added
if
(CFactory::_('Compiler.Builder.Access.Switch')->exists($nameSingleCode)
&&
!CFactory::_('Compiler.Builder.Field.Names')->isString($nameSingleCode
. '.access'))
{
// the side bar option is single
if
(CFactory::_('Compiler.Builder.Admin.Filter.Type')->get($nameListCode,
1) == 1)
{
$stored .= PHP_EOL . Indent::_(2)
. "\$id .= ':' .
\$this->getState('filter.access');";
}
else
{
// top bar selection can result in
// an array due to multi selection
$stored .= $this->getStoredIdCodeMulti('access',
$Component);
}
}
$stored .= PHP_EOL . Indent::_(2)
. "\$id .= ':' .
\$this->getState('filter.ordering');";
// add this if not already added
if
(!CFactory::_('Compiler.Builder.Field.Names')->isString($nameSingleCode
. '.created_by'))
{
$stored .= PHP_EOL . Indent::_(2)
. "\$id .= ':' .
\$this->getState('filter.created_by');";
}
// add this if not already added
if
(!CFactory::_('Compiler.Builder.Field.Names')->isString($nameSingleCode
. '.modified_by'))
{
$stored .= PHP_EOL . Indent::_(2)
. "\$id .= ':' .
\$this->getState('filter.modified_by');";
}
// add the rest of the set filters
if
(CFactory::_('Compiler.Builder.Filter')->exists($nameListCode))
{
foreach
(CFactory::_('Compiler.Builder.Filter')->get($nameListCode) as
$filter)
{
if (!isset($donelist[$filter['code']]))
{
$stored .= $this->getStoredIdCode(
$filter, $nameListCode, $Component
);
$donelist[$filter['code']] = true;
}
}
}
// add the rest of the set filters
if
(CFactory::_('Compiler.Builder.Sort')->exists($nameListCode))
{
foreach
(CFactory::_('Compiler.Builder.Sort')->get($nameListCode) as
$filter)
{
if (!isset($donelist[$filter['code']]))
{
$stored .= $this->getStoredIdCode(
$filter, $nameListCode, $Component
);
$donelist[$filter['code']] = true;
}
}
}
return $stored;
}
/**
* Add the code of the stored ids
*
* @param array $filter The field/filter array
* @param string $nameListCode The list view name
* @param string $Component The Component name
*
* @return string The code for the stored IDs
*
*/
protected function getStoredIdCode(&$filter, &$nameListCode,
&$Component)
{
if ($filter['type'] === 'category')
{
// the side bar option is single (1 = sidebar)
if
(CFactory::_('Compiler.Builder.Admin.Filter.Type')->get($nameListCode,
1) == 1)
{
$stored = PHP_EOL . Indent::_(2)
. "\$id .= ':' .
\$this->getState('filter.category');";
$stored .= PHP_EOL . Indent::_(2)
. "\$id .= ':' .
\$this->getState('filter.category_id');";
if ($filter['code'] != 'category')
{
$stored .= PHP_EOL . Indent::_(2)
. "\$id .= ':' .
\$this->getState('filter."
. $filter['code'] . "');";
}
}
else
{
$stored = $this->getStoredIdCodeMulti('category',
$Component);
$stored .= $this->getStoredIdCodeMulti(
'category_id', $Component
);
if ($filter['code'] != 'category')
{
$stored .= $this->getStoredIdCodeMulti(
$filter['code'], $Component
);
}
}
}
else
{
// check if this is the topbar filter, and multi option (2 = topbar)
if (isset($filter['multi']) &&
$filter['multi'] == 2
&&
CFactory::_('Compiler.Builder.Admin.Filter.Type')->get($nameListCode,
1) == 2)
{
// top bar selection can result in
// an array due to multi selection
$stored = $this->getStoredIdCodeMulti(
$filter['code'], $Component
);
}
else
{
$stored = PHP_EOL . Indent::_(2)
. "\$id .= ':' .
\$this->getState('filter."
. $filter['code'] . "');";
}
}
return $stored;
}
/**
* Add the code of the stored multi ids
*
* @param string $key The key field name
* @param string $Component The Component name
*
* @return string The code for the stored IDs
*
*/
protected function getStoredIdCodeMulti($key, &$Component)
{
// top bar selection can result in
// an array due to multi selection
$stored = PHP_EOL . Indent::_(2)
. "//" . Line::_(__Line__, __Class__)
. " Check if the value is an array";
$stored .= PHP_EOL . Indent::_(2)
. "\$_" . $key . " =
\$this->getState('filter."
. $key . "');";
$stored .= PHP_EOL . Indent::_(2)
. "if (Super_" .
"__0a59c65c_9daf_4bc9_baf4_e063ff9e6a8a___Power::check(\$_"
. $key . "))";
$stored .= PHP_EOL . Indent::_(2)
. "{";
$stored .= PHP_EOL . Indent::_(3)
. "\$id .= ':' . implode(':', \$_" . $key
. ");";
$stored .= PHP_EOL . Indent::_(2)
. "}";
$stored .= PHP_EOL . Indent::_(2)
. "//" . Line::_(__Line__, __Class__)
. " Check if this is only an number or string";
$stored .= PHP_EOL . Indent::_(2)
. "elseif (is_numeric(\$_" . $key . ")";
$stored .= PHP_EOL . Indent::_(2)
. " || Super_" .
"__1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::check(\$_" .
$key . "))";
$stored .= PHP_EOL . Indent::_(2)
. "{";
$stored .= PHP_EOL . Indent::_(3)
. "\$id .= ':' . \$_" . $key . ";";
$stored .= PHP_EOL . Indent::_(2)
. "}";
return $stored;
}
public function setAddToolBar(&$view)
{
// set view name
$nameSingleCode = $view['settings']->name_single_code;
if (CFactory::_('Config')->get('joomla_version',
3) != 3)
{
$langViews = CFactory::_('Config')->lang_prefix .
'_'
. StringHelper::safe(
$view['settings']->name_list_code, 'U'
);
$name_list = strtolower($view['settings']->name_list);
$name_single = strtolower($view['settings']->name_single);
// add empty title
CFactory::_('Language')->set(
CFactory::_('Config')->lang_target,
$langViews . '_EMPTYSTATE_TITLE',
'No ' . $name_list . ' have been created yet.'
);
// add empty content
CFactory::_('Language')->set(
CFactory::_('Config')->lang_target,
$langViews . '_EMPTYSTATE_CONTENT',
$view['settings']->description
);
// add empty button add
CFactory::_('Language')->set(
CFactory::_('Config')->lang_target,
$langViews . '_EMPTYSTATE_BUTTON_ADD',
'Add your first ' . $name_single
);
}
// check type
if ($view['settings']->type == 2)
{
// set lang strings
$viewNameLang_readonly = CFactory::_('Config')->lang_prefix
. '_'
. StringHelper::safe(
$view['settings']->name_single . ' readonly',
'U'
);
// load to lang
CFactory::_('Language')->set(
CFactory::_('Config')->lang_target,
$viewNameLang_readonly,
$view['settings']->name_single . ' :: Readonly'
);
// build toolbar
$toolBar
=
"Factory::getApplication()->input->set('hidemainmenu',
true);";
$toolBar .= PHP_EOL . Indent::_(2) .
"ToolbarHelper::title(Text:"
. ":_('" . $viewNameLang_readonly . "'),
'" . $nameSingleCode
. "');";
$toolBar .= PHP_EOL . Indent::_(2) .
"ToolbarHelper::cancel('"
. $nameSingleCode . ".cancel',
'JTOOLBAR_CLOSE');";
}
else
{
// set lang strings
$viewNameLang_new = CFactory::_('Config')->lang_prefix .
'_'
. StringHelper::safe(
$view['settings']->name_single . ' New',
'U'
);
$viewNameLang_edit = CFactory::_('Config')->lang_prefix .
'_'
. StringHelper::safe(
$view['settings']->name_single . ' Edit',
'U'
);
// load to lang
CFactory::_('Language')->set(
CFactory::_('Config')->lang_target, $viewNameLang_new,
'A New ' . $view['settings']->name_single
);
CFactory::_('Language')->set(
CFactory::_('Config')->lang_target, $viewNameLang_edit,
'Editing the ' . $view['settings']->name_single
);
// build toolbar
$toolBar
=
"Factory::getApplication()->input->set('hidemainmenu',
true);";
if (CFactory::_('Config')->get('joomla_version',
3) == 3)
{
$toolBar .= PHP_EOL . Indent::_(2)
. "\$user = Factory::getUser();";
}
else
{
$toolBar .= PHP_EOL . Indent::_(2)
. "\$user = Factory::getApplication()->getIdentity();";
}
$toolBar .= PHP_EOL . Indent::_(2) . "\$userId =
\$user->id;";
$toolBar .= PHP_EOL . Indent::_(2)
. "\$isNew = \$this->item->id == 0;";
$toolBar .= PHP_EOL . PHP_EOL . Indent::_(2)
. "ToolbarHelper::title( Text:" . ":_(\$isNew ?
'"
. $viewNameLang_new . "' : '" . $viewNameLang_edit
. "'), 'pencil-2 article-add');";
$toolBar .= PHP_EOL . Indent::_(2) . "//" . Line::_(__Line__,
__Class__)
. " Built the actions for new and existing records.";
$toolBar .= PHP_EOL . Indent::_(2) . "if ("
. "Super_" .
"__1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::check(\$this->referral))";
$toolBar .= PHP_EOL . Indent::_(2) . "{";
$toolBar .= PHP_EOL . Indent::_(3) . "if
(\$this->canDo->get('"
.
CFactory::_('Compiler.Creator.Permission')->getGlobal($nameSingleCode,
'core.create') . "') && \$isNew)";
$toolBar .= PHP_EOL . Indent::_(3) . "{";
$toolBar .= PHP_EOL . Indent::_(4) . "//" . Line::_(__Line__,
__Class__)
. " We can create the record.";
$toolBar .= PHP_EOL . Indent::_(4) .
"ToolbarHelper::save('"
. $nameSingleCode . ".save',
'JTOOLBAR_SAVE');";
$toolBar .= PHP_EOL . Indent::_(3) . "}";
$toolBar .= PHP_EOL . Indent::_(3)
. "elseif (\$this->canDo->get('"
.
CFactory::_('Compiler.Creator.Permission')->getGlobal($nameSingleCode,
'core.edit')
. "'))";
$toolBar .= PHP_EOL . Indent::_(3) . "{";
$toolBar .= PHP_EOL . Indent::_(4) . "//" . Line::_(__Line__,
__Class__)
. " We can save the record.";
$toolBar .= PHP_EOL . Indent::_(4) .
"ToolbarHelper::save('"
. $nameSingleCode . ".save',
'JTOOLBAR_SAVE');";
$toolBar .= PHP_EOL . Indent::_(3) . "}";
$toolBar .= PHP_EOL . Indent::_(3) . "if (\$isNew)";
$toolBar .= PHP_EOL . Indent::_(3) . "{";
$toolBar .= PHP_EOL . Indent::_(4) . "//" . Line::_(__Line__,
__Class__)
. " Do not creat but cancel.";
$toolBar .= PHP_EOL . Indent::_(4) .
"ToolbarHelper::cancel('"
. $nameSingleCode . ".cancel',
'JTOOLBAR_CANCEL');";
$toolBar .= PHP_EOL . Indent::_(3) . "}";
$toolBar .= PHP_EOL . Indent::_(3) . "else";
$toolBar .= PHP_EOL . Indent::_(3) . "{";
$toolBar .= PHP_EOL . Indent::_(4) . "//" . Line::_(__Line__,
__Class__)
. " We can close it.";
$toolBar .= PHP_EOL . Indent::_(4) .
"ToolbarHelper::cancel('"
. $nameSingleCode . ".cancel',
'JTOOLBAR_CLOSE');";
$toolBar .= PHP_EOL . Indent::_(3) . "}";
$toolBar .= PHP_EOL . Indent::_(2) . "}";
$toolBar .= PHP_EOL . Indent::_(2) . "else";
$toolBar .= PHP_EOL . Indent::_(2) . "{";
$toolBar .= PHP_EOL . Indent::_(3) . "if (\$isNew)";
$toolBar .= PHP_EOL . Indent::_(3) . "{";
$toolBar .= PHP_EOL . Indent::_(4) . "//" . Line::_(__Line__,
__Class__)
. " For new records, check the create permission.";
$toolBar .= PHP_EOL . Indent::_(4) . "if
(\$this->canDo->get('"
.
CFactory::_('Compiler.Creator.Permission')->getGlobal($nameSingleCode,
'core.create') . "'))";
$toolBar .= PHP_EOL . Indent::_(4) . "{";
$toolBar .= PHP_EOL . Indent::_(5) .
"ToolbarHelper::apply('"
. $nameSingleCode . ".apply',
'JTOOLBAR_APPLY');";
$toolBar .= PHP_EOL . Indent::_(5) .
"ToolbarHelper::save('"
. $nameSingleCode . ".save',
'JTOOLBAR_SAVE');";
$toolBar .= PHP_EOL . Indent::_(5) .
"ToolbarHelper::custom('"
. $nameSingleCode
. ".save2new', 'save-new.png',
'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW',
false);";
$toolBar .= PHP_EOL . Indent::_(4) . "};";
$toolBar .= PHP_EOL . Indent::_(4) .
"ToolbarHelper::cancel('"
. $nameSingleCode . ".cancel',
'JTOOLBAR_CANCEL');";
$toolBar .= PHP_EOL . Indent::_(3) . "}";
$toolBar .= PHP_EOL . Indent::_(3) . "else";
$toolBar .= PHP_EOL . Indent::_(3) . "{";
$toolBar .= PHP_EOL . Indent::_(4) . "if
(\$this->canDo->get('"
.
CFactory::_('Compiler.Creator.Permission')->getGlobal($nameSingleCode,
'core.edit') . "'))";
$toolBar .= PHP_EOL . Indent::_(4) . "{";
$toolBar .= PHP_EOL . Indent::_(5) . "//" . Line::_(__Line__,
__Class__)
. " We can save the new record";
$toolBar .= PHP_EOL . Indent::_(5) .
"ToolbarHelper::apply('"
. $nameSingleCode . ".apply',
'JTOOLBAR_APPLY');";
$toolBar .= PHP_EOL . Indent::_(5) .
"ToolbarHelper::save('"
. $nameSingleCode . ".save',
'JTOOLBAR_SAVE');";
$toolBar .= PHP_EOL . Indent::_(5) . "//" . Line::_(__Line__,
__Class__)
. " We can save this record, but check the create permission to
see";
$toolBar .= PHP_EOL . Indent::_(5) . "//" . Line::_(__Line__,
__Class__)
. " if we can return to make a new one.";
$toolBar .= PHP_EOL . Indent::_(5) . "if
(\$this->canDo->get('"
.
CFactory::_('Compiler.Creator.Permission')->getGlobal($nameSingleCode,
'core.create') . "'))";
$toolBar .= PHP_EOL . Indent::_(5) . "{";
$toolBar .= PHP_EOL . Indent::_(6) .
"ToolbarHelper::custom('"
. $nameSingleCode
. ".save2new', 'save-new.png',
'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW',
false);";
$toolBar .= PHP_EOL . Indent::_(5) . "}";
$toolBar .= PHP_EOL . Indent::_(4) . "}";
if
(CFactory::_('Compiler.Creator.Permission')->globalExist($nameSingleCode,
'core.edit'))
{
if
(CFactory::_('Compiler.Builder.History')->exists($nameSingleCode))
{
$toolBar .= PHP_EOL . Indent::_(4)
. "\$canVersion =
(\$this->canDo->get('core.version') &&
\$this->canDo->get('"
.
CFactory::_('Compiler.Creator.Permission')->getGlobal($nameSingleCode,
'core.version')
. "'));";
$toolBar .= PHP_EOL . Indent::_(4)
. "if
(\$this->state->params->get('save_history', 1)
&& \$this->canDo->get('"
.
CFactory::_('Compiler.Creator.Permission')->getGlobal($nameSingleCode,
'core.edit')
. "') && \$canVersion)";
$toolBar .= PHP_EOL . Indent::_(4) . "{";
$toolBar .= PHP_EOL . Indent::_(5)
. "ToolbarHelper::versions('com_"
. CFactory::_('Config')->component_code_name .
"." . $nameSingleCode
. "', \$this->item->id);";
$toolBar .= PHP_EOL . Indent::_(4) . "}";
}
}
else
{
if
(CFactory::_('Compiler.Builder.History')->exists($nameSingleCode))
{
$toolBar .= PHP_EOL . Indent::_(4)
. "\$canVersion =
(\$this->canDo->get('core.version') &&
\$this->canDo->get('"
.
CFactory::_('Compiler.Creator.Permission')->getGlobal($nameSingleCode,
'core.version') . "'));";
$toolBar .= PHP_EOL . Indent::_(4)
. "if
(\$this->state->params->get('save_history', 1)
&& \$this->canDo->get('core.edit') &&
\$canVersion)";
$toolBar .= PHP_EOL . Indent::_(4) . "{";
$toolBar .= PHP_EOL . Indent::_(5)
. "ToolbarHelper::versions('com_"
. CFactory::_('Config')->component_code_name .
"." . $nameSingleCode
. "', \$this->item->id);";
$toolBar .= PHP_EOL . Indent::_(4) . "}";
}
}
$toolBar .= PHP_EOL . Indent::_(4) . "if
(\$this->canDo->get('"
.
CFactory::_('Compiler.Creator.Permission')->getGlobal($nameSingleCode,
'core.create') . "'))";
$toolBar .= PHP_EOL . Indent::_(4) . "{";
$toolBar .= PHP_EOL . Indent::_(5) .
"ToolbarHelper::custom('"
. $nameSingleCode
. ".save2copy', 'save-copy.png',
'save-copy_f2.png', 'JTOOLBAR_SAVE_AS_COPY',
false);";
$toolBar .= PHP_EOL . Indent::_(4) . "}";
// add custom buttons
$toolBar .= $this->setCustomButtons($view, 2, Indent::_(2));
$toolBar .= PHP_EOL . Indent::_(4) .
"ToolbarHelper::cancel('"
. $nameSingleCode . ".cancel',
'JTOOLBAR_CLOSE');";
$toolBar .= PHP_EOL . Indent::_(3) . "}";
$toolBar .= PHP_EOL . Indent::_(2) . "}";
$toolBar .= PHP_EOL . Indent::_(2) .
"ToolbarHelper::divider();";
if (CFactory::_('Config')->get('joomla_version',
3) != 3)
{
$toolBar .= PHP_EOL . Indent::_(2) .
"ToolbarHelper::inlinehelp();";
}
$toolBar .= PHP_EOL . Indent::_(2) . "//" . Line::_(__Line__,
__Class__)
. " set help url for this view if found";
$toolBar .= PHP_EOL . Indent::_(2) . "\$this->help_url = "
.
CFactory::_('Compiler.Builder.Content.One')->get('Component')
. "Helper::getHelpUrl('" . $nameSingleCode
. "');";
$toolBar .= PHP_EOL . Indent::_(2) . "if ("
. "Super_" .
"__1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::check(\$this->help_url))";
$toolBar .= PHP_EOL . Indent::_(2) . "{";
$toolBar .= PHP_EOL . Indent::_(3) .
"ToolbarHelper::help('"
. CFactory::_('Config')->lang_prefix .
"_HELP_MANAGER', false, \$this->help_url);";
$toolBar .= PHP_EOL . Indent::_(2) . "}";
}
return $toolBar;
}
/**
* set the populate state code
*
* @param string $nameSingleCode The single view name
* @param string $nameListCode The list view name
*
* @return string The code for the populate state
*
*/
public function setPopulateState(&$nameSingleCode,
&$nameListCode)
{
// reset bucket
$state = '';
// keep track of all fields already added
$donelist = [];
// we must add the formSubmited code if new above filters is used (2 =
topbar)
$new_filter = false;
if
(CFactory::_('Compiler.Builder.Admin.Filter.Type')->get($nameListCode,
1) == 2)
{
$state .= PHP_EOL . PHP_EOL . Indent::_(2) . "//"
. Line::_(__Line__, __Class__) . " Check if the form was
submitted";
$state .= PHP_EOL . Indent::_(2) . "\$formSubmited"
. " =
\$app->input->post->get('form_submited');";
$new_filter = true;
}
// add the default populate states (this must be added first)
$state .= $this->setDefaultPopulateState($nameSingleCode,
$new_filter);
// add the filters
if
(CFactory::_('Compiler.Builder.Filter')->exists($nameListCode))
{
foreach
(CFactory::_('Compiler.Builder.Filter')->get($nameListCode) as
$filter)
{
if (!isset($donelist[$filter['code']]))
{
$state .= $this->getPopulateStateFilterCode(
$filter, $new_filter
);
$donelist[$filter['code']] = true;
}
}
}
// add the rest of the set filters
if
(CFactory::_('Compiler.Builder.Sort')->exists($nameListCode))
{
foreach
(CFactory::_('Compiler.Builder.Sort')->get($nameListCode) as
$filter)
{
if (!isset($donelist[$filter['code']]))
{
$state .= $this->getPopulateStateFilterCode(
$filter, $new_filter
);
$donelist[$filter['code']] = true;
}
}
}
return $state;
}
/**
* Add the code of the filter in the populate state
*
* @param array $filter The field/filter array
* @param bool $newFilter The switch to use the new filter
* @param string $extra The defaults/extra options of the filter
*
* @return string The code for the populate state
*
*/
protected function getPopulateStateFilterCode(&$filter, $newFilter,
$extra = ''
)
{
$state = '';
// add category stuff (may still remove these) TODO
if (isset($filter['type']) && $filter['type']
=== 'category')
{
$state .= PHP_EOL . PHP_EOL . Indent::_(2)
. "\$category =
\$app->getUserStateFromRequest(\$this->context .
'.filter.category', 'filter_category');";
$state .= PHP_EOL . Indent::_(2)
. "\$this->setState('filter.category',
\$category);";
$state .= PHP_EOL . PHP_EOL . Indent::_(2)
. "\$categoryId =
\$this->getUserStateFromRequest(\$this->context .
'.filter.category_id', 'filter_category_id');";
$state .= PHP_EOL . Indent::_(2)
. "\$this->setState('filter.category_id',
\$categoryId);";
}
// always add the default filter
$state .= PHP_EOL . PHP_EOL . Indent::_(2) . "\$" .
$filter['code']
. " = \$this->getUserStateFromRequest(\$this->context .
'.filter."
. $filter['code'] . "', 'filter_" .
$filter['code']
. "'" . $extra . ");";
if ($newFilter)
{
// add the new filter option
$state .= PHP_EOL . Indent::_(2)
. "if (\$formSubmited)";
$state .= PHP_EOL . Indent::_(2) . "{";
$state .= PHP_EOL . Indent::_(3) . "\$" .
$filter['code']
. " = \$app->input->post->get('" .
$filter['code'] . "');";
$state .= PHP_EOL . Indent::_(3)
. "\$this->setState('filter." .
$filter['code']
. "', \$" . $filter['code'] . ");";
$state .= PHP_EOL . Indent::_(2) . "}";
}
else
{
// the old filter option
$state .= PHP_EOL . Indent::_(2)
. "\$this->setState('filter." .
$filter['code']
. "', \$" . $filter['code'] . ");";
}
return $state;
}
/**
* set the default populate state code
*
* @param string $nameSingleCode The single view name
* @param bool $newFilter The switch to use the new filter
*
* @return string The state code added
*
*/
protected function setDefaultPopulateState(&$nameSingleCode,
$newFilter)
{
$state = '';
// start filter
$filter = array('type' => 'text');
// if access is not set add its default filter here
if
(!CFactory::_('Compiler.Builder.Field.Names')->isString($nameSingleCode
. '.access'))
{
$filter['code'] = "access";
$state .= $this->getPopulateStateFilterCode(
$filter, $newFilter, ", 0, 'int'"
);
}
// if published is not set add its default filter here
if
(!CFactory::_('Compiler.Builder.Field.Names')->isString($nameSingleCode
. '.published'))
{
$filter['code'] = "published";
$state .= $this->getPopulateStateFilterCode(
$filter, false, ", ''"
);
}
// if created_by is not set add its default filter here
if
(!CFactory::_('Compiler.Builder.Field.Names')->isString($nameSingleCode
. '.created_by'))
{
$filter['code'] = "created_by";
$state .= $this->getPopulateStateFilterCode(
$filter, false, ", ''"
);
}
// if created is not set add its default filter here
if
(!CFactory::_('Compiler.Builder.Field.Names')->isString($nameSingleCode
. '.created'))
{
$filter['code'] = "created";
$state .= $this->getPopulateStateFilterCode(
$filter, false
);
}
// the sorting defaults are always added
$filter['code'] = "sorting";
$state .= $this->getPopulateStateFilterCode(
$filter, false, ", 0, 'int'"
);
// the search defaults are always added
$filter['code'] = "search";
$state .= $this->getPopulateStateFilterCode($filter, false);
return $state;
}
/**
* set the sorted field array for the getSortFields method
*
* @param string $nameSingleCode The single view name
*
* @return string The array/string of fields to add to the getSortFields
method
*
*/
public function setSortFields(&$nameListCode)
{
// keep track of all fields already added
$donelist = array('ordering', 'published');
// set the default first
$fields = "return array(";
$fields .= PHP_EOL . Indent::_(3) . "'a.ordering' =>
Text:"
. ":_('JGRID_HEADING_ORDERING')";
$fields .= "," . PHP_EOL . Indent::_(3) .
"'a.published' => Text:"
. ":_('JSTATUS')";
// add the rest of the set filters
if
(CFactory::_('Compiler.Builder.Sort')->exists($nameListCode))
{
foreach
(CFactory::_('Compiler.Builder.Sort')->get($nameListCode) as
$filter)
{
if (!in_array($filter['code'], $donelist))
{
if ($filter['type'] === 'category')
{
$fields .= "," . PHP_EOL . Indent::_(3)
. "'category_title' => Text:" .
":_('"
. $filter['lang'] . "')";
}
elseif (ArrayHelper::check(
$filter['custom']
))
{
$fields .= "," . PHP_EOL . Indent::_(3) .
"'"
. $filter['custom']['db'] . "."
. $filter['custom']['text'] . "' =>
Text:" . ":_('"
. $filter['lang'] . "')";
}
else
{
$fields .= "," . PHP_EOL . Indent::_(3) .
"'a."
. $filter['code'] . "' => Text:" .
":_('"
. $filter['lang'] . "')";
}
}
}
}
$fields .= "," . PHP_EOL . Indent::_(3) .
"'a.id' => Text:"
. ":_('JGRID_HEADING_ID')";
$fields .= PHP_EOL . Indent::_(2) . ");";
// return fields
return $fields;
}
public function setCheckinCall()
{
$call = PHP_EOL . Indent::_(2) . "//" . Line::_(__Line__,
__Class__)
. " Check in items";
$call .= PHP_EOL . Indent::_(2) . "\$this->checkInNow();" .
PHP_EOL;
return $call;
}
public function setAutoCheckin($view, $component)
{
$checkin = PHP_EOL . PHP_EOL . Indent::_(1) . "/**";
$checkin .= PHP_EOL . Indent::_(1)
. " * Build an SQL query to checkin all items left checked out
longer then a set time.";
$checkin .= PHP_EOL . Indent::_(1) . " *";
$checkin .= PHP_EOL . Indent::_(1) . " * @return bool";
$checkin .= PHP_EOL . Indent::_(1) . " * @since 3.2.0";
$checkin .= PHP_EOL . Indent::_(1) . " */";
$checkin .= PHP_EOL . Indent::_(1) . "protected function
checkInNow(): bool";
$checkin .= PHP_EOL . Indent::_(1) . "{";
$checkin .= PHP_EOL . Indent::_(2) . "//" . Line::_(__Line__,
__Class__)
. " Get set check in time";
$checkin .= PHP_EOL . Indent::_(2)
. "\$time = ComponentHelper::getParams('com_" .
$component
. "')->get('check_in');";
$checkin .= PHP_EOL . PHP_EOL . Indent::_(2) . "if (\$time)";
$checkin .= PHP_EOL . Indent::_(2) . "{";
$checkin .= PHP_EOL . Indent::_(3) . "//" . Line::_(
__LINE__,__CLASS__
) . " Get a db connection.";
if (CFactory::_('Config')->get('joomla_version',
3) == 3)
{
$checkin .= PHP_EOL . Indent::_(3) . "\$db =
Factory::getDbo();";
}
else
{
$checkin .= PHP_EOL . Indent::_(3) . "\$db =
\$this->getDatabase();";
}
$checkin .= PHP_EOL . Indent::_(3) . "//" . Line::_(__Line__,
__Class__)
. " Reset query.";
$checkin .= PHP_EOL . Indent::_(3) . "\$query =
\$db->getQuery(true);";
$checkin .= PHP_EOL . Indent::_(3) .
"\$query->select('*');";
$checkin .= PHP_EOL . Indent::_(3)
. "\$query->from(\$db->quoteName('#__" . $component
. "_" . $view
. "'));";
$checkin .= PHP_EOL . Indent::_(3) . "//" . Line::_(__Line__,
__Class__)
. " Only select items that are checked out.";
$checkin .= PHP_EOL . Indent::_(3)
. "\$query->where(\$db->quoteName('checked_out') .
'!=0');";
Indent::_(3) . "//" . Line::_(__Line__, __Class__)
. " Query only to see if we have a rows";
$checkin .= PHP_EOL . Indent::_(3) . "\$db->setQuery(\$query, 0,
1);";
$checkin .= PHP_EOL . Indent::_(3) . "\$db->execute();";
$checkin .= PHP_EOL . Indent::_(3) . "if
(\$db->getNumRows())";
$checkin .= PHP_EOL . Indent::_(3) . "{";
$checkin .= PHP_EOL . Indent::_(4) . "//" . Line::_(__Line__,
__Class__)
. " Get Yesterdays date.";
$checkin .= PHP_EOL . Indent::_(4)
. "\$date =
Factory::getDate()->modify(\$time)->toSql();";
$checkin .= PHP_EOL . Indent::_(4) . "//" . Line::_(__Line__,
__Class__)
. " Reset query.";
$checkin .= PHP_EOL . Indent::_(4) . "\$query =
\$db->getQuery(true);";
$checkin .= PHP_EOL . PHP_EOL . Indent::_(4) . "//" . Line::_(
__LINE__,__CLASS__
) . " Fields to update.";
$checkin .= PHP_EOL . Indent::_(4) . "\$fields = array(";
$checkin .= PHP_EOL . Indent::_(5)
. "\$db->quoteName('checked_out_time') .
'=\'0000-00-00 00:00:00\'',";
$checkin .= PHP_EOL . Indent::_(5)
. "\$db->quoteName('checked_out') .
'=0'";
$checkin .= PHP_EOL . Indent::_(4) . ");";
$checkin .= PHP_EOL . PHP_EOL . Indent::_(4) . "//" . Line::_(
__LINE__,__CLASS__
) . " Conditions for which records should be updated.";
$checkin .= PHP_EOL . Indent::_(4) . "\$conditions = array(";
$checkin .= PHP_EOL . Indent::_(5)
. "\$db->quoteName('checked_out') . '!=0',
";
$checkin .= PHP_EOL . Indent::_(5)
. "\$db->quoteName('checked_out_time') .
'<\''.\$date.'\''";
$checkin .= PHP_EOL . Indent::_(4) . ");";
$checkin .= PHP_EOL . PHP_EOL . Indent::_(4) . "//" . Line::_(
__LINE__,__CLASS__
) . " Check table.";
$checkin .= PHP_EOL . Indent::_(4)
. "\$query->update(\$db->quoteName('#__" .
$component . "_" . $view
. "'))->set(\$fields)->where(\$conditions); ";
$checkin .= PHP_EOL . PHP_EOL . Indent::_(4)
. "\$db->setQuery(\$query);";
$checkin .= PHP_EOL . PHP_EOL . Indent::_(4) . "return
\$db->execute();";
$checkin .= PHP_EOL . Indent::_(3) . "}";
$checkin .= PHP_EOL . Indent::_(2) . "}";
$checkin .= PHP_EOL . PHP_EOL . Indent::_(2) . "return
false;";
$checkin .= PHP_EOL . Indent::_(1) . "}";
return $checkin;
}
public function setGetItemsMethodStringFix($nameSingleCode,
$nameListCode,
$Component, $tab = '', $export = false, $all = false)
{
// add the fix if this view has the need for it
$fix = '';
$forEachStart = '';
$fix_access = '';
// encryption switches
foreach (CFactory::_('Config')->cryption_types as
$cryptionType)
{
${$cryptionType . 'Crypt'} = false;
}
$component = StringHelper::safe($Component);
// check if the item has permissions.
if
(CFactory::_('Compiler.Creator.Permission')->actionExist($nameSingleCode,
'core.access'))
{
$fix_access = PHP_EOL . Indent::_(1) . $tab . Indent::_(3) .
"//"
. Line::_(__Line__, __Class__)
. " Remove items the user can't access.";
$fix_access .= PHP_EOL . Indent::_(1) . $tab . Indent::_(3)
. "\$access = (\$user->authorise('"
.
CFactory::_('Compiler.Creator.Permission')->getAction($nameSingleCode,
'core.access')
. "', 'com_" . $component . "." .
$nameSingleCode
. ".' . (int) \$item->id) &&
\$user->authorise('"
.
CFactory::_('Compiler.Creator.Permission')->getAction($nameSingleCode,
'core.access')
. "', 'com_" . $component . "'));";
$fix_access .= PHP_EOL . Indent::_(1) . $tab . Indent::_(3)
. "if (!\$access)";
$fix_access .= PHP_EOL . Indent::_(1) . $tab . Indent::_(3) .
"{";
$fix_access .= PHP_EOL . Indent::_(1) . $tab . Indent::_(4)
. "unset(\$items[\$nr]);";
$fix_access .= PHP_EOL . Indent::_(1) . $tab . Indent::_(4)
. "continue;";
$fix_access .= PHP_EOL . Indent::_(1) . $tab . Indent::_(3) .
"}"
. PHP_EOL;
}
// add the tags if needed
if
(CFactory::_('Compiler.Builder.Tags')->exists($nameSingleCode))
{
$fix_access .= PHP_EOL . Indent::_(1) . $tab . Indent::_(3) .
"//"
. Line::_(
__LINE__,__CLASS__
) . " Add the tags";
$fix_access .= PHP_EOL . Indent::_(1) . $tab . Indent::_(3)
. "\$item->tags = new TagsHelper;";
$fix_access .= PHP_EOL . Indent::_(1) . $tab . Indent::_(3)
. "\$item->tags->getTagIds(";
$fix_access .= PHP_EOL . Indent::_(1) . $tab . Indent::_(4)
. "\$item->id, 'com_"
.
CFactory::_('Compiler.Builder.Content.One')->get('component')
. ".$nameSingleCode'";
$fix_access .= PHP_EOL . Indent::_(1) . $tab . Indent::_(3) .
");";
$fix_access .= PHP_EOL . Indent::_(1) . $tab . Indent::_(3)
. "if (\$item->tags->tags)";
$fix_access .= PHP_EOL . Indent::_(1) . $tab . Indent::_(3) .
"{";
$fix_access .= PHP_EOL . Indent::_(1) . $tab . Indent::_(4)
. "\$item->tags = implode(', ',";
$fix_access .= PHP_EOL . Indent::_(1) . $tab . Indent::_(5)
. "\$item->tags->getTagNames(";
$fix_access .= PHP_EOL . Indent::_(1) . $tab . Indent::_(6)
. "explode(',', \$item->tags->tags)";
$fix_access .= PHP_EOL . Indent::_(1) . $tab . Indent::_(5) .
")";
$fix_access .= PHP_EOL . Indent::_(1) . $tab . Indent::_(4) .
");";
$fix_access .= PHP_EOL . Indent::_(1) . $tab . Indent::_(3) .
"}";
$fix_access .= PHP_EOL . Indent::_(1) . $tab . Indent::_(3)
. "else";
$fix_access .= PHP_EOL . Indent::_(1) . $tab . Indent::_(3) .
"{";
$fix_access .= PHP_EOL . Indent::_(1) . $tab . Indent::_(4)
. "\$item->tags = '';";
$fix_access .= PHP_EOL . Indent::_(1) . $tab . Indent::_(3) .
"}";
}
// get the correct array
if ($export || $all)
{
$action_ = 'Eximport';
}
else
{
$action_ = 'List';
}
// load the relations before modeling
if (($field_relations =
CFactory::_('Compiler.Builder.Field.Relations')->get($nameListCode))
!== null)
{
foreach ($field_relations as $field_id => $fields)
{
foreach ($fields as $area => $field)
{
if ($area == 1 && isset($field['code']))
{
$fix .= $this->setModelFieldRelation(
$field, $nameListCode, $tab
);
}
}
}
}
// open the values
if
(CFactory::_("Compiler.Builder.Items.Method.{$action_}.String")->exists($nameSingleCode))
{
foreach
(CFactory::_("Compiler.Builder.Items.Method.{$action_}.String")->
get($nameSingleCode) as $item)
{
switch ($item['method'])
{
case 1:
// JSON_STRING_ENCODE
$decode = 'json_decode';
$suffix_decode = ', true';
break;
case 2:
// BASE_SIXTY_FOUR
$decode = 'base64_decode';
$suffix_decode = '';
break;
case 3:
// BASIC_ENCRYPTION_LOCALKEY
$decode = '$basic->decryptString';
$basicCrypt = true;
$suffix_decode = '';
break;
case 4:
// WHMCS_ENCRYPTION_WHMCS
$decode = '$whmcs->decryptString';
$whmcsCrypt = true;
$suffix_decode = '';
break;
case 5:
// MEDIUM_ENCRYPTION_LOCALFILE
$decode = '$medium->decryptString';
$mediumCrypt = true;
$suffix_decode = '';
break;
case 6:
// EXPERT_ENCRYPTION
$expertCrypt = true;
break;
default:
// JSON_ARRAY_ENCODE
$decode = 'json_decode';
$suffix_decode = ', true';
// fallback on json
$item['method'] = 1;
break;
}
if (($item['type'] === 'usergroup' ||
$item['type'] === 'usergrouplist') && !$export
&& $item['method'] != 6)
{
$fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(3) . "//"
. Line::_(__Line__, __Class__) . " decode " .
$item['name'];
$fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(3) . "\$"
. $item['name'] . "Array = " . $decode .
"(\$item->"
. $item['name'] . $suffix_decode . ");";
$fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(3)
. "if (Super_" .
"__0a59c65c_9daf_4bc9_baf4_e063ff9e6a8a___Power::check(\$"
. $item['name'] . "Array))";
$fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(3) . "{";
$fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(4) . "\$"
. $item['name'] . "Names = [];";
$fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(4)
. "foreach (\$" . $item['name'] . "Array as
\$"
. $item['name'] . ")";
$fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(4) . "{";
$fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(5) . "\$"
. $item['name'] . "Names[] = " . $Component
. "Helper::getGroupName(\$" . $item['name'] .
");";
$fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(4) . "}";
$fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(4)
. "\$item->" . $item['name'] . " =
implode(', ', \$"
. $item['name'] . "Names);";
$fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(3) . "}";
}
/* elseif (($item['type'] === 'usergroup' ||
$item['type'] === 'usergrouplist') && $export)
{
$fix .= PHP_EOL.Indent::_(1).$tab.Indent::_(3) .
"//".Line::_(__Line__, __Class__)." decode
".$item['name'];
$fix .= PHP_EOL.Indent::_(1).$tab.Indent::_(3) .
"\$".$item['name']."Array =
".$decode."(\$item->".$item['name'].$suffix_decode.");";
$fix .= PHP_EOL.Indent::_(1).$tab.Indent::_(3) . "if
(Super_" .
"__0a59c65c_9daf_4bc9_baf4_e063ff9e6a8a___Power::check(\$".$item['name']."Array))";
$fix .= PHP_EOL.Indent::_(1).$tab.Indent::_(3) . "{";
$fix .= PHP_EOL.Indent::_(1).$tab.Indent::_(4) .
"\$item->".$item['name']." =
implode('|',\$".$item['name']."Array);";
$fix .= PHP_EOL.Indent::_(1).$tab.Indent::_(3) . "}";
} */
elseif ($item['translation'] && !$export
&& $item['method'] != 6)
{
$fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(3) . "//"
. Line::_(__Line__, __Class__) . " decode " .
$item['name'];
$fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(3) . "\$"
. $item['name'] . "Array = " . $decode .
"(\$item->"
. $item['name'] . $suffix_decode . ");";
$fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(3)
. "if (Super_" .
"__0a59c65c_9daf_4bc9_baf4_e063ff9e6a8a___Power::check(\$"
. $item['name'] . "Array))";
$fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(3) . "{";
$fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(4) . "\$"
. $item['name'] . "Names = [];";
$fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(4)
. "foreach (\$" . $item['name'] . "Array as
\$"
. $item['name'] . ")";
$fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(4) . "{";
$fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(5) . "\$"
. $item['name'] . "Names[] = Text:"
. ":_(\$this->selectionTranslation(\$" .
$item['name']
. ", '" . $item['name'] .
"'));";
$fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(4) . "}";
$fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(4)
. "\$item->" . $item['name'] . " =
implode(', ', \$"
. $item['name'] . "Names);";
$fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(3) . "}";
}
else
{
if ($item['method'] == 2 || $item['method'] == 3
|| $item['method'] == 4
|| $item['method'] == 5 || $item['method'] == 6)
{
// expert mode (dev must do it all)
if ($item['method'] == 6)
{
$_placeholder_for_field
= array('[[[field]]]' => "\$item->" .
$item['name']);
$fix .= CFactory::_('Placeholder')->update(
PHP_EOL . Indent::_(1) . $tab . Indent::_(3)
. implode(PHP_EOL . Indent::_(1) . $tab . Indent::_(3),
CFactory::_('Compiler.Builder.Model.Expert.Field')->get(
$nameSingleCode . '.' . $item['name'] .
'.get', []
)
), $_placeholder_for_field
);
}
else
{
$taber = '';
if ($item['method'] == 3)
{
$taber = Indent::_(1);
$fix .= PHP_EOL . Indent::_(1) . $tab
. Indent::_(3)
. "if (\$basickey && !is_numeric(\$item->"
. $item['name'] . ") && \$item->"
. $item['name']
. " === base64_encode(base64_decode(\$item->"
. $item['name'] . ", true)))";
$fix .= PHP_EOL . Indent::_(1) . $tab
. Indent::_(3) . "{";
}
elseif ($item['method'] == 5)
{
$taber = Indent::_(1);
$fix .= PHP_EOL . Indent::_(1) . $tab
. Indent::_(3)
. "if (\$mediumkey && !is_numeric(\$item->"
. $item['name'] . ") && \$item->"
. $item['name']
. " === base64_encode(base64_decode(\$item->"
. $item['name'] . ", true)))";
$fix .= PHP_EOL . Indent::_(1) . $tab
. Indent::_(3) . "{";
}
elseif ($item['method'] == 4)
{
$taber = Indent::_(1);
$fix .= PHP_EOL . Indent::_(1) . $tab
. Indent::_(3)
. "if (\$whmcskey && !is_numeric(\$item->"
. $item['name'] . ") && \$item->"
. $item['name']
. " === base64_encode(base64_decode(\$item->"
. $item['name'] . ", true)))";
$fix .= PHP_EOL . Indent::_(1) . $tab
. Indent::_(3) . "{";
}
if ($item['method'] == 3 || $item['method'] ==
4
|| $item['method'] == 5)
{
$fix .= PHP_EOL . Indent::_(1) . $tab
. Indent::_(4) . "//" . Line::_(
__LINE__,__CLASS__
) . " decrypt " . $item['name'];
}
else
{
$fix .= PHP_EOL . Indent::_(1) . $tab . $taber
. Indent::_(3) . "//" . Line::_(
__LINE__,__CLASS__
) . " decode " . $item['name'];
}
$fix .= PHP_EOL . Indent::_(1) . $tab . $taber
. Indent::_(3) . "\$item->" . $item['name']
. " = " . $decode . "(\$item->" .
$item['name']
. ");";
if ($item['method'] == 3 || $item['method'] ==
4
|| $item['method'] == 5)
{
$fix .= PHP_EOL . Indent::_(1) . $tab
. Indent::_(3) . "}";
}
}
}
else
{
if ($export && $item['type'] ===
'repeatable')
{
$fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(3)
. "//" . Line::_(__Line__, __Class__)
. " decode repeatable " . $item['name'];
$fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(3)
. "\$" . $item['name'] . "Array = " .
$decode
. "(\$item->" . $item['name'] .
$suffix_decode
. ");";
$fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(3)
. "if (Super_" .
"__0a59c65c_9daf_4bc9_baf4_e063ff9e6a8a___Power::check(\$"
. $item['name'] . "Array))";
$fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(3)
. "{";
$fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(4)
. "\$bucket" . $item['name'] . " =
[];";
$fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(4)
. "foreach (\$" . $item['name'] . "Array
as \$"
. $item['name'] . "FieldName => \$"
. $item['name'] . ")";
$fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(4)
. "{";
$fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(5)
. "if (Super_" .
"__0a59c65c_9daf_4bc9_baf4_e063ff9e6a8a___Power::check(\$"
. $item['name'] . "))";
$fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(5)
. "{";
$fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(6)
. "\$bucket" . $item['name'] . "[] =
\$"
. $item['name']
. "FieldName . '<||VDM||>' .
implode('<|VDM|>',\$"
. $item['name'] . ");";
$fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(5)
. "}";
$fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(4)
. "}";
$fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(4)
. "//" . Line::_(__Line__, __Class__)
. " make sure the bucket has values.";
$fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(4)
. "if (Super_" .
"__0a59c65c_9daf_4bc9_baf4_e063ff9e6a8a___Power::check(\$bucket"
. $item['name'] . "))";
$fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(4)
. "{";
$fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(5)
. "//" . Line::_(__Line__, __Class__)
. " clear the repeatable field.";
$fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(5)
. "unset(\$item->" . $item['name'] .
");";
$fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(5)
. "//" . Line::_(__Line__, __Class__)
. " set repeatable field for export.";
$fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(5)
. "\$item->" . $item['name']
. " = implode('<|||VDM|||>',\$bucket"
. $item['name'] . ");";
$fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(5)
. "//" . Line::_(__Line__, __Class__)
. " unset the bucket.";
$fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(5)
. "unset(\$bucket" . $item['name'] .
");";
$fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(4)
. "}";
$fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(3)
. "}";
}
elseif ($item['method'] == 1 && !$export)
{
// TODO we check if this works well.
$fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(3)
. "//" . Line::_(__Line__, __Class__) . " convert
"
. $item['name'];
if (isset($item['custom']['table']))
{
// check if this is a local table
if (strpos(
(string) $item['custom']['table'],
'#__' .
CFactory::_('Config')->component_code_name . '_'
) !== false)
{
$keyTableNAme = str_replace(
'#__' .
CFactory::_('Config')->component_code_name . '_',
'', (string)
$item['custom']['table']
);
}
else
{
$keyTableNAme = $item['custom']['table'];
}
$fix .= PHP_EOL . Indent::_(1) . $tab
. Indent::_(3) . "\$item->" .
$item['name']
. " = Super_" .
"__4b225c51_d293_48e4_b3f6_5136cf5c3f18___Power::string(\$item->"
. $item['name'] . ", ', ', '"
. $keyTableNAme . "', '"
. $item['custom']['id'] . "',
'"
. $item['custom']['text'] .
"');";
}
else
{
$fix .= PHP_EOL . Indent::_(1) . $tab
. Indent::_(3) . "\$item->" .
$item['name']
. " = Super_" .
"__4b225c51_d293_48e4_b3f6_5136cf5c3f18___Power::string(\$item->"
. $item['name'] . ", ', ', '"
. $item['name'] . "');";
}
}
else
{
if (!$export)
{
// For those we have not cached yet.
$fix .= PHP_EOL . Indent::_(1) . $tab
. Indent::_(3) . "//" . Line::_(
__LINE__,__CLASS__
) . " convert " . $item['name'];
$fix .= PHP_EOL . Indent::_(1) . $tab
. Indent::_(3) . "\$item->" .
$item['name']
. " = Super_" .
"__4b225c51_d293_48e4_b3f6_5136cf5c3f18___Power::string(\$item->"
. $item['name'] . ");";
}
}
}
}
}
}
/* // set translation (TODO) would be nice to cut down on double loops..
if (!$export &&
CFactory::_('Compiler.Builder.Selection.Translation')->exists($nameListCode))
{
foreach
(CFactory::_('Compiler.Builder.Selection.Translation')->get($nameListCode)
as $name => $values)
{
$fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(3) . "//" .
Line::_(__Line__, __Class__) . " convert " . $name;
$fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(3) .
"\$item->" . $name . " =
\$this->selectionTranslation(\$item->" . $name . ",
'" . $name . "');";
}
} */
// load the relations after modeling
if (($field_relations =
CFactory::_('Compiler.Builder.Field.Relations')->get($nameListCode))
!== null)
{
foreach ($field_relations as $fields)
{
foreach ($fields as $area => $field)
{
if ($area == 3 && isset($field['code']))
{
$fix .= $this->setModelFieldRelation(
$field, $nameListCode, $tab
);
}
}
}
}
// close the foreach if needed
if (StringHelper::check($fix) || StringHelper::check($fix_access) ||
$export || $all)
{
// start the loop
$forEachStart = PHP_EOL . PHP_EOL . Indent::_(1) . $tab . Indent::_(
1
) . "//" . Line::_(__Line__, __Class__)
. " Set values to display correctly.";
$forEachStart .= PHP_EOL . Indent::_(1) . $tab . Indent::_(1)
. "if (Super_" .
"__0a59c65c_9daf_4bc9_baf4_e063ff9e6a8a___Power::check(\$items))";
$forEachStart .= PHP_EOL . Indent::_(1) . $tab . Indent::_(1) .
"{";
// do not add to export since it is already done
if (!$export)
{
$forEachStart .= PHP_EOL . Indent::_(1) . $tab . Indent::_(2)
. "//" . Line::_(__Line__, __Class__)
. " Get the user object if not set.";
$forEachStart .= PHP_EOL . Indent::_(1) . $tab . Indent::_(2)
. "if (!isset(\$user) || !"
. "Super_" .
"__91004529_94a9_4590_b842_e7c6b624ecf5___Power::check(\$user))";
$forEachStart .= PHP_EOL . Indent::_(1) . $tab . Indent::_(2)
. "{";
if (CFactory::_('Config')->get('joomla_version',
3) == 3)
{
$forEachStart .= PHP_EOL . Indent::_(1) . $tab . Indent::_(3)
. "\$user = Factory::getUser();";
}
else
{
$forEachStart .= PHP_EOL . Indent::_(1) . $tab . Indent::_(3)
. "\$user = \$this->getCurrentUser();";
}
$forEachStart .= PHP_EOL . Indent::_(1) . $tab . Indent::_(2)
. "}";
}
// the permissional acttion switch
$hasPermissional = false;
// add the permissional removal of values the user has not right to view
or access
if
(CFactory::_('Config')->get('permission_strict_per_field',
false)
&&
CFactory::_('Compiler.Builder.Permission.Fields')->isArray($nameSingleCode))
{
foreach
(CFactory::_('Compiler.Builder.Permission.Fields')->get($nameSingleCode)
as $fieldName => $permission_options)
{
if (!$hasPermissional)
{
foreach ($permission_options as $permission_option => $fieldType)
{
if (!$hasPermissional)
{
switch ($permission_option)
{
case 'access':
case 'view':
$hasPermissional = true;
break;
}
}
}
}
}
// add the notes and get the global switch
if ($hasPermissional)
{
$forEachStart .= PHP_EOL . Indent::_(1) . $tab . Indent::_(
2
) . "//" . Line::_(__Line__, __Class__)
. " Get global permissional control activation. (default is
inactive)";
$forEachStart .= PHP_EOL . Indent::_(1) . $tab . Indent::_(
2
)
. "\$strict_permission_per_field =
ComponentHelper::getParams('com_"
. $component
. "')->get('strict_permission_per_field',
0);"
. PHP_EOL;
}
}
$forEachStart .= PHP_EOL . Indent::_(1) . $tab . Indent::_(2)
. "foreach (\$items as \$nr => &\$item)";
$forEachStart .= PHP_EOL . Indent::_(1) . $tab . Indent::_(2) .
"{";
// add the access options
$forEachStart .= $fix_access;
// add the permissional removal of values the user has not right to view
or access
if ($hasPermissional)
{
$forEachStart .= PHP_EOL . Indent::_(1) . $tab . Indent::_(3)
. "//" . Line::_(__Line__, __Class__)
. " use permissional control if globally set.";
$forEachStart .= PHP_EOL . Indent::_(1) . $tab . Indent::_(3)
. "if (\$strict_permission_per_field)";
$forEachStart .= PHP_EOL . Indent::_(1) . $tab . Indent::_(3)
. "{";
foreach
(CFactory::_('Compiler.Builder.Permission.Fields')->get($nameSingleCode)
as $fieldName => $permission_options)
{
foreach ($permission_options as $permission_option => $fieldType)
{
switch ($permission_option)
{
case 'access':
case 'view':
$forEachStart .= PHP_EOL . Indent::_(1) . $tab
. Indent::_(4) . "//" . Line::_(
__LINE__,__CLASS__
) . " set " . $permission_option
. " permissional control for " . $fieldName
. " value.";
$forEachStart .= PHP_EOL . Indent::_(1) . $tab
. Indent::_(4) . "if (isset(\$item->"
. $fieldName . ") &&
(!\$user->authorise('"
. $nameSingleCode . "."
. $permission_option . "." . $fieldName
. "', 'com_" . $component . "."
. $nameSingleCode
. ".' . (int) \$item->id)";
$forEachStart .= PHP_EOL . Indent::_(1) . $tab
. Indent::_(5) . "|| !\$user->authorise('"
. $nameSingleCode . "."
. $permission_option . "." . $fieldName
. "', 'com_" . $component .
"')))";
$forEachStart .= PHP_EOL . Indent::_(1) . $tab
. Indent::_(4) . "{";
$forEachStart .= PHP_EOL . Indent::_(1) . $tab
. Indent::_(5) . "//" . Line::_(
__LINE__,__CLASS__
)
. " We JUST empty the value (do you have a better
idea)";
$forEachStart .= PHP_EOL . Indent::_(1) . $tab
. Indent::_(5) . "\$item->" . $fieldName
. " = '';";
$forEachStart .= PHP_EOL . Indent::_(1) . $tab
. Indent::_(4) . "}";
break;
}
}
}
$forEachStart .= PHP_EOL . Indent::_(1) . $tab . Indent::_(3)
. "}";
}
// remove these values if export
if ($export)
{
$fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(3) . "//"
. Line::_(__Line__, __Class__)
. " unset the values we don't want exported.";
$fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(3)
. "unset(\$item->asset_id);";
$fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(3)
. "unset(\$item->checked_out);";
$fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(3)
. "unset(\$item->checked_out_time);";
}
$fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(2) . "}";
$fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(1) . "}";
if ($export)
{
$fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(1) . "//"
. Line::_(__Line__, __Class__) . " Add headers to items
array.";
$fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(1)
. "\$headers = \$this->getExImPortHeaders();";
$fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(1) . "if
("
. "Super_" .
"__91004529_94a9_4590_b842_e7c6b624ecf5___Power::check(\$headers))";
$fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(1) . "{";
$fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(2)
. "array_unshift(\$items,\$headers);";
$fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(1) . "}";
}
}
// add custom php to getitems method
$fix .= CFactory::_('Customcode.Dispenser')->get(
'php_getitems', $nameSingleCode, PHP_EOL . PHP_EOL . $tab
);
// load the encryption object if needed
$script = '';
foreach (CFactory::_('Config')->cryption_types as
$cryptionType)
{
if (${$cryptionType . 'Crypt'})
{
if ('expert' !== $cryptionType)
{
$script .= PHP_EOL . PHP_EOL . Indent::_(1) . $tab
. Indent::_(1) . "//" . Line::_(__Line__, __Class__)
. " Get the " . $cryptionType . " encryption
key.";
$script .= PHP_EOL . Indent::_(1) . $tab . Indent::_(1)
. "\$" . $cryptionType . "key = " . $Component
. "Helper::getCryptKey('" . $cryptionType .
"');";
$script .= PHP_EOL . Indent::_(1) . $tab . Indent::_(1)
. "//" . Line::_(__Line__, __Class__)
. " Get the encryption object.";
$script .= PHP_EOL . Indent::_(1) . $tab . Indent::_(1)
. "\$" . $cryptionType . " = new Super_" .
"__99175f6d_dba8_4086_8a65_5c4ec175e61d___Power(\$"
. $cryptionType . "key);";
}
elseif (CFactory::_('Compiler.Builder.Model.' .
ucfirst($cryptionType). '.Field.Initiator')->
exists("{$nameSingleCode}.get"))
{
foreach (CFactory::_('Compiler.Builder.Model.' .
ucfirst($cryptionType). '.Field.Initiator')->
get("{$nameSingleCode}.get") as $block)
{
$script .= PHP_EOL . Indent::_(1) . $tab . Indent::_(1) . implode(
PHP_EOL . Indent::_(1) . $tab . Indent::_(1), $block
);
}
}
}
}
// add the encryption script
return $script . $forEachStart . $fix;
}
/**
* Build headers for the various files
*
* @param string $context The name of the context
* @param string $codeName The view, views, or layout code name
* @param string $default The default to return if none is found
*
* @return string The php to place in the header
* @deprecated 3.3 Use CFactory::_('Header')->get($context,
$codeName, $default);
*/
public function setFileHeader($context, $codeName, $default =
'')
{
return CFactory::_('Header')->get($context, $codeName,
$default);
}
/**
* set Helper Dynamic Headers
*
* @param array $headers The headers array
* @param string $target_client
*
* @return void
* @deprecated 3.3
*/
protected function setHelperClassHeader(&$headers, $target_client)
{
// set notice that we could not get a valid string from the target
$this->app->enqueueMessage(
Text::sprintf('COM_COMPONENTBUILDER_HR_HTHREES_WARNINGHTHREE',
__CLASS__), 'Error'
);
$this->app->enqueueMessage(
Text::sprintf(
'Use of a deprecated method (%s)!', __METHOD__
), 'Error'
);
}
/**
* Build chosen multi selection headers for the view
*
* @param array $headers The headers array
* @param string $nameListCode The list view name
*
* @return void
* @deprecated 3.3
*/
protected function setChosenMultiSelectionHeaders(&$headers,
$nameListCode)
{
// set notice that we could not get a valid string from the target
$this->app->enqueueMessage(
Text::sprintf('COM_COMPONENTBUILDER_HR_HTHREES_WARNINGHTHREE',
__CLASS__), 'Error'
);
$this->app->enqueueMessage(
Text::sprintf(
'Use of a deprecated method (%s)!', __METHOD__
), 'Error'
);
}
protected function setModelFieldRelation($item, $nameListCode, $tab)
{
$fix = '';
// set fields
$field = [];
// set list field name
$field['$item->{' . (int) $item['listfield'] .
'}'] = '$item->'
. $item['code'];
// load joint field names
if (isset($item['joinfields'])
&& ArrayHelper::check(
$item['joinfields']
))
{
foreach ($item['joinfields'] as $join)
{
$field['$item->{' . (int) $join . '}'] =
'$item->'
.
CFactory::_('Compiler.Builder.List.Join')->get($nameListCode .
'.' . (int) $join . '.code', 'error');
}
}
// set based on join_type
if ($item['join_type'] == 2)
{
// code
$code = (array) explode(
PHP_EOL, str_replace(
array_keys($field), array_values($field), (string)
$item['set']
)
);
$fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(3) . implode(
PHP_EOL . Indent::_(1) . $tab . Indent::_(3), $code
);
}
else
{
// concatenate
$fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(3) . "//"
. Line::_(__Line__, __Class__) . " concatenate these
fields";
$fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(3) .
"\$item->"
. $item['code'] . ' = ' . implode(
" . '" . str_replace("'",
''', (string) $item['set']) . "' .
",
$field
) . ';';
}
return CFactory::_('Placeholder')->update_($fix);
}
public function setSelectionTranslationFix($views, $Component, $tab =
'')
{
// add the fix if this view has the need for it
$fix = '';
if
(CFactory::_('Compiler.Builder.Selection.Translation')->exists($views))
{
$fix .= PHP_EOL . PHP_EOL . Indent::_(1) . $tab . Indent::_(1)
. "//" . Line::_(__Line__, __Class__)
. " set selection value to a translatable value";
$fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(1) . "if ("
. "Super_" .
"__0a59c65c_9daf_4bc9_baf4_e063ff9e6a8a___Power::check(\$items))";
$fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(1) . "{";
$fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(2)
. "foreach (\$items as \$nr => &\$item)";
$fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(2) . "{";
foreach
(CFactory::_('Compiler.Builder.Selection.Translation')->
get($views) as $name => $values)
{
$fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(3) . "//"
. Line::_(__Line__, __Class__) . " convert " . $name;
$fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(3)
. "\$item->" . $name
. " = \$this->selectionTranslation(\$item->" . $name .
", '"
. $name . "');";
}
$fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(2) . "}";
$fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(1) . "}"
. PHP_EOL;
}
return $fix;
}
public function setSelectionTranslationFixFunc($views, $Component)
{
// add the fix if this view has the need for it
$fix = '';
if
(CFactory::_('Compiler.Builder.Selection.Translation')->exists($views))
{
$fix .= PHP_EOL . PHP_EOL . Indent::_(1) . "/**";
$fix .= PHP_EOL . Indent::_(1)
. " * Method to convert selection values to translatable
string.";
$fix .= PHP_EOL . Indent::_(1) . " *";
$fix .= PHP_EOL . Indent::_(1) . " * @return string The
translatable string.";
$fix .= PHP_EOL . Indent::_(1) . " */";
$fix .= PHP_EOL . Indent::_(1)
. "public function selectionTranslation(\$value,\$name)";
$fix .= PHP_EOL . Indent::_(1) . "{";
foreach
(CFactory::_('Compiler.Builder.Selection.Translation')->
get($views) as $name => $values)
{
if (ArrayHelper::check($values))
{
$fix .= PHP_EOL . Indent::_(2) . "//" . Line::_(
__LINE__,__CLASS__
) . " Array of " . $name . " language strings";
$fix .= PHP_EOL . Indent::_(2) . "if (\$name ===
'"
. $name . "')";
$fix .= PHP_EOL . Indent::_(2) . "{";
$fix .= PHP_EOL . Indent::_(3) . "\$" . $name
. "Array = array(";
$counter = 0;
foreach ($values as $value => $translang)
{
// only add quotes to strings
if (StringHelper::check($value))
{
$key = "'" . $value . "'";
}
else
{
if ($value == '')
{
$value = 0;
}
$key = $value;
}
if ($counter == 0)
{
$fix .= PHP_EOL . Indent::_(4) . $key . " => '"
. $translang . "'";
}
else
{
$fix .= "," . PHP_EOL . Indent::_(4) . $key
. " => '" . $translang . "'";
}
$counter++;
}
$fix .= PHP_EOL . Indent::_(3) . ");";
$fix .= PHP_EOL . Indent::_(3) . "//" . Line::_(
__LINE__,__CLASS__
) . " Now check if value is found in this array";
$fix .= PHP_EOL . Indent::_(3) . "if (isset(\$" . $name
. "Array[\$value]) && "
. "Super_" .
"__1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::check(\$" .
$name . "Array[\$value]))";
$fix .= PHP_EOL . Indent::_(3) . "{";
$fix .= PHP_EOL . Indent::_(4) . "return \$" . $name
. "Array[\$value];";
$fix .= PHP_EOL . Indent::_(3) . "}";
$fix .= PHP_EOL . Indent::_(2) . "}";
}
}
$fix .= PHP_EOL . Indent::_(2) . "return \$value;";
$fix .= PHP_EOL . Indent::_(1) . "}";
}
return $fix;
}
public function setRouterCase($viewsCodeName)
{
if (strlen((string) $viewsCodeName) > 0)
{
$router = PHP_EOL . Indent::_(2) . "case '" .
$viewsCodeName . "':";
$router .= PHP_EOL . Indent::_(3)
. "\$id = explode(':', \$segments[\$count-1]);";
$router .= PHP_EOL . Indent::_(3) . "\$vars['id'] = (int)
\$id[0];";
$router .= PHP_EOL . Indent::_(3) . "\$vars['view'] =
'"
. $viewsCodeName
. "';";
$router .= PHP_EOL . Indent::_(2) . "break;";
return $router;
}
return '';
}
public function setComponentImageType($path)
{
$type = \ComponentbuilderHelper::imageInfo($path);
if ($type)
{
$imagePath = CFactory::_('Utilities.Paths')->component_path
. '/admin/assets/images';
// move the image to its place
File::copy(
JPATH_SITE . '/' . $path,
$imagePath . '/vdm-component.' . $type
);
// now set the type to global for re-use
$this->componentImageType = $type;
// return image type
return $type;
}
$this->componentImageType = 'jpg';
return 'jpg';
}
public function setDashboardIconAccess()
{
return
CFactory::_('Compiler.Builder.Permission.Dashboard')->build();
}
public function setDashboardIcons()
{
if
(CFactory::_('Component')->isArray('admin_views'))
{
$icons = '';
$counter = 0;
$catArray = [];
foreach
(CFactory::_('Component')->get('admin_views') as
$view)
{
$name_single = StringHelper::safe(
$view['settings']->name_single
);
$name_list = StringHelper::safe(
$view['settings']->name_list
);
$icons .= $this->addCustomDashboardIcons($view, $counter);
if (isset($view['dashboard_add'])
&& $view['dashboard_add'] == 1)
{
$type = \ComponentbuilderHelper::imageInfo(
$view['settings']->icon_add
);
if ($type)
{
$type = $type . ".";
// icon builder loader
$this->iconBuilder[$type . $name_single . ".add"]
= $view['settings']->icon_add;
}
else
{
$type = 'png.';
}
if ($counter == 0)
{
$icons .= "'" . $type . $name_single .
".add'";
}
else
{
$icons .= ", '" . $type . $name_single .
".add'";
}
// build lang
$langName = 'Add '
. StringHelper::safe(
$view['settings']->name_single, 'W'
) . '<br /><br />';
$langKey = CFactory::_('Config')->lang_prefix .
'_DASHBOARD_'
. StringHelper::safe(
$view['settings']->name_single, 'U'
) . '_ADD';
// add to lang
CFactory::_('Language')->set(CFactory::_('Config')->lang_target,
$langKey, $langName);
$counter++;
}
if (isset($view['dashboard_list'])
&& $view['dashboard_list'] == 1)
{
$type = \ComponentbuilderHelper::imageInfo(
$view['settings']->icon
);
if ($type)
{
$type = $type . ".";
// icon builder loader
$this->iconBuilder[$type . $name_list]
= $view['settings']->icon;
}
else
{
$type = 'png.';
}
if ($counter == 0)
{
$icons .= "'" . $type . $name_list .
"'";
}
else
{
$icons .= ", '" . $type . $name_list .
"'";
}
// build lang
$langName = StringHelper::safe(
$view['settings']->name_list, 'W'
) . '<br /><br />';
$langKey = CFactory::_('Config')->lang_prefix .
'_DASHBOARD_'
. StringHelper::safe(
$view['settings']->name_list, 'U'
);
// add to lang
CFactory::_('Language')->set(CFactory::_('Config')->lang_target,
$langKey, $langName);
$counter++;
}
// dashboard link to category on dashboard is build here
if
(CFactory::_('Compiler.Builder.Category')->exists("{$name_list}.code")
&&
CFactory::_('Compiler.Builder.Category')->get("{$name_list}.add_icon"))
{
$catCode =
CFactory::_('Compiler.Builder.Category')->get("{$name_list}.code");
// check if category has another name
$otherViews =
CFactory::_('Compiler.Builder.Category.Other.Name')->
get($name_list . '.views', $name_list);
$otherNames =
CFactory::_('Compiler.Builder.Category.Other.Name')->
get($name_list . '.name');
if ($otherNames !== null)
{
// build lang
$langName = StringHelper::safe(
$otherNames, 'W'
);
}
else
{
// build lang
$langName = 'Categories For<br />'
. StringHelper::safe(
$otherViews, 'W'
);
}
// only load this category once
if (!in_array($otherViews, $catArray))
{
// set the extension key string, new convention (more stable)
$_key_extension = str_replace(
'.', '_po0O0oq_',
(string)
CFactory::_('Compiler.Builder.Category')->get("{$name_list}.extension",
'error')
);
// add to lang
$langKey = CFactory::_('Config')->lang_prefix .
'_DASHBOARD_'
. StringHelper::safe(
$otherViews, 'U'
) . '_' . StringHelper::safe(
$catCode, 'U'
);
CFactory::_('Language')->set(CFactory::_('Config')->lang_target,
$langKey, $langName);
// get image type
$type = \ComponentbuilderHelper::imageInfo(
$view['settings']->icon_category
);
if ($type)
{
$type = $type . ".";
// icon builder loader
$this->iconBuilder[$type . $otherViews . "."
. $catCode]
= $view['settings']->icon_category;
}
else
{
$type = 'png.';
}
if ($counter == 0)
{
$icons .= "'" . $type . $otherViews . "." .
$catCode
. '_qpo0O0oqp_' . $_key_extension . "'";
}
else
{
$icons .= ", '" . $type . $otherViews .
"."
. $catCode . '_qpo0O0oqp_' . $_key_extension
. "'";
}
$counter++;
// make sure we add a category only once
$catArray[] = $otherViews;
}
}
}
if (isset($this->lastCustomDashboardIcon)
&& ArrayHelper::check(
$this->lastCustomDashboardIcon
))
{
foreach ($this->lastCustomDashboardIcon as $icon)
{
$icons .= $icon;
}
unset($this->lastCustomDashboardIcon);
}
if (isset($this->iconBuilder)
&& ArrayHelper::check(
$this->iconBuilder
))
{
$imagePath =
CFactory::_('Utilities.Paths')->component_path
. '/admin/assets/images/icons';
foreach ($this->iconBuilder as $icon => $path)
{
$array_buket = explode('.', (string) $icon);
if (count((array) $array_buket) == 3)
{
list($type, $name, $action) = $array_buket;
}
else
{
list($type, $name) = $array_buket;
$action = false;
}
// set the new image name
if ($action)
{
$imageName = $name . '_' . $action . '.' .
$type;
}
else
{
$imageName = $name . '.' . $type;
}
// move the image to its place
File::copy(
JPATH_SITE . '/' . $path, $imagePath . '/' .
$imageName
);
}
}
return $icons;
}
return false;
}
public function setDashboardModelMethods()
{
if
(CFactory::_('Component')->isString('php_dashboard_methods'))
{
// get hte value
$php_dashboard_methods =
CFactory::_('Component')->get('php_dashboard_methods');
// get all the mothods that should load date to the view
$this->DashboardGetCustomData
= GetHelper::allBetween(
$php_dashboard_methods,
'public function get', '()'
);
// return the methods
return PHP_EOL . PHP_EOL .
CFactory::_('Placeholder')->update_(
$php_dashboard_methods
);
}
return '';
}
public function setDashboardGetCustomData()
{
if (isset($this->DashboardGetCustomData)
&& ArrayHelper::check(
$this->DashboardGetCustomData
))
{
// gets array reset
$gets = [];
// set dashboard gets
foreach ($this->DashboardGetCustomData as $get)
{
$string = StringHelper::safe($get);
$gets[] = "\$this->" . $string . " =
\$this->get('" . $get
. "');";
}
// return the gets
return PHP_EOL . Indent::_(2) . implode(
PHP_EOL . Indent::_(2), $gets
);
}
return '';
}
public function setDashboardDisplayData()
{
if (CFactory::_('Config')->get('joomla_version',
3) == 3)
{
return $this->setDashboardDisplayDataJ3();
}
return $this->setDashboardDisplayDataJ4();
}
public function setDashboardDisplayDataJ3()
{
// display array reset
$display = [];
$mainAccordianName = 'cPanel';
$builder = [];
$tab = Indent::_(3);
$loadTabs = false;
$width_class = 'span';
$row_class = 'row-fluid';
$form_class = 'form-horizontal';
$uitab = 'bootstrap';
// check if we have custom tabs
if
(CFactory::_('Component')->isArray('dashboard_tab'))
{
// build the tabs and accordians
foreach
(CFactory::_('Component')->get('dashboard_tab') as
$data)
{
$builder[$data['name']][$data['header']]
= CFactory::_('Placeholder')->update_(
$data['html']
);
}
// since we have custom tabs we must load the tab structure around the
cpanel
$display[] = '<div id="j-main-container">';
$display[] = Indent::_(1) . '<div class="' .
$form_class . '">';
$display[] = Indent::_(1)
. "<?php echo Html::_('{$uitab}.startTabSet',
'cpanel_tab', array('active' =>
'cpanel')); ?>";
$display[] = PHP_EOL . Indent::_(2)
. "<?php echo Html::_('{$uitab}.addTab',
'cpanel_tab', 'cpanel', Text:"
. ":_('cPanel', true)); ?>";
$display[] = Indent::_(2) . '<div class="' .
$row_class . '">';
// change the name of the main tab
$mainAccordianName = 'Control Panel';
$loadTabs = true;
}
else
{
$display[] = '<div id="j-main-container">';
$display[] = Indent::_(1) . '<div class="' .
$form_class . '" style="padding: 20px;">';
$display[] = Indent::_(2) . '<div class="' .
$row_class . '">';
}
// set dashboard display
$display[] = $tab . '<div class="' . $width_class .
'9">';
$display[] = $tab . Indent::_(1)
. "<?php echo Html::_('bootstrap.startAccordion',
'dashboard_left', array('active' =>
'main')); ?>";
$display[] = $tab . Indent::_(2)
. "<?php echo Html::_('bootstrap.addSlide',
'dashboard_left', '"
. $mainAccordianName . "', 'main'); ?>";
$display[] = $tab . Indent::_(3)
. "<?php echo
\$this->loadTemplate('main');?>";
$display[] = $tab . Indent::_(2)
. "<?php echo Html::_('bootstrap.endSlide');
?>";
$display[] = $tab . Indent::_(1)
. "<?php echo Html::_('bootstrap.endAccordion');
?>";
$display[] = $tab . "</div>";
$display[] = $tab . '<div class="' . $width_class .
'3">';
$display[] = $tab . Indent::_(1)
. "<?php echo Html::_('bootstrap.startAccordion',
'dashboard_right', array('active' =>
'vdm')); ?>";
$display[] = $tab . Indent::_(2)
. "<?php echo Html::_('bootstrap.addSlide',
'dashboard_right', '"
.
CFactory::_('Compiler.Builder.Content.One')->get('COMPANYNAME')
. "', 'vdm'); ?>";
$display[] = $tab . Indent::_(3)
. "<?php echo
\$this->loadTemplate('vdm');?>";
$display[] = $tab . Indent::_(2)
. "<?php echo Html::_('bootstrap.endSlide');
?>";
$display[] = $tab . Indent::_(1)
. "<?php echo Html::_('bootstrap.endAccordion');
?>";
$display[] = $tab . "</div>";
if ($loadTabs)
{
$display[] = Indent::_(2) . "</div>";
$display[] = Indent::_(2)
. "<?php echo Html::_('{$uitab}.endTab');
?>";
// load the new tabs
foreach ($builder as $tabname => $accordians)
{
$alias = StringHelper::safe($tabname);
$display[] = PHP_EOL . Indent::_(2)
. "<?php echo Html::_('{$uitab}.addTab',
'cpanel_tab', '"
. $alias . "', Text:" . ":_('" .
$tabname
. "', true)); ?>";
$display[] = Indent::_(2) . '<div class="' .
$row_class . '">';
$display[] = $tab . '<div class="' . $width_class
. '12">';
$display[] = $tab . Indent::_(1)
. "<?php echo Html::_('bootstrap.startAccordion',
'"
. $alias . "_accordian', array('active' =>
'" . $alias
. "_one')); ?>";
$slidecounter = 1;
foreach ($accordians as $accordianname => $html)
{
$ac_alias = StringHelper::safe(
$accordianname
);
$counterName = StringHelper::safe(
$slidecounter
);
$tempName = $alias . '_' . $ac_alias;
$display[] = $tab . Indent::_(2)
. "<?php echo Html::_('bootstrap.addSlide',
'"
. $alias . "_accordian', '" . $accordianname .
"', '"
. $alias . "_" . $counterName . "');
?>";
$display[] = $tab . Indent::_(3)
. "<?php echo \$this->loadTemplate('" .
$tempName
. "');?>";
$display[] = $tab . Indent::_(2)
. "<?php echo Html::_('bootstrap.endSlide');
?>";
$slidecounter++;
// build the template file
$target = array('custom_admin' =>
CFactory::_('Config')->component_code_name);
CFactory::_('Utilities.Structure')->build($target,
'template', $tempName);
// set the file data
$TARGET = StringHelper::safe(
CFactory::_('Config')->build_target, 'U'
);
// SITE_TEMPLATE_BODY <<<DYNAMIC>>>
CFactory::_('Compiler.Builder.Content.Multi')->set(CFactory::_('Config')->component_code_name
. '_' . $tempName . '|CUSTOM_ADMIN_TEMPLATE_BODY',
PHP_EOL . $html);
// SITE_TEMPLATE_CODE_BODY <<<DYNAMIC>>>
CFactory::_('Compiler.Builder.Content.Multi')->set(CFactory::_('Config')->component_code_name
. '_' . $tempName . '|CUSTOM_ADMIN_TEMPLATE_CODE_BODY',
'');
}
$display[] = $tab . Indent::_(1)
. "<?php echo Html::_('bootstrap.endAccordion');
?>";
$display[] = $tab . "</div>";
$display[] = Indent::_(2) . "</div>";
$display[] = Indent::_(2)
. "<?php echo Html::_('{$uitab}.endTab');
?>";
}
$display[] = PHP_EOL . Indent::_(1)
. "<?php echo Html::_('{$uitab}.endTabSet');
?>";
}
else
{
$display[] = Indent::_(2) . "</div>";
}
$display[] = Indent::_(1) . "</div>";
$display[] = "</div>";
// return the display
return PHP_EOL . implode(PHP_EOL, $display);
}
public function setDashboardDisplayDataJ4()
{
// display array reset
$display = [];
$mainAccordianName = 'cPanel';
$builder = [];
$tab = Indent::_(3);
$loadTabs = false;
$width_class = 'col-md-';
$row_class = 'row';
$form_class = 'main-card';
$uitab = 'uitab';
// check if we have custom tabs
if
(CFactory::_('Component')->isArray('dashboard_tab'))
{
// build the tabs and accordians
foreach
(CFactory::_('Component')->get('dashboard_tab') as
$data)
{
$builder[$data['name']][$data['header']]
= CFactory::_('Placeholder')->update_(
$data['html']
);
}
// since we have custom tabs we must load the tab structure around the
cpanel
$display[] = '<div id="j-main-container">';
$display[] = Indent::_(1) . '<div class="' .
$form_class . '">';
$display[] = Indent::_(1)
. "<?php echo Html::_('{$uitab}.startTabSet',
'cpanel_tab', array('active' =>
'cpanel')); ?>";
$display[] = PHP_EOL . Indent::_(2)
. "<?php echo Html::_('{$uitab}.addTab',
'cpanel_tab', 'cpanel', Text:"
. ":_('cPanel', true)); ?>";
$display[] = Indent::_(2) . '<div class="' .
$row_class . '">';
// change the name of the main tab
$mainAccordianName = 'Control Panel';
$loadTabs = true;
}
else
{
$display[] = '<div id="j-main-container">';
$display[] = Indent::_(1) . '<div class="' .
$form_class . '" style="padding: 20px;">';
$display[] = Indent::_(2) . '<div class="' .
$row_class . '">';
}
// set dashboard display
$display[] = $tab . '<div class="' . $width_class .
'9">';
$display[] = $tab . Indent::_(1)
. "<?php echo
\$this->loadTemplate('main');?>";
$display[] = $tab . "</div>";
$display[] = $tab . '<div class="' . $width_class .
'3">';
$display[] = $tab . Indent::_(1)
. "<?php echo
\$this->loadTemplate('vdm');?>";
$display[] = $tab . "</div>";
if ($loadTabs)
{
$display[] = Indent::_(2) . "</div>";
$display[] = Indent::_(2)
. "<?php echo Html::_('{$uitab}.endTab');
?>";
// load the new tabs
foreach ($builder as $tabname => $accordians)
{
$alias = StringHelper::safe($tabname);
$display[] = PHP_EOL . Indent::_(2)
. "<?php echo Html::_('{$uitab}.addTab',
'cpanel_tab', '"
. $alias . "', Text:" . ":_('" .
$tabname
. "', true)); ?>";
$display[] = Indent::_(2) . '<div class="' .
$row_class . '">';
$display[] = $tab . '<div class="' . $width_class
. '12">';
$slidecounter = 1;
foreach ($accordians as $accordianname => $html)
{
$ac_alias = StringHelper::safe(
$accordianname
);
$counterName = StringHelper::safe(
$slidecounter
);
$tempName = $alias . '_' . $ac_alias;
$display[] = $tab . Indent::_(1)
. "<?php echo \$this->loadTemplate('" .
$tempName
. "');?>";
$slidecounter++;
// build the template file
$target = array('custom_admin' =>
CFactory::_('Config')->component_code_name);
CFactory::_('Utilities.Structure')->build($target,
'template', $tempName);
// set the file data
$TARGET = StringHelper::safe(
CFactory::_('Config')->build_target, 'U'
);
// SITE_TEMPLATE_BODY <<<DYNAMIC>>>
CFactory::_('Compiler.Builder.Content.Multi')->set(CFactory::_('Config')->component_code_name
. '_' . $tempName . '|CUSTOM_ADMIN_TEMPLATE_BODY',
PHP_EOL . $html);
// SITE_TEMPLATE_CODE_BODY <<<DYNAMIC>>>
CFactory::_('Compiler.Builder.Content.Multi')->set(CFactory::_('Config')->component_code_name
. '_' . $tempName . '|CUSTOM_ADMIN_TEMPLATE_CODE_BODY',
'');
}
$display[] = $tab . "</div>";
$display[] = Indent::_(2) . "</div>";
$display[] = Indent::_(2)
. "<?php echo Html::_('{$uitab}.endTab');
?>";
}
$display[] = PHP_EOL . Indent::_(1)
. "<?php echo Html::_('{$uitab}.endTabSet');
?>";
}
else
{
$display[] = Indent::_(2) . "</div>";
}
$display[] = Indent::_(1) . "</div>";
$display[] = "</div>";
// return the display
return PHP_EOL . implode(PHP_EOL, $display);
}
public function addCustomDashboardIcons(&$view, &$counter)
{
$icon = '';
if
(CFactory::_('Component')->isArray('custom_admin_views'))
{
foreach
(CFactory::_('Component')->get('custom_admin_views')
as $nr => $menu)
{
if
(!isset($this->customAdminAdded[$menu['settings']->code])
&& isset($menu['dashboard_list'])
&& $menu['dashboard_list'] == 1
&& $menu['before'] == $view['adminview'])
{
$type = \ComponentbuilderHelper::imageInfo(
$menu['settings']->icon
);
if ($type)
{
$type = $type . ".";
// icon builder loader
$this->iconBuilder[$type . $menu['settings']->code]
= $menu['settings']->icon;
}
else
{
$type = 'png.';
}
// build lang
$langName = $menu['settings']->name . '<br
/><br />';
$langKey = CFactory::_('Config')->lang_prefix .
'_DASHBOARD_'
. $menu['settings']->CODE;
// add to lang
CFactory::_('Language')->set(CFactory::_('Config')->lang_target,
$langKey, $langName);
// set icon
if ($counter == 0)
{
$counter++;
$icon .= "'" . $type .
$menu['settings']->code . "'";
}
else
{
$counter++;
$icon .= ", '" . $type .
$menu['settings']->code . "'";
}
}
elseif
(!isset($this->customAdminAdded[$menu['settings']->code])
&& isset($menu['dashboard_list'])
&& $menu['dashboard_list'] == 1
&& empty($menu['before']))
{
$type = \ComponentbuilderHelper::imageInfo(
$menu['settings']->icon
);
if ($type)
{
$type = $type . ".";
// icon builder loader
$this->iconBuilder[$type . $menu['settings']->code]
= $menu['settings']->icon;
}
else
{
$type = 'png.';
}
// build lang
$langName = $menu['settings']->name . '<br
/><br />';
$langKey = CFactory::_('Config')->lang_prefix .
'_DASHBOARD_'
. $menu['settings']->CODE;
// add to lang
CFactory::_('Language')->set(CFactory::_('Config')->lang_target,
$langKey, $langName);
// set icon
$this->lastCustomDashboardIcon[$nr] = ", '" . $type
. $menu['settings']->code . "'";
}
}
}
// see if we should have custom menus
if
(CFactory::_('Component')->isArray('custommenus'))
{
foreach
(CFactory::_('Component')->get('custommenus') as $nr
=> $menu)
{
$nr = $nr + 100;
$nameList = StringHelper::safe(
$menu['name_code']
);
$nameUpper = StringHelper::safe(
$menu['name_code'], 'U'
);
if (isset($menu['dashboard_list'])
&& $menu['dashboard_list'] == 1
&& $view['adminview'] == $menu['before'])
{
$type = \ComponentbuilderHelper::imageInfo(
'images/' . $menu['icon']
);
if ($type)
{
// icon builder loader
$this->iconBuilder[$type . "." . $nameList] =
'images/'
. $menu['icon'];
}
else
{
$type = 'png';
}
// build lang
$langName = $menu['name'] . '<br /><br
/>';
$langKey = CFactory::_('Config')->lang_prefix .
'_DASHBOARD_' . $nameUpper;
// add to lang
CFactory::_('Language')->set(CFactory::_('Config')->lang_target,
$langKey, $langName);
// if this is a link build the icon values with pipe
if (isset($menu['link'])
&& StringHelper::check($menu['link']))
{
// set icon
if ($counter == 0)
{
$counter++;
$icon .= "'" . $type . "||" . $nameList .
"||"
. $menu['link'] . "'";
}
else
{
$counter++;
$icon .= ", '" . $type . "||" . $nameList .
"||"
. $menu['link'] . "'";
}
}
else
{
// set icon
if ($counter == 0)
{
$counter++;
$icon .= "'" . $type . "." . $nameList .
"'";
}
else
{
$counter++;
$icon .= ", '" . $type . "." . $nameList .
"'";
}
}
}
elseif (isset($menu['dashboard_list'])
&& $menu['dashboard_list'] == 1
&& empty($menu['before']))
{
$type = \ComponentbuilderHelper::imageInfo(
'images/' . $menu['icon']
);
if ($type)
{
// icon builder loader
$this->iconBuilder[$type . "." . $nameList] =
'images/'
. $menu['icon'];
}
else
{
$type = 'png';
}
// build lang
$langName = $menu['name'] . '<br /><br
/>';
$langKey = CFactory::_('Config')->lang_prefix .
'_DASHBOARD_' . $nameUpper;
// add to lang
CFactory::_('Language')->set(CFactory::_('Config')->lang_target,
$langKey, $langName);
// if this is a link build the icon values with pipe
if (isset($menu['link'])
&& StringHelper::check($menu['link']))
{
// set icon
$this->lastCustomDashboardIcon[$nr] = ", '" .
$type
. "||" . $nameList . "||" .
$menu['link'] . "'";
}
else
{
// set icon
$this->lastCustomDashboardIcon[$nr] = ", '" .
$type
. "." . $nameList . "'";
}
}
}
}
return $icon;
}
public function setSubMenus()
{
if
(CFactory::_('Component')->isArray('admin_views'))
{
$menus = '';
// main lang prefix
$lang = CFactory::_('Config')->lang_prefix .
'_SUBMENU';
// set the code name
$codeName = CFactory::_('Config')->component_code_name;
// set default dashboard
if
(!CFactory::_('Registry')->get('build.dashboard'))
{
$menus .= "\JHtmlSidebar::addEntry(Text:" .
":_('" . $lang
. "_DASHBOARD'), 'index.php?option=com_" .
$codeName
. "&view=" . $codeName . "', \$submenu ===
'" . $codeName
. "');";
CFactory::_('Language')->set(
CFactory::_('Config')->lang_target, $lang .
'_DASHBOARD', 'Dashboard'
);
}
$catArray = [];
// loop over all the admin views
foreach
(CFactory::_('Component')->get('admin_views') as
$view)
{
// set custom menu
$menus .= $this->addCustomSubMenu(
$view, $codeName, $lang
);
$nameSingleCode = $view['settings']->name_single_code;
$nameListCode = $view['settings']->name_list_code;
$nameUpper = StringHelper::safe(
$view['settings']->name_list, 'U'
);
// check if view is set to be in the sub-menu
if (isset($view['submenu']) &&
$view['submenu'] == 1)
{
// setup access defaults
$tab = "";
$has_permissions = false;
// check if the item has permissions.
if
(CFactory::_('Compiler.Creator.Permission')->globalExist($nameSingleCode,
'core.access'))
{
$menus .= PHP_EOL . Indent::_(2)
. "if (\$user->authorise('"
.
CFactory::_('Compiler.Creator.Permission')->getGlobal($nameSingleCode,
'core.access')
. "', 'com_" . $codeName
. "') && \$user->authorise('" .
$nameSingleCode
. ".submenu', 'com_" . $codeName .
"'))";
$menus .= PHP_EOL . Indent::_(2) . "{";
// add tab to lines to follow
$tab = Indent::_(1);
$has_permissions = true;
}
$menus .= PHP_EOL . Indent::_(2) . $tab
. "\JHtmlSidebar::addEntry(Text:" . ":_('" .
$lang . "_"
. $nameUpper . "'), 'index.php?option=com_" .
$codeName
. "&view=" . $nameListCode . "', \$submenu
=== '"
. $nameListCode . "');";
CFactory::_('Language')->set(
CFactory::_('Config')->lang_target, $lang .
"_" . $nameUpper,
$view['settings']->name_list
);
// check if category has another name
$otherViews =
CFactory::_('Compiler.Builder.Category.Other.Name')->
get($nameListCode . '.views', $nameListCode);
// first check if category sub-menu should be added
// then check if view has category, if true add sub-menu for it
if ($view['settings']->add_category_submenu == 1
&&
CFactory::_('Compiler.Builder.Category')->exists("{$nameListCode}.extension")
&& !in_array($otherViews, $catArray))
{
// get the extension array
$_extension_array = (array) explode(
'.',
(string)
CFactory::_('Compiler.Builder.Category')->get("{$nameListCode}.extension")
);
// set the menu selection
if (isset($_extension_array[1]))
{
$_menu = "categories." . trim($_extension_array[1]);
}
else
{
$_menu = "categories";
}
// now load the menus
$menus .= PHP_EOL . Indent::_(2) . $tab
. "\JHtmlSidebar::addEntry(Text:" . ":_('"
.
CFactory::_('Compiler.Builder.Category')->get("{$nameListCode}.name",
'error')
. "'),
'index.php?option=com_categories&view=categories&extension="
.
CFactory::_('Compiler.Builder.Category')->get("{$nameListCode}.extension")
. "', \$submenu === '" . $_menu .
"');";
// make sure we add a category only once
$catArray[] = $otherViews;
}
// check if the item has permissions.
if ($has_permissions)
{
$menus .= PHP_EOL . Indent::_(2) . "}";
}
}
// set the Joomla custom fields options
if (isset($view['joomla_fields'])
&& $view['joomla_fields'] == 1)
{
$menus .= PHP_EOL . Indent::_(2)
. "if
(ComponentHelper::isEnabled('com_fields'))";
$menus .= PHP_EOL . Indent::_(2) . "{";
$menus .= PHP_EOL . Indent::_(3)
. "\JHtmlSidebar::addEntry(Text:" . ":_('" .
$lang . "_"
. $nameUpper
. "_FIELDS'),
'index.php?option=com_fields&context=com_"
. $codeName . "." . $nameSingleCode
. "', \$submenu === 'fields.fields');";
$menus .= PHP_EOL . Indent::_(3)
. "\JHtmlSidebar::addEntry(Text:" . ":_('" .
$lang . "_"
. $nameUpper
. "_FIELDS_GROUPS'),
'index.php?option=com_fields&view=groups&context=com_"
. $codeName . "." . $nameSingleCode
. "', \$submenu === 'fields.groups');";
$menus .= PHP_EOL . Indent::_(2) . "}";
CFactory::_('Language')->set(
CFactory::_('Config')->lang_target, $lang .
"_" . $nameUpper . "_FIELDS",
$view['settings']->name_list . ' Fields'
);
CFactory::_('Language')->set(
CFactory::_('Config')->lang_target,
$lang . "_" . $nameUpper . "_FIELDS_GROUPS",
$view['settings']->name_list . ' Field
Groups'
);
// build uninstall script for fields
$this->uninstallScriptBuilder[$nameSingleCode] = 'com_'
. $codeName . '.' . $nameSingleCode;
$this->uninstallScriptFields[$nameSingleCode]
= $nameSingleCode;
}
}
if (isset($this->lastCustomSubMenu)
&& ArrayHelper::check($this->lastCustomSubMenu))
{
foreach ($this->lastCustomSubMenu as $menu)
{
$menus .= $menu;
}
unset($this->lastCustomSubMenu);
}
return $menus;
}
return false;
}
public function addCustomSubMenu(&$view, &$codeName, &$lang)
{
// see if we should have custom menus
$custom = '';
if
(CFactory::_('Component')->isArray('custom_admin_views'))
{
foreach
(CFactory::_('Component')->get('custom_admin_views')
as $nr => $menu)
{
if
(!isset($this->customAdminAdded[$menu['settings']->code]))
{
if (($_custom = $this->setCustomAdminSubMenu(
$view, $codeName, $lang, $nr, $menu, 'customView'
)) !== false)
{
$custom .= $_custom;
}
}
}
}
if
(CFactory::_('Component')->isArray('custommenus'))
{
foreach
(CFactory::_('Component')->get('custommenus') as $nr
=> $menu)
{
if (($_custom = $this->setCustomAdminSubMenu(
$view, $codeName, $lang, $nr, $menu, 'customMenu'
)) !== false)
{
$custom .= $_custom;
}
}
}
return $custom;
}
public function setCustomAdminSubMenu(&$view, &$codeName,
&$lang, &$nr, &$menu, $type)
{
if ($type === 'customMenu')
{
$name = $menu['name'];
$nameSingle = StringHelper::safe($menu['name']);
$nameList = StringHelper::safe($menu['name']);
$nameUpper = StringHelper::safe(
$menu['name'], 'U'
);
}
elseif ($type === 'customView')
{
$name = $menu['settings']->name;
$nameSingle = $menu['settings']->code;
$nameList = $menu['settings']->code;
$nameUpper = $menu['settings']->CODE;
}
if (isset($menu['submenu']) &&
$menu['submenu'] == 1
&& $view['adminview'] == $menu['before'])
{
// setup access defaults
$tab = "";
$custom = '';
// check if the item has permissions.
if
(CFactory::_('Compiler.Creator.Permission')->globalExist($nameSingle,
'core.access'))
{
$custom .= PHP_EOL . Indent::_(2) . "//" . Line::_(
__LINE__,__CLASS__
) . " Access control (" .
CFactory::_('Compiler.Creator.Permission')->getGlobal($nameSingle,
'core.access') . " && "
. $nameSingle . ".submenu).";
$custom .= PHP_EOL . Indent::_(2) . "if
(\$user->authorise('"
.
CFactory::_('Compiler.Creator.Permission')->getGlobal($nameSingle,
'core.access') . "', 'com_" . $codeName
. "') && \$user->authorise('" .
$nameSingle
. ".submenu', 'com_" . $codeName .
"'))";
$custom .= PHP_EOL . Indent::_(2) . "{";
// add tab to lines to follow
$tab = Indent::_(1);
}
else
{
$custom .= PHP_EOL . Indent::_(2) . "//" . Line::_(
__LINE__,__CLASS__
) . " Access control (" . $nameSingle .
".submenu).";
$custom .= PHP_EOL . Indent::_(2) . "if
(\$user->authorise('"
. $nameSingle . ".submenu', 'com_" . $codeName .
"'))";
$custom .= PHP_EOL . Indent::_(2) . "{";
// add tab to lines to follow
$tab = Indent::_(1);
}
if (isset($menu['link'])
&& StringHelper::check(
$menu['link']
))
{
CFactory::_('Language')->set(
CFactory::_('Config')->lang_target, $lang . '_'
. $nameUpper, $name
);
// add custom menu
$custom .= PHP_EOL . Indent::_(2) . $tab
. "\JHtmlSidebar::addEntry(Text:" . ":_('" .
$lang . "_"
. $nameUpper . "'), '" . $menu['link']
. "', \$submenu === '" . $nameList .
"');";
}
else
{
CFactory::_('Language')->set(
CFactory::_('Config')->lang_target, $lang . '_'
. $nameUpper, $name
);
// add custom menu
$custom .= PHP_EOL . Indent::_(2) . $tab
. "\JHtmlSidebar::addEntry(Text:" . ":_('" .
$lang . "_"
. $nameUpper . "'), 'index.php?option=com_" .
$codeName
. "&view=" . $nameList . "', \$submenu ===
'" . $nameList
. "');";
}
// check if the item has permissions.
$custom .= PHP_EOL . Indent::_(2) . "}";
return $custom;
}
elseif (isset($menu['submenu']) &&
$menu['submenu'] == 1
&& empty($menu['before']))
{
// setup access defaults
$tab = "";
$nameSingle = StringHelper::safe($name);
$this->lastCustomSubMenu[$nr] = '';
// check if the item has permissions.
if
(CFactory::_('Compiler.Creator.Permission')->globalExist($nameSingle,
'core.access'))
{
$this->lastCustomSubMenu[$nr] .= PHP_EOL . Indent::_(2)
. "if (\$user->authorise('" .
CFactory::_('Compiler.Creator.Permission')->getGlobal($nameSingle,
'core.access')
. "', 'com_" . $codeName . "')
&& \$user->authorise('"
. $nameSingle . ".submenu', 'com_" . $codeName .
"'))";
$this->lastCustomSubMenu[$nr] .= PHP_EOL . Indent::_(2) .
"{";
// add tab to lines to follow
$tab = Indent::_(1);
}
else
{
$this->lastCustomSubMenu[$nr] .= PHP_EOL . Indent::_(2)
. "if (\$user->authorise('" . $nameSingle
. ".submenu', 'com_" . $codeName .
"'))";
$this->lastCustomSubMenu[$nr] .= PHP_EOL . Indent::_(2) .
"{";
// add tab to lines to follow
$tab = Indent::_(1);
}
if (isset($menu['link'])
&& StringHelper::check(
$menu['link']
))
{
CFactory::_('Language')->set(
CFactory::_('Config')->lang_target, $lang . '_'
. $nameUpper, $name
);
// add custom menu
$this->lastCustomSubMenu[$nr] .= PHP_EOL . Indent::_(2) . $tab
. "\JHtmlSidebar::addEntry(Text:" . ":_('" .
$lang . "_"
. $nameUpper . "'), '" . $menu['link']
. "', \$submenu === '" . $nameList .
"');";
}
else
{
CFactory::_('Language')->set(
CFactory::_('Config')->lang_target, $lang . '_'
. $nameUpper, $name
);
// add custom menu
$this->lastCustomSubMenu[$nr] .= PHP_EOL . Indent::_(2) . $tab
. "\JHtmlSidebar::addEntry(Text:" . ":_('" .
$lang . "_"
. $nameUpper . "'), 'index.php?option=com_" .
$codeName
. "&view=" . $nameList . "', \$submenu ===
'" . $nameList
. "');";
}
// check if the item has permissions.
$this->lastCustomSubMenu[$nr] .= PHP_EOL . Indent::_(2) .
"}";
}
return false;
}
public function setMainMenus()
{
if
(CFactory::_('Component')->isArray('admin_views'))
{
$menus = '';
// main lang prefix
$lang = CFactory::_('Config')->lang_prefix .
'_MENU';
// set the code name
$codeName = CFactory::_('Config')->component_code_name;
// default prefix is none
$prefix = '';
// check if local is set
if
(CFactory::_('Component')->isNumeric('add_menu_prefix'))
{
// set main menu prefix switch
$addPrefix =
CFactory::_('Component')->get('add_menu_prefix');
if ($addPrefix == 1 &&
CFactory::_('Component')->isString('menu_prefix'))
{
$prefix = trim((string)
CFactory::_('Component')->get('menu_prefix')) .
' ';
}
}
else
{
// set main menu prefix switch
$addPrefix = $this->params->get('add_menu_prefix', 1);
if ($addPrefix == 1)
{
$prefix = trim((string)
$this->params->get('menu_prefix', '»'))
. ' ';
}
}
// add the prefix
if ($addPrefix == 1)
{
CFactory::_('Language')->set(
'adminsys', $lang, $prefix .
CFactory::_('Component')->get('name')
);
}
else
{
CFactory::_('Language')->set(
'adminsys', $lang,
CFactory::_('Component')->get('name')
);
}
if (CFactory::_('Config')->get('joomla_version',
3) != 3
&&
CFactory::_('Registry')->get('build.dashboard',
null) === null)
{
$menus .= PHP_EOL . Indent::_(3) . '<menu
option="com_'
. $codeName . '" view="' . $codeName .
'">' . $lang
. '_DASHBOARD</menu>';
CFactory::_('Language')->set(
'adminsys', $lang . '_DASHBOARD',
'Dashboard'
);
}
// loop over the admin views
foreach
(CFactory::_('Component')->get('admin_views') as
$view)
{
// set custom menu
$menus .= $this->addCustomMainMenu($view, $codeName, $lang);
if (isset($view['mainmenu']) &&
$view['mainmenu'] == 1)
{
$nameList = StringHelper::safe(
$view['settings']->name_list
);
$nameUpper = StringHelper::safe(
$view['settings']->name_list, 'U'
);
$menus .= PHP_EOL . Indent::_(3) . '<menu
option="com_'
. $codeName . '" view="' . $nameList .
'">' . $lang
. '_' . $nameUpper . '</menu>';
CFactory::_('Language')->set(
'adminsys', $lang . '_' . $nameUpper,
$view['settings']->name_list
);
}
}
if (isset($this->lastCustomMainMenu)
&& ArrayHelper::check(
$this->lastCustomMainMenu
))
{
foreach ($this->lastCustomMainMenu as $menu)
{
$menus .= $menu;
}
unset($this->lastCustomMainMenu);
}
return $menus;
}
return false;
}
public function addCustomMainMenu(&$view, &$codeName, &$lang)
{
$customMenu = '';
// see if we should have custom admin views
if
(CFactory::_('Component')->isArray('custom_admin_views'))
{
foreach
(CFactory::_('Component')->get('custom_admin_views')
as $nr => $menu)
{
if
(!isset($this->customAdminAdded[$menu['settings']->code]))
{
if (isset($menu['mainmenu']) &&
$menu['mainmenu'] == 1
&& $view['adminview'] ==
$menu['before'])
{
CFactory::_('Language')->set(
'adminsys', $lang . '_' .
$menu['settings']->CODE,
$menu['settings']->name
);
// add custom menu
$customMenu .= PHP_EOL . Indent::_(3)
. '<menu option="com_' . $codeName . '"
view="'
. $menu['settings']->code . '">' .
$lang . '_'
. $menu['settings']->CODE . '</menu>';
}
elseif (isset($menu['mainmenu']) &&
$menu['mainmenu'] == 1
&& empty($menu['before']))
{
CFactory::_('Language')->set(
'adminsys', $lang . '_' .
$menu['settings']->CODE,
$menu['settings']->name
);
// add custom menu
$this->lastCustomMainMenu[$nr] = PHP_EOL . Indent::_(3)
. '<menu option="com_' . $codeName . '"
view="'
. $menu['settings']->code . '">' .
$lang . '_'
. $menu['settings']->CODE . '</menu>';
}
}
}
}
// see if we should have custom menus
if
(CFactory::_('Component')->isArray('custommenus'))
{
foreach
(CFactory::_('Component')->get('custommenus') as $nr
=> $menu)
{
$nr = $nr + 100;
if (isset($menu['mainmenu']) &&
$menu['mainmenu'] == 1
&& $view['adminview'] == $menu['before'])
{
if (isset($menu['link'])
&& StringHelper::check($menu['link']))
{
$nameList = StringHelper::safe(
$menu['name']
);
$nameUpper = StringHelper::safe(
$menu['name'], 'U'
);
CFactory::_('Language')->set(
'adminsys', $lang . '_' . $nameUpper,
$menu['name']
);
// sanitize url
if (strpos((string) $menu['link'], 'http') ===
false)
{
$menu['link'] = str_replace(
'/administrator/index.php?', '', (string)
$menu['link']
);
$menu['link'] = str_replace(
'administrator/index.php?', '',
$menu['link']
);
// check if the index is still there
if (strpos($menu['link'], 'index.php?') !==
false)
{
$menu['link'] = str_replace(
'/index.php?', '', $menu['link']
);
$menu['link'] = str_replace(
'index.php?', '', $menu['link']
);
}
}
// urlencode
$menu['link'] = htmlspecialchars(
(string) $menu['link'], ENT_XML1, 'UTF-8'
);
// add custom menu
$customMenu .= PHP_EOL . Indent::_(3) . '<menu
link="'
. $menu['link'] . '">' . $lang .
'_' . $nameUpper
. '</menu>';
}
else
{
$nameList = StringHelper::safe(
$menu['name_code']
);
$nameUpper = StringHelper::safe(
$menu['name_code'], 'U'
);
CFactory::_('Language')->set(
'adminsys', $lang . '_' . $nameUpper,
$menu['name']
);
// add custom menu
$customMenu .= PHP_EOL . Indent::_(3)
. '<menu option="com_' . $codeName . '"
view="'
. $nameList . '">' . $lang . '_' .
$nameUpper
. '</menu>';
}
}
elseif (isset($menu['mainmenu']) &&
$menu['mainmenu'] == 1
&& empty($menu['before']))
{
if (isset($menu['link'])
&& StringHelper::check($menu['link']))
{
$nameList = StringHelper::safe(
$menu['name']
);
$nameUpper = StringHelper::safe(
$menu['name'], 'U'
);
CFactory::_('Language')->set(
'adminsys', $lang . '_' . $nameUpper,
$menu['name']
);
// sanitize url
if (strpos((string) $menu['link'], 'http') ===
false)
{
$menu['link'] = str_replace(
'/administrator/index.php?', '', (string)
$menu['link']
);
$menu['link'] = str_replace(
'administrator/index.php?', '',
$menu['link']
);
// check if the index is still there
if (strpos($menu['link'], 'index.php?') !==
false)
{
$menu['link'] = str_replace(
'/index.php?', '', $menu['link']
);
$menu['link'] = str_replace(
'index.php?', '', $menu['link']
);
}
}
// urlencode
$menu['link'] = htmlspecialchars(
(string) $menu['link'], ENT_XML1, 'UTF-8'
);
// add custom menu
$this->lastCustomMainMenu[$nr] = PHP_EOL . Indent::_(3)
. '<menu link="' . $menu['link'] .
'">' . $lang
. '_' . $nameUpper . '</menu>';
}
else
{
$nameList = StringHelper::safe(
$menu['name_code']
);
$nameUpper = StringHelper::safe(
$menu['name_code'], 'U'
);
CFactory::_('Language')->set(
'adminsys', $lang . '_' . $nameUpper,
$menu['name']
);
// add custom menu
$this->lastCustomMainMenu[$nr] = PHP_EOL . Indent::_(3)
. '<menu option="com_' . $codeName . '"
view="'
. $nameList . '">' . $lang . '_' .
$nameUpper
. '</menu>';
}
}
}
}
return $customMenu;
}
/**
* Set Config Fieldsets
*
* @param int $timer
*
* @since 1.0
* @deprecated 3.3
CFactory::_('Compiler.Creator.Config.Fieldsets')->set($timer);
*/
public function setConfigFieldsets(int $timer = 0): void
{
CFactory::_('Compiler.Creator.Config.Fieldsets')->set($timer);
}
/**
* Set Site Control Config Fieldsets
*
* @param string $lang
*
* @since 1.0
* @deprecated 3.3
CFactory::_('Compiler.Creator.Config.Fieldsets.Site.Control')->set($lang);
*/
public function setSiteControlConfigFieldsets(string $lang): void
{
CFactory::_('Compiler.Creator.Config.Fieldsets.Site.Control')->set($lang);
}
/**
* Set the request values
*
* @param string $view
* @param string $field
* @param string $search
* @param string $target
*
* @since 1.0
* @deprecated 3.3 Use
CFactory::_('Compiler.Creator.Request')->set($view, $field,
$search, $target);
*/
protected function setRequestValues(string $view, string $field, string
$search, string $target): void
{
CFactory::_('Compiler.Creator.Request')->set($view, $field,
$search, $target);
}
/**
* Set Custom Control Config Fieldsets
*
* @param string $lang
*
* @since 1.0
* @deprecated 3.3
CFactory::_('Compiler.Creator.Config.Fieldsets.Customfield')->set($lang);
*/
public function setCustomControlConfigFieldsets(string $lang): void
{
CFactory::_('Compiler.Creator.Config.Fieldsets.Customfield')->set($lang);
}
/**
* Set Group Control Config Fieldsets
*
* @param string $lang
*
* @since 1.0
* @deprecated 3.3
CFactory::_('Compiler.Creator.Config.Fieldsets.Group.Control')->set($lang);
*/
public function setGroupControlConfigFieldsets(string $lang): void
{
CFactory::_('Compiler.Creator.Config.Fieldsets.Group.Control')->set($lang);
}
/**
* Set Global Config Fieldsets
*
* @param string $lang
* @param string $authorName
* @param string $authorEmail
*
* @since 1.0
* @deprecated 3.3
CFactory::_('Compiler.Creator.Config.Fieldsets.Global')->set($lang,
$authorName, $authorEmail);
*/
public function setGlobalConfigFieldsets(string $lang, string $authorName,
string $authorEmail): void
{
CFactory::_('Compiler.Creator.Config.Fieldsets.Global')->set($lang,
$authorName, $authorEmail);
}
/**
* Set Uikit Config Fieldsets
*
* @param string $lang
*
* @since 1.0
* @deprecated 3.3
CFactory::_('Compiler.Creator.Config.Fieldsets.Uikit')->set($lang);
*/
public function setUikitConfigFieldsets($lang)
{
CFactory::_('Compiler.Creator.Config.Fieldsets.Uikit')->set($lang);
}
/**
* Set Email Helper Config Fieldsets
*
* @param string $lang
*
* @since 1.0
* @deprecated 3.3
CFactory::_('Compiler.Creator.Config.Fieldsets.Email.Helper')->set($lang);
*/
public function setEmailHelperConfigFieldsets($lang)
{
CFactory::_('Compiler.Creator.Config.Fieldsets.Email.Helper')->set($lang);
}
/**
* Set Googlechart Config Fieldsets
*
* @param string $lang
*
* @since 1.0
* @deprecated 3.3
CFactory::_('Compiler.Creator.Config.Fieldsets.Googlechart')->set($lang);
*/
public function setGooglechartConfigFieldsets($lang)
{
CFactory::_('Compiler.Creator.Config.Fieldsets.Googlechart')->set($lang);
}
/**
* Set Encryption Config Fieldsets
*
* @param string $lang
*
* @since 1.0
* @deprecated 3.3
CFactory::_('Compiler.Creator.Config.Fieldsets.Encryption')->set($lang);
*/
public function setEncryptionConfigFieldsets($lang)
{
CFactory::_('Compiler.Creator.Config.Fieldsets.Encryption')->set($lang);
}
/**
* Set Access Sections Category
*
* @param string $nameSingleCode
* @param string $nameListCode
*
* @return string
* @since 1.0
* @deprecated 3.3
CFactory::_('Compiler.Creator.Access.Sections.Category')->get($nameSingleCode,
$nameListCode);
*/
public function setAccessSectionsCategory(string $nameSingleCode, string
$nameListCode): string
{
return
CFactory::_('Compiler.Creator.Access.Sections.Category')->get($nameSingleCode,
$nameListCode);
}
/**
* Set Access Sections Joomla Fields
*
* @return string
* @since 1.0
* @deprecated 3.3
CFactory::_('Compiler.Creator.Access.Sections.Joomla.Fields')->get();
*/
public function setAccessSectionsJoomlaFields(): string
{
return
CFactory::_('Compiler.Creator.Access.Sections.Joomla.Fields')->get();
}
/**
* Set Access Sections
*
* @return string
* @since 1.0
* @deprecated 3.3
CFactory::_('Compiler.Creator.Access.Sections')->get();
*/
public function setAccessSections()
{
return
CFactory::_('Compiler.Creator.Access.Sections')->get();
}
/**
* Add Custom Button Permissions
*
* @param object $settings The view settings
* @param string $nameView The view name
* @param string $code The view code name.
*
* @since 1.0
* @deprecated 3.3 Use
CFactory::_('Compiler.Creator.Custom.Button.Permissions')->add($settings,
$nameView, $code);
*/
protected function addCustomButtonPermissions($settings, $nameView,
$code)
{
CFactory::_('Compiler.Creator.Custom.Button.Permissions')->add($settings,
$nameView, $code);
}
/**
* Set the permissions
*
* @param array $view View details
* @param string $nameView View Single Code Name
* @param string $nameViews View List Code Name
* @param array $menuControllers Menu Controllers
* @param string $type Type of permissions area
*
* @return void
* @deprecated 3.3 Use
CFactory::_('Compiler.Creator.Permission')->set($view,
$nameView, $nameViews, $menuControllers, $type);
*/
public function buildPermissions(&$view, $nameView, $nameViews,
$menuControllers, $type = 'admin')
{
CFactory::_('Compiler.Creator.Permission')->set($view,
$nameView, $nameViews, $menuControllers, $type);
}
public function getInbetweenStrings($str, $start = '#' .
'#' . '#', $end = '#' . '#' .
'#')
{
$matches = [];
$regex = "/$start([a-zA-Z0-9_]*)$end/";
preg_match_all($regex, (string) $str, $matches);
return $matches[1];
}
public function getModCode(&$module)
{
// get component helper string
$Helper =
CFactory::_('Compiler.Builder.Content.One')->get('Component')
. 'Helper';
$component =
CFactory::_('Compiler.Builder.Content.One')->get('component');
$_helper = '';
// get libraries code
$libraries = array(Placefix::_('MOD_LIBRARIES') =>
$this->getModLibCode($module));
$code =
CFactory::_('Placeholder')->update($module->mod_code,
$libraries);
// check if component helper class should be added
if (strpos((string) $code, $Helper . '::') !== false
&& strpos(
(string) $code,
"/components/com_" . $component . "/helpers/" .
$component
. ".php"
) === false)
{
$_helper = '//' . Line::_(__Line__, __Class__)
. ' Include the component helper functions only once';
$_helper .= PHP_EOL . "JLoader::register('" . $Helper
. "', JPATH_ADMINISTRATOR . '/components/com_" .
$component
. "/helpers/" . $component . ".php');";
}
return CFactory::_('Placeholder')->update($_helper . PHP_EOL
. $code . PHP_EOL,
CFactory::_('Compiler.Builder.Content.One')->allActive());
}
public function getModDefault(&$module, &$key)
{
// first add the header
$default = PHP_EOL . $module->default_header . PHP_EOL .
'?>';
// add any css from the fields
$default .= CFactory::_('Customcode.Dispenser')->get(
'css_views', $key, PHP_EOL . '<style>',
'', true, null,
PHP_EOL . '</style>' . PHP_EOL
);
// now add the body
$default .= PHP_EOL . $module->default . PHP_EOL;
// add any JavaScript from the fields
$default .= CFactory::_('Customcode.Dispenser')->get(
'views_footer', $key,
PHP_EOL . '<script type="text/javascript">',
'', true,
null, PHP_EOL . '</script>' . PHP_EOL
);
// return the default content for the model default area
return CFactory::_('Placeholder')->update($default,
CFactory::_('Compiler.Builder.Content.One')->allActive());
}
public function setModTemplates(&$module)
{
if (($data_ =
CFactory::_('Compiler.Builder.Template.Data')->
get(CFactory::_('Config')->build_target . '.' .
$module->code_name)) !== null)
{
foreach ($data_ as $template => $data)
{
$header = $data['php_view'] ?? '';
$body = $data['html'] ?? '';
$default = PHP_EOL . $header . PHP_EOL . '?>';
$default .= PHP_EOL . $body;
$TARGET = StringHelper::safe("MODDEFAULT_{$template}",
'U');
CFactory::_('Compiler.Builder.Content.Multi')->set($module->key
. '|' . $TARGET,
CFactory::_('Placeholder')->update(
$default,
CFactory::_('Compiler.Builder.Content.One')->allActive()
)
);
}
}
}
public function getModHelperCode(&$module)
{
return
CFactory::_('Placeholder')->update($module->class_helper_header
. PHP_EOL .
$module->class_helper_type . $module->class_helper_name .
PHP_EOL
. '{' . PHP_EOL .
$module->class_helper_code . PHP_EOL .
"}" . PHP_EOL,
CFactory::_('Compiler.Builder.Content.One')->allActive());
}
public function getModLibCode(&$module)
{
$setter = '';
if (($data_ =
CFactory::_('Compiler.Builder.Library.Manager')->
get($module->key . '.' . $module->code_name)) !== null)
{
$setter .= '//' . Line::_(__Line__, __Class__)
. 'get the document object';
$setter .= PHP_EOL . '$document = Factory::getDocument();';
foreach ($data_ as $id => $true)
{
// get the library
$library =
CFactory::_('Registry')->get("builder.libraries.$id",
null);
if (is_object($library)
&& isset($library->document)
&& StringHelper::check(
$library->document
))
{
$setter .= PHP_EOL . $library->document;
}
elseif (is_object($library)
&& isset($library->how))
{
$setter .= $this->setLibraryDocument($id);
}
}
}
// check if we have string
if (StringHelper::check($setter))
{
return CFactory::_('Placeholder')->update(
CFactory::_('Placeholder')->update_(
str_replace(
'$this->document->', '$document->',
implode(
PHP_EOL,
array_map(
'trim',
(array) explode(PHP_EOL, $setter)
)
)
)
),
CFactory::_('Compiler.Builder.Content.One')->allActive());
}
return '';
}
public function getModuleMainXML(&$module)
{
// set the custom table key
$dbkey = 'yyy';
// build the xml
$xml = '';
// search if we must add the component path
$add_component_path = false;
// build the config fields
$config_fields = [];
if (isset($module->config_fields)
&& ArrayHelper::check(
$module->config_fields
))
{
$add_scripts_field = true;
foreach ($module->config_fields as $field_name => $fieldsets)
{
foreach ($fieldsets as $fieldset => $fields)
{
// get the field set
$xmlFields =
CFactory::_('Compiler.Creator.Fieldset.Extension')->get(
$module, $fields, $dbkey
);
// check if the custom script field must be set
if ($add_scripts_field && $module->add_scripts_field)
{
// get the custom script field
$xmlFields .= PHP_EOL . Indent::_(2)
. "<field type=\"modadminvvvvvvvdm\" />";
// don't add it again
$add_scripts_field = false;
}
// make sure the xml is set and a string
if (isset($xmlFields)
&& StringHelper::check($xmlFields))
{
$config_fields[$field_name . $fieldset] = $xmlFields;
}
$dbkey++;
// check if the fieldset path requiers component paths
if (!$add_component_path
&& isset(
$module->fieldsets_paths[$field_name . $fieldset]
)
&& $module->fieldsets_paths[$field_name . $fieldset]
== 1)
{
$add_component_path = true;
}
}
}
}
// switch to add the language xml
$addLang = [];
// now build the language files
if (CFactory::_('Language')->exist($module->key))
{
// get model lang content
$langContent =
CFactory::_('Language')->getTarget($module->key);
// Trigger Event: jcb_ce_onBeforeBuildModuleLang
CFactory::_('Event')->trigger(
'jcb_ce_onBeforeBuildModuleLang', [&$module,
&$langContent]
);
// get other languages
$values = array_unique($langContent);
// get the other lang strings if there is any
CFactory::_('Compiler.Builder.Multilingual')->set('modules',
CFactory::_('Language.Multilingual')->get($values)
);
// start the modules language bucket (must rest every time)
$langTag = CFactory::_('Config')->get('lang_tag',
'en-GB');
CFactory::_('Compiler.Builder.Languages')->set(
"modules.{$langTag}.all",
$langContent
);
CFactory::_('Language')->setTarget($module->key, null);
// update insert the current lang in to DB
CFactory::_('Language.Set')->execute($values,
$module->id, 'modules');
// remove old unused language strings
CFactory::_('Language.Purge')->execute($values,
$module->id, 'modules');
$total = count($values);
unset($values);
// Trigger Event: jcb_ce_onBeforeBuildModuleLangFiles
CFactory::_('Event')->trigger(
'jcb_ce_onBeforeBuildModuleLangFiles', [&$module]
);
// now we insert the values into the files
if
(CFactory::_('Compiler.Builder.Languages')->IsArray('modules'))
{
foreach
(CFactory::_('Compiler.Builder.Languages')->get('modules')
as $tag => $areas)
{
// trim the tag
$tag = trim($tag);
foreach ($areas as $area => $languageStrings)
{
$file_name = $tag . '.' . $module->file_name .
'.ini';
// check if language should be added
if (CFactory::_('Language.Translation')->check(
$tag, $languageStrings, $total,
$file_name
))
{
$lang = array_map(
fn($langstring, $placeholder) => $placeholder .
'="' . $langstring . '"',
array_values($languageStrings),
array_keys($languageStrings)
);
// set path
$path = $module->folder_path . '/language/' . $tag .
'/';
// create path if not exist
if (!Folder::exists($path))
{
Folder::create($path);
// count the folder created
CFactory::_('Utilities.Counter')->folder++;
}
// add to language files (for now we add all to both TODO)
CFactory::_('Utilities.File')->write(
$path . $file_name,
implode(PHP_EOL, $lang)
);
CFactory::_('Utilities.File')->write(
$path . $tag . '.' . $module->file_name
. '.sys.ini',
implode(PHP_EOL, $lang)
);
// set the line counter
CFactory::_('Utilities.Counter')->line += count(
(array) $lang
);
unset($lang);
// trigger to add language
$addLang[$tag] = $tag;
}
}
}
}
}
// get all files and folders in module folder
$files = Folder::files($module->folder_path);
$folders = Folder::folders($module->folder_path);
// the files/folders to ignore
$ignore = array('sql', 'language',
'script.php',
$module->file_name . '.xml',
$module->file_name . '.php');
// should the scriptfile be added
if ($module->add_install_script)
{
$xml .= PHP_EOL . PHP_EOL . Indent::_(1) . '<!--' .
Line::_(
__LINE__,__CLASS__
) . ' Scripts to run on installation -->';
$xml .= PHP_EOL . Indent::_(1)
. '<scriptfile>script.php</scriptfile>';
}
// should the sql install be added
if ($module->add_sql)
{
$xml .= PHP_EOL . PHP_EOL . Indent::_(1) . '<!--' .
Line::_(
__LINE__,__CLASS__
) . ' Runs on install; New in Joomla 1.5 -->';
$xml .= PHP_EOL . Indent::_(1) . '<install>';
$xml .= PHP_EOL . Indent::_(2) . '<sql>';
$xml .= PHP_EOL . Indent::_(3)
. '<file driver="mysql"
charset="utf8">sql/mysql/install.sql</file>';
$xml .= PHP_EOL . Indent::_(2) . '</sql>';
$xml .= PHP_EOL . Indent::_(1) . '</install>';
}
// should the sql uninstall be added
if ($module->add_sql_uninstall)
{
$xml .= PHP_EOL . PHP_EOL . Indent::_(1) . '<!--' .
Line::_(
__LINE__,__CLASS__
) . ' Runs on uninstall; New in Joomla 1.5 -->';
$xml .= PHP_EOL . Indent::_(1) . '<uninstall>';
$xml .= PHP_EOL . Indent::_(2) . '<sql>';
$xml .= PHP_EOL . Indent::_(3)
. '<file driver="mysql"
charset="utf8">sql/mysql/uninstall.sql</file>';
$xml .= PHP_EOL . Indent::_(2) . '</sql>';
$xml .= PHP_EOL . Indent::_(1) . '</uninstall>';
}
// should the language xml be added
if (ArrayHelper::check($addLang))
{
$xml .= PHP_EOL . PHP_EOL . Indent::_(1) . '<!--' .
Line::_(
__LINE__,__CLASS__
) . ' Language files -->';
$xml .= PHP_EOL . Indent::_(1)
. '<languages folder="language">';
// load all the language files to xml
foreach ($addLang as $addTag)
{
$xml .= PHP_EOL . Indent::_(2) . '<language tag="'
. $addTag . '">' . $addTag . '/' . $addTag
. '.'
. $module->file_name . '.ini</language>';
$xml .= PHP_EOL . Indent::_(2) . '<language tag="'
. $addTag . '">' . $addTag . '/' . $addTag
. '.'
. $module->file_name . '.sys.ini</language>';
}
$xml .= PHP_EOL . Indent::_(1) . '</languages>';
}
// add the module files
$xml .= PHP_EOL . PHP_EOL . Indent::_(1) . '<!--' .
Line::_(
__LINE__,__CLASS__
) . ' Model files -->';
$xml .= PHP_EOL . Indent::_(1) . '<files>';
$xml .= PHP_EOL . Indent::_(2) . '<filename module="'
. $module->file_name . '">' .
$module->file_name
. '.php</filename>';
// add other files found
if (ArrayHelper::check($files))
{
foreach ($files as $file)
{
// only add what is not ignored
if (!in_array($file, $ignore))
{
$xml .= PHP_EOL . Indent::_(2) . '<filename>' . $file
. '</filename>';
}
}
}
// add language folder
if (ArrayHelper::check($addLang))
{
$xml .= PHP_EOL . Indent::_(2) .
'<folder>language</folder>';
}
// add sql folder
if ($module->add_sql || $module->add_sql_uninstall)
{
$xml .= PHP_EOL . Indent::_(2) .
'<folder>sql</folder>';
}
// add other files found
if (ArrayHelper::check($folders))
{
foreach ($folders as $folder)
{
// only add what is not ignored
if (!in_array($folder, $ignore))
{
$xml .= PHP_EOL . Indent::_(2) . '<folder>' . $folder
. '</folder>';
}
}
}
$xml .= PHP_EOL . Indent::_(1) . '</files>';
// now add the Config Params if needed
if (ArrayHelper::check($config_fields))
{
$xml .= PHP_EOL . PHP_EOL . Indent::_(1) . '<!--' .
Line::_(
__LINE__,__CLASS__
) . ' Config parameter -->';
// only add if part of the component field types path is required
if ($add_component_path)
{
// add path to module rules and custom fields
$xml .= PHP_EOL . Indent::_(1) . '<config';
if (CFactory::_('Config')->get('joomla_version',
3) == 3)
{
$xml .= PHP_EOL . Indent::_(2)
. 'addrulepath="/administrator/components/com_'
. CFactory::_('Config')->component_code_name .
'/models/rules"';
$xml .= PHP_EOL . Indent::_(2)
. 'addfieldpath="/administrator/components/com_'
. CFactory::_('Config')->component_code_name .
'/models/fields"';
}
else
{
$xml .= PHP_EOL . Indent::_(3)
. 'addruleprefix="' .
CFactory::_('Config')->namespace_prefix
. '\Component\\' .
CFactory::_('Compiler.Builder.Content.One')->get('ComponentNamespace')
. '\Administrator\Rule"';
$xml .= PHP_EOL . Indent::_(3)
. 'addfieldprefix="' .
CFactory::_('Config')->namespace_prefix
. '\Component\\' .
CFactory::_('Compiler.Builder.Content.One')->get('ComponentNamespace')
. '\Administrator\Field">';
}
$xml .= PHP_EOL . Indent::_(1) . '>';
}
else
{
$xml .= PHP_EOL . Indent::_(1) . '<config>';
}
// add the fields
foreach ($module->config_fields as $field_name => $fieldsets)
{
$xml .= PHP_EOL . Indent::_(1) . '<fields name="' .
$field_name
. '">';
foreach ($fieldsets as $fieldset => $fields)
{
// default to the field set name
$label = $fieldset;
if (isset($module->fieldsets_label[$field_name . $fieldset]))
{
$label = $module->fieldsets_label[$field_name . $fieldset];
}
// add path to module rules and custom fields
if (isset($module->fieldsets_paths[$field_name . $fieldset])
&& ($module->fieldsets_paths[$field_name . $fieldset] ==
2
|| $module->fieldsets_paths[$field_name . $fieldset] == 3))
{
if ($module->target == 2)
{
if (!isset($module->add_rule_path[$field_name . $fieldset]))
{
$module->add_rule_path[$field_name . $fieldset] =
'/administrator/modules/'
. $module->file_name . '/rules';
}
if (!isset($module->add_field_path[$field_name . $fieldset]))
{
$module->add_field_path[$field_name . $fieldset] =
'/administrator/modules/'
. $module->file_name . '/fields';
}
}
else
{
if (!isset($module->add_rule_path[$field_name . $fieldset]))
{
$module->add_rule_path[$field_name . $fieldset] =
'/modules/' . $module->file_name
. '/rules';
}
if (!isset($module->add_field_path[$field_name . $fieldset]))
{
$module->add_field_path[$field_name . $fieldset] =
'/modules/' . $module->file_name
. '/fields';
}
}
}
// add path to module rules and custom fields
if (isset($module->add_rule_path[$field_name . $fieldset])
|| isset($module->add_field_path[$field_name . $fieldset]))
{
$xml .= PHP_EOL . Indent::_(1) . '<!--'
. Line::_(__Line__, __Class__) . ' default paths of '
. $fieldset . ' fieldset points to the module -->';
$xml .= PHP_EOL . Indent::_(1) . '<fieldset
name="'
. $fieldset . '" label="' . $label .
'"';
if (isset($module->add_rule_path[$field_name . $fieldset]))
{
$xml .= PHP_EOL . Indent::_(2)
. 'addrulepath="' .
$module->add_rule_path[$field_name . $fieldset] . '"';
}
if (isset($module->add_field_path[$field_name . $fieldset]))
{
$xml .= PHP_EOL . Indent::_(2)
. 'addfieldpath="' .
$module->add_field_path[$field_name . $fieldset] . '"';
}
$xml .= PHP_EOL . Indent::_(1) . '>';
}
else
{
$xml .= PHP_EOL . Indent::_(1) . '<fieldset
name="'
. $fieldset . '" label="' . $label .
'">';
}
// load the fields
if (isset($config_fields[$field_name . $fieldset]))
{
$xml .= $config_fields[$field_name . $fieldset];
unset($config_fields[$field_name . $fieldset]);
}
$xml .= PHP_EOL . Indent::_(1) . '</fieldset>';
}
$xml .= PHP_EOL . Indent::_(1) . '</fields>';
}
$xml .= PHP_EOL . Indent::_(1) . '</config>';
}
// set update server if found
if ($module->add_update_server)
{
$xml .= PHP_EOL . PHP_EOL . Indent::_(1) . '<!--' .
Line::_(
__LINE__,__CLASS__
) . ' Update servers -->';
$xml .= PHP_EOL . Indent::_(1) . '<updateservers>';
$xml .= PHP_EOL . Indent::_(2)
. '<server type="extension" priority="1"
name="'
. $module->official_name . '">' .
$module->update_server_url
. '</server>';
$xml .= PHP_EOL . Indent::_(1) . '</updateservers>';
}
return $xml;
}
/**
* get Plugin Main Class
*
* @param object $plugin The plugin object
*
* @return string The fields set in xml
* @deprecated 3.4
CFactory::_('Architecture.Plugin.Extension')->get(...);
*/
public function getPluginMainClass(&$plugin)
{
return
CFactory::_('Architecture.Plugin.Extension')->get($plugin);
}
/**
* get Plugin Main XML
*
* @param object $plugin The plugin object
*
* @return string The xml
* @deprecated 3.4
CFactory::_('Architecture.Plugin.MainXML')->get(...);
*/
public function getPluginMainXML(&$plugin)
{
return
CFactory::_('Architecture.Plugin.MainXML')->get($plugin);
}
/**
* get power code
*
* @param object $power
*
* @return string
* @deprecated 3.4 (line 393 private Compiler.Power.Infusion->code())
*/
public function getPowerCode(&$power)
{
$code = [];
// set the name space
$code[] = 'namespace ' . $power->_namespace . ';'
. PHP_EOL;
// check if we have header data
if (StringHelper::check($power->head))
{
$code[] = PHP_EOL . $power->head;
}
// add description if set
if (StringHelper::check($power->description))
{
// check if this is escaped
if (strpos((string) $power->description, '/*') === false)
{
// make this description escaped
$power->description = '/**' . PHP_EOL . ' * ' .
implode(PHP_EOL . ' * ', explode(PHP_EOL, (string)
$power->description)) . PHP_EOL . ' */';
}
$code[] = PHP_EOL . $power->description;
}
// build power declaration
$declaration = $power->type . ' ' . $power->class_name;
// check if we have extends
if (StringHelper::check($power->extends_name))
{
$declaration .= ' extends ' . $power->extends_name;
}
// check if we have implements
if (ArrayHelper::check($power->implement_names))
{
$declaration .= ' implements ' . implode(', ',
$power->implement_names);
}
$code[] = $declaration;
$code[] = '{';
// add the main code if set
if (StringHelper::check($power->main_class_code))
{
$code[] = $power->main_class_code;
}
$code[] = '}' . PHP_EOL . PHP_EOL;
return CFactory::_('Placeholder')->update(implode(PHP_EOL,
$code),
CFactory::_('Compiler.Builder.Content.One')->allActive());
}
/**
* build field set for an extention
*
* @param object $extension The extention object
* @param array $fields The fields to build
* @param string $dbkey The database key
*
* @return string The fields set in xml
* @deprecated 3.4
CFactory::_('Compiler.Creator.Access.Sections.Joomla.Fields')->get(...);
*/
public function getExtensionFieldsetXML(&$extension, &$fields,
$dbkey = 'zz'): string
{
// build the fieldset
return
CFactory::_('Compiler.Creator.Fieldset.Extension')->get($extension,
$fields, $dbkey);
}
/**
* check if a translation should be added
*
* @return bool
* @deprecated 3.4 Use
CFactory::_('Language.Translation')->check(...);
*/
public function shouldLanguageBeAdded(&$tag, &$languageStrings,
&$total, &$file_name)
{
return CFactory::_('Language.Translation')->check($tag,
$languageStrings, $total, $file_name);
}
}
src/Componentbuilder/Compiler/Helper/Structure.php000064400000052266151162054160016362
0ustar00<?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\Helper;
use Joomla\CMS\Filesystem\File;
use Joomla\CMS\Language\Text;
use VDM\Joomla\Utilities\ArrayHelper;
use VDM\Joomla\Utilities\GetHelper;
use VDM\Joomla\Utilities\FileHelper;
use VDM\Joomla\Componentbuilder\Compiler\Factory as CFactory;
use VDM\Joomla\Componentbuilder\Compiler\Helper\Get;
/**
* Structure class
*
* @deprecated 3.3
*/
class Structure extends Get
{
/**
* The folder counter
*
* @var int
* @deprecated 3.3 Use
CFactory::_('Utilities.Counter')->folder;
*/
public $folderCount = 0;
/**
* The file counter
*
* @var int
* @deprecated 3.3 Use
CFactory::_('Utilities.Counter')->file;
*/
public $fileCount = 0;
/**
* The page counter
*
* @var int
* @deprecated 3.3
*/
public $pageCount = 0;
/**
* The line counter
*
* @var int
* @deprecated 3.3 Use
CFactory::_('Utilities.Counter')->line;
*/
public $lineCount = 0;
/**
* The field counter
*
* @var int
* @deprecated 3.3
*/
public $fieldCount = 0;
/**
* The seconds counter
*
* @var int
* @deprecated 3.3
*/
public $seconds = 0;
/**
* The actual seconds counter
*
* @var int
* @deprecated 3.3
*/
public $actualSeconds = 0;
/**
* The folder seconds counter
*
* @var int
* @deprecated 3.3
*/
public $folderSeconds = 0;
/**
* The file seconds counter
*
* @var int
* @deprecated 3.3
*/
public $fileSeconds = 0;
/**
* The line seconds counter
*
* @var int
* @deprecated 3.3
*/
public $lineSeconds = 0;
/**
* The seconds debugging counter
*
* @var int
* @deprecated 3.3
*/
public $secondsDebugging = 0;
/**
* The seconds planning counter
*
* @var int
* @deprecated 3.3
*/
public $secondsPlanning = 0;
/**
* The seconds mapping counter
*
* @var int
* @deprecated 3.3
*/
public $secondsMapping = 0;
/**
* The seconds office counter
*
* @var int
* @deprecated 3.3
*/
public $secondsOffice = 0;
/**
* The total hours counter
*
* @var int
* @deprecated 3.3
*/
public $totalHours = 0;
/**
* The debugging hours counter
*
* @var int
* @deprecated 3.3
*/
public $debuggingHours = 0;
/**
* The planning hours counter
*
* @var int
* @deprecated 3.3
*/
public $planningHours = 0;
/**
* The mapping hours counter
*
* @var int
* @deprecated 3.3
*/
public $mappingHours = 0;
/**
* The office hours counter
*
* @var int
* @deprecated 3.3
*/
public $officeHours = 0;
/**
* The actual Total Hours counter
*
* @var int
* @deprecated 3.3
*/
public $actualTotalHours = 0;
/**
* The actual hours spent counter
*
* @var int
* @deprecated 3.3
*/
public $actualHoursSpent = 0;
/**
* The actual days spent counter
*
* @var int
* @deprecated 3.3
*/
public $actualDaysSpent = 0;
/**
* The total days counter
*
* @var int
* @deprecated 3.3
*/
public $totalDays = 0;
/**
* The actual Total Days counter
*
* @var int
* @deprecated 3.3
*/
public $actualTotalDays = 0;
/**
* The project week time counter
*
* @var int
* @deprecated 3.3
*/
public $projectWeekTime = 0;
/**
* The project month time counter
*
* @var int
* @deprecated 3.3
*/
public $projectMonthTime = 0;
/**
* The template path
*
* @var string
* @deprecated 3.3 Use
CFactory::_('Utilities.Paths')->template_path;
*/
public $templatePath;
/**
* The custom template path
*
* @var string
* @deprecated 3.3 Use
CFactory::_('Utilities.Paths')->template_path_custom;
*/
public $templatePathCustom;
/**
* The Joomla Version Data
*
* @var object
* @deprecated 3.3 Use CFactory::_('Component.Settings')
*/
public $joomlaVersionData;
/**
* Static File Content
*
* @var array
* @deprecated 3.3 Use
CFactory::_('Compiler.Builder.Content.One')->allActive()
*/
public $fileContentStatic = [];
/**
* Extention Custom Fields
*
* @var array
* @deprecated 3.3 Use
CFactory::_('Compiler.Builder.Extension.Custom.Fields')->get($key)
*/
public $extentionCustomfields = [];
/**
* Extention Tracking Files Moved
*
* @var array
*/
public $extentionTrackingFilesMoved = [];
/**
* The standard folders
*
* @var array
* @deprecated 3.3
*/
public $stdFolders = array('site', 'admin',
'media');
/**
* The standard root files
*
* @var array
* @deprecated 3.3
*/
public $stdRootFiles
= array('access.xml', 'config.xml',
'controller.php', 'index.html',
'README.txt');
/**
* Dynamic File Content
*
* @var array
* @deprecated 3.3 Use
CFactory::_('Compiler.Builder.Content.Multi')->allActive()
*/
public $fileContentDynamic = [];
/**
* The Component Sales name
*
* @var string
* @deprecated 3.3 Use
CFactory::_('Utilities.Paths')->component_sales_name;
*/
public $componentSalesName;
/**
* The Component Backup name
*
* @var string
* @deprecated 3.3 Use
CFactory::_('Utilities.Paths')->component_backup_name;
*/
public $componentBackupName;
/**
* The Component Folder name
*
* @var string
* @deprecated 3.3 Use
CFactory::_('Utilities.Paths')->component_folder_name;
*/
public $componentFolderName;
/**
* The Component path
*
* @var string
* @deprecated 3.3 Use
CFactory::_('Utilities.Paths')->component_path;
*/
public $componentPath;
/**
* The Dynamic paths
*
* @var array
* @deprecated 3.3 Use
CFactory::_('Registry')->get('dynamic_paths');
*/
public $dynamicPaths = [];
/**
* The not new static items
*
* @var array
* @deprecated 3.3 Use
CFactory::_('Registry')->get('files.not.new', []);
*/
public $notNew = [];
/**
* Update the file content
*
* @var array
* @deprecated 3.3 Use
CFactory::_('Registry')->get('update.file.content');
*/
public $updateFileContent = [];
/**
* The new files
*
* @var array
* @deprecated 3.3 Use CFactory::_('Utilities.Files');
*/
public $newFiles = [];
/**
* The Checkin Switch
*
* @var boolean
*/
public $addCheckin = false;
/**
* The Move Folders Switch
*
* @var boolean
*/
public $setMoveFolders = false;
/**
* The array of last modified dates
*
* @var array
* @deprecated 3.3
*/
protected $lastModifiedDate = [];
/**
* The default view switch
*
* @var bool/string
* @deprecated 3.3 Use
CFactory::_('Registry')->get('build.dashboard');
*/
public $dynamicDashboard = false;
/**
* The default view type
*
* @var string
* @deprecated 3.3 Use
CFactory::_('Registry')->get('build.dashboard.type');
*/
public $dynamicDashboardType;
/**
* Constructor
*/
public function __construct()
{
// first we run the parent constructor
if (parent::__construct())
{
// set incase no extra admin folder are loaded
CFactory::_('Compiler.Builder.Content.One')->set('EXSTRA_ADMIN_FOLDERS',
'');
// set incase no extra site folder are loaded
CFactory::_('Compiler.Builder.Content.One')->set('EXSTRA_SITE_FOLDERS',
'');
// set incase no extra media folder are loaded
CFactory::_('Compiler.Builder.Content.One')->set('EXSTRA_MEDIA_FOLDERS',
'');
// set incase no extra admin files are loaded
CFactory::_('Compiler.Builder.Content.One')->set('EXSTRA_ADMIN_FILES',
'');
// set incase no extra site files are loaded
CFactory::_('Compiler.Builder.Content.One')->set('EXSTRA_SITE_FILES',
'');
// set incase no extra media files are loaded
CFactory::_('Compiler.Builder.Content.One')->set('EXSTRA_MEDIA_FILES',
'');
// make sure there is no old build
CFactory::_('Utilities.Folder')->remove(CFactory::_('Utilities.Paths')->component_path);
// load the libraries files/folders and url's
CFactory::_('Library.Structure')->build();
// load the powers files/folders
CFactory::_('Power.Structure')->build();
// load the module files/folders and url's
CFactory::_('Joomlamodule.Structure')->build();
// load the plugin files/folders and url's
CFactory::_('Joomlaplugin.Structure')->build();
// set the dashboard
CFactory::_('Component.Dashboard')->set();
// set the component base structure
if (!CFactory::_('Component.Structure')->build())
{
return false;
}
// set all single instance folders and files
if (!CFactory::_('Component.Structure.Single')->build())
{
return false;
}
// set all the dynamic folders and files
if (!CFactory::_('Component.Structure.Multiple')->build())
{
return false;
}
return true;
}
return false;
}
/**
* Build the Powers files, folders
*
* @return void
* @deprecated 3.3 Use
CFactory::_('Power.Structure')->build();
*/
private function buildPowers()
{
// set notice that we could not get a valid string from the target
$this->app->enqueueMessage(
Text::sprintf('COM_COMPONENTBUILDER_HR_HTHREES_WARNINGHTHREE',
__CLASS__), 'Error'
);
$this->app->enqueueMessage(
Text::sprintf(
'Use of a deprecated method (%s)!', __METHOD__
), 'Error'
);
}
/**
* Build the Modules files, folders, url's and config
*
* @return void
* @deprecated 3.3 Use
CFactory::_('Joomlamodule.Structure')->build();
*/
private function buildModules()
{
// set notice that we could not get a valid string from the target
$this->app->enqueueMessage(
Text::sprintf('COM_COMPONENTBUILDER_HR_HTHREES_WARNINGHTHREE',
__CLASS__), 'Error'
);
$this->app->enqueueMessage(
Text::sprintf(
'Use of a deprecated method (%s)!', __METHOD__
), 'Error'
);
}
/**
* Build the Plugins files, folders, url's and config
*
* @return void
* @deprecated 3.3 Use
CFactory::_('Joomlaplugin.Structure')->build();
*/
private function buildPlugins()
{
// set notice that we could not get a valid string from the target
$this->app->enqueueMessage(
Text::sprintf('COM_COMPONENTBUILDER_HR_HTHREES_WARNINGHTHREE',
__CLASS__), 'Error'
);
$this->app->enqueueMessage(
Text::sprintf(
'Use of a deprecated method (%s)!', __METHOD__
), 'Error'
);
}
/**
* Create Path if not exist
*
* @return void
* @deprecated 3.3 Use
CFactory::_('Utilities.Folder')->create($path);
*/
private function createFolder($path)
{
// set notice that we could not get a valid string from the target
$this->app->enqueueMessage(
Text::sprintf('COM_COMPONENTBUILDER_HR_HTHREES_WARNINGHTHREE',
__CLASS__), 'Error'
);
$this->app->enqueueMessage(
Text::sprintf(
'Use of a deprecated method (%s)!', __METHOD__
), 'Error'
);
}
/**
* Build the Libraries files, folders, url's and config
*
* @return void
* @deprecated 3.3 Use
CFactory::_('Library.Structure')->build();
*/
private function setLibraries()
{
// set notice that we could not get a valid string from the target
$this->app->enqueueMessage(
Text::sprintf('COM_COMPONENTBUILDER_HR_HTHREES_WARNINGHTHREE',
__CLASS__), 'Error'
);
$this->app->enqueueMessage(
Text::sprintf(
'Use of a deprecated method (%s)!', __METHOD__
), 'Error'
);
}
/**
* set the dynamic dashboard if set
*
* @return void
* @deprecated 3.3 Use
CFactory::_('Component.Dashboard')->set();
*/
private function setDynamicDashboard()
{
// set notice that we could not get a valid string from the target
$this->app->enqueueMessage(
Text::sprintf('COM_COMPONENTBUILDER_HR_HTHREES_WARNINGHTHREE',
__CLASS__), 'Error'
);
$this->app->enqueueMessage(
Text::sprintf(
'Use of a deprecated method (%s)!', __METHOD__
), 'Error'
);
}
/**
* Write data to file
*
* @return bool true on success
* @deprecated 3.3
*/
public function writeFile($path, $data)
{
return FileHelper::write($path, $data);
}
/**
* Build the Initial Folders
*
* @return void
* @deprecated 3.3 Use
CFactory::_('Component.Structure')->build();
*/
private function setFolders()
{
// set notice that we could not get a valid string from the target
$this->app->enqueueMessage(
Text::sprintf('COM_COMPONENTBUILDER_HR_HTHREES_WARNINGHTHREE',
__CLASS__), 'Error'
);
$this->app->enqueueMessage(
Text::sprintf(
'Use of a deprecated method (%s)!', __METHOD__
), 'Error'
);
}
/**
* Set the Static File & Folder
*
* @return boolean
* @deprecated 3.3 Use
CFactory::_('Component.Structure.Single')->build();
*/
private function setStatic()
{
// set notice that we could not get a valid string from the target
$this->app->enqueueMessage(
Text::sprintf('COM_COMPONENTBUILDER_HR_HTHREES_WARNINGHTHREE',
__CLASS__), 'Error'
);
$this->app->enqueueMessage(
Text::sprintf(
'Use of a deprecated method (%s)!', __METHOD__
), 'Error'
);
}
/**
* Set the Dynamic File & Folder
*
* @return boolean
* @deprecated 3.3 Use
CFactory::_('Component.Structure.Multiple')->build();
*/
private function setDynamique()
{
// set notice that we could not get a valid string from the target
$this->app->enqueueMessage(
Text::sprintf('COM_COMPONENTBUILDER_HR_HTHREES_WARNINGHTHREE',
__CLASS__), 'Error'
);
$this->app->enqueueMessage(
Text::sprintf(
'Use of a deprecated method (%s)!', __METHOD__
), 'Error'
);
return false;
}
/**
* move the fields and Rules
*
* @param array $field The field data
* @param string $path The path to move to
*
* @return void
*
*/
public function moveFieldsRules($field, $path)
{
// check if we have a subform or repeatable field
if ($field['type_name'] === 'subform'
|| $field['type_name'] === 'repeatable')
{
// since we could have a custom field or rule inside
$this->moveMultiFieldsRules($field, $path);
}
else
{
// check if this is a custom field that should be moved
if
(CFactory::_('Compiler.Builder.Extension.Custom.Fields')->exists($field['type_name']))
{
$check = md5($path . 'type' .
$field['type_name']);
// lets check if we already moved this
if (CFactory::_('Config')->get('joomla_version',
3) == 3 &&
!isset($this->extentionTrackingFilesMoved[$check]))
{
// check files exist
if (File::exists(
CFactory::_('Utilities.Paths')->component_path .
'/admin/models/fields/'
. $field['type_name'] . '.php'
))
{
// copy the custom field
File::copy(
CFactory::_('Utilities.Paths')->component_path .
'/admin/models/fields/'
. $field['type_name'] . '.php',
$path . '/fields/' . $field['type_name'] .
'.php'
);
}
// stop from doing this again.
$this->extentionTrackingFilesMoved[$check] = true;
}
}
// check if this has validation that should be moved
if
(CFactory::_('Registry')->get('validation.linked.' .
$field['field']) !== null)
{
$check = md5(
$path . 'rule'
.
CFactory::_('Registry')->get('validation.linked.' .
$field['field'])
);
// lets check if we already moved this
if (CFactory::_('Config')->get('joomla_version',
3) == 3 &&
!isset($this->extentionTrackingFilesMoved[$check]))
{
// check files exist
if (File::exists(
CFactory::_('Utilities.Paths')->component_path .
'/admin/models/rules/'
.
CFactory::_('Registry')->get('validation.linked.' .
$field['field'])
. '.php'
))
{
// copy the custom field
File::copy(
CFactory::_('Utilities.Paths')->component_path .
'/admin/models/rules/'
.
CFactory::_('Registry')->get('validation.linked.' .
$field['field'])
. '.php', $path . '/rules/'
.
CFactory::_('Registry')->get('validation.linked.' .
$field['field'])
. '.php'
);
}
// stop from doing this again.
$this->extentionTrackingFilesMoved[$check] = true;
}
}
}
}
/**
* move the fields and Rules of multi fields
*
* @param array $multi_field The field data
* @param string $path The path to move to
*
* @return void
*
*/
protected function moveMultiFieldsRules($multi_field, $path)
{
// get the fields ids
$ids = array_map(
'trim',
explode(
',',
(string) GetHelper::between(
$multi_field['settings']->xml, 'fields="',
'"'
)
)
);
if (ArrayHelper::check($ids))
{
foreach ($ids as $id)
{
// setup the field
$field = [];
$field['field'] = $id;
CFactory::_('Field')->set($field);
// move field and rules if needed
$this->moveFieldsRules($field, $path);
}
}
}
/**
* get the created date of the (view)
*
* @param array $view The view values
*
* @return string Last Modified Date
* @deprecated 3.3 Use
CFactory::_('Model.Createdate')->get($view);
*/
public function getCreatedDate($view)
{
return CFactory::_('Model.Createdate')->get($view);
}
/**
* get the last modified date of a MVC (view)
*
* @param array $view The view values
*
* @return string Last Modified Date
* @deprecated 3.3 Use
CFactory::_('Model.Modifieddate')->get($view);
*/
public function getLastModifiedDate($view)
{
return CFactory::_('Model.Modifieddate')->get($view);
}
/**
* Set the Static File & Folder
*
* @param array $target The main target and name
* @param string $type The type in the target
* @param string $fileName The custom file name
* @param array $cofig to add more data to the files info
*
* @return boolean
* @deprecated 3.3 Use
CFactory::_('Utilities.Structure')->build($target, $type,
$fileName, $config);
*/
public function buildDynamique($target, $type, $fileName = null, $config =
null)
{
return CFactory::_('Utilities.Structure')->build($target,
$type, $fileName, $config);
}
/**
* set the Joomla Version Data
*
* @return object The version data
* @deprecated 3.3
*/
private function setJoomlaVersionData()
{
// set notice that we could not get a valid string from the target
$this->app->enqueueMessage(
Text::sprintf('COM_COMPONENTBUILDER_HR_HTHREES_WARNINGHTHREE',
__CLASS__), 'Error'
);
$this->app->enqueueMessage(
Text::sprintf(
'Use of a deprecated method (%s)!', __METHOD__
), 'Error'
);
}
/**
* Add the dynamic folders
*/
protected function setDynamicFolders()
{
// check if we should add the dynamic folder moving script to the
installer script
if
(!CFactory::_('Registry')->get('set_move_folders_install_script'))
{
// add the setDynamicF0ld3rs() method to the install scipt.php file
CFactory::_('Registry')->set('set_move_folders_install_script',
true);
// set message that this was done (will still add a tutorial link
later)
$this->app->enqueueMessage(
Text::_(
'<hr /><h3>Dynamic folder(s) were
detected.</h3>'
), 'Notice'
);
$_function = 'setDynamicF0ld3rs';
$_script = 'script.php';
if (CFactory::_('Config')->get('joomla_version',
3) != 3)
{
$_function = 'moveFolders';
$_script = 'ComponentnameInstallerScript.php';
}
$this->app->enqueueMessage(
Text::sprintf(
'A method (%s) was added to the install <b>%s</b> of
this package to insure that the folder(s) are copied into the correct place
when this component is installed!',
$_function, $_script
), 'Notice'
);
}
}
/**
* set the index.html file in a folder path
*
* @param string $path The path to place the index.html file in
*
* @return void
* @deprecated 3.3 Use
CFactory::_('Utilities.File')->write($path, $root);
*
*/
private function indexHTML($path, $root = 'component')
{
CFactory::_('Utilities.File')->write($path, $root);
}
/**
* Update paths with real value
*
* @param string $path The full path
*
* @return string The updated path
* @deprecated 3.3 Use
CFactory::_('Utilities.Dynamicpath')->update($path);
*/
protected function updateDynamicPath($path)
{
return CFactory::_('Utilities.Dynamicpath')->update($path);
}
/**
* Remove folders with files
*
* @param string $dir The path to folder to remove
* @param boolean $ignore The files and folders to ignore
*
* @return boolean True if all is removed
* @deprecated 3.3 Use
CFactory::_('Utilities.Folder')->remove($dir, $ignore);
*/
protected function removeFolder($dir, $ignore = false)
{
return CFactory::_('Utilities.Folder')->remove($dir,
$ignore);
}
}
src/Componentbuilder/Compiler/Helper/index.html000064400000000054151162054160015632
0ustar00<html><body
bgcolor="#FFFFFF"></body></html>src/Componentbuilder/Compiler/Interfaces/Architecture/ComHelperClass/CreateUserInterface.php000064400000002424151162054160026366
0ustar00<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder
<https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights
reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
namespace
VDM\Joomla\Componentbuilder\Compiler\Interfaces\Architecture\ComHelperClass;
/**
* Component Helper Class Create User Interface
*
* @since 5.0.2
*/
interface CreateUserInterface
{
/**
* Generates the method definition for creating or updating a user based
on the provided parameters.
*
* This method returns a string representation of a PHP function that
includes various
* steps for handling user creation and updates, depending on the mode
(site registration or admin registration).
*
* @param $add Determines whether to generate the user creation
method or not.
* If true, the method will be generated and returned
as a string.
*
* @return string The generated method code as a string if $add is true.
* Returns an empty string if $add is false.
*/
public function get($add): string;
}
src/Componentbuilder/Compiler/Interfaces/Architecture/ComHelperClass/index.html000064400000000054151162054160023764
0ustar00<html><body
bgcolor="#FFFFFF"></body></html>src/Componentbuilder/Compiler/Interfaces/Architecture/Controller/AllowAddInterface.php000064400000001505151162054160025271
0ustar00<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder
<https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights
reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
namespace
VDM\Joomla\Componentbuilder\Compiler\Interfaces\Architecture\Controller;
/**
* Controller Allow Add Interface
*
* @since 3.2.0
*/
interface AllowAddInterface
{
/**
* 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;
}
src/Componentbuilder/Compiler/Interfaces/Architecture/Controller/AllowEditInterface.php000064400000001645151162054160025473
0ustar00<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder
<https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights
reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
namespace
VDM\Joomla\Componentbuilder\Compiler\Interfaces\Architecture\Controller;
/**
* Controller Allow Edit Interface
*
* @since 3.2.0
*/
interface AllowEditInterface
{
/**
* 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;
}
src/Componentbuilder/Compiler/Interfaces/Architecture/Controller/AllowEditViewsInterface.php000064400000001743151162054160026510
0ustar00<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder
<https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights
reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
namespace
VDM\Joomla\Componentbuilder\Compiler\Interfaces\Architecture\Controller;
/**
* Controller Allow Edit Views Interface
*
* @since 5.0.2
*/
interface AllowEditViewsInterface
{
/**
* Get Array Code
*
* @param array $views
*
* @since 5.0.2
* @return string The array of Code (string)
*/
public function getArray(array $views): string;
/**
* Get Custom Function Code
*
* @param array $views
*
* @since 5.0.2
* @return string The functions of Code (string)
*/
public function getFunctions(array $views): string;
}
src/Componentbuilder/Compiler/Interfaces/Architecture/Controller/index.html000064400000000054151162054160023243
0ustar00<html><body
bgcolor="#FFFFFF"></body></html>src/Componentbuilder/Compiler/Interfaces/Architecture/Model/CanDeleteInterface.php000064400000001477151162054160024353
0ustar00<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder
<https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights
reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
namespace
VDM\Joomla\Componentbuilder\Compiler\Interfaces\Architecture\Model;
/**
* Model Can Delete Interface
*
* @since 3.2.0
*/
interface CanDeleteInterface
{
/**
* 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;
}
src/Componentbuilder/Compiler/Interfaces/Architecture/Model/CanEditStateInterface.php000064400000001516151162054160025031
0ustar00<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder
<https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights
reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
namespace
VDM\Joomla\Componentbuilder\Compiler\Interfaces\Architecture\Model;
/**
* Model Can Edit State Interface
*
* @since 3.2.0
*/
interface CanEditStateInterface
{
/**
* 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;
}
src/Componentbuilder/Compiler/Interfaces/Architecture/Model/index.html000064400000000054151162054160022160
0ustar00<html><body
bgcolor="#FFFFFF"></body></html>src/Componentbuilder/Compiler/Interfaces/Architecture/Plugin/ExtensionInterface.php000064400000001546151162054160024676
0ustar00<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder
<https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights
reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
namespace
VDM\Joomla\Componentbuilder\Compiler\Interfaces\Architecture\Plugin;
/**
* Plugin Extension Interface
*
* @since 5.0.2
*/
interface ExtensionInterface
{
/**
* Get the updated placeholder content for the given plugin.
*
* @param object $plugin The plugin object containing the necessary
data.
*
* @return string The updated placeholder content.
*
* @since 5.0.2
*/
public function get(object $plugin): string;
}
src/Componentbuilder/Compiler/Interfaces/Architecture/Plugin/ProviderInterface.php000064400000001544151162054160024512
0ustar00<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder
<https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights
reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
namespace
VDM\Joomla\Componentbuilder\Compiler\Interfaces\Architecture\Plugin;
/**
* Plugin Provider Interface
*
* @since 5.0.2
*/
interface ProviderInterface
{
/**
* Get the updated placeholder content for the given plugin.
*
* @param object $plugin The plugin object containing the necessary
data.
*
* @return string The updated placeholder content.
*
* @since 5.0.2
*/
public function get(object $plugin): string;
}
src/Componentbuilder/Compiler/Interfaces/Architecture/Plugin/index.html000064400000000054151162054160022356
0ustar00<html><body
bgcolor="#FFFFFF"></body></html>src/Componentbuilder/Compiler/Interfaces/Component/PlaceholderInterface.php000064400000001327151162054160023223
0ustar00<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder
<https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights
reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
namespace VDM\Joomla\Componentbuilder\Compiler\Interfaces\Component;
/**
* Component Placeholder Interface
*
* @since 3.2.0
*/
interface PlaceholderInterface
{
/**
* get all System Placeholders
*
* @return array The global placeholders
*
* @since 3.2.0
*/
public function get(): array;
}
src/Componentbuilder/Compiler/Interfaces/Component/SettingsInterface.php000064400000003230151162054160022574
0ustar00<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder
<https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights
reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
namespace VDM\Joomla\Componentbuilder\Compiler\Interfaces\Component;
/**
* Compiler Component Settings Interface
*
* @since 3.2.0
*/
interface SettingsInterface
{
/**
* Check if data set is loaded
*
* @return bool
* @since 3.2.0
*/
public function exists(): bool;
/**
* Get Joomla - Folder Structure to Create
*
* @return object The version related structure
* @since 3.2.0
*/
public function structure(): object;
/**
* Get Joomla - Move Multiple Structure
*
* @return object The version related multiple structure
* @since 3.2.0
*/
public function multiple(): object;
/**
* Get Joomla - Move Single Structure
*
* @return object The version related single structure
* @since 3.2.0
*/
public function single(): object;
/**
* 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;
/**
* 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;
}
src/Componentbuilder/Compiler/Interfaces/Component/index.html000064400000000054151162054160020440
0ustar00<html><body
bgcolor="#FFFFFF"></body></html>src/Componentbuilder/Compiler/Interfaces/Creator/Fielddynamicinterface.php000064400000002717151162054160023072
0ustar00<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder
<https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights
reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
namespace VDM\Joomla\Componentbuilder\Compiler\Interfaces\Creator;
/**
* Field Creator Interface (needed for the container)
*
* @since 3.2.0
*/
interface Fielddynamicinterface
{
/**
* Get the Dynamic field and build all it needs
*
* @param array $field The field data
* @param array $view The view data
* @param int $viewType The view type
* @param string $langView The language string of the view
* @param string $nameSingleCode The single view name
* @param string $nameListCode The list view name
* @param array $placeholders The place holder and replace values
* @param string $dbkey The the custom table key
* @param boolean $build The switch to set the build option
*
* @return mixed The complete field
* @since 3.2.0
*/
public function get(array &$field, array &$view, int
&$viewType, string &$langView, string &$nameSingleCode,
string &$nameListCode, array &$placeholders, string &$dbkey,
bool $build);
}
src/Componentbuilder/Compiler/Interfaces/Creator/Fieldsetinterface.php000064400000002021151162054160022225
0ustar00<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder
<https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights
reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
namespace VDM\Joomla\Componentbuilder\Compiler\Interfaces\Creator;
/**
* Fieldset Creator Interface (needed for the container)
*
* @since 3.2.0
*/
interface Fieldsetinterface
{
/**
* Get a fieldset
*
* @param array $view The view data
* @param string $component The component name
* @param string $nameSingleCode The single view name
* @param string $nameListCode The list view name
*
* @return string The fields set as a string
* @since 3.2.0
*/
public function get(array $view, string $component, string
$nameSingleCode, string $nameListCode): string;
}
src/Componentbuilder/Compiler/Interfaces/Creator/Fieldtypeinterface.php000064400000003540151162054160022422
0ustar00<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder
<https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights
reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
namespace VDM\Joomla\Componentbuilder\Compiler\Interfaces\Creator;
/**
* Field (Types) Creator Interface (needed for the container)
*
* @since 3.2.0
*/
interface Fieldtypeinterface
{
/**
* Create a field
*
* @param string $setType The set of fields type
* @param array $fieldAttributes The field values
* @param string $name The field name
* @param string $typeName The field type
* @param string $langView The language string of the view
* @param string $nameSingleCode The single view name
* @param string $nameListCode The list view name
* @param array $placeholders The place holder and replace
values
* @param array|null $optionArray The option bucket array used to
set the field options if needed.
* @param array|null $custom Used when field is from config
* @param array|null $custom Used when field is from config
* @param string $taber The tabs to add in layout
*
* @return mixed The field (two return types based of
field_builder_type selected Object->xml or String)
* @since 3.2.0
*/
public function get(string $setType, array &$fieldAttributes, string
&$name,
string &$typeName, string &$langView, string
&$nameSingleCode, string &$nameListCode,
array $placeholders, ?array &$optionArray, ?array $custom = null,
string $taber = '');
}
src/Componentbuilder/Compiler/Interfaces/Creator/index.html000064400000000054151162054160020075
0ustar00<html><body
bgcolor="#FFFFFF"></body></html>src/Componentbuilder/Compiler/Interfaces/Customcode/DispenserInterface.php000064400000004677151162054160023113
0ustar00<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder
<https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights
reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
namespace VDM\Joomla\Componentbuilder\Compiler\Interfaces\Customcode;
/**
* Customcode Dispenser Interface
*
* @since 3.2.0
*/
interface DispenserInterface
{
/**
* Set the script for the customcode dispenser
*
* @param string $script The script
* @param string $first The first key
* @param string|null $second The second key (if not set we use only
first key)
* @param string|null $third The third key (if not set we use only
first and second key)
* @param array $config The config options
* @param bool $base64 The switch to decode base64 the script
* default: true
* @param bool $dynamic The switch to dynamic update the
script
* default: true
* @param bool $add The switch to add to exiting instead of
replace
* default: false
*
* @return bool true on success
* @since 3.2.0
*/
public function set(&$script, string $first, ?string $second = null,
?string $third = null,
array $config = [], bool $base64 = true, bool $dynamic = true, bool $add
= false): bool;
/**
* Get the script from the customcode dispenser
*
* @param string $first The first key
* @param string $second The second key
* @param string $prefix The prefix to add in front of the script
if found
* @param string|null $note The switch/note to add to the script
* @param bool $unset The switch to unset the value if found
* @param mixed|null $default The switch/string to use as default
return if script not found
* @param string $suffix The suffix to add after the script if
found
*
* @return mixed The string/script if found or the default value if not
found
*
* @since 3.2.0
*/
public function get(string $first, string $second, string $prefix =
'', ?string $note = null,
bool $unset = false, $default = null, string $suffix =
'');
}
src/Componentbuilder/Compiler/Interfaces/Customcode/ExternalInterface.php000064400000001545151162054160022730
0ustar00<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder
<https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights
reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
namespace VDM\Joomla\Componentbuilder\Compiler\Interfaces\Customcode;
/**
* Customcode External Interface
*
* @since 3.2.0
*/
interface ExternalInterface
{
/**
* Set the external code string & load it in to string
*
* @param string $string The content to check
* @param int $debug The switch to debug the update
*
* @return string
* @since 3.2.0
*/
public function set(string $string, int $debug = 0): string;
}
src/Componentbuilder/Compiler/Interfaces/Customcode/ExtractorInterface.php000064400000001275151162054160023121
0ustar00<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder
<https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights
reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
namespace VDM\Joomla\Componentbuilder\Compiler\Interfaces\Customcode;
/**
* Customcode Extractor Interface
*
* @since 3.2.0
*/
interface ExtractorInterface
{
/**
* get the custom code from the local files
*
* @return void
* @since 3.2.0
*/
public function run();
}
src/Componentbuilder/Compiler/Interfaces/Customcode/GuiInterface.php000064400000002445151162054160021672
0ustar00<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder
<https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights
reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
namespace VDM\Joomla\Componentbuilder\Compiler\Interfaces\Customcode;
/**
* Customcode Gui Interface
*
* @since 3.2.0
*/
interface GuiInterface
{
/**
* Set the JCB GUI code placeholder
*
* @param string $string The code string
* @param array $config The placeholder config values
*
* @return string
* @since 3.2.0
*/
public function set(string $string, array $config): string;
/**
* search a file for gui code blocks that were updated in the IDE
*
* @param string $file The file path to search
* @param array $placeholders The values to replace in the code being
stored
* @param string $today The date for today
* @param string $target The target path type
*
* @return void
* @since 3.2.0
*/
public function search(string &$file, array &$placeholders, string
&$today, string &$target);
}
src/Componentbuilder/Compiler/Interfaces/Customcode/LockBaseInterface.php000064400000001375151162054160022632
0ustar00<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder
<https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights
reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
namespace VDM\Joomla\Componentbuilder\Compiler\Interfaces\Customcode;
/**
* Customcode LockBase Interface
*
* @since 3.2.0
*/
interface LockBaseInterface
{
/**
* Set a string as bsae64 (basic)
*
* @param string $script The code string
*
* @return string
* @since 3.2.0
*/
public function set(string $script): string;
}
src/Componentbuilder/Compiler/Interfaces/Customcode/index.html000064400000000054151162054160020603
0ustar00<html><body
bgcolor="#FFFFFF"></body></html>src/Componentbuilder/Compiler/Interfaces/CustomcodeInterface.php000064400000003346151162054160021147
0ustar00<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder
<https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights
reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
namespace VDM\Joomla\Componentbuilder\Compiler\Interfaces;
/**
* Compiler Customcode Interface
*
* @since 3.2.0
*/
interface CustomcodeInterface
{
/**
* Update **ALL** dynamic values in a strings here
*
* @param string $string The content to check
* @param int $debug The switch to debug the update
* We can now at any time debug the
* dynamic build values if it gets broken
*
* @return string
* @since 3.2.0
*/
public function update(string $string, int $debug = 0): string;
/**
* Set the custom code data & can load it in to string
*
* @param string $string The content to check
* @param int $debug The switch to debug the update
* @param int|null $not The not switch
*
* @return string
* @since 3.2.0
*/
public function set(string $string, int $debug = 0, ?int $not = null):
string;
/**
* Load the custom code from the system
*
* @param array|null $ids The custom code ides if known
* @param bool $setLang The set lang switch
* @param int $debug The switch to debug the update
*
* @return bool
* @since 3.2.0
*/
public function get(?array $ids = null, bool $setLang = true, $debug = 0):
bool;
}
src/Componentbuilder/Compiler/Interfaces/EventInterface.php000064400000001455151162054160020122
0ustar00<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder
<https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights
reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
namespace VDM\Joomla\Componentbuilder\Compiler\Interfaces;
/**
* Compiler Events Interface
*
* @since 3.2.0
*/
interface EventInterface
{
/**
* Trigger an event
*
* @param string $event The event to trigger
* @param mixed $data The values to pass to the event/plugin
*
* @return void
* @since 3.2.0
*/
public function trigger(string $event, $data = null);
}
src/Componentbuilder/Compiler/Interfaces/Extension/InstallInterface.php000064400000002024151162054160022414
0ustar00<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder
<https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights
reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
namespace VDM\Joomla\Componentbuilder\Compiler\Interfaces\Extension;
/**
* The properties an extension should have to be passed to the
InstallScript class
*
* @since 3.2.0
*/
interface InstallInterface
{
/**
* The extension official name
*
* @return string
* @since 3.2.0
*/
public function getOfficialName(): string;
/**
* The extension class name
*
* @return string
* @since 3.2.0
*/
public function getClassName(): string;
/**
* The extension installer class name
*
* @return string
* @since 3.2.0
*/
public function getInstallerClassName(): string;
}
src/Componentbuilder/Compiler/Interfaces/Extension/index.html000064400000000054151162054160020452
0ustar00<html><body
bgcolor="#FFFFFF"></body></html>src/Componentbuilder/Compiler/Interfaces/Field/CoreFieldInterface.php000064400000001437151162054160021720
0ustar00<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder
<https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights
reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
namespace VDM\Joomla\Componentbuilder\Compiler\Interfaces\Field;
/**
* Field Joomla Core Field Interface
*
* @since 3.2.0
*/
interface CoreFieldInterface
{
/**
* Get the Array of Existing Core Field Names
*
* @param bool $lowercase Switch to set field lowercase
*
* @return array
* @since 3.2.0
*/
public function get(bool $lowercase = false): array;
}
src/Componentbuilder/Compiler/Interfaces/Field/CoreRuleInterface.php000064400000001434151162054160021601
0ustar00<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder
<https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights
reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
namespace VDM\Joomla\Componentbuilder\Compiler\Interfaces\Field;
/**
* Field Joomla Core Rule Interface
*
* @since 3.2.0
*/
interface CoreRuleInterface
{
/**
* Get the Array of Existing Core Rule Names
*
* @param bool $lowercase Switch to set rules lowercase
*
* @return array
* @since 3.2.0
*/
public function get(bool $lowercase = false): array;
}
src/Componentbuilder/Compiler/Interfaces/Field/InputButtonInterface.php000064400000001514151162054160022353
0ustar00<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder
<https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights
reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
namespace VDM\Joomla\Componentbuilder\Compiler\Interfaces\Field;
/**
* Compiler Field Input Button
*
* @since 3.2.0
*/
interface InputButtonInterface
{
/**
* 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;
}
src/Componentbuilder/Compiler/Interfaces/Field/index.html000064400000000054151162054160017521
0ustar00<html><body
bgcolor="#FFFFFF"></body></html>src/Componentbuilder/Compiler/Interfaces/GetScriptInterface.php000064400000001366151162054160020746
0ustar00<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder
<https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights
reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
namespace VDM\Joomla\Componentbuilder\Compiler\Interfaces;
/**
* The functions a get script should have
*
* @since 3.2.0
*/
interface GetScriptInterface
{
/**
* get code to use
*
* @param Object $code The code object
*
* @return string
* @since 3.2.0
*/
public function get(object $extension): string;
}
src/Componentbuilder/Compiler/Interfaces/HeaderInterface.php000064400000001605151162054160020226
0ustar00<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder
<https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights
reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
namespace VDM\Joomla\Componentbuilder\Compiler\Interfaces;
/**
* Compiler Header Interface
*
* @since 3.2.0
*/
interface HeaderInterface
{
/**
* Get the headers for a file
*
* @param string $context The name of the context
* @param string $codeName The view, views, or layout code name
*
* @return string The header string to place in the header of the file
* @since 3.2.0
*/
public function get(string $context, string $codeName): string;
}
src/Componentbuilder/Compiler/Interfaces/HistoryInterface.php000064400000001465151162054160020503
0ustar00<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder
<https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights
reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
namespace VDM\Joomla\Componentbuilder\Compiler\Interfaces;
/**
* Compiler History Interface
*
* @since 3.2.0
*/
interface HistoryInterface
{
/**
* Get Item History object
*
* @param string $type The type of item
* @param int $id The item ID
*
* @return ?object The history item object
* @since 3.2.0
*/
public function get(string $type, int $id): ?object;
}
src/Componentbuilder/Compiler/Interfaces/LanguageInterface.php000064400000004665151162054160020572
0ustar00<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder
<https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights
reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
namespace VDM\Joomla\Componentbuilder\Compiler\Interfaces;
/**
* Compiler Language Interface
*
* @since 3.2.0
*/
interface LanguageInterface
{
/**
* Get the language string key
*
* @param string $string The plan text string (English)
*
* @return string The key language string (all uppercase)
* @since 3.2.0
*/
public function key($string): string;
/**
* check if the language string exist
*
* @param string $target The target area for the language string
* @param string|null $language The language key string
*
* @return bool
* @since 3.2.0
*/
public function exist(string $target, ?string $language = null): bool;
/**
* get the language string
*
* @param string $target The target area for the language string
* @param string|null $language The language key string
*
* @return Mixed The language string found or empty string if none is
found
* @since 3.2.0
*/
public function get(string $target, string $language): string;
/**
* get target array
*
* @param string $target The target area for the language string
*
* @return array The target array or empty array if none is found
* @since 3.2.0
*/
public function getTarget(string $target): array;
/**
* set target array
*
* @param string $target The target area for the language string
* @param array|null $content The language content string
*
* @return void
* @since 3.2.0
*/
public function setTarget(string $target, ?array $content);
/**
* set the language content values to language content array
*
* @param string $target The target area for the language string
* @param string $language The language key string
* @param string $string The language string
* @param bool $addPrefix The switch to add langPrefix
*
* @return void
* @since 3.2.0
*/
public function set(string $target, string $language, string $string, bool
$addPrefix = false);
}
src/Componentbuilder/Compiler/Interfaces/Model/CustomtabsInterface.php000064400000001332151162054160022217
0ustar00<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder
<https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights
reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
namespace VDM\Joomla\Componentbuilder\Compiler\Interfaces\Model;
/**
* Model Custom Tabs Interface
*
* @since 3.2.0
*/
interface CustomtabsInterface
{
/**
* Set custom tabs
*
* @param object $item The view data
*
* @return void
* @since 3.2.0
*/
public function set(object &$item);
}
src/Componentbuilder/Compiler/Interfaces/Model/index.html000064400000000054151162054160017536
0ustar00<html><body
bgcolor="#FFFFFF"></body></html>src/Componentbuilder/Compiler/Interfaces/PlaceholderInterface.php000064400000012416151162054160021262
0ustar00<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder
<https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights
reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
namespace VDM\Joomla\Componentbuilder\Compiler\Interfaces;
/**
* Compiler Placeholder Interface
*
* @since 3.2.0
*/
interface PlaceholderInterface
{
/**
* Set content
*
* @param string $key The main string key
* @param mixed $value The values to set
* @param bool $hash Add the hash around the key
*
* @return void
* @since 3.2.0
*/
public function set(string $key, $value, bool $hash = true);
/**
* Get content by key
*
* @param string $key The main string key
*
* @return mixed
* @since 3.2.0
*/
public function get(string $key);
/**
* Does key exist at all in any variation
*
* @param string $key The main string key
*
* @return bool
* @since 3.2.0
*/
public function exist(string $key): bool;
/**
* Add content
*
* @param string $key The main string key
* @param mixed $value The values to set
* @param bool $hash Add the hash around the key
*
* @return void
* @since 3.2.0
*/
public function add(string $key, $value, bool $hash = true);
/**
* Remove content
*
* @param string $key The main string key
*
* @return void
* @since 3.2.0
*/
public function remove(string $key);
/**
* Set content with [ [ [ ... ] ] ] hash
*
* @param string $key The main string key
* @param mixed $value The values to set
*
* @return void
* @since 3.2.0
*/
public function set_(string $key, $value);
/**
* Get content with [ [ [ ... ] ] ] hash
*
* @param string $key The main string key
*
* @return mixed
* @since 3.2.0
*/
public function get_(string $key);
/**
* Does key exist with [ [ [ ... ] ] ] hash
*
* @param string $key The main string key
*
* @return bool
* @since 3.2.0
*/
public function exist_(string $key): bool;
/**
* Add content with [ [ [ ... ] ] ] hash
*
* @param string $key The main string key
* @param mixed $value The values to set
*
* @return void
* @since 3.2.0
*/
public function add_(string $key, $value);
/**
* Remove content with [ [ [ ... ] ] ] hash
*
* @param string $key The main string key
*
* @return void
* @since 3.2.0
*/
public function remove_(string $key);
/**
* Set content with # # # hash
*
* @param string $key The main string key
* @param mixed $value The values to set
*
* @return void
* @since 3.2.0
*/
public function set_h(string $key, $value);
/**
* Get content with # # # hash
*
* @param string $key The main string key
*
* @return mixed
* @since 3.2.0
*/
public function get_h(string $key);
/**
* Does key exist with # # # hash
*
* @param string $key The main string key
*
* @return bool
* @since 3.2.0
*/
public function exist_h(string $key): bool;
/**
* Add content with # # # hash
*
* @param string $key The main string key
* @param mixed $value The values to set
*
* @return void
* @since 3.2.0
*/
public function add_h(string $key, $value);
/**
* Remove content with # # # hash
*
* @param string $key The main string key
*
* @return void
* @since 3.2.0
*/
public function remove_h(string $key);
/**
* Set a type of placeholder with set of values
*
* @param string $key The main string for placeholder key
* @param array $values The values to add
*
* @return void
* @since 3.2.0
*/
public function setType(string $key, array $values);
/**
* Remove a type of placeholder by main key
*
* @param string $key The main string for placeholder key
*
* @return void
* @since 3.2.0
*/
public function clearType(string $key);
/**
* Update the data with the placeholders
*
* @param string $data The actual data
* @param array $placeholder The placeholders
* @param int $action The action to use
*
* THE ACTION OPTIONS ARE
* 1 -> Just replace (default)
* 2 -> Check if data string has placeholders
* 3 -> Remove placeholders not in data string
*
* @return string
* @since 3.2.0
*/
public function update(string $data, array $placeholder, int $action = 1):
string;
/**
* Update the data with the active placeholders
*
* @param string $data The actual data
*
* @return string
* @since 3.2.0
*/
public function update_(string $data): string;
/**
* return the placeholders for inserted and replaced code
*
* @param int $type The type of placement
* @param int|null $id The code id in the system
*
* @return array with start and end keys
* @since 3.2.0
*/
public function keys(int $type, ?int $id = null): array;
}
src/Componentbuilder/Compiler/Interfaces/PluginDataInterface.php000064400000002370151162054160021066
0ustar00<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder
<https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights
reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
namespace VDM\Joomla\Componentbuilder\Compiler\Interfaces;
/**
* Plug-in Data Interface
*
* @since 5.0.2
*/
interface PluginDataInterface
{
/**
* Get the Joomla Plugin/s
*
* @param int|null $id the plugin id
*
* @return object|array|null if ID found it returns object, if no ID
given it returns all set
* @since 3.2.0
*/
public function get(int $id = null);
/**
* Check if the Joomla Plugin/s exists
*
* @param int|null $id the plugin id
*
* @return bool if ID found it returns true, if no ID given it returns
true if any are set
* @since 3.2.0
*/
public function exists(int $id = null): bool;
/**
* Set the Joomla Plugin
*
* @param int $id the plugin id
*
* @return bool true on success
* @since 3.2.0
*/
public function set(int $id): bool;
}
src/Componentbuilder/Compiler/Interfaces/Power/ExtractorInterface.php000064400000002452151162054160022106
0ustar00<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder
<https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights
reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
namespace VDM\Joomla\Componentbuilder\Compiler\Interfaces\Power;
/**
* Compiler Power Extractor
* @since 3.2.1
*/
interface ExtractorInterface
{
/**
* Get Super Powers from the code string
*
* @param string $code The code
*
* @return array|null
* @since 3.2.0
*/
public function get_(): ?array;
/**
* Get Super Powers from the code string
*
* @param string $code The code
*
* @return array|null
* @since 3.2.0
*/
public function get(string $code): ?array;
/**
* Get Super Powers from the code string
*
* @param string $code The code
*
* @return array|null
* @since 3.2.0
*/
public function reverse(string $code): ?array;
/**
* Get Super Powers from the code string and load it
*
* @param string $code The code
*
* @return void
* @since 3.2.0
*/
public function search(string $code): void;
}
src/Componentbuilder/Compiler/Interfaces/Power/InjectorInterface.php000064400000001377151162054160021715
0ustar00<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder
<https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights
reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
namespace VDM\Joomla\Componentbuilder\Compiler\Interfaces\Power;
/**
* Compiler Power Injector
* @since 3.2.1
*/
interface InjectorInterface
{
/**
* Inject the powers found in the code
*
* @param string $code The class code
*
* @return string The updated code
* @since 3.2.0
*/
public function power(string $code): string;
}
src/Componentbuilder/Compiler/Interfaces/Power/index.html000064400000000054151162054160017572
0ustar00<html><body
bgcolor="#FFFFFF"></body></html>src/Componentbuilder/Compiler/Interfaces/PowerInterface.php000064400000002031151162054160020124
0ustar00<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder
<https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights
reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
namespace VDM\Joomla\Componentbuilder\Compiler\Interfaces;
/**
* Compiler Power Interface
*
* @since 3.2.0
*/
interface PowerInterface
{
/**
* load all the powers linked to this component
*
* @param array $guids The global unique ids of the linked powers
*
* @return void
* @since 3.2.0
*/
public function load(array $guids);
/**
* Get a power
*
* @param string $guid The global unique id of the power
* @param int $build Force build switch (to override global
switch)
*
* @return mixed
* @since 3.2.0
*/
public function get(string $guid, int $build = 0);
}
src/Componentbuilder/Compiler/Interfaces/index.html000064400000000054151162054160016476
0ustar00<html><body
bgcolor="#FFFFFF"></body></html>src/Componentbuilder/Compiler/JoomlaFive/Event.php000064400000004747151162054160016260
0ustar00<?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\JoomlaFive;
use Joomla\CMS\Factory;
use Joomla\CMS\Plugin\PluginHelper;
use Joomla\Event\DispatcherInterface;
use Joomla\Registry\Registry;
use VDM\Joomla\Utilities\Component\Helper;
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\EventInterface;
/**
* Compiler Events
*
* @since 3.2.0
*/
class Event implements EventInterface
{
/**
* event plug-in trigger switch
*
* @var boolean
* @since 3.2.0
*/
protected $activePlugins = false;
/**
* The dispatcher to get events
*
* @since 5.0.2
*/
protected $dispatcher;
/**
* Constructor
*
* @param Registry|null $params The component parameters
*
* @since 3.2.0
*/
public function __construct(?Registry $params = null)
{
// Set the params
$params = $params ?:
Helper::getParams('com_componentbuilder');
// get active plugins
if (($plugins = $params->get('compiler_plugin', false))
!== false)
{
foreach ($plugins as $plugin)
{
// get possible plugins
if (PluginHelper::isEnabled('extension', $plugin))
{
// Import the appropriate plugin group.
PluginHelper::importPlugin('extension', $plugin);
// activate events
$this->activePlugins = true;
}
}
}
$this->dispatcher =
Factory::getContainer()->get(DispatcherInterface::class);
}
/**
* Trigger an event
*
* @param string $event The event to trigger
* @param mixed $data The values to pass to the event/plugin
*
* @return void
* @throws \Exception
* @since 3.2.0
*/
public function trigger(string $event, $data = null)
{
// only execute if plugins were loaded (active)
if ($this->activePlugins)
{
try
{
$data ??= [];
$listeners = $this->dispatcher->getListeners($event);
foreach ($listeners as $listener)
{
// Call the listener with the unpacked arguments
$listener(...$data);
}
}
catch (\Exception $e)
{
throw new \Exception("Error processing event '$event':
" . $e->getMessage());
}
}
}
}
src/Componentbuilder/Compiler/JoomlaFive/Header.php000064400000047071151162054160016364
0ustar00<?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\JoomlaFive;
use VDM\Joomla\Componentbuilder\Compiler\Config;
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\EventInterface as
Event;
use VDM\Joomla\Componentbuilder\Compiler\Placeholder;
use VDM\Joomla\Componentbuilder\Compiler\Language;
use VDM\Joomla\Componentbuilder\Compiler\Builder\UikitComp;
use VDM\Joomla\Componentbuilder\Compiler\Builder\AdminFilterType;
use VDM\Joomla\Componentbuilder\Compiler\Builder\Category;
use VDM\Joomla\Componentbuilder\Compiler\Builder\AccessSwitchList;
use VDM\Joomla\Componentbuilder\Compiler\Builder\Filter;
use VDM\Joomla\Componentbuilder\Compiler\Builder\Tags;
use VDM\Joomla\Utilities\ArrayHelper;
use VDM\Joomla\Utilities\StringHelper;
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\HeaderInterface;
/**
* Build headers for all Joomla 5 files
*
* @since 3.2.0
*/
final class Header implements HeaderInterface
{
/**
* The Config Class.
*
* @var Config
* @since 3.2.0
*/
protected Config $config;
/**
* The EventInterface Class.
*
* @var Event
* @since 3.2.0
*/
protected Event $event;
/**
* The Placeholder Class.
*
* @var Placeholder
* @since 3.2.0
*/
protected Placeholder $placeholder;
/**
* The Language Class.
*
* @var Language
* @since 3.2.0
*/
protected Language $language;
/**
* The UikitComp Class.
*
* @var UikitComp
* @since 3.2.0
*/
protected UikitComp $uikitcomp;
/**
* The AdminFilterType Class.
*
* @var AdminFilterType
* @since 3.2.0
*/
protected AdminFilterType $adminfiltertype;
/**
* The Category Class.
*
* @var Category
* @since 3.2.0
*/
protected Category $category;
/**
* The AccessSwitchList Class.
*
* @var AccessSwitchList
* @since 3.2.0
*/
protected AccessSwitchList $accessswitchlist;
/**
* The Filter Class.
*
* @var Filter
* @since 3.2.0
*/
protected Filter $filter;
/**
* The Tags Class.
*
* @var Tags
* @since 3.2.0
*/
protected Tags $tags;
/**
* The Header Context array
*
* @var array
* @since 3.2.0
*/
protected array $headers = [];
/**
* The Namespace Prefix
*
* @var string
* @since 3.2.0
*/
protected string $NamespacePrefix;
/**
* The Component Name (in code)
*
* @var string
* @since 3.2.0
*/
protected string $ComponentName;
/**
* The Component Namespace (in code)
*
* @var string
* @since 3.2.0
*/
protected string $ComponentNamespace;
/**
* Constructor.
*
* @param Config $config The Config Class.
* @param Event $event The EventInterface
Class.
* @param Placeholder $placeholder The Placeholder Class.
* @param Language $language The Language Class.
* @param UikitComp $uikitcomp The UikitComp Class.
* @param AdminFilterType $adminfiltertype The AdminFilterType
Class.
* @param Category $category The Category Class.
* @param AccessSwitchList $accessswitchlist The AccessSwitchList
Class.
* @param Filter $filter The Filter Class.
* @param Tags $tags The Tags Class.
*
* @since 3.2.0
*/
public function __construct(Config $config, Event $event, Placeholder
$placeholder,
Language $language, UikitComp $uikitcomp,
AdminFilterType $adminfiltertype, Category $category,
AccessSwitchList $accessswitchlist, Filter $filter,
Tags $tags)
{
$this->config = $config;
$this->event = $event;
$this->placeholder = $placeholder;
$this->language = $language;
$this->uikitcomp = $uikitcomp;
$this->adminfiltertype = $adminfiltertype;
$this->category = $category;
$this->accessswitchlist = $accessswitchlist;
$this->filter = $filter;
$this->tags = $tags;
// set some global values
$this->NamespacePrefix =
$this->placeholder->get('NamespacePrefix');
$this->ComponentName =
$this->placeholder->get('Component');
$this->ComponentNamespace =
$this->placeholder->get('ComponentNamespace');
}
/**
* Get the headers for a file
*
* @param string $context The name of the context
* @param string $codeName The view, views, or layout code name
*
* @return string The header string to place in the header of the file
* @since 3.2.0
*/
public function get(string $context, string $codeName): string
{
// get static headers
$headers = $this->getHeaders($context);
// add to all except the helper classes
if ('admin.helper' !== $context &&
'site.helper' !== $context &&
'plugin.extension.header' !== $context &&
'plugin.provider.header' !== $context)
{
$target = 'Administrator';
if ($this->config->get('build_target',
'admin') === 'site')
{
$target = 'Site';
}
$headers[] = "use
{$this->NamespacePrefix}\\Component\\{$this->ComponentNamespace}\\{$target}\\Helper\\{$this->ComponentName}Helper;";
// we will add more as needed
switch ($context)
{
case 'site.view.model':
case 'site.views.model':
case 'site.view.html':
case 'site.views.html':
$headers[] = "use
{$this->NamespacePrefix}\\Component\\{$this->ComponentNamespace}\\Site\\Helper\\RouteHelper;";
break;
default:
break;
}
}
// get dynamic headers
switch ($context)
{
case 'admin.view.html':
case 'admin.views.html':
case 'custom.admin.view.html':
case 'custom.admin.views.html':
case 'site.admin.view.html':
case 'site.view.html':
case 'site.views.html':
if ((2 == $this->config->uikit || 1 ==
$this->config->uikit)
&& $this->uikitcomp->exists($codeName))
{
$headers[] = 'use Joomla\Filesystem\File;';
}
break;
case 'admin.view':
case 'custom.admin.view':
case 'custom.admin.views':
case 'site.admin.view':
$headers[] = '';
$headers[] = '/** @var Joomla\CMS\WebAsset\WebAssetManager $wa
*/';
$headers[] = '$wa =
$this->getDocument()->getWebAssetManager();';
$headers[] =
'$wa->useScript(\'keepalive\')->useScript(\'form.validate\');';
$headers[] = 'Html::_(\'bootstrap.tooltip\');';
break;
case 'admin.view.model':
case 'site.admin.view.model':
case 'custom.admin.view.model':
case 'site.view.model':
case 'admin.views.model':
case 'site.views.model':
$headers[] = 'use Joomla\CMS\Helper\TagsHelper;';
break;
case 'plugin.provider.header':
$headers[] = "use
{$this->NamespacePrefix}\\Plugin\\[[[PluginGroupNamespace]]]\\[[[PluginNamespace]]]\\Extension\\{$codeName};";
break;
default:
break;
}
// Trigger Event: jcb_ce_setClassHeader
$this->event->trigger(
'jcb_ce_setClassHeader', [&$context, &$codeName,
&$headers]
);
// return the headers
return $this->placeholder->update_(implode(PHP_EOL, $headers));
}
/**
* Get the headers for a file
*
* @param string $context The name of the context
*
* @return array The header string to place in the header of the file
* @since 3.2.0
*/
protected function getHeaders(string $context): array
{
if (isset($this->headers[$context]))
{
return $this->headers[$context];
}
// set the defaults
$headers = [];
$headers[] = 'use Joomla\CMS\Factory;';
$headers[] = 'use Joomla\CMS\Language\Text;';
switch ($context)
{
case 'admin.component':
$headers[] = 'use Joomla\CMS\Access\Exception\NotAllowed;';
$headers[] = 'use Joomla\CMS\HTML\HTMLHelper as Html;';
$headers[] = 'use
Joomla\CMS\MVC\Controller\BaseController;';
break;
case 'admin.helper':
case 'site.helper':
$headers[] = 'use Joomla\CMS\Access\Access;';
$headers[] = 'use Joomla\CMS\Access\Rules as AccessRules;';
$headers[] = 'use Joomla\CMS\Component\ComponentHelper;';
$headers[] = 'use Joomla\Filesystem\File;';
$headers[] = 'use Joomla\CMS\Language\Language;';
$headers[] = 'use Joomla\CMS\MVC\Model\BaseDatabaseModel;';
$headers[] = 'use Joomla\CMS\Object\CMSObject;';
$headers[] = 'use Joomla\CMS\Session\Session;';
$headers[] = 'use Joomla\CMS\Table\Table;';
$headers[] = 'use Joomla\CMS\Uri\Uri;';
$headers[] = 'use Joomla\CMS\Version;';
$headers[] = 'use Joomla\Database\DatabaseInterface;';
$headers[] = 'use Joomla\Registry\Registry;';
$headers[] = 'use Joomla\String\StringHelper;';
$headers[] = 'use Joomla\Utilities\ArrayHelper;';
break;
case 'admin.layout':
case 'site.layout':
case 'custom.admin.layout':
case 'override.layout':
$headers[] = 'use Joomla\CMS\HTML\HTMLHelper as Html;';
$headers[] = 'use Joomla\CMS\Layout\LayoutHelper;';
break;
case 'admin.view':
case 'custom.admin.view':
case 'custom.admin.views':
case 'site.admin.view':
$headers[] = 'use Joomla\CMS\HTML\HTMLHelper as Html;';
$headers[] = 'use Joomla\CMS\Layout\LayoutHelper;';
$headers[] = 'use Joomla\CMS\Router\Route;';
break;
case 'admin.view.controller':
$headers[] = 'use Joomla\CMS\Form\FormFactoryInterface;';
$headers[] = 'use Joomla\CMS\Application\CMSApplication;';
$headers[] = 'use
Joomla\CMS\MVC\Factory\MVCFactoryInterface;';
$headers[] = 'use Joomla\Input\Input;';
case 'site.admin.view.controller':
$headers[] = 'use
Joomla\CMS\Versioning\VersionableControllerTrait;';
case 'site.view.controller':
$headers[] = 'use
Joomla\CMS\MVC\Controller\FormController;';
$headers[] = 'use Joomla\CMS\MVC\Model\BaseDatabaseModel;';
$headers[] = 'use Joomla\Utilities\ArrayHelper;';
$headers[] = 'use Joomla\CMS\Router\Route;';
$headers[] = 'use Joomla\CMS\Session\Session;';
$headers[] = 'use Joomla\CMS\Uri\Uri;';
break;
case 'admin.view.html':
case 'admin.views.html':
case 'site.admin.view.html':
$headers[] = 'use Joomla\CMS\Toolbar\Toolbar;';
$headers[] = 'use Joomla\CMS\Form\FormHelper;';
$headers[] = 'use Joomla\CMS\Session\Session;';
$headers[] = 'use Joomla\CMS\Uri\Uri;';
$headers[] = 'use Joomla\CMS\User\User;';
$headers[] = 'use Joomla\CMS\Component\ComponentHelper;';
$headers[] = 'use Joomla\CMS\HTML\HTMLHelper as Html;';
$headers[] = 'use Joomla\CMS\Layout\FileLayout;';
$headers[] = 'use Joomla\CMS\MVC\View\HtmlView as
BaseHtmlView;';
$headers[] = 'use Joomla\CMS\Plugin\PluginHelper;';
$headers[] = 'use Joomla\CMS\Toolbar\ToolbarHelper;';
$headers[] = 'use Joomla\CMS\Document\Document;';
break;
case 'site.view.html':
case 'site.views.html':
$headers[] = 'use Joomla\CMS\Toolbar\Toolbar;';
$headers[] = 'use Joomla\CMS\Component\ComponentHelper;';
$headers[] = 'use Joomla\CMS\HTML\HTMLHelper as Html;';
$headers[] = 'use Joomla\CMS\Layout\FileLayout;';
$headers[] = 'use Joomla\CMS\MVC\View\HtmlView as
BaseHtmlView;';
$headers[] = 'use Joomla\CMS\Plugin\PluginHelper;';
$headers[] = 'use Joomla\CMS\Toolbar\ToolbarHelper;';
$headers[] = 'use Joomla\CMS\Document\Document;';
$headers[] = "use
{$this->NamespacePrefix}\\Component\\{$this->ComponentNamespace}\\Site\\Helper\\HeaderCheck;";
break;
case 'custom.admin.view.html':
case 'custom.admin.views.html':
$target = 'Administrator';
if ($this->config->get('build_target',
'admin') === 'site')
{
$target = 'Site';
}
$headers[] = 'use Joomla\CMS\Component\ComponentHelper;';
$headers[] = 'use Joomla\CMS\HTML\HTMLHelper as Html;';
$headers[] = 'use Joomla\CMS\Layout\FileLayout;';
$headers[] = 'use Joomla\CMS\MVC\View\HtmlView as
BaseHtmlView;';
$headers[] = 'use Joomla\CMS\Plugin\PluginHelper;';
$headers[] = 'use Joomla\CMS\Toolbar\ToolbarHelper;';
$headers[] = 'use Joomla\CMS\User\User;';
$headers[] = 'use Joomla\CMS\Document\Document;';
$headers[] = "use
{$this->NamespacePrefix}\\Component\\{$this->ComponentNamespace}\\{$target}\\Helper\\HeaderCheck;";
break;
case 'admin.view.model':
case 'site.admin.view.model':
$headers[] = 'use
Joomla\CMS\Application\CMSApplicationInterface;';
$headers[] = 'use Joomla\CMS\Component\ComponentHelper;';
$headers[] = 'use Joomla\CMS\Form\Form;';
$headers[] = 'use Joomla\CMS\Filter\InputFilter;';
$headers[] = 'use Joomla\CMS\Filter\OutputFilter;';
$headers[] = 'use Joomla\CMS\MVC\Model\AdminModel;';
$headers[] = 'use
Joomla\CMS\MVC\Factory\MVCFactoryInterface;';
$headers[] = 'use Joomla\CMS\Table\Table;';
$headers[] = 'use Joomla\CMS\UCM\UCMType;';
$headers[] = 'use
Joomla\CMS\Versioning\VersionableModelTrait;';
$headers[] = 'use Joomla\CMS\User\User;';
$headers[] = 'use Joomla\Registry\Registry;';
$headers[] = 'use Joomla\String\StringHelper;';
$headers[] = 'use Joomla\Utilities\ArrayHelper;';
$headers[] = 'use Joomla\Input\Input;';
break;
case 'admin.views':
$headers[] = 'use Joomla\CMS\HTML\HTMLHelper as Html;';
$headers[] = 'use Joomla\CMS\Layout\LayoutHelper;';
$headers[] = 'use Joomla\CMS\Router\Route;';
break;
case 'admin.views.controller':
case 'custom.admin.views.controller':
case 'dashboard.controller':
$headers[] = 'use
Joomla\CMS\MVC\Controller\AdminController;';
$headers[] = 'use Joomla\Utilities\ArrayHelper;';
$headers[] = 'use Joomla\CMS\Router\Route;';
$headers[] = 'use Joomla\CMS\Session\Session;';
break;
case 'ajax.admin.model':
case 'ajax.site.model':
$headers[] = 'use
Joomla\CMS\Application\CMSApplicationInterface;';
$headers[] = 'use Joomla\CMS\Component\ComponentHelper;';
$headers[] = 'use Joomla\CMS\HTML\HTMLHelper as Html;';
$headers[] = 'use Joomla\CMS\Layout\LayoutHelper;';
$headers[] = 'use Joomla\CMS\MVC\Model\ListModel;';
$headers[] = 'use
Joomla\CMS\MVC\Factory\MVCFactoryInterface;';
$headers[] = 'use Joomla\CMS\Plugin\PluginHelper;';
$headers[] = 'use Joomla\CMS\User\User;';
$headers[] = 'use Joomla\Utilities\ArrayHelper;';
$headers[] = 'use Joomla\Input\Input;';
$headers[] = 'use Joomla\CMS\Router\Route;';
$headers[] = 'use Joomla\CMS\Session\Session;';
$headers[] = 'use Joomla\CMS\Uri\Uri;';
$headers[] = 'use Joomla\Registry\Registry;';
break;
case 'dashboard.model':
$headers[] = 'use Joomla\CMS\HTML\HTMLHelper as Html;';
$headers[] = 'use Joomla\CMS\Session\Session;';
$headers[] = 'use Joomla\CMS\Uri\Uri;';
case 'admin.views.model':
case 'custom.admin.views.model':
case 'site.views.model':
$headers[] = 'use
Joomla\CMS\Application\CMSApplicationInterface;';
$headers[] = 'use Joomla\CMS\Component\ComponentHelper;';
$headers[] = 'use Joomla\CMS\MVC\Model\ListModel;';
$headers[] = 'use
Joomla\CMS\MVC\Factory\MVCFactoryInterface;';
$headers[] = 'use Joomla\CMS\Plugin\PluginHelper;';
$headers[] = 'use Joomla\CMS\Router\Route;';
$headers[] = 'use Joomla\CMS\User\User;';
$headers[] = 'use Joomla\Utilities\ArrayHelper;';
$headers[] = 'use Joomla\Input\Input;';
break;
case 'custom.admin.view.controller':
case 'import.controller':
case 'import.custom.controller':
$headers[] = 'use
Joomla\CMS\MVC\Controller\BaseController;';
$headers[] = 'use Joomla\CMS\Router\Route;';
$headers[] = 'use Joomla\CMS\Session\Session;';
$headers[] = 'use Joomla\Utilities\ArrayHelper;';
break;
case 'custom.admin.view.model':
case 'site.view.model':
$headers[] = 'use
Joomla\CMS\Application\CMSApplicationInterface;';
$headers[] = 'use Joomla\CMS\Component\ComponentHelper;';
$headers[] = 'use Joomla\CMS\MVC\Model\ItemModel;';
$headers[] = 'use
Joomla\CMS\MVC\Factory\MVCFactoryInterface;';
$headers[] = 'use Joomla\CMS\Plugin\PluginHelper;';
$headers[] = 'use Joomla\CMS\Router\Route;';
$headers[] = 'use Joomla\CMS\Uri\Uri;';
$headers[] = 'use Joomla\CMS\User\User;';
$headers[] = 'use Joomla\Input\Input;';
$headers[] = 'use Joomla\Utilities\ArrayHelper;';
break;
case 'import.custom.model':
case 'import.model':
$headers[] = 'use Joomla\Filesystem\File;';
$headers[] = 'use Joomla\Filesystem\Folder;';
$headers[] = 'use Joomla\CMS\Filesystem\Path;';
$headers[] = 'use Joomla\CMS\Filter\OutputFilter;';
$headers[] = 'use Joomla\CMS\Installer\InstallerHelper;';
$headers[] = 'use Joomla\CMS\MVC\Model\BaseDatabaseModel;';
$headers[] = 'use Joomla\String\StringHelper;';
$headers[] = 'use Joomla\Utilities\ArrayHelper;';
$headers[] = 'use PhpOffice\PhpSpreadsheet\IOFactory;';
break;
case 'dashboard.view':
$headers[] = 'use Joomla\CMS\HTML\HTMLHelper as Html;';
break;
case 'dashboard.view.html':
$headers[] = 'use Joomla\CMS\HTML\HTMLHelper as Html;';
$headers[] = 'use Joomla\CMS\MVC\View\HtmlView as
BaseHtmlView;';
$headers[] = 'use Joomla\CMS\Toolbar\ToolbarHelper;';
$headers[] = 'use Joomla\CMS\Document\Document;';
break;
case 'site.router':
$headers[] = 'use Joomla\CMS\Application\SiteApplication;';
$headers[] = 'use
Joomla\CMS\Categories\CategoryFactoryInterface;';
$headers[] = 'use Joomla\CMS\Component\ComponentHelper;';
$headers[] = 'use Joomla\CMS\Component\Router\RouterView;';
$headers[] = 'use
Joomla\CMS\Component\Router\RouterViewConfiguration;';
$headers[] = 'use
Joomla\CMS\Component\Router\Rules\MenuRules;';
$headers[] = 'use
Joomla\CMS\Component\Router\Rules\NomenuRules;';
$headers[] = 'use
Joomla\CMS\Component\Router\Rules\StandardRules;';
$headers[] = 'use Joomla\CMS\Menu\AbstractMenu;';
$headers[] = 'use Joomla\Database\DatabaseInterface;';
$headers[] = 'use Joomla\Database\ParameterType;';
$headers[] = 'use Joomla\Registry\Registry;';
break;
case 'site.view':
case 'site.views':
$headers[] = 'use Joomla\CMS\Router\Route;';
$headers[] = 'use Joomla\CMS\Layout\LayoutHelper;';
$headers[] = 'use Joomla\CMS\HTML\HTMLHelper as Html;';
break;
case 'form.custom.field':
$headers[] = 'use Joomla\CMS\HTML\HTMLHelper as Html;';
$headers[] = 'use Joomla\CMS\Component\ComponentHelper;';
$headers[] = 'use
Joomla\CMS\Form\Field\###FORM_EXTENDS###;';
break;
case 'plugin.extension.header':
$headers = [];
break;
case 'plugin.provider.header':
$headers = [];
$headers[] = 'use Joomla\CMS\Factory;';
$headers[] = 'use Joomla\CMS\Plugin\PluginHelper;';
$headers[] = 'use Joomla\CMS\Extension\PluginInterface;';
$headers[] = 'use Joomla\Event\DispatcherInterface;';
$headers[] = 'use Joomla\DI\ServiceProviderInterface;';
$headers[] = 'use Joomla\DI\Container;';
break;
case 'api.view.controller':
case 'api.views.controller':
$headers = [];
$headers[] = 'use Joomla\CMS\Factory;';
$headers[] = 'use Joomla\CMS\MVC\Controller\ApiController;';
break;
case 'api.view.json':
case 'api.views.json':
$headers = [];
$headers[] = 'use Joomla\CMS\Factory;';
$headers[] = 'use Joomla\CMS\MVC\View\JsonApiView as
BaseApiView;';
break;
default:
break;
}
$this->headers[$context] = $headers;
return $headers;
}
}
src/Componentbuilder/Compiler/JoomlaFive/History.php000064400000012726151162054160016634
0ustar00<?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\JoomlaFive;
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\Componentbuilder\Compiler\Config;
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\HistoryInterface;
/**
* Compiler History
*
* @since 3.2.0
*/
final class History implements HistoryInterface
{
/**
* History Item Object
*
* @var object|null
* @since 3.2.0
*/
protected ?object $tmp;
/**
* Compiler Config
*
* @var Config
* @since 3.2.0
*/
protected Config $config;
/**
* Database object to query local DB
*
* @since 3.2.0
*/
protected $db;
/**
* Constructor
*
* @param Config|null $config The compiler config object.
*
* @since 3.2.0
*/
public function __construct(?Config $config = null)
{
$this->config = $config ?: Compiler::_('Config');
$this->db = Factory::getDbo();
}
/**
* Get Item History object
*
* @param string $type The type of item
* @param int $id The item ID
*
* @return ?object The history
* @since 3.2.0
*/
public function get(string $type, int $id): ?object
{
// quick class object to store old history object
$this->tmp = null;
// Create a new query object.
$query = $this->db->getQuery(true);
$query->select('h.*');
$query->from('#__history AS h');
$query->where(
$this->db->quoteName('h.item_id') . ' = ' .
$this->db->quote('com_componentbuilder.' . $type .
'.' . (int) $id)
);
$query->order('h.save_date DESC');
$this->db->setQuery($query, 0, 1);
$this->db->execute();
if ($this->db->getNumRows())
{
// new version of this item found
// so we need to mark it as the last compiled version
$newActive = $this->db->loadObject();
// set the new version watch
$this->set($newActive, 1);
}
// Get last compiled verion
$query = $this->db->getQuery(true);
$query->select('h.*');
$query->from('#__history AS h');
$query->where(
$this->db->quoteName('h.item_id') . ' = ' .
$this->db->quote('com_componentbuilder.' . $type .
'.' . (int) $id)
);
$query->where('h.keep_forever = 1');
$query->where('h.version_note LIKE ' .
$this->db->quote('%component%'));
// make sure it does not return the active version
if (isset($newActive) && isset($newActive->version_id))
{
$query->where('h.version_id != ' . (int)
$newActive->version_id);
}
$query->order('h.save_date DESC');
$this->db->setQuery($query);
$this->db->execute();
if ($this->db->getNumRows())
{
// the old active version was found
// so we may need to do an SQL update
// and unmark the old compiled version
$oldActives = $this->db->loadObjectList();
foreach ($oldActives as $oldActive)
{
// remove old version watch
$this->set($oldActive, 0);
}
}
// return the last used history record or null.
return $this->tmp;
}
/**
* Set Item History Watch
*
* @param Object $object The history object
* @param int $action The action to take
* 0 = remove watch
* 1 = add watch
*
* @return bool
* @since 3.2.0
*/
protected function set(object $object, int $action): bool
{
// check the note
if (JsonHelper::check($object->version_note))
{
$version_note = json_decode((string) $object->version_note, true);
}
else
{
$version_note = array('component' => []);
}
// set watch
switch ($action)
{
case 0:
// remove watch
if (isset($version_note['component'])
&& ($key = array_search(
$this->config->component_id,
$version_note['component']
)) !== false)
{
// last version that was used to build/compile
$this->tmp = json_decode((string) $object->version_data);
// remove it from this component
unset($version_note['component'][$key]);
}
else
{
// since it was not found, no need to update anything
return true;
}
break;
case 1:
// add watch
if (!in_array($this->config->component_id,
$version_note['component']))
{
$version_note['component'][] =
$this->config->component_id;
}
else
{
// since it is there already, no need to update anything
return true;
}
break;
}
// check if we need to still keep this locked
if (isset($version_note['component'])
&& ArrayHelper::check($version_note['component']))
{
// insure component ids are only added once per item
$version_note['component'] = array_unique(
$version_note['component']
);
// we may change this, little risky (but since JCB does not have history
notes it should be okay for now)
$object->version_note = json_encode($version_note);
$object->keep_forever = '1';
}
else
{
$object->version_note = '';
$object->keep_forever = '0';
}
// run the update
return $this->db->updateObject('#__history', $object,
'version_id');
}
}
src/Componentbuilder/Compiler/JoomlaFive/index.html000064400000000054151162054160016446
0ustar00<html><body
bgcolor="#FFFFFF"></body></html>src/Componentbuilder/Compiler/JoomlaFour/Event.php000064400000004755151162054160016301
0ustar00<?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\JoomlaFour;
use Joomla\CMS\Factory;
use Joomla\CMS\Plugin\PluginHelper;
use Joomla\Event\DispatcherInterface;
use Joomla\Registry\Registry;
use VDM\Joomla\Utilities\Component\Helper;
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\EventInterface;
/**
* Compiler Events
*
* @since 3.2.0
*/
final class Event implements EventInterface
{
/**
* event plug-in trigger switch
*
* @var boolean
* @since 3.2.0
*/
protected $activePlugins = false;
/**
* The dispatcher to get events
*
* @since 5.0.2
*/
protected $dispatcher;
/**
* Constructor
*
* @param Registry|null $params The component parameters
*
* @since 3.2.0
*/
public function __construct(?Registry $params = null)
{
// Set the params
$params = $params ?:
Helper::getParams('com_componentbuilder');
// get active plugins
if (($plugins = $params->get('compiler_plugin', false))
!== false)
{
foreach ($plugins as $plugin)
{
// get possible plugins
if (PluginHelper::isEnabled('extension', $plugin))
{
// Import the appropriate plugin group.
PluginHelper::importPlugin('extension', $plugin);
// activate events
$this->activePlugins = true;
}
}
}
$this->dispatcher =
Factory::getContainer()->get(DispatcherInterface::class);
}
/**
* Trigger an event
*
* @param string $event The event to trigger
* @param mixed $data The values to pass to the event/plugin
*
* @return void
* @throws \Exception
* @since 3.2.0
*/
public function trigger(string $event, $data = null)
{
// only execute if plugins were loaded (active)
if ($this->activePlugins)
{
try
{
$data ??= [];
$listeners = $this->dispatcher->getListeners($event);
foreach ($listeners as $listener)
{
// Call the listener with the unpacked arguments
$listener(...$data);
}
}
catch (\Exception $e)
{
throw new \Exception("Error processing event '$event':
" . $e->getMessage());
}
}
}
}
src/Componentbuilder/Compiler/JoomlaFour/Header.php000064400000046766151162054160016420
0ustar00<?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\JoomlaFour;
use VDM\Joomla\Componentbuilder\Compiler\Config;
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\EventInterface as
Event;
use VDM\Joomla\Componentbuilder\Compiler\Placeholder;
use VDM\Joomla\Componentbuilder\Compiler\Language;
use VDM\Joomla\Componentbuilder\Compiler\Builder\UikitComp;
use VDM\Joomla\Componentbuilder\Compiler\Builder\AdminFilterType;
use VDM\Joomla\Componentbuilder\Compiler\Builder\Category;
use VDM\Joomla\Componentbuilder\Compiler\Builder\AccessSwitchList;
use VDM\Joomla\Componentbuilder\Compiler\Builder\Filter;
use VDM\Joomla\Componentbuilder\Compiler\Builder\Tags;
use VDM\Joomla\Utilities\ArrayHelper;
use VDM\Joomla\Utilities\StringHelper;
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\HeaderInterface;
/**
* Build headers for all Joomla 4 files
*
* @since 3.2.0
*/
final class Header implements HeaderInterface
{
/**
* The Config Class.
*
* @var Config
* @since 3.2.0
*/
protected Config $config;
/**
* The EventInterface Class.
*
* @var Event
* @since 3.2.0
*/
protected Event $event;
/**
* The Placeholder Class.
*
* @var Placeholder
* @since 3.2.0
*/
protected Placeholder $placeholder;
/**
* The Language Class.
*
* @var Language
* @since 3.2.0
*/
protected Language $language;
/**
* The UikitComp Class.
*
* @var UikitComp
* @since 3.2.0
*/
protected UikitComp $uikitcomp;
/**
* The AdminFilterType Class.
*
* @var AdminFilterType
* @since 3.2.0
*/
protected AdminFilterType $adminfiltertype;
/**
* The Category Class.
*
* @var Category
* @since 3.2.0
*/
protected Category $category;
/**
* The AccessSwitchList Class.
*
* @var AccessSwitchList
* @since 3.2.0
*/
protected AccessSwitchList $accessswitchlist;
/**
* The Filter Class.
*
* @var Filter
* @since 3.2.0
*/
protected Filter $filter;
/**
* The Tags Class.
*
* @var Tags
* @since 3.2.0
*/
protected Tags $tags;
/**
* The Header Context array
*
* @var array
* @since 3.2.0
*/
protected array $headers = [];
/**
* The Namespace Prefix
*
* @var string
* @since 3.2.0
*/
protected string $NamespacePrefix;
/**
* The Component Name (in code)
*
* @var string
* @since 3.2.0
*/
protected string $ComponentName;
/**
* The Component Namespace (in code)
*
* @var string
* @since 3.2.0
*/
protected string $ComponentNamespace;
/**
* Constructor.
*
* @param Config $config The Config Class.
* @param Event $event The EventInterface
Class.
* @param Placeholder $placeholder The Placeholder Class.
* @param Language $language The Language Class.
* @param UikitComp $uikitcomp The UikitComp Class.
* @param AdminFilterType $adminfiltertype The AdminFilterType
Class.
* @param Category $category The Category Class.
* @param AccessSwitchList $accessswitchlist The AccessSwitchList
Class.
* @param Filter $filter The Filter Class.
* @param Tags $tags The Tags Class.
*
* @since 3.2.0
*/
public function __construct(Config $config, Event $event, Placeholder
$placeholder,
Language $language, UikitComp $uikitcomp,
AdminFilterType $adminfiltertype, Category $category,
AccessSwitchList $accessswitchlist, Filter $filter,
Tags $tags)
{
$this->config = $config;
$this->event = $event;
$this->placeholder = $placeholder;
$this->language = $language;
$this->uikitcomp = $uikitcomp;
$this->adminfiltertype = $adminfiltertype;
$this->category = $category;
$this->accessswitchlist = $accessswitchlist;
$this->filter = $filter;
$this->tags = $tags;
// set some global values
$this->NamespacePrefix =
$this->placeholder->get('NamespacePrefix');
$this->ComponentName =
$this->placeholder->get('Component');
$this->ComponentNamespace =
$this->placeholder->get('ComponentNamespace');
}
/**
* Get the headers for a file
*
* @param string $context The name of the context
* @param string $codeName The view, views, or layout code name
*
* @return string The header string to place in the header of the file
* @since 3.2.0
*/
public function get(string $context, string $codeName): string
{
// get static headers
$headers = $this->getHeaders($context);
// add to all except the helper classes
if ('admin.helper' !== $context &&
'site.helper' !== $context)
{
$target = 'Administrator';
if ($this->config->get('build_target',
'admin') === 'site')
{
$target = 'Site';
}
$headers[] = "use
{$this->NamespacePrefix}\\Component\\{$this->ComponentNamespace}\\{$target}\\Helper\\{$this->ComponentName}Helper;";
// we will add more as needed
switch ($context)
{
case 'site.view.model':
case 'site.views.model':
case 'site.view.html':
case 'site.views.html':
$headers[] = "use
{$this->NamespacePrefix}\\Component\\{$this->ComponentNamespace}\\Site\\Helper\\RouteHelper;";
break;
default:
break;
}
}
// get dynamic headers
switch ($context)
{
case 'admin.view.html':
case 'admin.views.html':
case 'custom.admin.view.html':
case 'custom.admin.views.html':
case 'site.admin.view.html':
case 'site.view.html':
case 'site.views.html':
if ((2 == $this->config->uikit || 1 ==
$this->config->uikit)
&& $this->uikitcomp->exists($codeName))
{
$headers[] = 'use Joomla\CMS\Filesystem\File;';
}
break;
case 'admin.view':
case 'custom.admin.view':
case 'custom.admin.views':
case 'site.admin.view':
$headers[] = '';
$headers[] = '/** @var Joomla\CMS\WebAsset\WebAssetManager $wa
*/';
$headers[] = '$wa =
$this->getDocument()->getWebAssetManager();';
$headers[] =
'$wa->useScript(\'keepalive\')->useScript(\'form.validate\');';
$headers[] = 'Html::_(\'bootstrap.tooltip\');';
break;
case 'admin.view.model':
case 'site.admin.view.model':
case 'custom.admin.view.model':
case 'site.view.model':
case 'admin.views.model':
case 'site.views.model':
$headers[] = 'use Joomla\CMS\Helper\TagsHelper;';
break;
case 'plugin.provider.header':
$headers[] = "use
{$this->NamespacePrefix}\\Plugin\\[[[PluginGroupNamespace]]]\\[[[PluginNamespace]]]\\Extension\\{$codeName};";
break;
default:
break;
}
// Trigger Event: jcb_ce_setClassHeader
$this->event->trigger(
'jcb_ce_setClassHeader', [&$context, &$codeName,
&$headers]
);
// return the headers
return $this->placeholder->update_(implode(PHP_EOL, $headers));
}
/**
* Get the headers for a file
*
* @param string $context The name of the context
*
* @return array The header string to place in the header of the file
* @since 3.2.0
*/
protected function getHeaders(string $context): array
{
if (isset($this->headers[$context]))
{
return $this->headers[$context];
}
// set the defaults
$headers = [];
$headers[] = 'use Joomla\CMS\Factory;';
$headers[] = 'use Joomla\CMS\Language\Text;';
switch ($context)
{
case 'admin.component':
$headers[] = 'use Joomla\CMS\Access\Exception\NotAllowed;';
$headers[] = 'use Joomla\CMS\HTML\HTMLHelper as Html;';
$headers[] = 'use
Joomla\CMS\MVC\Controller\BaseController;';
break;
case 'admin.helper':
case 'site.helper':
$headers[] = 'use Joomla\CMS\Access\Access;';
$headers[] = 'use Joomla\CMS\Access\Rules as AccessRules;';
$headers[] = 'use Joomla\CMS\Component\ComponentHelper;';
$headers[] = 'use Joomla\CMS\Filesystem\File;';
$headers[] = 'use Joomla\CMS\Language\Language;';
$headers[] = 'use Joomla\CMS\MVC\Model\BaseDatabaseModel;';
$headers[] = 'use Joomla\CMS\Object\CMSObject;';
$headers[] = 'use Joomla\CMS\Session\Session;';
$headers[] = 'use Joomla\CMS\Table\Table;';
$headers[] = 'use Joomla\CMS\Uri\Uri;';
$headers[] = 'use Joomla\CMS\Version;';
$headers[] = 'use Joomla\Database\DatabaseInterface;';
$headers[] = 'use Joomla\Registry\Registry;';
$headers[] = 'use Joomla\String\StringHelper;';
$headers[] = 'use Joomla\Utilities\ArrayHelper;';
break;
case 'admin.layout':
case 'site.layout':
case 'custom.admin.layout':
case 'override.layout':
$headers[] = 'use Joomla\CMS\HTML\HTMLHelper as Html;';
$headers[] = 'use Joomla\CMS\Layout\LayoutHelper;';
break;
case 'admin.view':
case 'custom.admin.view':
case 'custom.admin.views':
case 'site.admin.view':
$headers[] = 'use Joomla\CMS\HTML\HTMLHelper as Html;';
$headers[] = 'use Joomla\CMS\Layout\LayoutHelper;';
$headers[] = 'use Joomla\CMS\Router\Route;';
break;
case 'admin.view.controller':
$headers[] = 'use Joomla\CMS\Form\FormFactoryInterface;';
$headers[] = 'use Joomla\CMS\Application\CMSApplication;';
$headers[] = 'use
Joomla\CMS\MVC\Factory\MVCFactoryInterface;';
$headers[] = 'use Joomla\Input\Input;';
case 'site.admin.view.controller':
$headers[] = 'use
Joomla\CMS\Versioning\VersionableControllerTrait;';
case 'site.view.controller':
$headers[] = 'use
Joomla\CMS\MVC\Controller\FormController;';
$headers[] = 'use Joomla\CMS\MVC\Model\BaseDatabaseModel;';
$headers[] = 'use Joomla\Utilities\ArrayHelper;';
$headers[] = 'use Joomla\CMS\Router\Route;';
$headers[] = 'use Joomla\CMS\Session\Session;';
$headers[] = 'use Joomla\CMS\Uri\Uri;';
break;
case 'admin.view.html':
case 'admin.views.html':
case 'site.admin.view.html':
$headers[] = 'use Joomla\CMS\Toolbar\Toolbar;';
$headers[] = 'use Joomla\CMS\Form\FormHelper;';
$headers[] = 'use Joomla\CMS\Session\Session;';
$headers[] = 'use Joomla\CMS\Uri\Uri;';
$headers[] = 'use Joomla\CMS\User\User;';
$headers[] = 'use Joomla\CMS\Component\ComponentHelper;';
$headers[] = 'use Joomla\CMS\HTML\HTMLHelper as Html;';
$headers[] = 'use Joomla\CMS\Layout\FileLayout;';
$headers[] = 'use Joomla\CMS\MVC\View\HtmlView as
BaseHtmlView;';
$headers[] = 'use Joomla\CMS\Plugin\PluginHelper;';
$headers[] = 'use Joomla\CMS\Toolbar\ToolbarHelper;';
$headers[] = 'use Joomla\CMS\Document\Document;';
break;
case 'site.view.html':
case 'site.views.html':
$headers[] = 'use Joomla\CMS\Toolbar\Toolbar;';
$headers[] = 'use Joomla\CMS\Component\ComponentHelper;';
$headers[] = 'use Joomla\CMS\HTML\HTMLHelper as Html;';
$headers[] = 'use Joomla\CMS\Layout\FileLayout;';
$headers[] = 'use Joomla\CMS\MVC\View\HtmlView as
BaseHtmlView;';
$headers[] = 'use Joomla\CMS\Plugin\PluginHelper;';
$headers[] = 'use Joomla\CMS\Toolbar\ToolbarHelper;';
$headers[] = 'use Joomla\CMS\Document\Document;';
$headers[] = "use
{$this->NamespacePrefix}\\Component\\{$this->ComponentNamespace}\\Site\\Helper\\HeaderCheck;";
break;
case 'custom.admin.view.html':
case 'custom.admin.views.html':
$target = 'Administrator';
if ($this->config->get('build_target',
'admin') === 'site')
{
$target = 'Site';
}
$headers[] = 'use Joomla\CMS\Component\ComponentHelper;';
$headers[] = 'use Joomla\CMS\HTML\HTMLHelper as Html;';
$headers[] = 'use Joomla\CMS\Layout\FileLayout;';
$headers[] = 'use Joomla\CMS\MVC\View\HtmlView as
BaseHtmlView;';
$headers[] = 'use Joomla\CMS\Plugin\PluginHelper;';
$headers[] = 'use Joomla\CMS\Toolbar\ToolbarHelper;';
$headers[] = 'use Joomla\CMS\User\User;';
$headers[] = 'use Joomla\CMS\Document\Document;';
$headers[] = "use
{$this->NamespacePrefix}\\Component\\{$this->ComponentNamespace}\\{$target}\\Helper\\HeaderCheck;";
break;
case 'admin.view.model':
case 'site.admin.view.model':
$headers[] = 'use
Joomla\CMS\Application\CMSApplicationInterface;';
$headers[] = 'use Joomla\CMS\Component\ComponentHelper;';
$headers[] = 'use Joomla\CMS\Form\Form;';
$headers[] = 'use Joomla\CMS\Filter\InputFilter;';
$headers[] = 'use Joomla\CMS\Filter\OutputFilter;';
$headers[] = 'use Joomla\CMS\MVC\Model\AdminModel;';
$headers[] = 'use
Joomla\CMS\MVC\Factory\MVCFactoryInterface;';
$headers[] = 'use Joomla\CMS\Table\Table;';
$headers[] = 'use Joomla\CMS\UCM\UCMType;';
$headers[] = 'use
Joomla\CMS\Versioning\VersionableModelTrait;';
$headers[] = 'use Joomla\CMS\User\User;';
$headers[] = 'use Joomla\Registry\Registry;';
$headers[] = 'use Joomla\String\StringHelper;';
$headers[] = 'use Joomla\Utilities\ArrayHelper;';
$headers[] = 'use Joomla\Input\Input;';
break;
case 'admin.views':
$headers[] = 'use Joomla\CMS\HTML\HTMLHelper as Html;';
$headers[] = 'use Joomla\CMS\Layout\LayoutHelper;';
$headers[] = 'use Joomla\CMS\Router\Route;';
break;
case 'admin.views.controller':
case 'custom.admin.views.controller':
case 'dashboard.controller':
$headers[] = 'use
Joomla\CMS\MVC\Controller\AdminController;';
$headers[] = 'use Joomla\Utilities\ArrayHelper;';
$headers[] = 'use Joomla\CMS\Router\Route;';
$headers[] = 'use Joomla\CMS\Session\Session;';
break;
case 'ajax.admin.model':
case 'ajax.site.model':
$headers[] = 'use
Joomla\CMS\Application\CMSApplicationInterface;';
$headers[] = 'use Joomla\CMS\Component\ComponentHelper;';
$headers[] = 'use Joomla\CMS\HTML\HTMLHelper as Html;';
$headers[] = 'use Joomla\CMS\Layout\LayoutHelper;';
$headers[] = 'use Joomla\CMS\MVC\Model\ListModel;';
$headers[] = 'use
Joomla\CMS\MVC\Factory\MVCFactoryInterface;';
$headers[] = 'use Joomla\CMS\Plugin\PluginHelper;';
$headers[] = 'use Joomla\CMS\User\User;';
$headers[] = 'use Joomla\Utilities\ArrayHelper;';
$headers[] = 'use Joomla\Input\Input;';
$headers[] = 'use Joomla\CMS\Router\Route;';
$headers[] = 'use Joomla\CMS\Session\Session;';
$headers[] = 'use Joomla\CMS\Uri\Uri;';
$headers[] = 'use Joomla\Registry\Registry;';
break;
case 'dashboard.model':
$headers[] = 'use Joomla\CMS\HTML\HTMLHelper as Html;';
$headers[] = 'use Joomla\CMS\Session\Session;';
$headers[] = 'use Joomla\CMS\Uri\Uri;';
case 'admin.views.model':
case 'custom.admin.views.model':
case 'site.views.model':
$headers[] = 'use
Joomla\CMS\Application\CMSApplicationInterface;';
$headers[] = 'use Joomla\CMS\Component\ComponentHelper;';
$headers[] = 'use Joomla\CMS\MVC\Model\ListModel;';
$headers[] = 'use
Joomla\CMS\MVC\Factory\MVCFactoryInterface;';
$headers[] = 'use Joomla\CMS\Plugin\PluginHelper;';
$headers[] = 'use Joomla\CMS\Router\Route;';
$headers[] = 'use Joomla\CMS\User\User;';
$headers[] = 'use Joomla\Utilities\ArrayHelper;';
$headers[] = 'use Joomla\Input\Input;';
break;
case 'custom.admin.view.controller':
case 'import.controller':
case 'import.custom.controller':
$headers[] = 'use
Joomla\CMS\MVC\Controller\BaseController;';
$headers[] = 'use Joomla\CMS\Router\Route;';
$headers[] = 'use Joomla\CMS\Session\Session;';
$headers[] = 'use Joomla\Utilities\ArrayHelper;';
break;
case 'custom.admin.view.model':
case 'site.view.model':
$headers[] = 'use
Joomla\CMS\Application\CMSApplicationInterface;';
$headers[] = 'use Joomla\CMS\Component\ComponentHelper;';
$headers[] = 'use Joomla\CMS\MVC\Model\ItemModel;';
$headers[] = 'use
Joomla\CMS\MVC\Factory\MVCFactoryInterface;';
$headers[] = 'use Joomla\CMS\Plugin\PluginHelper;';
$headers[] = 'use Joomla\CMS\Router\Route;';
$headers[] = 'use Joomla\CMS\Uri\Uri;';
$headers[] = 'use Joomla\CMS\User\User;';
$headers[] = 'use Joomla\Input\Input;';
$headers[] = 'use Joomla\Utilities\ArrayHelper;';
break;
case 'import.custom.model':
case 'import.model':
$headers[] = 'use Joomla\CMS\Filesystem\File;';
$headers[] = 'use Joomla\CMS\Filesystem\Folder;';
$headers[] = 'use Joomla\CMS\Filesystem\Path;';
$headers[] = 'use Joomla\CMS\Filter\OutputFilter;';
$headers[] = 'use Joomla\CMS\Installer\InstallerHelper;';
$headers[] = 'use Joomla\CMS\MVC\Model\BaseDatabaseModel;';
$headers[] = 'use Joomla\String\StringHelper;';
$headers[] = 'use Joomla\Utilities\ArrayHelper;';
$headers[] = 'use PhpOffice\PhpSpreadsheet\IOFactory;';
break;
case 'dashboard.view':
$headers[] = 'use Joomla\CMS\HTML\HTMLHelper as Html;';
break;
case 'dashboard.view.html':
$headers[] = 'use Joomla\CMS\HTML\HTMLHelper as Html;';
$headers[] = 'use Joomla\CMS\MVC\View\HtmlView as
BaseHtmlView;';
$headers[] = 'use Joomla\CMS\Toolbar\ToolbarHelper;';
$headers[] = 'use Joomla\CMS\Document\Document;';
break;
case 'site.router':
$headers[] = 'use Joomla\CMS\Application\SiteApplication;';
$headers[] = 'use
Joomla\CMS\Categories\CategoryFactoryInterface;';
$headers[] = 'use Joomla\CMS\Component\ComponentHelper;';
$headers[] = 'use Joomla\CMS\Component\Router\RouterView;';
$headers[] = 'use
Joomla\CMS\Component\Router\RouterViewConfiguration;';
$headers[] = 'use
Joomla\CMS\Component\Router\Rules\MenuRules;';
$headers[] = 'use
Joomla\CMS\Component\Router\Rules\NomenuRules;';
$headers[] = 'use
Joomla\CMS\Component\Router\Rules\StandardRules;';
$headers[] = 'use Joomla\CMS\Menu\AbstractMenu;';
$headers[] = 'use Joomla\Database\DatabaseInterface;';
$headers[] = 'use Joomla\Database\ParameterType;';
$headers[] = 'use Joomla\Registry\Registry;';
break;
case 'site.view':
case 'site.views':
$headers[] = 'use Joomla\CMS\Router\Route;';
$headers[] = 'use Joomla\CMS\Layout\LayoutHelper;';
$headers[] = 'use Joomla\CMS\HTML\HTMLHelper as Html;';
break;
case 'form.custom.field':
$headers[] = 'use Joomla\CMS\HTML\HTMLHelper as Html;';
$headers[] = 'use Joomla\CMS\Component\ComponentHelper;';
$headers[] = 'use
Joomla\CMS\Form\Field\###FORM_EXTENDS###;';
break;
case 'plugin.extension.header':
$headers = [];
break;
case 'plugin.provider.header':
$headers = [];
$headers[] = 'use Joomla\CMS\Factory;';
$headers[] = 'use Joomla\CMS\Plugin\PluginHelper;';
$headers[] = 'use Joomla\CMS\Extension\PluginInterface;';
$headers[] = 'use Joomla\Event\DispatcherInterface;';
$headers[] = 'use Joomla\DI\ServiceProviderInterface;';
$headers[] = 'use Joomla\DI\Container;';
break;
case 'api.view.controller':
case 'api.views.controller':
$headers = [];
$headers[] = 'use Joomla\CMS\Factory;';
$headers[] = 'use Joomla\CMS\MVC\Controller\ApiController;';
break;
case 'api.view.json':
case 'api.views.json':
$headers = [];
$headers[] = 'use Joomla\CMS\Factory;';
$headers[] = 'use Joomla\CMS\MVC\View\JsonApiView as
BaseApiView;';
break;
default:
break;
}
$this->headers[$context] = $headers;
return $headers;
}
}
src/Componentbuilder/Compiler/JoomlaFour/History.php000064400000012726151162054160016656
0ustar00<?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\JoomlaFour;
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\Componentbuilder\Compiler\Config;
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\HistoryInterface;
/**
* Compiler History
*
* @since 3.2.0
*/
final class History implements HistoryInterface
{
/**
* History Item Object
*
* @var object|null
* @since 3.2.0
*/
protected ?object $tmp;
/**
* Compiler Config
*
* @var Config
* @since 3.2.0
*/
protected Config $config;
/**
* Database object to query local DB
*
* @since 3.2.0
*/
protected $db;
/**
* Constructor
*
* @param Config|null $config The compiler config object.
*
* @since 3.2.0
*/
public function __construct(?Config $config = null)
{
$this->config = $config ?: Compiler::_('Config');
$this->db = Factory::getDbo();
}
/**
* Get Item History object
*
* @param string $type The type of item
* @param int $id The item ID
*
* @return ?object The history
* @since 3.2.0
*/
public function get(string $type, int $id): ?object
{
// quick class object to store old history object
$this->tmp = null;
// Create a new query object.
$query = $this->db->getQuery(true);
$query->select('h.*');
$query->from('#__history AS h');
$query->where(
$this->db->quoteName('h.item_id') . ' = ' .
$this->db->quote('com_componentbuilder.' . $type .
'.' . (int) $id)
);
$query->order('h.save_date DESC');
$this->db->setQuery($query, 0, 1);
$this->db->execute();
if ($this->db->getNumRows())
{
// new version of this item found
// so we need to mark it as the last compiled version
$newActive = $this->db->loadObject();
// set the new version watch
$this->set($newActive, 1);
}
// Get last compiled verion
$query = $this->db->getQuery(true);
$query->select('h.*');
$query->from('#__history AS h');
$query->where(
$this->db->quoteName('h.item_id') . ' = ' .
$this->db->quote('com_componentbuilder.' . $type .
'.' . (int) $id)
);
$query->where('h.keep_forever = 1');
$query->where('h.version_note LIKE ' .
$this->db->quote('%component%'));
// make sure it does not return the active version
if (isset($newActive) && isset($newActive->version_id))
{
$query->where('h.version_id != ' . (int)
$newActive->version_id);
}
$query->order('h.save_date DESC');
$this->db->setQuery($query);
$this->db->execute();
if ($this->db->getNumRows())
{
// the old active version was found
// so we may need to do an SQL update
// and unmark the old compiled version
$oldActives = $this->db->loadObjectList();
foreach ($oldActives as $oldActive)
{
// remove old version watch
$this->set($oldActive, 0);
}
}
// return the last used history record or null.
return $this->tmp;
}
/**
* Set Item History Watch
*
* @param Object $object The history object
* @param int $action The action to take
* 0 = remove watch
* 1 = add watch
*
* @return bool
* @since 3.2.0
*/
protected function set(object $object, int $action): bool
{
// check the note
if (JsonHelper::check($object->version_note))
{
$version_note = json_decode((string) $object->version_note, true);
}
else
{
$version_note = array('component' => []);
}
// set watch
switch ($action)
{
case 0:
// remove watch
if (isset($version_note['component'])
&& ($key = array_search(
$this->config->component_id,
$version_note['component']
)) !== false)
{
// last version that was used to build/compile
$this->tmp = json_decode((string) $object->version_data);
// remove it from this component
unset($version_note['component'][$key]);
}
else
{
// since it was not found, no need to update anything
return true;
}
break;
case 1:
// add watch
if (!in_array($this->config->component_id,
$version_note['component']))
{
$version_note['component'][] =
$this->config->component_id;
}
else
{
// since it is there already, no need to update anything
return true;
}
break;
}
// check if we need to still keep this locked
if (isset($version_note['component'])
&& ArrayHelper::check($version_note['component']))
{
// insure component ids are only added once per item
$version_note['component'] = array_unique(
$version_note['component']
);
// we may change this, little risky (but since JCB does not have history
notes it should be okay for now)
$object->version_note = json_encode($version_note);
$object->keep_forever = '1';
}
else
{
$object->version_note = '';
$object->keep_forever = '0';
}
// run the update
return $this->db->updateObject('#__history', $object,
'version_id');
}
}
src/Componentbuilder/Compiler/JoomlaFour/index.html000064400000000054151162054160016470
0ustar00<html><body
bgcolor="#FFFFFF"></body></html>src/Componentbuilder/Compiler/JoomlaPower.php000064400000027663151162054160015404
0ustar00<?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;
use Joomla\CMS\Factory;
use Joomla\CMS\Application\CMSApplication;
use Joomla\CMS\Language\Text;
use VDM\Joomla\Componentbuilder\Compiler\Config;
use VDM\Joomla\Componentbuilder\Compiler\Placeholder;
use VDM\Joomla\Componentbuilder\Compiler\Customcode;
use VDM\Joomla\Componentbuilder\Compiler\Customcode\Gui;
use VDM\Joomla\Componentbuilder\JoomlaPower\Remote\Get as SuperPower;
use VDM\Joomla\Utilities\ArrayHelper;
use VDM\Joomla\Utilities\JsonHelper;
use VDM\Joomla\Utilities\GuidHelper;
use VDM\Joomla\Utilities\String\NamespaceHelper;
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\PowerInterface;
/**
* Joomla Power
*
* @since 3.2.1
*/
final class JoomlaPower implements PowerInterface
{
/**
* All loaded powers
*
* @var array
* @since 3.2.1
**/
public array $active = [];
/**
* All power namespaces
*
* @var array
* @since 3.2.1
**/
public array $namespace = [];
/**
* All super powers of this build
*
* @var array
* @since 3.2.1
**/
public array $superpowers = [];
/**
* Old super powers found in the local repos
*
* @var array
* @since 3.2.1
**/
public array $old_superpowers = [];
/**
* The url to the power, if there is an error.
*
* @var string
* @since 3.2.1
**/
protected string $fixUrl;
/**
* The state of all loaded powers
*
* @var array
* @since 3.2.1
**/
protected array $state = [];
/**
* The state of retry to loaded powers
*
* @var array
* @since 3.2.1
**/
protected array $retry = [];
/**
* Compiler Config
*
* @var Config
* @since 3.2.1
**/
protected Config $config;
/**
* Compiler Placeholder
*
* @var Placeholder
* @since 3.2.1
**/
protected Placeholder $placeholder;
/**
* Compiler Customcode
*
* @var Customcode
* @since 3.2.1
**/
protected Customcode $customcode;
/**
* Compiler Customcode in Gui
*
* @var Gui
* @since 3.2.1
**/
protected Gui $gui;
/**
* The JCB Superpower class
*
* @var Superpower
* @since 3.2.1
**/
protected Superpower $superpower;
/**
* Database object to query local DB
*
* @since 3.2.1
**/
protected $db;
/**
* Database object to query local DB
*
* @since 3.2.1
**/
protected $app;
/**
* Constructor.
*
* @param Config $config The compiler config object.
* @param Placeholder $placeholder The compiler placeholder
object.
* @param Customcode $customcode The compiler customcode
object.
* @param Gui $gui The compiler customcode gui
object.
* @param Superpower $superpower The JCB superpower object.
*
* @throws \Exception
* @since 3.2.1
*/
public function __construct(Config $config, Placeholder $placeholder,
Customcode $customcode, Gui $gui, Superpower $superpower)
{
$this->config = $config;
$this->placeholder = $placeholder;
$this->customcode = $customcode;
$this->gui = $gui;
$this->superpower = $superpower;
$this->db = Factory::getDbo();
$this->app = Factory::getApplication();
}
/**
* load all the powers linked to this component
*
* @param array $guids The global unique ids of the linked powers
*
* @return void
* @since 3.2.1
*/
public function load(array $guids)
{
if (ArrayHelper::check($guids))
{
foreach ($guids as $guid => $build)
{
$this->get($guid, $build);
}
}
}
/**
* Get a power
*
* @param string $guid The global unique id of the power
* @param int $build Force build switch (to override global
switch)
*
* @return object|null
* @since 3.2.1
*/
public function get(string $guid, int $build = 0): ?object
{
if (($this->config->get('add_power', true) || $build ==
1) && $this->set($guid))
{
return $this->active[$guid];
}
return null;
}
/**
* Set a Joomla power
*
* @param string $guid The global unique id of the power
*
* @return bool true on successful setting of a power
* @since 3.2.1
*/
private function set(string $guid): bool
{
// Check if power is already set
if ($this->isPowerSet($guid))
{
return $this->state[$guid];
}
// Validate GUID
if (!$this->isGuidValid($guid))
{
$this->state[$guid] = false;
return false;
}
// Get the power data
$this->active[$guid] = $this->getPowerData($guid);
// Validate power data object
if ($this->active[$guid] === null)
{
return $this->handlePowerNotFound($guid);
}
// Prevent recursive loading of the same power
$this->state[$guid] = true;
// Convert settings to array if valid JSON
$settings = $this->convertSettingsToArray(
$this->active[$guid]->settings
);
// Set the target version if settings array is valid
if (!$this->setTargetVersion($guid, $settings))
{
return false;
}
// Set class name and namespace
$this->setClassAndNamespace($guid);
return true;
}
/**
* Convert settings JSON string to array
*
* @param string $settingsJson
*
* @return array|null
* @since 3.2.2
*/
private function convertSettingsToArray(string $settingsJson): ?array
{
if (JsonHelper::check($settingsJson))
{
return json_decode($settingsJson, true);
}
return null;
}
/**
* Set the target version based on Joomla version and settings
*
* @param string $guid
* @param array|null $settings
*
* @return bool
* @since 3.2.2
*/
private function setTargetVersion(string $guid, ?array $settings): bool
{
$joomla_version = $this->config->joomla_version;
if (!$joomla_version || !ArrayHelper::check($settings))
{
return false;
}
$joomla_version_target = null;
$target_found = false;
foreach ($settings as $namespace)
{
// Set default values for all versions
if ($namespace['joomla_version'] == 0)
{
$this->setNamespaceAndType($guid, $namespace);
$target_found = true;
}
// Check for direct target version
if ($joomla_version == $namespace['joomla_version'])
{
$joomla_version_target = $namespace;
break;
}
}
if ($joomla_version_target)
{
$this->setNamespaceAndType($guid, $joomla_version_target);
$target_found = true;
}
if (!$target_found)
{
$this->app->enqueueMessage(
Text::sprintf('COM_COMPONENTBUILDER_PJOOMLA_POWER_BGUIDSB_WAS_FOUND_BUT_MISSING_A_NAMESPACE_VALUE_FOR_JOOMLA_SP',
$guid, $joomla_version),
'Error'
);
$this->state[$guid] = false;
return false;
}
return true;
}
/**
* Set namespace and type for the active power
*
* @param string $guid
* @param array $namespace
*
* @since 3.2.2
*/
private function setNamespaceAndType(string $guid, array $namespace):
void
{
$this->active[$guid]->namespace =
$this->placeholder->update_(
$namespace['namespace']
);
$this->active[$guid]->type = $namespace['type'] ??
'class';
}
/**
* Set class name and namespace for the active power
*
* @param string $guid
*
* @since 3.2.2
*/
private function setClassAndNamespace(string $guid): void
{
$this->active[$guid]->class_name =
$this->extractLastNameFromNamespace(
$this->active[$guid]->namespace
);
$this->active[$guid]->_namespace =
$this->removeLastNameFromNamespace(
$this->active[$guid]->namespace
);
}
/**
* Handle power not found scenario
*
* @param string $guid
*
* @return bool
* @since 3.2.2
*/
private function handlePowerNotFound(string $guid): bool
{
if (empty($this->retry[$guid]) &&
$this->superpower->item($guid, ['remote',
'local']))
{
// Retry loading the power
unset($this->state[$guid]);
unset($this->active[$guid]);
$this->retry[$guid] = true;
return $this->set($guid);
}
$this->app->enqueueMessage(
Text::sprintf('COM_COMPONENTBUILDER_PJOOMLA_POWER_BGUIDSB_NOT_FOUNDP',
$guid),
'Error'
);
$this->state[$guid] = false;
return false;
}
/**
* Extracts the last part of a namespace string, which is typically the
class name.
*
* @param string $namespace The namespace string to extract from.
*
* @return string|null The extracted class name.
* @since 3.2.1
*/
private function extractLastNameFromNamespace(string $namespace): ?string
{
$parts = explode('\\', $namespace);
$result = end($parts);
// Remove '\\' from the beginning and end of the resulting
string
$result = trim($result, '\\');
// If the resulting string is empty, return null
return empty($result) ? null : $result;
}
/**
* Removes the last name from the namespace.
*
* @param string $namespace The namespace
*
* @return string The namespace shortened
* @since 3.2.1
*/
private function removeLastNameFromNamespace(string $namespace): string
{
// Remove '\\' from the beginning and end of the resulting
string
$namespace = trim($namespace, '\\');
$parts = explode('\\', $namespace);
// Remove the last part (the class name)
array_pop($parts);
// Reassemble the namespace without the class name
return implode('\\', $parts);
}
/**
* Check if the power is already set
*
* @param string $guid The global unique id of the power
*
* @return bool true if the power is already set
* @since 3.2.1
*/
private function isPowerSet(string $guid): bool
{
return isset($this->state[$guid]);
}
/**
* Validate the GUID
*
* @param string $guid The global unique id of the power
*
* @return bool true if the GUID is valid
* @since 3.2.1
*/
private function isGuidValid(string $guid): bool
{
return GuidHelper::valid($guid);
}
/**
* Get the power data from the database
*
* @param string $guid The global unique id of the power
*
* @return object|null The power data
* @since 3.2.1
*/
private function getPowerData(string $guid): ?object
{
$query = $this->db->getQuery(true);
$query->select('a.*');
$query->from('#__componentbuilder_joomla_power AS a');
$query->where($this->db->quoteName('a.guid') . '
= ' . $this->db->quote($guid));
$this->db->setQuery($query);
$this->db->execute();
if ($this->db->getNumRows())
{
return $this->db->loadObject();
}
return null;
}
/**
* Get Clean Namespace without use or ; as part of the name space
*
* @param string $namespace The actual name space
* @param bool $removeNumbers The switch to remove numbers
*
* @return string
* @since 3.2.1
*/
private function getCleanNamespace(string $namespace): string
{
// trim possible (use) or (;) or (starting or ending \) added to the
namespace
return NamespaceHelper::safe(str_replace(['use ',
';'], '', $namespace));
}
/**
* Get [use Namespace\Class;]
*
* @param string $namespace The actual name space
* @param string $as The use as name (default is none)
*
* @return string
* @since 3.2.1
*/
private function getUseNamespace(string $namespace, string $as =
'default'): string
{
// check if it has an AS option
if ($as !== 'default')
{
return 'use ' . $namespace . ' as ' . $as .
';';
}
return 'use ' . $namespace . ';';
}
/**
* Set the super powers of this power
*
* @param string $guid The global unique id of the power
*
* @return void
* @since 3.2.1
*/
private function setSuperPowers(string $guid): void
{
// soon
}
}
src/Componentbuilder/Compiler/JoomlaPower/Extractor.php000064400000005414151162054160017345
0ustar00<?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\JoomlaPower;
use VDM\Joomla\Utilities\JsonHelper;
use
VDM\Joomla\Componentbuilder\Compiler\Interfaces\Power\ExtractorInterface;
use VDM\Joomla\Componentbuilder\Compiler\Power\Extractor as
ExtendingExtractor;
/**
* Compiler Joomla Power Extractor
* @since 3.2.1
*/
final class Extractor extends ExtendingExtractor implements
ExtractorInterface
{
/**
* The pattern to get the powers
*
* @var string
* @since 3.2.0
**/
protected string $pattern =
'/Joomla_'.'_'.'_[a-zA-Z0-9_]+_'.'_'.'_Power/';
/**
* The pattern to get the Front
*
* @var string
* @since 3.2.1
**/
protected string $_pattern = 'Joomla';
/**
* The pattern to get the Back
*
* @var string
* @since 3.2.1
**/
protected string $pattern_ = 'Power';
/**
* The Table
*
* @var string
* @since 3.2.1
**/
protected string $table = 'joomla_power';
/**
* Current Joomla Version Being Build
*
* @var int
* @since 3.2.0
**/
protected $targetVersion;
/**
* Constructor.
*
* @param int $targetVersion The targeted Joomla version.
*
* @since 3.2.1
*/
public function __construct(int $targetVersion)
{
parent::__construct();
$this->targetVersion = $targetVersion;
}
/**
* Get the complete namespace strings of the guids passed as an array.
*
* @param array $guids The guids to filter the results
*
* @return array|null The result namespaces with their guids
* @since 3.2.0
**/
protected function namespaces(array $guids): ?array
{
$query = $this->db->getQuery(true);
$query->select($this->db->quoteName(['settings',
'guid']))
->from($this->db->quoteName('#__componentbuilder_' .
$this->table))
->where($this->db->quoteName('guid') . ' IN
(' . implode(',', array_map([$this->db,
'quote'], $guids)) . ')');
$this->db->setQuery($query);
$this->db->execute();
if ($this->db->getNumRows())
{
$namespaces = [];
$items = $this->db->loadAssocList();
foreach ($items as $item)
{
if (JsonHelper::check($item->settings))
{
$item->settings = json_decode($item->settings, true);
echo '<pre>'; var_dump($item->settings,
'Joomla Version: ' . $this->targetVersion); exit;
}
}
if ($namespaces !== [])
{
return $namespaces;
}
}
return null;
}
}
src/Componentbuilder/Compiler/JoomlaPower/Injector.php000064400000004735151162054160017154
0ustar00<?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\JoomlaPower;
use
VDM\Joomla\Componentbuilder\Compiler\Interfaces\Power\InjectorInterface;
use VDM\Joomla\Componentbuilder\Compiler\Power\Injector as
ExtendingInjector;
/**
* Compiler Joomla Power Injector
* @since 3.2.0
*/
final class Injector extends ExtendingInjector implements InjectorInterface
{
/**
* Builds the namespace statement from the power object's namespace
and class name.
*
* @param object $power The power object.
*
* @return string The constructed use statement.
* @since 3.2.0
*/
protected function buildNamespaceStatment(object $power): string
{
return $power->_namespace . '\\' . $power->class_name;
}
/**
* Ensures the name for the use statement is unique, avoiding conflicts
with other classes.
*
* @param string $name The current name
* @param object $power The power object containing type, namespace,
and class name.
*
* @return string The unique name
* @since 3.2.0
*/
protected function getUniqueName(string $name, object $power): string
{
// set search namespace
$namespace = ($name !== $power->class_name) ?
$this->buildNamespaceStatment($power) : $power->_namespace;
// check if we need to update the name
if (isset($this->other[$name]))
{
// if the name is already used
while (isset($this->other[$name]))
{
if (($tmp = $this->extractClassNameOrAlias($namespace)) !== null)
{
$name = ucfirst($tmp) . $name;
$namespace = $this->removeLastNameFromNamespace($namespace);
}
else
{
$name = 'Unique' . $name;
}
}
}
// also loop new found use statements
if (isset($this->useStatements[$name]))
{
// if the name is already used
while (isset($this->useStatements[$name]))
{
if (($tmp = $this->extractClassNameOrAlias($namespace)) !== null)
{
$name = ucfirst($tmp) . $name;
$namespace = $this->removeLastNameFromNamespace($namespace);
}
else
{
$name = 'Unique' . $name;
}
}
}
return $name;
}
}
src/Componentbuilder/Compiler/JoomlaPower/index.html000064400000000054151162054160016651
0ustar00<html><body
bgcolor="#FFFFFF"></body></html>src/Componentbuilder/Compiler/JoomlaThree/Event.php000064400000004521151162054160016424
0ustar00<?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\JoomlaThree;
use Joomla\Registry\Registry;
use VDM\Joomla\Utilities\Component\Helper;
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\EventInterface;
/**
* Compiler Events
*
* @since 3.2.0
*/
final class Event implements EventInterface
{
/**
* event plugin trigger switch
*
* @var boolean
* @since 3.2.0
*/
protected $activePlugins = false;
/**
* Constructor
*
* @param Registry|null $params The component parameters
*
* @since 3.2.0
*/
public function __construct(?Registry $params = null)
{
// Set the params
$params = $params ?:
Helper::getParams('com_componentbuilder');
// get active plugins
if (($plugins = $params->get('compiler_plugin', false))
!== false)
{
foreach ($plugins as $plugin)
{
// get possible plugins
if (\JPluginHelper::isEnabled('extension', $plugin))
{
// Import the appropriate plugin group.
\JPluginHelper::importPlugin('extension', $plugin);
// activate events
$this->activePlugins = true;
}
}
}
}
/**
* Trigger an event
*
* @param string $event The event to trigger
* @param mixed $data The values to pass to the event/plugin
*
* @return void
* @throws \Exception
* @since 3.2.0
*/
public function trigger(string $event, $data = null)
{
// only execute if plugins were loaded (active)
if ($this->activePlugins)
{
// Get the dispatcher.
$dispatcher = \JEventDispatcher::getInstance();
// Trigger this compiler event.
$results = $dispatcher->trigger($event, $data);
// Check for errors encountered while trigger the event
if (count((array) $results) && in_array(false, $results, true))
{
// Get the last error.
$error = $dispatcher->getError();
if (!($error instanceof \Exception))
{
throw new \Exception($error);
}
}
}
}
}
src/Componentbuilder/Compiler/JoomlaThree/Header.php000064400000042240151162054160016533
0ustar00<?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\JoomlaThree;
use VDM\Joomla\Componentbuilder\Compiler\Config;
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\EventInterface as
Event;
use VDM\Joomla\Componentbuilder\Compiler\Placeholder;
use VDM\Joomla\Componentbuilder\Compiler\Language;
use VDM\Joomla\Componentbuilder\Compiler\Builder\UikitComp;
use VDM\Joomla\Componentbuilder\Compiler\Builder\AdminFilterType;
use VDM\Joomla\Componentbuilder\Compiler\Builder\Category;
use VDM\Joomla\Componentbuilder\Compiler\Builder\AccessSwitchList;
use VDM\Joomla\Componentbuilder\Compiler\Builder\Filter;
use VDM\Joomla\Componentbuilder\Compiler\Builder\Tags;
use VDM\Joomla\Utilities\ArrayHelper;
use VDM\Joomla\Utilities\StringHelper;
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\HeaderInterface;
/**
* Build headers for all Joomla 3 files
*
* @since 3.2.0
*/
final class Header implements HeaderInterface
{
/**
* The Config Class.
*
* @var Config
* @since 3.2.0
*/
protected Config $config;
/**
* The EventInterface Class.
*
* @var Event
* @since 3.2.0
*/
protected Event $event;
/**
* The Placeholder Class.
*
* @var Placeholder
* @since 3.2.0
*/
protected Placeholder $placeholder;
/**
* The Language Class.
*
* @var Language
* @since 3.2.0
*/
protected Language $language;
/**
* The UikitComp Class.
*
* @var UikitComp
* @since 3.2.0
*/
protected UikitComp $uikitcomp;
/**
* The AdminFilterType Class.
*
* @var AdminFilterType
* @since 3.2.0
*/
protected AdminFilterType $adminfiltertype;
/**
* The Category Class.
*
* @var Category
* @since 3.2.0
*/
protected Category $category;
/**
* The AccessSwitchList Class.
*
* @var AccessSwitchList
* @since 3.2.0
*/
protected AccessSwitchList $accessswitchlist;
/**
* The Filter Class.
*
* @var Filter
* @since 3.2.0
*/
protected Filter $filter;
/**
* The Tags Class.
*
* @var Tags
* @since 3.2.0
*/
protected Tags $tags;
/**
* The Header Context array
*
* @var array
* @since 3.2.0
*/
protected array $headers = [];
/**
* Constructor.
*
* @param Config $config The Config Class.
* @param Event $event The EventInterface
Class.
* @param Placeholder $placeholder The Placeholder Class.
* @param Language $language The Language Class.
* @param UikitComp $uikitcomp The UikitComp Class.
* @param AdminFilterType $adminfiltertype The AdminFilterType
Class.
* @param Category $category The Category Class.
* @param AccessSwitchList $accessswitchlist The AccessSwitchList
Class.
* @param Filter $filter The Filter Class.
* @param Tags $tags The Tags Class.
*
* @since 3.2.0
*/
public function __construct(Config $config, Event $event, Placeholder
$placeholder,
Language $language, UikitComp $uikitcomp,
AdminFilterType $adminfiltertype, Category $category,
AccessSwitchList $accessswitchlist, Filter $filter,
Tags $tags)
{
$this->config = $config;
$this->event = $event;
$this->placeholder = $placeholder;
$this->language = $language;
$this->uikitcomp = $uikitcomp;
$this->adminfiltertype = $adminfiltertype;
$this->category = $category;
$this->accessswitchlist = $accessswitchlist;
$this->filter = $filter;
$this->tags = $tags;
}
/**
* Get the headers for a file
*
* @param string $context The name of the context
* @param string $codeName The view, views, or layout code name
*
* @return string The header string to place in the header of the file
* @since 3.2.0
*/
public function get(string $context, string $codeName): string
{
// get static headers
$headers = $this->getHeaders($context);
// get dynamic headers
switch ($context)
{
case 'admin.helper':
case 'site.helper':
$this->setHelperClassHeader($headers, $codeName);
break;
case 'admin.view.html':
case 'admin.views.html':
case 'custom.admin.view.html':
case 'custom.admin.views.html':
case 'site.admin.view.html':
case 'site.view.html':
case 'site.views.html':
if ((2 == $this->config->uikit || 1 ==
$this->config->uikit)
&& $this->uikitcomp->exists($codeName))
{
$headers[] = 'use Joomla\CMS\Filesystem\File;';
}
break;
case 'admin.views':
$this->setChosenMultiSelectionHeaders($headers, $codeName);
break;
case 'admin.view.model':
case 'site.admin.view.model':
case 'custom.admin.view.model':
case 'site.view.model':
case 'admin.views.model':
case 'site.views.model':
$headers[] = 'use Joomla\CMS\Helper\TagsHelper;';
break;
case 'plugin.extension.header':
case 'plugin.provider.header':
$headers = [];
break;
default:
break;
}
// Trigger Event: jcb_ce_setClassHeader
$this->event->trigger(
'jcb_ce_setClassHeader', [&$context, &$codeName,
&$headers]
);
// return the headers
return $this->placeholder->update_(implode(PHP_EOL, $headers));
}
/**
* Get the headers for a file
*
* @param string $context The name of the context
*
* @return array The header string to place in the header of the file
* @since 3.2.0
*/
protected function getHeaders(string $context): array
{
if (isset($this->headers[$context]))
{
return $this->headers[$context];
}
// set the defaults
$headers = [];
$headers[] = 'use Joomla\CMS\Factory;';
$headers[] = 'use Joomla\CMS\Language\Text;';
switch ($context)
{
case 'admin.component':
$headers[] = 'use Joomla\CMS\Access\Exception\NotAllowed;';
$headers[] = 'use Joomla\CMS\HTML\HTMLHelper as Html;';
$headers[] = 'use
Joomla\CMS\MVC\Controller\BaseController;';
break;
case 'admin.helper':
case 'site.helper':
$headers[] = 'use Joomla\CMS\Access\Access;';
$headers[] = 'use Joomla\CMS\Access\Rules as AccessRules;';
$headers[] = 'use Joomla\CMS\Component\ComponentHelper;';
$headers[] = 'use Joomla\CMS\Filesystem\File;';
$headers[] = 'use Joomla\CMS\Language\Language;';
$headers[] = 'use Joomla\CMS\MVC\Model\BaseDatabaseModel;';
$headers[] = 'use Joomla\CMS\Object\CMSObject;';
$headers[] = 'use Joomla\CMS\Table\Table;';
$headers[] = 'use Joomla\CMS\Uri\Uri;';
$headers[] = 'use Joomla\CMS\Version;';
$headers[] = 'use Joomla\Registry\Registry;';
$headers[] = 'use Joomla\String\StringHelper;';
$headers[] = 'use Joomla\Utilities\ArrayHelper;';
break;
case 'admin.layout':
case 'site.layout':
case 'custom.admin.layout':
case 'override.layout':
$headers[] = 'use Joomla\CMS\HTML\HTMLHelper as Html;';
$headers[] = 'use Joomla\CMS\Layout\LayoutHelper;';
break;
case 'admin.view':
case 'custom.admin.view':
case 'custom.admin.views':
case 'site.admin.view':
$headers[] = 'use Joomla\CMS\HTML\HTMLHelper as Html;';
$headers[] = 'use Joomla\CMS\Layout\LayoutHelper;';
$headers[] = 'use Joomla\CMS\Router\Route;';
$headers[] =
'Html::addIncludePath(JPATH_COMPONENT.\'/helpers/html\');';
$headers[] =
'Html::_(\'behavior.formvalidator\');';
$headers[] = 'Html::_(\'formbehavior.chosen\',
\'select\');';
$headers[] = 'Html::_(\'behavior.keepalive\');';
break;
case 'admin.view.controller':
case 'site.admin.view.controller':
case 'site.view.controller':
$headers[] = 'use
Joomla\CMS\MVC\Controller\FormController;';
$headers[] = 'use Joomla\CMS\MVC\Model\BaseDatabaseModel;';
$headers[] = 'use Joomla\Utilities\ArrayHelper;';
$headers[] = 'use Joomla\CMS\Router\Route;';
$headers[] = 'use Joomla\CMS\Session\Session;';
$headers[] = 'use Joomla\CMS\Uri\Uri;';
break;
case 'admin.view.html':
case 'admin.views.html':
case 'site.admin.view.html':
$headers[] = 'use Joomla\CMS\Form\FormHelper;';
$headers[] = 'use Joomla\CMS\Session\Session;';
$headers[] = 'use Joomla\CMS\Uri\Uri;';
case 'site.view.html':
case 'site.views.html':
$headers[] = 'use Joomla\CMS\Toolbar\Toolbar;';
case 'custom.admin.view.html':
case 'custom.admin.views.html':
$headers[] = 'use Joomla\CMS\Component\ComponentHelper;';
$headers[] = 'use Joomla\CMS\HTML\HTMLHelper as Html;';
$headers[] = 'use Joomla\CMS\Layout\FileLayout;';
$headers[] = 'use Joomla\CMS\MVC\View\HtmlView;';
$headers[] = 'use Joomla\CMS\Plugin\PluginHelper;';
$headers[] = 'use Joomla\CMS\Toolbar\ToolbarHelper;';
break;
case 'admin.view.model':
case 'site.admin.view.model':
$headers[] = 'use Joomla\CMS\Component\ComponentHelper;';
$headers[] = 'use Joomla\CMS\Filter\InputFilter;';
$headers[] = 'use Joomla\CMS\Filter\OutputFilter;';
$headers[] = 'use Joomla\CMS\MVC\Model\AdminModel;';
$headers[] = 'use Joomla\CMS\Table\Table;';
$headers[] = 'use Joomla\CMS\UCM\UCMType;';
$headers[] = 'use Joomla\Registry\Registry;';
$headers[] = 'use Joomla\String\StringHelper;';
$headers[] = 'use Joomla\Utilities\ArrayHelper;';
break;
case 'admin.views':
$headers[] = 'use Joomla\CMS\Component\ComponentHelper;';
$headers[] = 'use Joomla\CMS\HTML\HTMLHelper as Html;';
$headers[] = 'use Joomla\CMS\Layout\LayoutHelper;';
$headers[] = 'use Joomla\CMS\Router\Route;';
$headers[] = 'Html::_(\'behavior.multiselect\');';
$headers[] = 'Html::_(\'dropdown.init\');';
$headers[] = 'Html::_(\'formbehavior.chosen\',
\'select\');';
break;
case 'admin.views.controller':
case 'custom.admin.views.controller':
case 'dashboard.controller':
$headers[] = 'use
Joomla\CMS\MVC\Controller\AdminController;';
$headers[] = 'use Joomla\Utilities\ArrayHelper;';
$headers[] = 'use Joomla\CMS\Router\Route;';
$headers[] = 'use Joomla\CMS\Session\Session;';
break;
case 'dashboard.model':
$headers[] = 'use Joomla\CMS\Uri\Uri;';
$headers[] = 'use Joomla\CMS\Session\Session;';
$headers[] = 'use Joomla\CMS\HTML\HTMLHelper as Html;';
case 'admin.views.model':
case 'ajax.admin.model':
case 'ajax.site.model':
case 'custom.admin.views.model':
case 'site.views.model':
$headers[] = 'use Joomla\CMS\Component\ComponentHelper;';
$headers[] = 'use Joomla\CMS\MVC\Model\ListModel;';
$headers[] = 'use Joomla\CMS\Plugin\PluginHelper;';
$headers[] = 'use Joomla\Utilities\ArrayHelper;';
break;
case 'custom.admin.view.controller':
case 'import.controller':
case 'import.custom.controller':
$headers[] = 'use
Joomla\CMS\MVC\Controller\BaseController;';
$headers[] = 'use Joomla\CMS\Router\Route;';
$headers[] = 'use Joomla\CMS\Session\Session;';
$headers[] = 'use Joomla\Utilities\ArrayHelper;';
break;
case 'custom.admin.view.model':
case 'site.view.model':
$headers[] = 'use Joomla\CMS\Component\ComponentHelper;';
$headers[] = 'use Joomla\CMS\MVC\Model\ItemModel;';
$headers[] = 'use Joomla\CMS\Plugin\PluginHelper;';
$headers[] = 'use Joomla\CMS\Router\Route;';
$headers[] = 'use Joomla\CMS\Uri\Uri;';
$headers[] = 'use Joomla\Utilities\ArrayHelper;';
break;
case 'import.custom.model':
case 'import.model':
$headers[] = 'use Joomla\CMS\Filesystem\File;';
$headers[] = 'use Joomla\CMS\Filesystem\Folder;';
$headers[] = 'use Joomla\CMS\Filesystem\Path;';
$headers[] = 'use Joomla\CMS\Filter\OutputFilter;';
$headers[] = 'use Joomla\CMS\Installer\InstallerHelper;';
$headers[] = 'use Joomla\CMS\MVC\Model\BaseDatabaseModel;';
$headers[] = 'use Joomla\String\StringHelper;';
$headers[] = 'use Joomla\Utilities\ArrayHelper;';
$headers[] = 'use PhpOffice\PhpSpreadsheet\IOFactory;';
break;
case 'dashboard.view':
$headers[] = 'use Joomla\CMS\HTML\HTMLHelper as Html;';
break;
case 'dashboard.view.html':
$headers[] = 'use Joomla\CMS\HTML\HTMLHelper as Html;';
$headers[] = 'use Joomla\CMS\MVC\View\HtmlView;';
$headers[] = 'use Joomla\CMS\Toolbar\ToolbarHelper;';
break;
case 'site.component':
$headers[] = 'use Joomla\CMS\HTML\HTMLHelper as Html;';
$headers[] = 'use
Joomla\CMS\MVC\Controller\BaseController;';
break;
case 'site.view':
case 'site.views':
$headers[] = 'use Joomla\CMS\Router\Route;';
$headers[] = 'use Joomla\CMS\HTML\HTMLHelper as Html;';
break;
case 'form.custom.field':
$headers[] = 'use Joomla\CMS\HTML\HTMLHelper as Html;';
$headers[] = "jimport('joomla.form.helper');";
$headers[] =
"\JFormHelper::loadFieldClass('###JFORM_extends###');";
break;
default:
break;
}
$this->headers[$context] = $headers;
return $headers;
}
/**
* set Helper Dynamic Headers
*
* @param array $headers The headers array
* @param string $target_client
*
* @return void
* @since 3.2.0
*/
protected function setHelperClassHeader(&$headers, $target_client)
{
// add only to admin client
if ('admin' === $target_client &&
$this->config->get('add_eximport', false))
{
$headers[] = 'use PhpOffice\PhpSpreadsheet\IOFactory;';
$headers[] = 'use PhpOffice\PhpSpreadsheet\Spreadsheet;';
$headers[] = 'use PhpOffice\PhpSpreadsheet\Writer\Xlsx;';
}
}
/**
* Build chosen multi selection headers for the view
*
* @param array $headers The headers array
* @param string $nameListCode The list view name
*
* @return void
* @since 3.2.0
*/
protected function setChosenMultiSelectionHeaders(&$headers,
$nameListCode)
{
// check that the filter type is the new filter option (2 = topbar)
if ($this->adminfiltertype->get($nameListCode, 1) == 2)
{
// add category switch
$add_category = false;
if
($this->category->exists("{$nameListCode}.extension")
&&
$this->category->get("{$nameListCode}.filter", 0) >= 1)
{
// is found so add it
$add_category = true;
}
// add accessLevels switch
$add_access_levels = false;
if ($this->accessswitchlist->exists($nameListCode))
{
// is found so add it
$add_access_levels = true;
}
// check if this view have filters
if ($this->filter->exists($nameListCode))
{
foreach ($this->filter->get($nameListCode) as $filter)
{
// we need this only for filters that are multi
if (isset($filter['multi']) &&
$filter['multi'] == 2)
{
// if this is a category we should make sure it must be added
if (!$add_category && $filter['type'] ===
'category')
{
continue;
}
elseif ($add_category && $filter['type'] ===
'category')
{
// already added here so no need to add again
$add_category = false;
}
// check if this was an access field
elseif ($filter['type'] === 'accesslevel')
{
// already added here so no need to add again
$add_access_levels = false;
}
// add the header
$headers[]
= 'Html::_(\'formbehavior.chosen\',
\'.multiple'
. $filter['class']
. '\', null, [\'placeholder_text_multiple\'
=> \'- \' . Text::_(\''
. $filter['lang_select'] . '\') . \'
-\']);';
}
elseif ($add_category && $filter['type'] ===
'category')
{
// add the header
$headers[]
= 'Html::_(\'formbehavior.chosen\',
\'.multipleCategories'
. '\', null, [\'placeholder_text_multiple\'
=> \'- \' . Text::_(\''
. $filter['lang_select'] . '\') . \'
-\']);';
// already added here so no need to add again
$add_category = false;
}
}
}
// add category if not already added
if ($add_category)
{
// add the header
$headers[]
= 'Html::_(\'formbehavior.chosen\',
\'.multipleCategories'
. '\', null, [\'placeholder_text_multiple\' =>
\'- \' . Text::_(\''
. $this->category->exists("{$nameListCode}.name",
'error')
. '\') . \' -\']);';
}
// add accessLevels if not already added
if ($add_access_levels)
{
// set the language strings for selection
$filter_name_select = 'Select Access';
$filter_name_select_lang = $this->config->lang_prefix .
'_FILTER_'
. StringHelper::safe(
$filter_name_select, 'U'
);
// and to translation
$this->language->set(
$this->config->lang_target, $filter_name_select_lang,
$filter_name_select
);
// add the header
$headers[]
= 'Html::_(\'formbehavior.chosen\',
\'.multipleAccessLevels'
. '\', null, [\'placeholder_text_multiple\' =>
\'- \' . Text::_(\''
. $filter_name_select_lang . '\') . \'
-\']);';
}
}
}
}
src/Componentbuilder/Compiler/JoomlaThree/History.php000064400000013553151162054160017011
0ustar00<?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\JoomlaThree;
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\Componentbuilder\Compiler\Config;
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\HistoryInterface;
/**
* Compiler History
*
* @since 3.2.0
*/
final class History implements HistoryInterface
{
/**
* History Item Object
*
* @var object|null
* @since 3.2.0
*/
protected ?object $tmp;
/**
* Compiler Config
*
* @var Config
* @since 3.2.0
*/
protected Config $config;
/**
* Database object to query local DB
*
* @since 3.2.0
*/
protected $db;
/**
* Constructor
*
* @param Config|null $config The compiler config object.
*
* @since 3.2.0
*/
public function __construct(?Config $config = null)
{
$this->config = $config ?: Compiler::_('Config');
$this->db = Factory::getDbo();
}
/**
* Get Item History object
*
* @param string $type The type of item
* @param int $id The item ID
*
* @return ?object The history
* @since 3.2.0
*/
public function get(string $type, int $id): ?object
{
// quick class object to store old history object
$this->tmp = null;
// Create a new query object.
$query = $this->db->getQuery(true);
$query->select('h.*');
$query->from('#__ucm_history AS h');
$query->where(
$this->db->quoteName('h.ucm_item_id') . ' = '
. (int) $id
);
// Join over the content type for the type id
$query->join(
'LEFT', '#__content_types AS ct ON ct.type_id =
h.ucm_type_id'
);
$query->where(
'ct.type_alias = ' . $this->db->quote(
'com_componentbuilder.' . $type
)
);
$query->order('h.save_date DESC');
$this->db->setQuery($query, 0, 1);
$this->db->execute();
if ($this->db->getNumRows())
{
// new version of this item found
// so we need to mark it as the last compiled version
$newActive = $this->db->loadObject();
// set the new version watch
$this->set($newActive, 1);
}
// Get last compiled verion
$query = $this->db->getQuery(true);
$query->select('h.*');
$query->from('#__ucm_history AS h');
$query->where(
$this->db->quoteName('h.ucm_item_id') . ' = '
. (int) $id
);
$query->where('h.keep_forever = 1');
$query->where('h.version_note LIKE ' .
$this->db->quote('%component%'));
// make sure it does not return the active version
if (isset($newActive) && isset($newActive->version_id))
{
$query->where('h.version_id != ' . (int)
$newActive->version_id);
}
// Join over the content type for the type id
$query->join(
'LEFT', '#__content_types AS ct ON ct.type_id =
h.ucm_type_id'
);
$query->where(
'ct.type_alias = ' . $this->db->quote(
'com_componentbuilder.' . $type
)
);
$query->order('h.save_date DESC');
$this->db->setQuery($query);
$this->db->execute();
if ($this->db->getNumRows())
{
// the old active version was found
// so we may need to do an SQL update
// and unmark the old compiled version
$oldActives = $this->db->loadObjectList();
foreach ($oldActives as $oldActive)
{
// remove old version watch
$this->set($oldActive, 0);
}
}
// return the last used history record or null.
return $this->tmp;
}
/**
* Set Item History Watch
*
* @param Object $object The history object
* @param int $action The action to take
* 0 = remove watch
* 1 = add watch
*
* @return bool
* @since 3.2.0
*/
protected function set(object $object, int $action): bool
{
// check the note
if (JsonHelper::check($object->version_note))
{
$version_note = json_decode((string) $object->version_note, true);
}
else
{
$version_note = array('component' => []);
}
// set watch
switch ($action)
{
case 0:
// remove watch
if (isset($version_note['component'])
&& ($key = array_search(
$this->config->component_id,
$version_note['component']
)) !== false)
{
// last version that was used to build/compile
$this->tmp = json_decode((string) $object->version_data);
// remove it from this component
unset($version_note['component'][$key]);
}
else
{
// since it was not found, no need to update anything
return true;
}
break;
case 1:
// add watch
if (!in_array($this->config->component_id,
$version_note['component']))
{
$version_note['component'][] =
$this->config->component_id;
}
else
{
// since it is there already, no need to update anything
return true;
}
break;
}
// check if we need to still keep this locked
if (isset($version_note['component'])
&& ArrayHelper::check($version_note['component']))
{
// insure component ids are only added once per item
$version_note['component'] = array_unique(
$version_note['component']
);
// we may change this, little risky (but since JCB does not have history
notes it should be okay for now)
$object->version_note = json_encode($version_note);
$object->keep_forever = '1';
}
else
{
$object->version_note = '';
$object->keep_forever = '0';
}
// run the update
return $this->db->updateObject('#__ucm_history', $object,
'version_id');
}
}
src/Componentbuilder/Compiler/JoomlaThree/index.html000064400000000054151162054160016624
0ustar00<html><body
bgcolor="#FFFFFF"></body></html>src/Componentbuilder/Compiler/Joomlamodule/Data.php000064400000064575151162054160016451
0ustar00<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder
<https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights
reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
namespace VDM\Joomla\Componentbuilder\Compiler\Joomlamodule;
use Joomla\CMS\Factory;
use Joomla\CMS\Filter\OutputFilter;
use VDM\Joomla\Componentbuilder\Compiler\Config;
use VDM\Joomla\Componentbuilder\Compiler\Customcode;
use VDM\Joomla\Componentbuilder\Compiler\Customcode\Gui;
use VDM\Joomla\Componentbuilder\Compiler\Placeholder;
use VDM\Joomla\Componentbuilder\Compiler\Language;
use VDM\Joomla\Componentbuilder\Compiler\Field;
use VDM\Joomla\Componentbuilder\Compiler\Field\Name as Fieldname;
use VDM\Joomla\Componentbuilder\Compiler\Model\Filesfolders;
use VDM\Joomla\Componentbuilder\Compiler\Model\Libraries;
use VDM\Joomla\Componentbuilder\Compiler\Dynamicget\Data as Dynamicget;
use VDM\Joomla\Componentbuilder\Compiler\Templatelayout\Data as
Templatelayout;
use VDM\Joomla\Utilities\ArrayHelper;
use VDM\Joomla\Utilities\String\ClassfunctionHelper;
use VDM\Joomla\Utilities\JsonHelper;
use VDM\Joomla\Utilities\StringHelper;
use VDM\Joomla\Utilities\GetHelper;
/**
* Joomla Module Data Class
*
* @since 3.2.0
*/
class Data
{
/**
* Compiler Joomla Plugins Data
*
* @var array
* @since 3.2.0
*/
protected array $data = [];
/**
* The Config Class.
*
* @var Config
* @since 3.2.0
*/
protected Config $config;
/**
* The Customcode Class.
*
* @var Customcode
* @since 3.2.0
*/
protected Customcode $customcode;
/**
* The Gui Class.
*
* @var Gui
* @since 3.2.0
*/
protected Gui $gui;
/**
* The Placeholder Class.
*
* @var Placeholder
* @since 3.2.0
*/
protected Placeholder $placeholder;
/**
* The Language Class.
*
* @var Language
* @since 3.2.0
*/
protected Language $language;
/**
* The Field Class.
*
* @var Field
* @since 3.2.0
*/
protected Field $field;
/**
* The Name Class.
*
* @var Fieldname
* @since 3.2.0
*/
protected Fieldname $fieldname;
/**
* The Filesfolders Class.
*
* @var Filesfolders
* @since 3.2.0
*/
protected Filesfolders $filesfolders;
/**
* The Libraries Class.
*
* @var Libraries
* @since 3.2.0
*/
protected Libraries $libraries;
/**
* The Data Class.
*
* @var Dynamicget
* @since 3.2.0
*/
protected Dynamicget $dynamicget;
/**
* The Data Class.
*
* @var Templatelayout
* @since 3.2.0
*/
protected Templatelayout $templatelayout;
/**
* The Database Class.
*
* @since 3.2.0
*/
protected $db;
/**
* Constructor.
*
* @param Config $config The Config Class.
* @param Customcode $customcode The Customcode Class.
* @param Gui $gui The Gui Class.
* @param Placeholder $placeholder The Placeholder Class.
* @param Language $language The Language Class.
* @param Field $field The Field Class.
* @param Fieldname $fieldname The Name Class.
* @param Filesfolders $filesfolders The Filesfolders Class.
* @param Libraries $libraries The Libraries Class.
* @param Dynamicget $dynamicget The Data Class.
* @param Templatelayout $templatelayout The Data Class.
*
* @since 3.2.0
*/
public function __construct(Config $config, Customcode $customcode, Gui
$gui,
Placeholder $placeholder, Language $language,
Field $field, Fieldname $fieldname,
Filesfolders $filesfolders, Libraries $libraries,
Dynamicget $dynamicget, Templatelayout $templatelayout)
{
$this->config = $config;
$this->customcode = $customcode;
$this->gui = $gui;
$this->placeholder = $placeholder;
$this->language = $language;
$this->field = $field;
$this->fieldname = $fieldname;
$this->filesfolders = $filesfolders;
$this->libraries = $libraries;
$this->dynamicget = $dynamicget;
$this->templatelayout = $templatelayout;
$this->db = Factory::getDbo();
}
/**
* Get the Joomla Module/s
*
* @param int|null $id the module id
*
* @return object|array|null if ID found it returns object, if no ID
given it returns all set
* @since 3.2.0
*/
public function get(int $id = null)
{
if (is_null($id) && $this->exists())
{
return $this->data;
}
elseif ($this->exists($id))
{
return $this->data[$id];
}
return null;
}
/**
* Check if the Joomla Module/s exists
*
* @param int|null $id the module id
*
* @return bool if ID found it returns true, if no ID given it returns
true if any are set
* @since 3.2.0
*/
public function exists(int $id = null): bool
{
if (is_null($id))
{
return ArrayHelper::check($this->data);
}
elseif (isset($this->data[$id]))
{
return true;
}
return $this->set($id);
}
/**
* Set the Joomla Module
*
* @param int $id the module id
*
* @return bool true on success
* @since 3.2.0
*/
public function set(int $id): bool
{
if (isset($this->data[$id]))
{
return true;
}
else
{
// Create a new query object.
$query = $this->db->getQuery(true);
$query->select('a.*');
$query->select(
$this->db->quoteName(
array(
'f.addfiles',
'f.addfolders',
'f.addfilesfullpath',
'f.addfoldersfullpath',
'f.addurls',
'u.version_update',
'u.id'
), array(
'addfiles',
'addfolders',
'addfilesfullpath',
'addfoldersfullpath',
'addurls',
'version_update',
'version_update_id'
)
)
);
// from these tables
$query->from('#__componentbuilder_joomla_module AS a');
$query->join(
'LEFT', $this->db->quoteName(
'#__componentbuilder_joomla_module_updates', 'u'
) . ' ON (' . $this->db->quoteName('a.id') .
' = '
. $this->db->quoteName('u.joomla_module') .
')'
);
$query->join(
'LEFT', $this->db->quoteName(
'#__componentbuilder_joomla_module_files_folders_urls',
'f'
) . ' ON (' . $this->db->quoteName('a.id') .
' = '
. $this->db->quoteName('f.joomla_module') .
')'
);
$query->where($this->db->quoteName('a.id') . ' =
' . (int) $id);
$query->where($this->db->quoteName('a.published') .
' >= 1');
$this->db->setQuery($query);
$this->db->execute();
if ($this->db->getNumRows())
{
// get the module data
$module = $this->db->loadObject();
// tweak system to set stuff to the module domain
$_backup_target = $this->config->build_target;
$_backup_lang = $this->config->lang_target;
$_backup_langPrefix = $this->config->lang_prefix;
// set some keys
$module->target_type = 'M0dUl3';
$module->key = $module->id . '_' .
$module->target_type;
// update to point to module
$this->config->build_target = $module->key;
$this->config->lang_target = $module->key;
// set version if not set
if (empty($module->module_version))
{
$module->module_version = '1.0.0';
}
// set target client
if ($module->target == 2)
{
$module->target_client = 'administrator';
}
else
{
// default is site area
$module->target_client = 'site';
}
// set GUI mapper
$guiMapper = array('table' => 'joomla_module',
'id' => (int) $id, 'type'
=> 'php');
// update the name if it has dynamic values
$module->name = $this->placeholder->update_(
$this->customcode->update($module->name)
);
// set safe class function name
$module->code_name
= ClassfunctionHelper::safe(
$module->name
);
// alias of code name
$module->class_name = $module->code_name;
// set official name
$module->official_name = StringHelper::safe(
$module->name, 'W'
);
$this->config->set('lang_prefix', 'MOD_' .
strtoupper((string) $module->code_name));
// set lang prefix
$module->lang_prefix = $this->config->lang_prefix;
// set module class name
$module->class_helper_name = 'Mod' . ucfirst((string)
$module->code_name)
. 'Helper';
$module->class_data_name = 'Mod' . ucfirst((string)
$module->code_name)
. 'Data';
// set module install class name
$module->installer_class_name = 'mod_' . ucfirst(
(string) $module->code_name
) . 'InstallerScript';
// set module folder name
$module->folder_name = 'mod_' . strtolower((string)
$module->code_name);
// set the zip name
$module->zip_name = $module->folder_name . '_v' .
str_replace(
'.', '_', (string) $module->module_version
) . '__J' . $this->config->joomla_version;
// set module file name
$module->file_name = $module->folder_name;
// set module context
$module->context = $module->file_name . '.' .
$module->id;
// set official_name lang strings
$this->language->set(
$module->key, $this->config->lang_prefix,
$module->official_name
);
// set some placeholder for this module
$this->placeholder->set('Module_name',
$module->official_name);
$this->placeholder->set('Module', ucfirst(
(string) $module->code_name
));
$this->placeholder->set('module', strtolower(
(string) $module->code_name
));
$this->placeholder->set('module.version',
$module->module_version);
$this->placeholder->set('module_version', str_replace(
'.', '_', (string) $module->module_version
));
// set description (TODO) add description field to module
if (!isset($module->description)
|| !StringHelper::check(
$module->description
))
{
$module->description = '';
}
else
{
$module->description = $this->placeholder->update_(
$this->customcode->update($module->description)
);
$this->language->set(
$module->key, $module->lang_prefix . '_DESCRIPTION',
$module->description
);
$module->description = '<p>' .
$module->description
. '</p>';
}
// get author name
$project_author = $this->config->project_author;
// set the description
$module->xml_description = "<h1>" .
$module->official_name
. " (v." . $module->module_version
. ")</h1> <div style='clear:
both;'></div>"
. $module->description . "<p>Created by <a
href='" . trim(
(string) $this->config->project_website
) . "' target='_blank'>" . trim(
(string) OutputFilter::cleanText($project_author)
) . "</a><br /><small>Development started
"
. Factory::getDate($module->created)->format("jS F,
Y")
. "</small></p>";
// set xml description
$this->language->set(
$module->key, $module->lang_prefix .
'_XML_DESCRIPTION',
$module->xml_description
);
// update the readme if set
if ($module->addreadme == 1 && !empty($module->readme))
{
$module->readme = $this->placeholder->update_(
$this->customcode->update(base64_decode((string)
$module->readme))
);
}
else
{
$module->addreadme = 0;
unset($module->readme);
}
// get the custom_get
$module->custom_get = (isset($module->custom_get)
&& JsonHelper::check($module->custom_get))
? json_decode((string) $module->custom_get, true) : null;
if (ArrayHelper::check($module->custom_get))
{
$module->custom_get = $this->dynamic->get(
$module->custom_get, $module->key, $module->key
);
}
else
{
$module->custom_get = null;
}
// set helper class details
if ($module->add_class_helper >= 1
&& StringHelper::check(
$module->class_helper_code
))
{
if ($module->add_class_helper_header == 1
&& StringHelper::check(
$module->class_helper_header
))
{
// set GUI mapper field
$guiMapper['field'] = 'class_helper_header';
// base64 Decode code
$module->class_helper_header = PHP_EOL
. $this->gui->set(
$this->placeholder->update_(
$this->customcode->update(
base64_decode(
(string) $module->class_helper_header
)
)
),
$guiMapper
) . PHP_EOL;
}
else
{
$module->add_class_helper_header = 0;
$module->class_helper_header = '';
}
// set GUI mapper field
$guiMapper['field'] = 'class_helper_code';
// base64 Decode code
$module->class_helper_code = $this->gui->set(
$this->placeholder->update_(
$this->customcode->update(
base64_decode((string) $module->class_helper_code)
)
),
$guiMapper
);
// set class type
if ($module->add_class_helper == 2)
{
$module->class_helper_type = 'abstract class ';
}
else
{
$module->class_helper_type = 'class ';
}
}
else
{
$module->add_class_helper = 0;
$module->class_helper_code = '';
$module->class_helper_header = '';
}
// base64 Decode mod_code
if (isset($module->mod_code)
&& StringHelper::check($module->mod_code))
{
// set GUI mapper field
$guiMapper['field'] = 'mod_code';
$module->mod_code = $this->gui->set(
$this->placeholder->update_(
$this->customcode->update(
base64_decode((string) $module->mod_code)
)
),
$guiMapper
);
// check if we have template or layouts to load
$this->templatelayout->set(
$module->mod_code , $module->code_name
);
}
else
{
$module->mod_code = "// get the module class sfx";
$module->mod_code .= PHP_EOL
. "\$moduleclass_sfx =
htmlspecialchars(\$params->get('moduleclass_sfx'), ENT_COMPAT,
'UTF-8');";
$module->mod_code .= PHP_EOL . "// load the default
Tmpl";
$module->mod_code .= PHP_EOL
. "require JModuleHelper::getLayoutPath('mod_"
. strtolower((string) $module->code_name)
. "', \$params->get('layout',
'default'));";
}
// base64 Decode default header
if (isset($module->default_header)
&& StringHelper::check(
$module->default_header
))
{
// set GUI mapper field
$guiMapper['field'] = 'default_header';
$module->default_header = $this->gui->set(
$this->placeholder->update_(
$this->customcode->update(
base64_decode((string) $module->default_header)
)
),
$guiMapper
);
}
else
{
$module->default_header = '';
}
// base64 Decode default
if (isset($module->default)
&& StringHelper::check($module->default))
{
// set GUI mapper field
$guiMapper['field'] = 'default';
$guiMapper['type'] = 'html';
$module->default = $this->gui->set(
$this->placeholder->update_(
$this->customcode->update(
base64_decode((string) $module->default)
)
),
$guiMapper
);
// check if we have template or layouts to load
$this->templatelayout->set(
$module->default , $module->code_name
);
}
else
{
$module->default = '<h1>No Tmpl set</h1>';
}
// start the config array
$module->config_fields = [];
// create the form arrays
$module->form_files = [];
$module->fieldsets_label = [];
$module->fieldsets_paths = [];
$module->add_rule_path = [];
$module->add_field_path = [];
// set global fields rule to default component path
$module->fields_rules_paths = 1;
// set the fields data
$module->fields = (isset($module->fields)
&& JsonHelper::check($module->fields))
? json_decode((string) $module->fields, true) : null;
if (ArrayHelper::check($module->fields))
{
// ket global key
$key = $module->key;
$dynamic_fields = array('fieldset' =>
'basic',
'fields_name' =>
'params',
'file' =>
'config');
foreach ($module->fields as $n => &$form)
{
if (isset($form['fields'])
&& ArrayHelper::check(
$form['fields']
))
{
// make sure the dynamic_field is set to dynamic_value by default
foreach (
$dynamic_fields as $dynamic_field =>
$dynamic_value
)
{
if (!isset($form[$dynamic_field])
|| !StringHelper::check(
$form[$dynamic_field]
))
{
$form[$dynamic_field] = $dynamic_value;
}
else
{
if ('fields_name' === $dynamic_field
&& strpos((string) $form[$dynamic_field], '.')
!== false)
{
$form[$dynamic_field]
= $form[$dynamic_field];
}
else
{
$form[$dynamic_field]
= StringHelper::safe(
$form[$dynamic_field]
);
}
}
}
// check if field is external form file
if (!isset($form['module']) || $form['module']
!= 1)
{
// now build the form key
$unique = $form['file'] . $form['fields_name']
. $form['fieldset'];
}
else
{
// now build the form key
$unique = $form['fields_name']
. $form['fieldset'];
}
// set global fields rule path switches
if ($module->fields_rules_paths == 1
&& isset($form['fields_rules_paths'])
&& $form['fields_rules_paths'] == 2)
{
$module->fields_rules_paths = 2;
}
// set where to path is pointing
$module->fieldsets_paths[$unique]
= $form['fields_rules_paths'];
// check for extra rule paths
if (isset($form['addrulepath'])
&& ArrayHelper::check($form['addrulepath']))
{
foreach ($form['addrulepath'] as $add_rule_path)
{
if (StringHelper::check($add_rule_path['path']))
{
$module->add_rule_path[$unique] =
$add_rule_path['path'];
}
}
}
// check for extra field paths
if (isset($form['addfieldpath'])
&& ArrayHelper::check($form['addfieldpath']))
{
foreach ($form['addfieldpath'] as $add_field_path)
{
if (StringHelper::check($add_field_path['path']))
{
$module->add_field_path[$unique] =
$add_field_path['path'];
}
}
}
// add the label if set to lang
if (isset($form['label'])
&& StringHelper::check(
$form['label']
))
{
$module->fieldsets_label[$unique]
= $this->language->key($form['label']);
}
// build the fields
$form['fields'] = array_map(
function ($field) use ($key, $unique) {
// make sure the alias and title is 0
$field['alias'] = 0;
$field['title'] = 0;
// set the field details
$this->field->set(
$field, $key, $key, $unique
);
// update the default if set
if (StringHelper::check(
$field['custom_value']
)
&& isset($field['settings']))
{
if (($old_default
= GetHelper::between(
$field['settings']->xml,
'default="', '"', false
)) !== false)
{
// replace old default
$field['settings']->xml
= str_replace(
'default="' . $old_default
. '"', 'default="'
. $field['custom_value'] . '"',
(string) $field['settings']->xml
);
}
else
{
// add the default (hmmm not ideal but okay it should work)
$field['settings']->xml
= 'default="'
. $field['custom_value'] . '" '
. $field['settings']->xml;
}
}
unset($field['custom_value']);
// return field
return $field;
}, array_values($form['fields'])
);
// check if field is external form file
if (!isset($form['module']) || $form['module']
!= 1)
{
// load the form file
if (!isset($module->form_files[$form['file']]))
{
$module->form_files[$form['file']]
= [];
}
if
(!isset($module->form_files[$form['file']][$form['fields_name']]))
{
$module->form_files[$form['file']][$form['fields_name']]
= [];
}
if
(!isset($module->form_files[$form['file']][$form['fields_name']][$form['fieldset']]))
{
$module->form_files[$form['file']][$form['fields_name']][$form['fieldset']]
= [];
}
// do some house cleaning (for fields)
foreach ($form['fields'] as $field)
{
// so first we lock the field name in
$this->fieldname->get(
$field, $module->key, $unique
);
// add the fields to the global form file builder
$module->form_files[$form['file']][$form['fields_name']][$form['fieldset']][]
= $field;
}
// remove form
unset($module->fields[$n]);
}
else
{
// load the config form
if
(!isset($module->config_fields[$form['fields_name']]))
{
$module->config_fields[$form['fields_name']]
= [];
}
if
(!isset($module->config_fields[$form['fields_name']][$form['fieldset']]))
{
$module->config_fields[$form['fields_name']][$form['fieldset']]
= [];
}
// do some house cleaning (for fields)
foreach ($form['fields'] as $field)
{
// so first we lock the field name in
$this->fieldname->get(
$field, $module->key, $unique
);
// add the fields to the config builder
$module->config_fields[$form['fields_name']][$form['fieldset']][]
= $field;
}
// remove form
unset($module->fields[$n]);
}
}
else
{
unset($module->fields[$n]);
}
}
}
unset($module->fields);
// set files and folders
$this->filesfolders->set($module);
// set libraries
$this->libraries->set($module->code_name, $module);
// add PHP in module install
$module->add_install_script = true;
$addScriptMethods = [
'php_script',
'php_preflight',
'php_postflight',
'php_method'
];
$addScriptTypes = [
'install',
'update',
'uninstall'
];
// the next are php placeholders
$guiMapper['type'] = 'php';
foreach ($addScriptMethods as $scriptMethod)
{
foreach ($addScriptTypes as $scriptType)
{
if (isset($module->{'add_' . $scriptMethod .
'_' . $scriptType})
&& $module->{'add_' . $scriptMethod .
'_' . $scriptType} == 1
&& StringHelper::check(
$module->{$scriptMethod . '_' . $scriptType}
))
{
// set GUI mapper field
$guiMapper['field'] = $scriptMethod . '_' .
$scriptType;
$module->{$scriptMethod . '_' . $scriptType} =
$this->gui->set(
$this->placeholder->update_(
$this->customcode->update(
base64_decode(
(string) $module->{$scriptMethod . '_' .
$scriptType}
)
)
),
$guiMapper
);
}
else
{
unset($module->{$scriptMethod . '_' . $scriptType});
$module->{'add_' . $scriptMethod . '_' .
$scriptType} = 0;
}
}
}
// add_sql
if ($module->add_sql == 1
&& StringHelper::check($module->sql))
{
$module->sql = $this->placeholder->update_(
$this->customcode->update(base64_decode((string)
$module->sql))
);
}
else
{
unset($module->sql);
$module->add_sql = 0;
}
// add_sql_uninstall
if ($module->add_sql_uninstall == 1
&& StringHelper::check(
$module->sql_uninstall
))
{
$module->sql_uninstall = $this->placeholder->update_(
$this->customcode->update(
base64_decode((string) $module->sql_uninstall)
)
);
}
else
{
unset($module->sql_uninstall);
$module->add_sql_uninstall = 0;
}
// update the URL of the update_server if set
if ($module->add_update_server == 1
&& StringHelper::check(
$module->update_server_url
))
{
$module->update_server_url = $this->placeholder->update_(
$this->customcode->update($module->update_server_url)
);
}
// add the update/sales server FTP details if that is the expected
protocol
$serverArray = array('update_server',
'sales_server');
foreach ($serverArray as $server)
{
if ($module->{'add_' . $server} == 1
&& is_numeric(
$module->{$server}
)
&& $module->{$server} > 0)
{
// get the server protocol
$module->{$server . '_protocol'}
= GetHelper::var(
'server', (int) $module->{$server}, 'id',
'protocol'
);
}
else
{
$module->{$server} = 0;
// only change this for sales server (update server can be added
locally to the zip file)
if ('sales_server' === $server)
{
$module->{'add_' . $server} = 0;
}
$module->{$server . '_protocol'} = 0;
}
}
// set the update server stuff (TODO)
// update_server_xml_path
// update_server_xml_file_name
// rest globals
$this->config->build_target = $_backup_target;
$this->config->lang_target = $_backup_lang;
$this->config->lang_prefix = $_backup_langPrefix;
$this->placeholder->remove('Module_name');
$this->placeholder->remove('Module');
$this->placeholder->remove('module');
$this->placeholder->remove('module.version');
$this->placeholder->remove('module_version');
$this->data[$id] = $module;
return true;
}
}
return false;
}
}
src/Componentbuilder/Compiler/Joomlamodule/Structure.php000064400000074372151162054160017574
0ustar00<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder
<https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights
reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
namespace VDM\Joomla\Componentbuilder\Compiler\Joomlamodule;
use VDM\Joomla\Componentbuilder\Compiler\Joomlamodule\Data as Module;
use VDM\Joomla\Componentbuilder\Compiler\Component;
use VDM\Joomla\Componentbuilder\Compiler\Config;
use VDM\Joomla\Componentbuilder\Compiler\Registry;
use VDM\Joomla\Componentbuilder\Compiler\Customcode\Dispenser;
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\EventInterface as
Event;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Counter;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Folder;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\File;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Files;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Indent;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Placefix;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Line;
use VDM\Joomla\Componentbuilder\Compiler\Builder\TemplateData;
use VDM\Joomla\Utilities\ArrayHelper;
use VDM\Joomla\Utilities\ObjectHelper;
use VDM\Joomla\Utilities\StringHelper;
use VDM\Joomla\Utilities\FileHelper;
/**
* Joomla Module Structure Builder Class
*
* @since 3.2.0
*/
class Structure
{
/**
* The Data Class.
*
* @var Module
* @since 3.2.0
*/
protected Module $module;
/**
* The Component Class.
*
* @var Component
* @since 3.2.0
*/
protected Component $component;
/**
* The Config Class.
*
* @var Config
* @since 3.2.0
*/
protected Config $config;
/**
* The Registry Class.
*
* @var Registry
* @since 3.2.0
*/
protected Registry $registry;
/**
* The Dispenser Class.
*
* @var Dispenser
* @since 3.2.0
*/
protected Dispenser $dispenser;
/**
* The EventInterface Class.
*
* @var Event
* @since 3.2.0
*/
protected Event $event;
/**
* The Counter Class.
*
* @var Counter
* @since 3.2.0
*/
protected Counter $counter;
/**
* The Folder Class.
*
* @var Folder
* @since 3.2.0
*/
protected Folder $folder;
/**
* The File Class.
*
* @var File
* @since 3.2.0
*/
protected File $file;
/**
* The Files Class.
*
* @var Files
* @since 3.2.0
*/
protected Files $files;
/**
* The TemplateData Class.
*
* @var TemplateData
* @since 3.2.0
*/
protected TemplateData $templatedata;
/**
* Constructor.
*
* @param Module $module The Data Class.
* @param Component $component The Component Class.
* @param Config $config The Config Class.
* @param Registry $registry The Registry Class.
* @param Dispenser $dispenser The Dispenser Class.
* @param Event $event The EventInterface Class.
* @param Counter $counter The Counter Class.
* @param Folder $folder The Folder Class.
* @param File $file The File Class.
* @param Files $files The Files Class.
* @param TemplateData $templatedata The TemplateData Class.
*
* @since 3.2.0
*/
public function __construct(Module $module, Component $component, Config
$config,
Registry $registry, Dispenser $dispenser, Event $event,
Counter $counter, Folder $folder, File $file,
Files $files, TemplateData $templatedata)
{
$this->module = $module;
$this->component = $component;
$this->config = $config;
$this->registry = $registry;
$this->dispenser = $dispenser;
$this->event = $event;
$this->counter = $counter;
$this->folder = $folder;
$this->file = $file;
$this->files = $files;
$this->templatedata = $templatedata;
}
/**
* Build the Modules files, folders, url's and config
*
* @return void
* @since 3.2.0
*/
public function build()
{
if ($this->module->exists())
{
// for plugin event TODO change event api signatures
$component_context = $this->config->component_context;
$modules = $this->module->get();
// Trigger Event: jcb_ce_onBeforeSetModules
$this->event->trigger(
'jcb_ce_onBeforeBuildModules',
array(&$component_context, &$modules)
);
foreach ($modules as $module)
{
if (ObjectHelper::check($module)
&& isset($module->folder_name)
&& StringHelper::check($module->folder_name))
{
// module path
$this->modulePath($module);
// set the module paths
$this->registry->set('dynamic_paths.' .
$module->key, $module->folder_path);
// make sure there is no old build
$this->folder->remove($module->folder_path);
// create the main module folder
$this->folder->create($module->folder_path);
// create the main module file
$this->setMainModFile($module);
// creat the custom get file
$this->setCustomGet($module);
// set helper file
$this->setHelperFile($module);
// set main xml file
$this->setMainXmlFile($module);
// set tmpl folder
$this->folder->create($module->folder_path .
'/tmpl');
// set default file
$this->setDefaultFile($module);
// set custom default files
$this->setTemplateFiles($module);
// set install script if needed
$this->setInstallScript($module);
// set readme if found
$this->setReadme($module);
// set the CSS and JavaScript in form
$this->setCssJsForm($module);
// set rules folders if needed
if (isset($module->fields_rules_paths)
&& $module->fields_rules_paths == 2)
{
// create rules folder
$this->folder->create($module->folder_path .
'/rules');
}
// set forms folder/files if needed
$this->setForms($module);
// set SQL stuff if needed
$this->setSQL($module);
// create the language folder
$this->folder->create($module->folder_path .
'/language');
// also create the lang tag folder
$this->folder->create(
$module->folder_path . '/language/' .
$this->config->get('lang_tag', 'en-GB')
);
// check if this module has files
$this->setFiles($module);
// check if this module has folders
$this->setFolders($module);
// check if this module has urls
$this->setUrls($module);
}
}
}
}
/**
* get the module xml template
*
* @param object $module The module object
*
* @return string
* @since 3.2.0
*/
protected function getXML(object &$module): string
{
$xml = '<?xml version="1.0"
encoding="utf-8"?>';
$xml .= PHP_EOL . '<extension type="module"
version="'
.
$this->config->joomla_versions[$this->config->joomla_version]['xml_version']
. '" client="'
. $module->target_client . '"
method="upgrade">';
$xml .= PHP_EOL . Indent::_(1) . '<name>' .
$module->lang_prefix
. '</name>';
$xml .= PHP_EOL . Indent::_(1) . '<creationDate>' .
Placefix::_h('BUILDDATE') . '</creationDate>';
$xml .= PHP_EOL . Indent::_(1) . '<author>' .
Placefix::_h('AUTHOR') . '</author>';
$xml .= PHP_EOL . Indent::_(1) . '<authorEmail>' .
Placefix::_h('AUTHOREMAIL') . '</authorEmail>';
$xml .= PHP_EOL . Indent::_(1) . '<authorUrl>' .
Placefix::_h('AUTHORWEBSITE') . '</authorUrl>';
$xml .= PHP_EOL . Indent::_(1) . '<copyright>' .
Placefix::_h('COPYRIGHT') . '</copyright>';
$xml .= PHP_EOL . Indent::_(1) . '<license>' .
Placefix::_h('LICENSE') . '</license>';
$xml .= PHP_EOL . Indent::_(1) . '<version>' .
$module->module_version
. '</version>';
$xml .= PHP_EOL . Indent::_(1) . '<description>' .
$module->lang_prefix
. '_XML_DESCRIPTION</description>';
$xml .= Placefix::_h('MAINXML');
$xml .= PHP_EOL . '</extension>';
return $xml;
}
/**
* get the module admin custom script field
*
* @param array $fieldScriptBucket The field
*
* @return string
* @since 3.2.0
*
*/
protected function getCustomScriptField(array $fieldScriptBucket): string
{
$form_field_class = [];
$form_field_class[] = Placefix::_h('BOM') . PHP_EOL;
$form_field_class[] = "//" . Line::_(__Line__, __Class__)
. " No direct access to this file";
$form_field_class[] = "defined('_JEXEC') or
die('Restricted access');";
$form_field_class[] = PHP_EOL . "use
Joomla\CMS\Form\FormField;";
$form_field_class[] = "use Joomla\CMS\Factory;";
$form_field_class[] = PHP_EOL
. "class JFormFieldModadminvvvvvvvdm extends FormField";
$form_field_class[] = "{";
$form_field_class[] = Indent::_(1)
. "protected \$type = 'modadminvvvvvvvdm';";
$form_field_class[] = PHP_EOL . Indent::_(1)
. "protected function getLabel()";
$form_field_class[] = Indent::_(1) . "{";
$form_field_class[] = Indent::_(2) . "return;";
$form_field_class[] = Indent::_(1) . "}";
$form_field_class[] = PHP_EOL . Indent::_(1)
. "protected function getInput()";
$form_field_class[] = Indent::_(1) . "{";
$form_field_class[] = Indent::_(2) . "//" . Line::_(__Line__,
__Class__)
. " Get the document";
$form_field_class[] = Indent::_(2)
. "\$document = Factory::getDocument();";
$form_field_class[] = implode(PHP_EOL, $fieldScriptBucket);
$form_field_class[] = Indent::_(2) . "return; // noting for now
:)";
$form_field_class[] = Indent::_(1) . "}";
$form_field_class[] = "}";
return implode(PHP_EOL, $form_field_class);
}
/**
* Set the module path
*
* @param object $module
*
* @return void
* @since 3.2.0
*/
protected function modulePath(object &$module): void
{
$module->folder_path =
$this->config->get('compiler_path',
JPATH_COMPONENT_ADMINISTRATOR . '/compiler') . '/'
. $module->folder_name;
}
/**
* Set the main module file
*
* @param object $module
*
* @return void
* @since 3.2.0
*/
protected function setMainModFile(object $module): void
{
// set main mod file
$file_details = [
'path' => $module->folder_path . '/' .
$module->file_name . '.php',
'name' => $module->file_name . '.php',
'zip' => $module->file_name . '.php'
];
$this->file->write(
$file_details['path'],
'<?php' . PHP_EOL . '// main modfile' .
PHP_EOL . Placefix::_h('BOM') . PHP_EOL .
PHP_EOL . '// No direct access to this file' . PHP_EOL .
"defined('_JEXEC') or die('Restricted
access');"
. PHP_EOL .
Placefix::_h('MODCODE')
);
$this->files->appendArray($module->key, $file_details);
// count the file created
$this->counter->file++;
}
/**
* Set the custom get file
*
* @param object $module
*
* @return void
* @since 3.2.0
*/
protected function setCustomGet(object $module): void
{
if ($module->custom_get)
{
$file_details = [
'path' => $module->folder_path .
'/data.php',
'name' => 'data.php',
'zip' => 'data.php'
];
$this->file->write(
$file_details['path'],
'<?php' . PHP_EOL . '// get data file' . PHP_EOL
. Placefix::_h('BOM') . PHP_EOL
. PHP_EOL . '// No direct access to this file'
. PHP_EOL . "defined('_JEXEC') or die('Restricted
access');"
. PHP_EOL . PHP_EOL . '/**' . PHP_EOL . ' * Module
' . $module->official_name . ' Data'
. PHP_EOL . ' */' . PHP_EOL . "class " .
$module->class_data_name
. ' extends \JObject' . PHP_EOL . "{" .
Placefix::_h('DYNAMICGETS') . "}"
. PHP_EOL
);
$this->files->appendArray($module->key, $file_details);
// count the file created
$this->counter->file++;
}
}
/**
* Set the helper file
*
* @param object $module
*
* @return void
* @since 3.2.0
*/
protected function setHelperFile(object $module): void
{
if ($module->add_class_helper >= 1)
{
$file_details = [
'path' => $module->folder_path .
'/helper.php',
'name' => 'helper.php',
'zip' => 'helper.php'
];
$this->file->write(
$file_details['path'],
'<?php' . PHP_EOL . '// helper file' . PHP_EOL .
Placefix::_h('BOM') . PHP_EOL
. PHP_EOL . '// No direct access to this file'
. PHP_EOL . "defined('_JEXEC') or die('Restricted
access');"
. PHP_EOL . Placefix::_h('HELPERCODE')
);
$this->files->appendArray($module->key, $file_details);
// count the file created
$this->counter->file++;
}
}
/**
* Set the main XML file
*
* @param object $module
*
* @return void
* @since 3.2.0
*/
protected function setMainXmlFile(object $module): void
{
$file_details = [
'path' => $module->folder_path . '/' .
$module->file_name . '.xml',
'name' => $module->file_name . '.xml',
'zip' => $module->file_name . '.xml'
];
$this->file->write(
$file_details['path'],
$this->getXML($module)
);
$this->files->appendArray($module->key, $file_details);
// count the file created
$this->counter->file++;
}
/**
* Set the main default template file
*
* @param object $module
*
* @return void
* @since 3.2.0
*/
protected function setDefaultFile(object $module): void
{
$file_details = [
'path' => $module->folder_path .
'/tmpl/default.php',
'name' => 'default.php',
'zip' => 'tmpl/default.php'
];
$this->file->write(
$file_details['path'],
'<?php' . PHP_EOL . '// default tmpl' . PHP_EOL .
Placefix::_h('BOM') . PHP_EOL
. PHP_EOL . '// No direct access to this file' . PHP_EOL
. "defined('_JEXEC') or die('Restricted
access');"
. PHP_EOL . Placefix::_h('MODDEFAULT')
);
$this->files->appendArray($module->key, $file_details);
// count the file created
$this->counter->file++;
}
/**
* Set the additional template files
*
* @param object $module
*
* @return void
* @since 3.2.0
*/
protected function setTemplateFiles(object $module): void
{
if (($data_ = $this->templatedata->
get($module->key . '.' . $module->code_name)) !== null)
{
foreach ($data_ as $template => $data)
{
$file_details = [
'path' => $module->folder_path .
"/tmpl/default_{$template}.php",
'name' => "default_{$template}.php",
'zip' => "tmpl/default_{$template}.php"
];
$this->file->write(
$file_details['path'],
'<?php' . PHP_EOL . '// default tmpl' . PHP_EOL
. Placefix::_h('BOM') . PHP_EOL
. PHP_EOL . '// No direct access to this file' . PHP_EOL
. "defined('_JEXEC') or die('Restricted
access');"
. PHP_EOL .
Placefix::_h(StringHelper::safe("MODDEFAULT_{$template}",
'U'))
);
$this->files->appendArray($module->key, $file_details);
// count the file created
$this->counter->file++;
}
}
}
/**
* Set the install script file
*
* @param object $module
*
* @return void
* @since 3.2.0
*/
protected function setInstallScript(object $module): void
{
if ($module->add_install_script)
{
$file_details = [
'path' => $module->folder_path .
'/script.php',
'name' => 'script.php',
'zip' => 'script.php'
];
$this->file->write(
$file_details['path'],
'<?php' . PHP_EOL . '// Script template'
. PHP_EOL . Placefix::_h('BOM') . PHP_EOL
. PHP_EOL . '// No direct access to this file' . PHP_EOL
. "defined('_JEXEC') or die('Restricted
access');" . PHP_EOL
. Placefix::_h('INSTALLCLASS')
);
$this->files->appendArray($module->key, $file_details);
// count the file created
$this->counter->file++;
}
}
/**
* Set the readme file
*
* @param object $module
*
* @return void
* @since 3.2.0
*/
protected function setReadme(object $module): void
{
if ($module->addreadme)
{
$file_details = [
'path' => $module->folder_path .
'/README.md',
'name' => 'README.md',
'zip' => 'README.md'
];
$this->file->write($file_details['path'],
$module->readme);
$this->files->appendArray($module->key, $file_details);
// count the file created
$this->counter->file++;
}
}
/**
* Set the css and javascript in form
*
* @param object $module
*
* @return void
* @since 3.2.0
*/
protected function setCssJsForm(object $module): void
{
// set the folders target path
$target_path = '';
if ($module->target_client === 'administrator')
{
$target_path = '/administrator';
}
// check if we have custom fields needed for scripts
$module->add_scripts_field = false;
$field_script_bucket = [];
// add any css from the fields
$this->setCssForm($module, $target_path, $field_script_bucket);
// add any JavaScript from the fields
$this->setJsForm($module, $target_path, $field_script_bucket);
// set fields folders if needed
if ($module->add_scripts_field
|| (isset($module->fields_rules_paths)
&& $module->fields_rules_paths == 2))
{
// create fields folder
$this->folder->create($module->folder_path .
'/fields');
// add the custom script field
if ($module->add_scripts_field)
{
$file_details = [
'path' => $module->folder_path .
'/fields/modadminvvvvvvvdm.php',
'name' => 'modadminvvvvvvvdm.php',
'zip' => 'modadminvvvvvvvdm.php'
];
$this->file->write(
$file_details['path'],
$this->getCustomScriptField(
$field_script_bucket
)
);
$this->files->appendArray($module->key, $file_details);
// count the file created
$this->counter->file++;
}
}
}
/**
* Set the css in form
*
* @param object $module
* @param string $targetPath
* @param array $bucket
*
* @return void
* @since 3.2.0
*/
protected function setCssForm(object &$module, string $targetPath,
array &$bucket): void
{
if (($css = $this->dispenser->get(
'css_view', $module->key
)) !== null && StringHelper::check($css))
{
// make sure this script does not have PHP
if (strpos((string) $css, '<?php') === false)
{
// make sure the field is added
$module->add_scripts_field = true;
// create the css folder
$this->folder->create($module->folder_path .
'/css');
// add the CSS file
$file_details = [
'path' => $module->folder_path .
'/css/mod_admin.css',
'name' => 'mod_admin.css',
'zip' => 'mod_admin.css'
];
$this->file->write(
$file_details['path'],
Placefix::_h('BOM') . PHP_EOL
. PHP_EOL . $css
);
$this->files->appendArray($module->key, $file_details);
// count the file created
$this->counter->file++;
// add the field script
$bucket[] = Indent::_(2) . "//"
. Line::_(__Line__, __Class__) . " Custom CSS";
$bucket[] = Indent::_(2)
. "Html::_('stylesheet', "
. "modules/" . $module->folder_name
. "/css/mod_admin.css', ['version' =>
'auto', 'relative' => true]);";
}
}
}
/**
* Set the javascript in form
*
* @param object $module
* @param string $targetPath
* @param array $bucket
*
* @return void
* @since 3.2.0
*/
protected function setJsForm(object &$module, string $targetPath,
array &$bucket): void
{
if (($javascript = $this->dispenser->get(
'view_footer', $module->key
)) !== null
&& StringHelper::check($javascript))
{
// make sure this script does not have PHP
if (strpos((string) $javascript, '<?php') === false)
{
// make sure the field is added
$module->add_scripts_field = true;
// add the JavaScript file
$this->folder->create($module->folder_path .
'/js');
// add the CSS file
$file_details = [
'path' => $module->folder_path .
'/js/mod_admin.js',
'name' => 'mod_admin.js',
'zip' => 'mod_admin.js'
];
$this->file->write(
$file_details['path'],
Placefix::_h('BOM') . PHP_EOL
. PHP_EOL . $javascript
);
$this->files->appendArray($module->key, $file_details);
// count the file created
$this->counter->file++;
// add the field script
$bucket[] = Indent::_(2) . "//"
. Line::_(__Line__, __Class__) . " Custom JS";
$bucket[] = Indent::_(2)
. "Html::_('script', "
. "/modules/" . $module->folder_name
. "/js/mod_admin.js', ['version' =>
'auto', 'relative' => true]);";
}
}
}
/**
* Set the form folders and files as needed
*
* @param object $module
*
* @return void
* @since 3.2.0
*/
protected function setForms(object &$module): void
{
if (isset($module->form_files)
&& ArrayHelper::check(
$module->form_files
))
{
// create forms folder
$this->folder->create($module->folder_path .
'/forms');
// set the template files
foreach ($module->form_files as $file => $fields)
{
// set file details
$file_details = [
'path' => $module->folder_path . '/forms/' .
$file . '.xml',
'name' => $file . '.xml',
'zip' => 'forms/' . $file . '.xml'
];
// build basic XML
$xml = '<?xml version="1.0"
encoding="utf-8"?>';
$xml .= PHP_EOL . '<!--' . Line::_(__Line__, __Class__)
. ' default paths of ' . $file
. ' form points to ' .
$this->config->component_code_name
. ' -->';
// search if we must add the component path
$add_component_path = false;
foreach ($fields as $field_name => $fieldsets)
{
if (!$add_component_path)
{
foreach ($fieldsets as $fieldset => $field)
{
if (!$add_component_path
&& isset(
$module->fieldsets_paths[$file
. $field_name . $fieldset]
)
&& $module->fieldsets_paths[$file
. $field_name . $fieldset] == 1)
{
$add_component_path = true;
}
}
}
}
// only add if part of the component field types path is required
if ($add_component_path)
{
$xml .= PHP_EOL . '<form';
if ($this->config->get('joomla_version', 3) == 3)
{
$xml .= PHP_EOL . Indent::_(1)
. 'addrulepath="/administrator/components/com_'
. $this->config->component_code_name
. '/models/rules"';
$xml .= PHP_EOL . Indent::_(1)
. 'addfieldpath="/administrator/components/com_'
. $this->config->component_code_name
. '/models/fields"';
}
else
{
$xml .= PHP_EOL . Indent::_(1)
. 'addruleprefix="' .
$this->config->namespace_prefix
. '\Component\\' .
StringHelper::safe($this->config->component_code_name,
'F')
. '\Administrator\Rule"';
$xml .= PHP_EOL . Indent::_(1)
.'addfieldprefix="' .
$this->config->namespace_prefix
. '\Component\\' .
StringHelper::safe($this->config->component_code_name,
'F')
. '\Administrator\Field"';
}
$xml .= PHP_EOL . '>';
}
else
{
$xml .= PHP_EOL . '<form>';
}
// add the fields
foreach ($fields as $field_name => $fieldsets)
{
// check if we have an double fields naming set
$field_name_inner = '';
$field_name_outer = $field_name;
if (strpos((string)$field_name, '.') !== false)
{
$field_names = explode('.', (string)$field_name);
if (count((array)$field_names) == 2)
{
$field_name_outer = $field_names[0];
$field_name_inner = $field_names[1];
}
}
$xml .= PHP_EOL . Indent::_(1)
. '<fields name="' . $field_name_outer
. '">';
foreach ($fieldsets as $fieldset => $field)
{
// default to the field set name
$label = $fieldset;
if (isset($module->fieldsets_label[$file . $field_name .
$fieldset]))
{
$label = $module->fieldsets_label[$file . $field_name .
$fieldset];
}
// add path to module rules and custom fields
if (isset($module->fieldsets_paths[$file . $field_name .
$fieldset])
&& ($module->fieldsets_paths[$file . $field_name .
$fieldset] == 2
|| $module->fieldsets_paths[$file . $field_name . $fieldset] ==
3))
{
if ($module->target == 2)
{
if (!isset($module->add_rule_path[$file . $field_name .
$fieldset]))
{
$module->add_rule_path[$file . $field_name . $fieldset] =
'/administrator/modules/' . $module->file_name .
'/rules';
}
if (!isset($module->add_field_path[$file . $field_name .
$fieldset]))
{
$module->add_field_path[$file . $field_name . $fieldset] =
'/administrator/modules/' . $module->file_name .
'/fields';
}
}
else
{
if (!isset($module->add_rule_path[$file . $field_name .
$fieldset]))
{
$module->add_rule_path[$file . $field_name . $fieldset] =
'/modules/' . $module->file_name .
'/rules';
}
if (!isset($module->add_field_path[$file . $field_name .
$fieldset]))
{
$module->add_field_path[$file . $field_name . $fieldset] =
'/modules/' . $module->file_name .
'/fields';
}
}
}
// add path to module rules and custom fields
if (isset($module->add_rule_path[$file . $field_name .
$fieldset])
|| isset($module->add_field_path[$file . $field_name .
$fieldset]))
{
$xml .= PHP_EOL . Indent::_(1) . '<!--'
. Line::_(__Line__, __Class__) . ' default paths of '
. $fieldset . ' fieldset points to the module -->';
$xml .= PHP_EOL . Indent::_(1) . '<fieldset
name="'
. $fieldset . '" label="' . $label .
'"';
if (isset($module->add_rule_path[$file . $field_name .
$fieldset]))
{
$xml .= PHP_EOL . Indent::_(2)
. 'addrulepath="' . $module->add_rule_path[$file
. $field_name . $fieldset] . '"';
}
if (isset($module->add_field_path[$file . $field_name .
$fieldset]))
{
$xml .= PHP_EOL . Indent::_(2)
. 'addfieldpath="' .
$module->add_field_path[$file . $field_name . $fieldset] .
'"';
}
$xml .= PHP_EOL . Indent::_(1) . '>';
}
else
{
$xml .= PHP_EOL . Indent::_(1) . '<fieldset
name="'
. $fieldset . '" label="' . $label .
'">';
}
// check if we have an inner field set
if (StringHelper::check(
$field_name_inner
))
{
$xml .= PHP_EOL . Indent::_(1)
. '<fields name="'
. $field_name_inner . '">';
}
// add the placeholder of the fields
$xml .= Placefix::_h('FIELDSET_' . $file
. $field_name . $fieldset);
// check if we have an inner field set
if (StringHelper::check(
$field_name_inner
))
{
$xml .= PHP_EOL . Indent::_(1)
. '</fields>';
}
$xml .= PHP_EOL . Indent::_(1)
. '</fieldset>';
}
$xml .= PHP_EOL . Indent::_(1) . '</fields>';
}
$xml .= PHP_EOL . '</form>';
// add xml to file
$this->file->write($file_details['path'], $xml);
$this->files->appendArray($module->key, $file_details);
// count the file created
$this->counter->file++;
}
}
}
/**
* Set the sql stuff
*
* @param object $module
*
* @return void
* @since 3.2.0
*/
protected function setSQL(object $module): void
{
if ($module->add_sql || $module->add_sql_uninstall)
{
// create SQL folder
$this->folder->create($module->folder_path .
'/sql');
// create mysql folder
$this->folder->create(
$module->folder_path . '/sql/mysql'
);
// now set the install file
if ($module->add_sql)
{
$this->file->write(
$module->folder_path . '/sql/mysql/install.sql',
$module->sql
);
// count the file created
$this->counter->file++;
}
// now set the uninstall file
if ($module->add_sql_uninstall)
{
$this->file->write(
$module->folder_path
. '/sql/mysql/uninstall.sql',
$module->sql_uninstall
);
// count the file created
$this->counter->file++;
}
}
}
/**
* Set the files
*
* @param object $module
*
* @return void
* @since 3.2.0
*/
protected function setFiles(object $module): void
{
if (isset($module->files)
&& ArrayHelper::check($module->files))
{
// add to component files
foreach ($module->files as $file)
{
// set the pathfinder
$file['target_type'] = $module->target_type;
$file['target_id'] = $module->id;
$this->component->appendArray('files', $file);
}
}
}
/**
* Set the folders
*
* @param object $module
*
* @return void
* @since 3.2.0
*/
protected function setFolders(object $module): void
{
if (isset($module->folders)
&& ArrayHelper::check($module->folders))
{
// add to component folders
foreach ($module->folders as $folder)
{
// set the pathfinder
$folder['target_type'] = $module->target_type;
$folder['target_id'] = $module->id;
$this->component->appendArray('folders', $folder);
}
}
}
/**
* Set the urls
*
* @param object $module
*
* @return void
* @since 3.2.0
*/
protected function setUrls(object &$module): void
{
if (isset($module->urls)
&& ArrayHelper::check($module->urls))
{
// add to component urls
foreach ($module->urls as &$url)
{
// should we add the local folder
if (isset($url['type']) && $url['type']
> 1
&& isset($url['url'])
&& StringHelper::check(
$url['url']
))
{
// set file name
$fileName = basename((string)$url['url']);
// get the file contents
$data = FileHelper::getContent(
$url['url']
);
// build sub path
if (strpos($fileName, '.js') !== false)
{
$path = '/js';
}
elseif (strpos($fileName, '.css') !== false)
{
$path = '/css';
}
else
{
$path = '';
}
// create sub media path if not set
$this->folder->create(
$module->folder_path . $path
);
// set the path to module file
$url['path'] = $module->folder_path . $path
. '/' . $fileName; // we need this for later
// write data to path
$this->file->write($url['path'], $data);
// count the file created
$this->counter->file++;
}
}
}
}
}
src/Componentbuilder/Compiler/Joomlamodule/index.html000064400000000054151162054160017042
0ustar00<html><body
bgcolor="#FFFFFF"></body></html>src/Componentbuilder/Compiler/Joomlaplugin/JoomlaFive/Data.php000064400000063716151162054160020511
0ustar00<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder
<https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights
reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
namespace VDM\Joomla\Componentbuilder\Compiler\Joomlaplugin\JoomlaFive;
use Joomla\CMS\Factory;
use Joomla\CMS\Filter\OutputFilter;
use VDM\Joomla\Componentbuilder\Compiler\Config;
use VDM\Joomla\Componentbuilder\Compiler\Customcode;
use VDM\Joomla\Componentbuilder\Compiler\Customcode\Gui;
use VDM\Joomla\Componentbuilder\Compiler\Placeholder;
use VDM\Joomla\Componentbuilder\Compiler\Language;
use VDM\Joomla\Componentbuilder\Compiler\Field;
use VDM\Joomla\Componentbuilder\Compiler\Field\Name as FieldName;
use VDM\Joomla\Componentbuilder\Compiler\Model\Filesfolders;
use VDM\Joomla\Utilities\ArrayHelper;
use VDM\Joomla\Utilities\String\ClassfunctionHelper;
use VDM\Joomla\Utilities\String\PluginHelper;
use VDM\Joomla\Utilities\JsonHelper;
use VDM\Joomla\Utilities\StringHelper;
use VDM\Joomla\Utilities\GetHelper;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Indent;
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\PluginDataInterface;
/**
* Joomla 5 Plug-in Data Class
*
* @since 5.0.2
*/
final class Data implements PluginDataInterface
{
/**
* Compiler Joomla Plug-in's Data
*
* @var array
* @since 3.2.0
*/
protected array $data = [];
/**
* The Configure Class.
*
* @var Config
* @since 5.0.2
*/
protected Config $config;
/**
* The Customcode Class.
*
* @var Customcode
* @since 5.0.2
*/
protected Customcode $customcode;
/**
* The Gui Class.
*
* @var Gui
* @since 5.0.2
*/
protected Gui $gui;
/**
* The Placeholder Class.
*
* @var Placeholder
* @since 5.0.2
*/
protected Placeholder $placeholder;
/**
* The Language Class.
*
* @var Language
* @since 5.0.2
*/
protected Language $language;
/**
* The Field Class.
*
* @var Field
* @since 5.0.2
*/
protected Field $field;
/**
* The Name Class.
*
* @var FieldName
* @since 5.0.2
*/
protected FieldName $fieldname;
/**
* The Filesfolders Class.
*
* @var Filesfolders
* @since 5.0.2
*/
protected Filesfolders $filesfolders;
/**
* Database object to query local DB
*
* @since 3.2.0
**/
protected $db;
/**
* Define the mappings of traits and classes to their respective methods
and services
*
* @var array
* @since 5.0.2
**/
protected array $service_checks = [
'DatabaseAwareTrait' => [
'trait' => 'Joomla\Database\DatabaseAwareTrait',
'class' =>
'Joomla__'.'_ae15e6b6_f7de_43ad_be4b_71499ae88f45___Power',
'method' => 'setDatabase',
'service' =>
'Joomla__'.'_7bd29d76_73c9_4c07_a5da_4f7a32aff78f___Power'
],
'UserFactoryAwareTrait' => [
'trait' =>
'Joomla\CMS\User\UserFactoryAwareTrait',
'class' =>
'Joomla__'.'_a6b2c321_5de3_4425_b05f_e5340965fb80___Power',
'method' => 'setUserFactory',
'service' =>
'Joomla__'.'_c2980d12_c3ef_4e23_b4a2_e6af1f5900a9___Power'
]
];
/**
* Constructor.
*
* @param Config $config The Config Class.
* @param Customcode $customcode The Customcode Class.
* @param Gui $gui The Gui Class.
* @param Placeholder $placeholder The Placeholder Class.
* @param Language $language The Language Class.
* @param Field $field The Field Class.
* @param FieldName $fieldname The Name Class.
* @param Filesfolders $filesfolders The Filesfolders Class.
*
* @since 5.0.2
*/
public function __construct(Config $config, Customcode $customcode, Gui
$gui,
Placeholder $placeholder, Language $language,
Field $field, FieldName $fieldname,
Filesfolders $filesfolders)
{
$this->config = $config;
$this->customcode = $customcode;
$this->gui = $gui;
$this->placeholder = $placeholder;
$this->language = $language;
$this->field = $field;
$this->fieldname = $fieldname;
$this->filesfolders = $filesfolders;
$this->db = Factory::getDbo();
}
/**
* Get the Joomla Plugin/s
*
* @param int|null $id the plugin id
*
* @return object|array|null if ID found it returns object, if no ID
given it returns all set
* @since 3.2.0
*/
public function get(int $id = null)
{
if (is_null($id) && $this->exists())
{
return $this->data;
}
elseif ($this->exists($id))
{
return $this->data[$id];
}
return null;
}
/**
* Check if the Joomla Plugin/s exists
*
* @param int|null $id the plugin id
*
* @return bool if ID found it returns true, if no ID given it returns
true if any are set
* @since 3.2.0
*/
public function exists(int $id = null): bool
{
if (is_null($id))
{
return ArrayHelper::check($this->data);
}
elseif (isset($this->data[$id]))
{
return true;
}
return $this->set($id);
}
/**
* Set the Joomla Plugin
*
* @param int $id the plugin id
*
* @return bool true on success
* @since 3.2.0
*/
public function set(int $id): bool
{
if (isset($this->data[$id]))
{
return true;
}
else
{
// Create a new query object.
$query = $this->db->getQuery(true);
$query->select('a.*');
$query->select(
$this->db->quoteName(
array(
'g.name',
'e.name',
'e.head',
'e.comment',
'e.id',
'f.addfiles',
'f.addfolders',
'f.addfilesfullpath',
'f.addfoldersfullpath',
'f.addurls',
'u.version_update',
'u.id'
), array(
'group',
'extends',
'class_head',
'comment',
'class_id',
'addfiles',
'addfolders',
'addfilesfullpath',
'addfoldersfullpath',
'addurls',
'version_update',
'version_update_id'
)
)
);
// from these tables
$query->from('#__componentbuilder_joomla_plugin AS a');
$query->join(
'LEFT', $this->db->quoteName(
'#__componentbuilder_joomla_plugin_group', 'g'
) . ' ON (' .
$this->db->quoteName('a.joomla_plugin_group')
. ' = ' . $this->db->quoteName('g.id') .
')'
);
$query->join(
'LEFT',
$this->db->quoteName('#__componentbuilder_class_extends',
'e')
. ' ON (' .
$this->db->quoteName('a.class_extends') . ' = '
. $this->db->quoteName('e.id') . ')'
);
$query->join(
'LEFT', $this->db->quoteName(
'#__componentbuilder_joomla_plugin_updates', 'u'
) . ' ON (' . $this->db->quoteName('a.id') .
' = '
. $this->db->quoteName('u.joomla_plugin') .
')'
);
$query->join(
'LEFT', $this->db->quoteName(
'#__componentbuilder_joomla_plugin_files_folders_urls',
'f'
) . ' ON (' . $this->db->quoteName('a.id') .
' = '
. $this->db->quoteName('f.joomla_plugin') .
')'
);
$query->where($this->db->quoteName('a.id') . ' =
' . (int) $id);
$query->where($this->db->quoteName('a.published') .
' >= 1');
$this->db->setQuery($query);
$this->db->execute();
if ($this->db->getNumRows())
{
// get the plugin data
$plugin = $this->db->loadObject();
// tweak system to set stuff to the plugin domain
$_backup_target = $this->config->build_target;
$_backup_lang = $this->config->lang_target;
$_backup_langPrefix = $this->config->lang_prefix;
// set some keys
$plugin->target_type = 'pLuG!n';
$plugin->key = $plugin->id . '_' .
$plugin->target_type;
// update to point to plugin
$this->config->build_target = $plugin->key;
$this->config->lang_target = $plugin->key;
// set version if not set
if (empty($plugin->plugin_version))
{
$plugin->plugin_version = '1.0.0';
}
// set GUI mapper
$guiMapper = array('table' => 'joomla_plugin',
'id' => (int) $id, 'type'
=> 'php');
// update the name if it has dynamic values
$plugin->name = $this->placeholder->update_(
$this->customcode->update($plugin->name)
);
// update the name if it has dynamic values
$plugin->code_name
= ClassfunctionHelper::safe(
$plugin->name
);
// set official name
$plugin->official_name = ucwords(
$plugin->group . ' - ' . $plugin->name
);
// set lang prefix
$plugin->lang_prefix = PluginHelper::safeLangPrefix(
$plugin->code_name,
$plugin->group
);
// set langPrefix
$this->config->lang_prefix = $plugin->lang_prefix;
// set plugin class name
$plugin->class_name = ucfirst(
$plugin->code_name
);
// set plugin context name
$plugin->context_name = strtolower((string)
$plugin->code_name
);
// set plugin namespace
$plugin->namespace = $plugin->code_name;
// set plugin group namespace
$plugin->group_namespace = ucfirst(
$plugin->group
);
// set plugin install class name
$plugin->installer_class_name
= PluginHelper::safeInstallClassName(
$plugin->code_name,
$plugin->group
);
// set plugin folder name
$plugin->folder_name
= PluginHelper::safeFolderName(
$plugin->code_name,
$plugin->group
);
// set the zip name
$plugin->zip_name = $plugin->folder_name . '_v' .
str_replace(
'.', '_', (string) $plugin->plugin_version
) . '__J' . $this->config->joomla_version;
// set plugin file name
$plugin->file_name = $plugin->context_name;
$plugin->class_file_name = $plugin->code_name;
// set plugin context
$plugin->context = $plugin->folder_name . '.' .
$plugin->id;
// set official_name lang strings
$this->language->set(
$plugin->key, $this->config->lang_prefix,
$plugin->official_name
);
// set some placeholder for this plugin
$this->placeholder->set('Plugin_name',
$plugin->official_name);
$this->placeholder->set('PLUGIN_NAME',
$plugin->official_name);
$this->placeholder->set('Plugin', ucfirst((string)
$plugin->code_name));
$this->placeholder->set('plugin', strtolower((string)
$plugin->code_name));
$this->placeholder->set('Plugin_group',
ucfirst((string) $plugin->group));
$this->placeholder->set('plugin_group',
strtolower((string) $plugin->group));
$this->placeholder->set('plugin.version',
$plugin->plugin_version);
$this->placeholder->set('VERSION',
$plugin->plugin_version);
$this->placeholder->set('plugin_version', str_replace(
'.', '_', (string) $plugin->plugin_version
));
// set description
$this->placeholder->set('DESCRIPTION', '');
if (!isset($plugin->description)
|| !StringHelper::check(
$plugin->description
))
{
$plugin->description = '';
}
else
{
$plugin->description = $this->placeholder->update_(
$this->customcode->update($plugin->description)
);
$this->language->set(
$plugin->key, $plugin->lang_prefix . '_DESCRIPTION',
$plugin->description
);
// set description
$this->placeholder->set('DESCRIPTION',
$plugin->description);
$plugin->description = '<p>' .
$plugin->description . '</p>';
}
// get author name
$project_author = $this->config->project_author;
// we can only set these if the component was passed
$plugin->xml_description = "<h1>" .
$plugin->official_name
. " (v." . $plugin->plugin_version
. ")</h1> <div style='clear:
both;'></div>"
. $plugin->description . "<p>Created by <a
href='" . trim(
(string) $this->config->project_website
) . "' target='_blank'>" . trim(
(string) OutputFilter::cleanText($project_author)
) . "</a><br /><small>Development started
"
. Factory::getDate($plugin->created)->format("jS F,
Y")
. "</small></p>";
// set xml discription
$this->language->set(
$plugin->key, $plugin->lang_prefix .
'_XML_DESCRIPTION',
$plugin->xml_description
);
// update the readme if set
if ($plugin->addreadme == 1 && !empty($plugin->readme))
{
$plugin->readme = $this->placeholder->update_(
$this->customcode->update(base64_decode((string)
$plugin->readme))
);
}
else
{
$plugin->addreadme = 0;
unset($plugin->readme);
}
// open some base64 strings
if (!empty($plugin->main_class_code))
{
// set GUI mapper field
$guiMapper['field'] = 'main_class_code';
// base64 Decode main_class_code.
$plugin->main_class_code = $this->gui->set(
$this->placeholder->update_(
$this->customcode->update(
base64_decode((string) $plugin->main_class_code)
)
),
$guiMapper
);
}
// set the head :)
if ($plugin->add_head == 1 && !empty($plugin->head))
{
// set GUI mapper field
$guiMapper['field'] = 'head';
// base64 Decode head.
$plugin->header = $this->gui->set(
$this->placeholder->update_(
$this->customcode->update(
base64_decode((string) $plugin->head)
)
),
$guiMapper
);
}
elseif (!empty($plugin->class_head))
{
// base64 Decode head.
$plugin->header = $this->gui->set(
$this->placeholder->update_(
$this->customcode->update(
base64_decode((string) $plugin->class_head)
)
),
array(
'table' => 'class_extends',
'field' => 'head',
'id' => (int) $plugin->class_id,
'type' => 'php')
);
}
unset($plugin->class_head);
// Check the plugin's code and header for each trait
foreach ($this->service_checks as $key => $info)
{
if (strpos($plugin->main_class_code, $key) !== false ||
strpos($plugin->main_class_code, $info['class']) !==
false ||
strpos($plugin->header, $info['trait']) !== false)
{
$service_provider[] = Indent::_(4) .
"\$plugin->{$info['method']}(\$container->get({$info['service']}::class));";
}
}
// Assign service provider if any services were added
if (!empty($service_provider))
{
$plugin->service_provider = implode(PHP_EOL, $service_provider);
}
// set the comment
if (!empty($plugin->comment))
{
// base64 Decode comment.
$plugin->comment = $this->gui->set(
$this->placeholder->update_(
$this->customcode->update(
base64_decode((string) $plugin->comment)
)
),
array(
'table' => 'class_extends',
'field' => 'comment',
'id' => (int) $plugin->class_id,
'type' => 'php')
);
}
// start the config array
$plugin->config_fields = [];
// create the form arrays
$plugin->form_files = [];
$plugin->fieldsets_label = [];
$plugin->fieldsets_paths = [];
$plugin->add_rule_path = [];
$plugin->add_field_path = [];
// set global fields rule to default component path
$plugin->fields_rules_paths = 1;
// set the fields data
$plugin->fields = (isset($plugin->fields)
&& JsonHelper::check($plugin->fields))
? json_decode((string) $plugin->fields, true) : null;
if (ArrayHelper::check($plugin->fields))
{
// ket global key
$key = $plugin->key;
$dynamic_fields = array('fieldset' =>
'basic',
'fields_name' =>
'params',
'file' =>
'config');
foreach ($plugin->fields as $n => &$form)
{
if (isset($form['fields'])
&& ArrayHelper::check(
$form['fields']
))
{
// make sure the dynamic_field is set to dynamic_value by default
foreach (
$dynamic_fields as $dynamic_field =>
$dynamic_value
)
{
if (!isset($form[$dynamic_field])
|| !StringHelper::check(
$form[$dynamic_field]
))
{
$form[$dynamic_field] = $dynamic_value;
}
else
{
if ('fields_name' === $dynamic_field
&& strpos((string) $form[$dynamic_field], '.')
!== false)
{
$form[$dynamic_field]
= $form[$dynamic_field];
}
else
{
$form[$dynamic_field]
= StringHelper::safe(
$form[$dynamic_field]
);
}
}
}
// check if field is external form file
if (!isset($form['plugin']) || $form['plugin']
!= 1)
{
// now build the form key
$unique = $form['file'] . $form['fields_name']
. $form['fieldset'];
}
else
{
// now build the form key
$unique = $form['fields_name']
. $form['fieldset'];
}
// set global fields rule path switchs
if ($plugin->fields_rules_paths == 1
&& isset($form['fields_rules_paths'])
&& $form['fields_rules_paths'] == 2)
{
$plugin->fields_rules_paths = 2;
}
// set where to path is pointing
$plugin->fieldsets_paths[$unique]
= $form['fields_rules_paths'];
// add the label if set to lang
if (isset($form['label'])
&& StringHelper::check(
$form['label']
))
{
$plugin->fieldsets_label[$unique]
= $this->language->key($form['label']);
}
// check for extra rule paths
if (isset($form['addrulepath'])
&& ArrayHelper::check($form['addrulepath']))
{
foreach ($form['addrulepath'] as $add_rule_path)
{
if (StringHelper::check($add_rule_path['path']))
{
$plugin->add_rule_path[$unique] =
$add_rule_path['path'];
}
}
}
// check for extra field paths
if (isset($form['addfieldpath'])
&& ArrayHelper::check($form['addfieldpath']))
{
foreach ($form['addfieldpath'] as $add_field_path)
{
if (StringHelper::check($add_field_path['path']))
{
$plugin->add_field_path[$unique] =
$add_field_path['path'];
}
}
}
// build the fields
$form['fields'] = array_map(
function ($field) use ($key, $unique) {
// make sure the alias and title is 0
$field['alias'] = 0;
$field['title'] = 0;
// set the field details
$this->field->set(
$field, $key, $key, $unique
);
// update the default if set
if (StringHelper::check(
$field['custom_value']
)
&& isset($field['settings']))
{
if (($old_default
= GetHelper::between(
$field['settings']->xml,
'default="', '"', false
)) !== false)
{
// replace old default
$field['settings']->xml
= str_replace(
'default="' . $old_default
. '"', 'default="'
. $field['custom_value'] . '"',
(string) $field['settings']->xml
);
}
else
{
// add the default (hmmm not ideal but okay it should work)
$field['settings']->xml
= 'default="'
. $field['custom_value'] . '" '
. $field['settings']->xml;
}
}
unset($field['custom_value']);
// return field
return $field;
}, array_values($form['fields'])
);
// check if field is external form file
if (!isset($form['plugin']) || $form['plugin']
!= 1)
{
// load the form file
if (!isset($plugin->form_files[$form['file']]))
{
$plugin->form_files[$form['file']]
= [];
}
if
(!isset($plugin->form_files[$form['file']][$form['fields_name']]))
{
$plugin->form_files[$form['file']][$form['fields_name']]
= [];
}
if
(!isset($plugin->form_files[$form['file']][$form['fields_name']][$form['fieldset']]))
{
$plugin->form_files[$form['file']][$form['fields_name']][$form['fieldset']]
= [];
}
// do some house cleaning (for fields)
foreach ($form['fields'] as $field)
{
// so first we lock the field name in
$this->fieldname->get(
$field, $plugin->key, $unique
);
// add the fields to the global form file builder
$plugin->form_files[$form['file']][$form['fields_name']][$form['fieldset']][]
= $field;
}
// remove form
unset($plugin->fields[$n]);
}
else
{
// load the config form
if
(!isset($plugin->config_fields[$form['fields_name']]))
{
$plugin->config_fields[$form['fields_name']]
= [];
}
if
(!isset($plugin->config_fields[$form['fields_name']][$form['fieldset']]))
{
$plugin->config_fields[$form['fields_name']][$form['fieldset']]
= [];
}
// do some house cleaning (for fields)
foreach ($form['fields'] as $field)
{
// so first we lock the field name in
$this->fieldname->get(
$field, $plugin->key, $unique
);
// add the fields to the config builder
$plugin->config_fields[$form['fields_name']][$form['fieldset']][]
= $field;
}
// remove form
unset($plugin->fields[$n]);
}
}
else
{
unset($plugin->fields[$n]);
}
}
}
unset($plugin->fields);
// set files and folders
$this->filesfolders->set($plugin);
// add PHP in plugin install
$plugin->add_install_script = true;
$addScriptMethods = [
'php_preflight',
'php_postflight',
'php_method',
'php_script'
];
$addScriptTypes = [
'install',
'update',
'uninstall',
'construct'
];
foreach ($addScriptMethods as $scriptMethod)
{
foreach ($addScriptTypes as $scriptType)
{
if (isset( $plugin->{'add_' . $scriptMethod .
'_' . $scriptType})
&& $plugin->{'add_' . $scriptMethod .
'_' . $scriptType} == 1
&& StringHelper::check(
$plugin->{$scriptMethod . '_' . $scriptType}
))
{
// set GUI mapper field
$guiMapper['field'] = $scriptMethod . '_' .
$scriptType;
$plugin->{$scriptMethod . '_' . $scriptType} =
$this->gui->set(
$this->placeholder->update_(
$this->customcode->update(
base64_decode(
(string) $plugin->{$scriptMethod . '_' .
$scriptType}
)
)
),
$guiMapper
);
}
else
{
unset($plugin->{$scriptMethod . '_' . $scriptType});
$plugin->{'add_' . $scriptMethod . '_' .
$scriptType} = 0;
}
}
}
// add_sql
if ($plugin->add_sql == 1
&& StringHelper::check($plugin->sql))
{
$plugin->sql = $this->placeholder->update_(
$this->customcode->update(base64_decode((string)
$plugin->sql))
);
}
else
{
unset($plugin->sql);
$plugin->add_sql = 0;
}
// add_sql_uninstall
if ($plugin->add_sql_uninstall == 1
&& StringHelper::check(
$plugin->sql_uninstall
))
{
$plugin->sql_uninstall = $this->placeholder->update_(
$this->customcode->update(
base64_decode((string) $plugin->sql_uninstall)
)
);
}
else
{
unset($plugin->sql_uninstall);
$plugin->add_sql_uninstall = 0;
}
// update the URL of the update_server if set
if ($plugin->add_update_server == 1
&& StringHelper::check(
$plugin->update_server_url
))
{
$plugin->update_server_url = $this->placeholder->update_(
$this->customcode->update($plugin->update_server_url)
);
}
// add the update/sales server FTP details if that is the expected
protocol
$serverArray = array('update_server',
'sales_server');
foreach ($serverArray as $server)
{
if ($plugin->{'add_' . $server} == 1
&& is_numeric(
$plugin->{$server}
)
&& $plugin->{$server} > 0)
{
// get the server protocol
$plugin->{$server . '_protocol'}
= GetHelper::var(
'server', (int) $plugin->{$server}, 'id',
'protocol'
);
}
else
{
$plugin->{$server} = 0;
// only change this for sales server (update server can be added
locally to the zip file)
if ('sales_server' === $server)
{
$plugin->{'add_' . $server} = 0;
}
$plugin->{$server . '_protocol'} = 0;
}
}
// old path (to remove)
$plugin->remove_file_paths = [];
$plugin->remove_file_paths[] =
"/plugins/{$plugin->group}/{$plugin->context_name}/{$plugin->file_name}.php";
// set the update server stuff (TODO)
// update_server_xml_path
// update_server_xml_file_name
// rest globals
$this->config->build_target = $_backup_target;
$this->config->lang_target = $_backup_lang;
$this->config->set('lang_prefix',
$_backup_langPrefix);
$this->placeholder->remove('Plugin_name');
$this->placeholder->remove('Plugin');
$this->placeholder->remove('plugin');
$this->placeholder->remove('Plugin_group');
$this->placeholder->remove('plugin_group');
$this->placeholder->remove('plugin.version');
$this->placeholder->remove('plugin_version');
$this->placeholder->remove('VERSION');
$this->placeholder->remove('DESCRIPTION');
$this->placeholder->remove('PLUGIN_NAME');
$this->data[$id] = $plugin;
return true;
}
}
return false;
}
}
src/Componentbuilder/Compiler/Joomlaplugin/JoomlaFive/Infusion.php000064400000024153151162054160021422
0ustar00<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder
<https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights
reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
namespace VDM\Joomla\Componentbuilder\Compiler\Joomlaplugin\JoomlaFive;
use VDM\Joomla\Componentbuilder\Compiler\Config;
use VDM\Joomla\Componentbuilder\Compiler\Placeholder;
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\HeaderInterface as
Header;
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\EventInterface as
Event;
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\PluginDataInterface as
Data;
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\GetScriptInterface as
InstallScript;
use
VDM\Joomla\Componentbuilder\Compiler\Interfaces\Architecture\Plugin\ExtensionInterface
as Extension;
use
VDM\Joomla\Componentbuilder\Compiler\Interfaces\Architecture\Plugin\ProviderInterface
as Provider;
use
VDM\Joomla\Componentbuilder\Interfaces\Architecture\Plugin\MainXMLInterface
as MainXML;
use VDM\Joomla\Componentbuilder\Compiler\Builder\ContentMulti;
use VDM\Joomla\Componentbuilder\Compiler\Builder\ContentOne;
use VDM\Joomla\Componentbuilder\Compiler\Creator\FieldsetExtension;
use VDM\Joomla\Utilities\ObjectHelper;
use VDM\Joomla\Utilities\ArrayHelper;
use VDM\Joomla\Componentbuilder\Interfaces\Plugin\InfusionInterface;
/**
* Joomla 5 Plugin Infusion Class
*
* @since 5.0.2
*/
final class Infusion implements InfusionInterface
{
/**
* The Config Class.
*
* @var Config
* @since 5.0.2
*/
protected Config $config;
/**
* The Placeholder Class.
*
* @var Placeholder
* @since 5.0.2
*/
protected Placeholder $placeholder;
/**
* The Header Class.
*
* @var Header
* @since 5.0.2
*/
protected Header $header;
/**
* The Event Class.
*
* @var Event
* @since 5.0.2
*/
protected Event $event;
/**
* The PluginData Class.
*
* @var Data
* @since 5.0.2
*/
protected Data $data;
/**
* The GetScript Class.
*
* @var InstallScript
* @since 5.0.2
*/
protected InstallScript $installscript;
/**
* The Extension Class.
*
* @var Extension
* @since 5.0.2
*/
protected Extension $extension;
/**
* The Provider Class.
*
* @var Provider
* @since 5.0.2
*/
protected Provider $provider;
/**
* The MainXML Class.
*
* @var MainXML
* @since 5.0.2
*/
protected MainXML $mainxml;
/**
* The Content Multi Class.
*
* @var ContentMulti
* @since 5.0.2
*/
protected ContentMulti $contentmulti;
/**
* The Content One Class.
*
* @var ContentOne
* @since 5.0.2
*/
protected ContentOne $contentone;
/**
* The Fieldset Extension Class.
*
* @var FieldsetExtension
* @since 5.0.2
*/
protected FieldsetExtension $fieldsetextension;
/**
* Constructor.
*
* @param Config $config The Config Class.
* @param Placeholder $placeholder The Placeholder Class.
* @param Header $header The HeaderInterface
Class.
* @param Event $event The EventInterface
Class.
* @param Data $data The PluginDataInterface
Class.
* @param InstallScript $installscript The GetScriptInterface
Class.
* @param Extension $extension The ExtensionInterface
Class.
* @param Provider $provider The ProviderInterface
Class.
* @param MainXML $mainxml The MainXMLInterface
Class.
* @param ContentMulti $contentmulti The ContentMulti
Class.
* @param ContentOne $contentone The ContentOne Class.
* @param FieldsetExtension $fieldsetextension The FieldsetExtension
Class.
*
* @since 5.0.2
*/
public function __construct(Config $config, Placeholder $placeholder,
Header $header,
Event $event, Data $data, InstallScript $installscript,
Extension $extension, Provider $provider,
MainXML $mainxml, ContentMulti $contentmulti,
ContentOne $contentone, FieldsetExtension $fieldsetextension)
{
$this->config = $config;
$this->placeholder = $placeholder;
$this->header = $header;
$this->event = $event;
$this->data = $data;
$this->installscript = $installscript;
$this->extension = $extension;
$this->provider = $provider;
$this->mainxml = $mainxml;
$this->contentmulti = $contentmulti;
$this->contentone = $contentone;
$this->fieldsetextension = $fieldsetextension;
}
/**
* Infuse the plugin data into the content.
*
* This method processes each plugin in the data set, triggering events
* before and after infusion, setting placeholders, and adding content
* such as headers, classes, and XML configurations.
*
* @return void
* @since 5.0.2
*/
public function set(): void
{
if (!$this->data->exists())
{
return;
}
foreach ($this->data->get() as $plugin)
{
if (!ObjectHelper::check($plugin))
{
continue;
}
$this->triggerBeforeInfusionEvent($plugin);
$this->setPlaceholders($plugin);
$this->buildPluginContent($plugin);
$this->triggerAfterInfusionEvent($plugin);
}
}
/**
* Trigger the event before infusing the plugin data.
*
* @param object $plugin The plugin object being processed.
*
* @return void
* @since 5.0.2
*/
protected function triggerBeforeInfusionEvent(&$plugin): void
{
$this->event->trigger('jcb_ce_onBeforeInfusePluginData',
[&$plugin]);
}
/**
* Set placeholders based on plugin data.
*
* @param object $plugin The plugin object being processed.
*
* @return void
* @since 5.0.2
*/
protected function setPlaceholders($plugin): void
{
$this->placeholder->set('PluginGroupNamespace',
$plugin->group_namespace ?? '');
$this->placeholder->set('PluginNamespace',
$plugin->namespace ?? '');
$this->config->build_target = $plugin->key;
$this->config->lang_target = $plugin->key;
$this->config->set('lang_prefix',
$plugin->lang_prefix);
}
/**
* Build and set the content related to the plugin.
*
* @param object $plugin The plugin object being processed.
*
* @return void
* @since 5.0.2
*/
protected function buildPluginContent($plugin): void
{
$this->setExtensionClassHeader($plugin);
$this->setExtensionClass($plugin);
$this->setProviderClassHeader($plugin);
$this->setProviderClass($plugin);
if ($plugin->add_install_script)
{
$this->setInstallClass($plugin);
}
if (isset($plugin->form_files) &&
ArrayHelper::check($plugin->form_files))
{
$this->setFieldsets($plugin);
}
$this->setMainXml($plugin);
}
/**
* Set the extension class header content.
*
* @param object $plugin The plugin object being processed.
*
* @return void
* @since 5.0.2
*/
protected function setExtensionClassHeader($plugin): void
{
$headerContent = trim(
$this->header->get('plugin.extension.header',
$plugin->class_name)
. PHP_EOL . ($plugin->header ?? '')
);
$this->contentmulti->set("{$plugin->key}|EXTENSION_CLASS_HEADER",
$this->placeholder->update($headerContent,
$this->contentone->allActive())
);
}
/**
* Set the extension class content.
*
* @param object $plugin The plugin object being processed.
*
* @return void
* @since 5.0.2
*/
protected function setExtensionClass($plugin): void
{
$extensionContent = $this->extension->get($plugin);
$this->contentmulti->set("{$plugin->key}|EXTENSION_CLASS",
$extensionContent);
}
/**
* Set the provider class header content.
*
* @param object $plugin The plugin object being processed.
*
* @return void
* @since 5.0.2
*/
protected function setProviderClassHeader($plugin): void
{
$providerHeader =
$this->header->get('plugin.provider.header',
$plugin->class_name);
$this->contentmulti->set("{$plugin->key}|PROVIDER_CLASS_HEADER",
$providerHeader);
}
/**
* Set the provider class content.
*
* @param object $plugin The plugin object being processed.
*
* @return void
* @since 5.0.2
*/
protected function setProviderClass($plugin): void
{
$providerContent = $this->provider->get($plugin);
$this->contentmulti->set("{$plugin->key}|PROVIDER_CLASS",
$providerContent);
}
/**
* Set the install script content, if needed.
*
* @param object $plugin The plugin object being processed.
*
* @return void
* @since 5.0.2
*/
protected function setInstallClass($plugin): void
{
$installContent = $this->installscript->get($plugin);
$this->contentmulti->set("{$plugin->key}|INSTALL_CLASS",
$installContent);
}
/**
* Set fieldset content based on form files.
*
* @param object $plugin The plugin object being processed.
*
* @return void
* @since 5.0.2
*/
protected function setFieldsets($plugin): void
{
foreach ($plugin->form_files as $file => $files)
{
foreach ($files as $field_name => $fieldsets)
{
foreach ($fieldsets as $fieldset => $fields)
{
$fieldsetContent = $this->fieldsetextension->get($plugin,
$fields);
$this->contentmulti->set(
"{$plugin->key}|FIELDSET_{$file}{$field_name}{$fieldset}",
$fieldsetContent
);
}
}
}
}
/**
* Set the main XML content for the plugin.
*
* @param object $plugin The plugin object being processed.
*
* @return void
* @since 5.0.2
*/
protected function setMainXml($plugin): void
{
$mainXmlContent = $this->mainxml->get($plugin);
$this->contentmulti->set("{$plugin->key}|MAINXML",
$mainXmlContent);
}
/**
* Trigger the event after infusing the plugin data.
*
* @param object $plugin The plugin object being processed.
*
* @return void
* @since 5.0.2
*/
protected function triggerAfterInfusionEvent(&$plugin): void
{
$this->event->trigger('jcb_ce_onAfterInfusePluginData',
[&$plugin]);
}
}
src/Componentbuilder/Compiler/Joomlaplugin/JoomlaFive/Structure.php000064400000053602151162054160021631
0ustar00<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder
<https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights
reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
namespace VDM\Joomla\Componentbuilder\Compiler\Joomlaplugin\JoomlaFive;
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\PluginDataInterface as
Plugin;
use VDM\Joomla\Componentbuilder\Compiler\Component;
use VDM\Joomla\Componentbuilder\Compiler\Config;
use VDM\Joomla\Componentbuilder\Compiler\Registry;
use VDM\Joomla\Componentbuilder\Compiler\Customcode\Dispenser;
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\EventInterface as
Event;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Counter;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Folder;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\File;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Files;
use VDM\Joomla\Componentbuilder\Compiler\Placeholder;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Indent;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Placefix;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Line;
use VDM\Joomla\Utilities\ArrayHelper;
use VDM\Joomla\Utilities\ObjectHelper;
use VDM\Joomla\Utilities\StringHelper;
use VDM\Joomla\Utilities\FileHelper;
use VDM\Joomla\Componentbuilder\Interfaces\Plugin\StructureInterface;
/**
* Joomla 5 Plugin Builder Class
*
* @since 5.0.2
*/
class Structure implements StructureInterface
{
/**
* The Data Class.
*
* @var Plugin
* @since 3.2.0
*/
protected Plugin $plugin;
/**
* The Component Class.
*
* @var Component
* @since 3.2.0
*/
protected Component $component;
/**
* The Config Class.
*
* @var Config
* @since 3.2.0
*/
protected Config $config;
/**
* The Registry Class.
*
* @var Registry
* @since 3.2.0
*/
protected Registry $registry;
/**
* The Dispenser Class.
*
* @var Dispenser
* @since 3.2.0
*/
protected Dispenser $dispenser;
/**
* The EventInterface Class.
*
* @var Event
* @since 3.2.0
*/
protected Event $event;
/**
* The Counter Class.
*
* @var Counter
* @since 3.2.0
*/
protected Counter $counter;
/**
* The Folder Class.
*
* @var Folder
* @since 3.2.0
*/
protected Folder $folder;
/**
* The File Class.
*
* @var File
* @since 3.2.0
*/
protected File $file;
/**
* The Files Class.
*
* @var Files
* @since 3.2.0
*/
protected Files $files;
/**
* The Placeholder Class.
*
* @var Placeholder
* @since 5.0.0
*/
protected Placeholder $placeholder;
/**
* The Namespace Prefix
*
* @var string
* @since 5.0.0
*/
protected string $NamespacePrefix;
/**
* The Component Namespace (in code)
*
* @var string
* @since 3.2.0
*/
protected string $ComponentNamespace;
/**
* Constructor.
*
* @param Plugin $plugin The Data Class.
* @param Component $component The Component Class.
* @param Config $config The Config Class.
* @param Registry $registry The Registry Class.
* @param Dispenser $dispenser The Dispenser Class.
* @param Event $event The EventInterface Class.
* @param Counter $counter The Counter Class.
* @param Folder $folder The Folder Class.
* @param File $file The File Class.
* @param Files $files The Files Class.
* @param Placeholder $placeholder The Placeholder Class.
*
* @since 3.2.0
*/
public function __construct(Plugin $plugin, Component $component, Config
$config,
Registry $registry, Dispenser $dispenser, Event $event,
Counter $counter, Folder $folder, File $file,
Files $files, Placeholder $placeholder)
{
$this->plugin = $plugin;
$this->component = $component;
$this->config = $config;
$this->registry = $registry;
$this->dispenser = $dispenser;
$this->event = $event;
$this->counter = $counter;
$this->folder = $folder;
$this->file = $file;
$this->files = $files;
$this->placeholder = $placeholder;
// set some global values
$this->NamespacePrefix =
$this->placeholder->get('NamespacePrefix');
$this->ComponentNamespace =
$this->placeholder->get('ComponentNamespace');
}
/**
* Build the Plugins files, folders, url's and config
*
* @return void
* @since 3.2.0
*/
public function build()
{
if ($this->plugin->exists())
{
// for plugin event TODO change event api signatures
$component_context = $this->config->component_context;
$plugins = $this->plugin->get();
// Trigger Event: jcb_ce_onBeforeSetPlugins
$this->event->trigger(
'jcb_ce_onBeforeBuildPlugins',
array(&$component_context, &$plugins)
);
foreach ($plugins as $plugin)
{
if (ObjectHelper::check($plugin)
&& isset($plugin->folder_name)
&& StringHelper::check($plugin->folder_name))
{
// plugin path
$this->pluginPath($plugin);
// create src folder
$this->folder->create($plugin->folder_path .
'/src');
// set the plugin paths
$this->registry->set('dynamic_paths.' .
$plugin->key, $plugin->folder_path);
// make sure there is no old build
$this->folder->remove($plugin->folder_path);
// creat the main component folder
$this->folder->create($plugin->folder_path);
// set main class file
$this->setMainClassFile($plugin);
// set service provider class file
$this->setServiceProviderClassFile($plugin);
// set main xml file
$this->setMainXmlFile($plugin);
// set install script if needed
$this->setInstallScript($plugin);
// set readme if found
$this->setReadme($plugin);
// set fields & rules folders if needed
if (isset($plugin->fields_rules_paths)
&& $plugin->fields_rules_paths == 2)
{
// create fields folder
$this->folder->create($plugin->folder_path .
'/src/Field');
// create rules folder
$this->folder->create($plugin->folder_path .
'/src/Rule');
}
// set forms folder if needed
$this->setForms($plugin);
// set SQL stuff if needed
$this->setSQL($plugin);
// create the language folder path
$this->folder->create($plugin->folder_path .
'/language');
// also create the lang tag folder path
$this->folder->create(
$plugin->folder_path . '/language/' .
$this->config->get('lang_tag', 'en-GB')
);
// check if this plugin has files
$this->setFiles($plugin);
// check if this plugin has folders
$this->setFolders($plugin);
// check if this plugin has urls
$this->setUrls($plugin);
}
}
}
}
/**
* get the plugin xml template
*
* @param object $plugin The plugin object
*
* @return string
* @since 3.2.0
*/
protected function getXML(object $plugin): string
{
$xml = '<?xml version="1.0"
encoding="utf-8"?>';
$xml .= PHP_EOL . '<extension type="plugin"
version="'
.
$this->config->joomla_versions[$this->config->joomla_version]['xml_version']
. '" group="'
. $plugin->group . '"
method="upgrade">';
$xml .= PHP_EOL . Indent::_(1) . '<name>' .
$plugin->lang_prefix
. '</name>';
$xml .= PHP_EOL . Indent::_(1) . '<creationDate>' .
Placefix::_h('BUILDDATE') . '</creationDate>';
$xml .= PHP_EOL . Indent::_(1) . '<author>' .
Placefix::_h('AUTHOR') . '</author>';
$xml .= PHP_EOL . Indent::_(1) . '<authorEmail>' .
Placefix::_h('AUTHOREMAIL') . '</authorEmail>';
$xml .= PHP_EOL . Indent::_(1) . '<authorUrl>' .
Placefix::_h('AUTHORWEBSITE') . '</authorUrl>';
$xml .= PHP_EOL . Indent::_(1) . '<copyright>' .
Placefix::_h('COPYRIGHT') . '</copyright>';
$xml .= PHP_EOL . Indent::_(1) . '<license>' .
Placefix::_h('LICENSE') . '</license>';
$xml .= PHP_EOL . Indent::_(1) . '<version>' .
$plugin->plugin_version
. '</version>';
$xml .= PHP_EOL . Indent::_(1) . '<namespace
path="src">' .
"{$this->NamespacePrefix}\\Plugin\\{$plugin->group_namespace}\\{$plugin->namespace}"
. '</namespace>';
$xml .= PHP_EOL . Indent::_(1) . '<description>' .
$plugin->lang_prefix
. '_XML_DESCRIPTION</description>';
$xml .= Placefix::_h('MAINXML');
$xml .= PHP_EOL . '</extension>';
return $xml;
}
/**
* set the plugin path
*
* @param object $plugin The plugin object
*
* @return void
* @since 3.2.0
*/
protected function pluginPath(object &$plugin): void
{
$plugin->folder_path =
$this->config->get('compiler_path',
JPATH_COMPONENT_ADMINISTRATOR . '/compiler') . '/'
. $plugin->folder_name;
}
/**
* set the main class path
*
* @param object $plugin The plugin object
*
* @return void
* @since 3.2.0
*/
protected function setMainClassFile(object $plugin): void
{
// create extension folder
$this->folder->create($plugin->folder_path .
'/src/Extension');
$file_details = [
'path' => $plugin->folder_path .
'/src/Extension/' . $plugin->class_file_name .
'.php',
'name' => $plugin->class_file_name . '.php',
'zip' => 'src/Extension/' .
$plugin->class_file_name . '.php'
];
$this->file->write(
$file_details['path'],
'<?php' . PHP_EOL . '// Plugin main class
template' .
PHP_EOL . Placefix::_h('BOM') . PHP_EOL .
"namespace
{$this->NamespacePrefix}\\Plugin\\{$plugin->group_namespace}\\{$plugin->namespace}\\Extension;"
.
PHP_EOL . PHP_EOL . Placefix::_h('EXTENSION_CLASS_HEADER') .
PHP_EOL . PHP_EOL . '// No direct access to this file' .
PHP_EOL .
"defined('_JEXEC') or die('Restricted
access');" .
PHP_EOL . PHP_EOL .
Placefix::_h('EXTENSION_CLASS')
);
$this->files->appendArray($plugin->key, $file_details);
// count the file created
$this->counter->file++;
}
/**
* set the service provider path
*
* @param object $plugin The plugin object
*
* @return void
* @since 3.2.0
*/
protected function setServiceProviderClassFile(object $plugin): void
{
// create services folder
$this->folder->create($plugin->folder_path .
'/services');
$file_details = [
'path' => $plugin->folder_path .
'/services/provider.php',
'name' => 'provider.php',
'zip' => 'services/provider.php'
];
$this->file->write(
$file_details['path'],
'<?php' . PHP_EOL . '// Plugin services provider class
template' .
PHP_EOL . Placefix::_h('BOM') . PHP_EOL .
PHP_EOL . '// No direct access to this file' . PHP_EOL .
"defined('_JEXEC') or die('Restricted
access');" .
PHP_EOL . PHP_EOL .
Placefix::_h('PROVIDER_CLASS_HEADER') .
Placefix::_h('PROVIDER_CLASS')
);
$this->files->appendArray($plugin->key, $file_details);
// count the file created
$this->counter->file++;
}
/**
* set the main xml file
*
* @param object $plugin The plugin object
*
* @return void
* @since 3.2.0
*/
protected function setMainXmlFile(object $plugin): void
{
$file_details = [
'path' => $plugin->folder_path . '/' .
$plugin->file_name . '.xml',
'name' => $plugin->file_name . '.xml',
'zip' => $plugin->file_name . '.xml'
];
$this->file->write(
$file_details['path'],
$this->getXML($plugin)
);
$this->files->appendArray($plugin->key, $file_details);
// count the file created
$this->counter->file++;
}
/**
* set the install script file
*
* @param object $plugin The plugin object
*
* @return void
* @since 3.2.0
*/
protected function setInstallScript(object $plugin): void
{
if ($plugin->add_install_script)
{
$file_details = [
'path' => $plugin->folder_path .
'/script.php',
'name' => 'script.php',
'zip' => 'script.php'
];
$this->file->write(
$file_details['path'],
'<?php' . PHP_EOL . '// Script template' .
PHP_EOL . Placefix::_h('BOM') . PHP_EOL .
PHP_EOL . '// No direct access to this file' . PHP_EOL .
"defined('_JEXEC') or die('Restricted
access');" . PHP_EOL .
Placefix::_h('INSTALL_CLASS')
);
$this->files->appendArray($plugin->key, $file_details);
// count the file created
$this->counter->file++;
}
}
/**
* set the readme file
*
* @param object $plugin The plugin object
*
* @return void
* @since 3.2.0
*/
protected function setReadme(object $plugin): void
{
if ($plugin->addreadme)
{
$file_details = [
'path' => $plugin->folder_path .
'/README.md',
'name' => 'README.md',
'zip' => 'README.md'
];
$this->file->write($file_details['path'],
$plugin->readme);
$this->files->appendArray($plugin->key, $file_details);
// count the file created
$this->counter->file++;
}
}
/**
* set the form files and folders
*
* @param object $plugin The plugin object
*
* @return void
* @since 3.2.0
*/
protected function setForms(object $plugin): void
{
if (isset($plugin->form_files)
&& ArrayHelper::check($plugin->form_files))
{
$Group = ucfirst((string) $plugin->group);
$FileName = $plugin->file_name;
// create forms folder
$this->folder->create($plugin->folder_path .
'/forms');
// set the template files
foreach ($plugin->form_files as $file => $fields)
{
// set file details
$file_details = [
'path' => $plugin->folder_path . '/forms/' .
$file . '.xml',
'name' => $file . '.xml',
'zip' => 'forms/' . $file . '.xml'
];
// build basic XML
$xml = '<?xml version="1.0"
encoding="utf-8"?>';
$xml .= PHP_EOL . '<!--' . Line::_(__Line__, __Class__)
. ' default paths of ' . $file
. ' form points to ' .
$this->config->component_code_name
. ' -->';
// search if we must add the component path
$add_component_path = false;
foreach ($fields as $field_name => $fieldsets)
{
if (!$add_component_path)
{
foreach ($fieldsets as $fieldset => $field)
{
if (!$add_component_path
&& isset($plugin->fieldsets_paths[$file . $field_name .
$fieldset])
&& $plugin->fieldsets_paths[$file. $field_name .
$fieldset] == 1)
{
$add_component_path = true;
}
}
}
}
// only add if part of the component field types path is required
if ($add_component_path)
{
$xml .= PHP_EOL . '<form';
$xml .= PHP_EOL . Indent::_(1)
. 'addruleprefix="' . $this->NamespacePrefix
. '\Component\\' . $this->ComponentNamespace
. '\Administrator\Rule"';
$xml .= PHP_EOL . Indent::_(1)
.'addfieldprefix="' . $this->NamespacePrefix
. '\Component\\' . $this->ComponentNamespace
. '\Administrator\Field"';
$xml .= PHP_EOL . '>';
}
else
{
$xml .= PHP_EOL . '<form>';
}
// add the fields
foreach ($fields as $field_name => $fieldsets)
{
// check if we have an double fields naming set
$field_name_inner = '';
$field_name_outer = $field_name;
if (strpos((string)$field_name, '.') !== false)
{
$field_names = explode('.', (string)$field_name);
if (count((array)$field_names) == 2)
{
$field_name_outer = $field_names[0];
$field_name_inner = $field_names[1];
}
}
$xml .= PHP_EOL . Indent::_(1)
. '<fields name="' . $field_name_outer
. '">';
foreach ($fieldsets as $fieldset => $field)
{
// default to the field set name
$label = $fieldset;
if (isset($plugin->fieldsets_label[$file . $field_name .
$fieldset]))
{
$label = $plugin->fieldsets_label[$file . $field_name .
$fieldset];
}
// add path to plugin rules and custom fields
if (isset($plugin->fieldsets_paths[$file . $field_name .
$fieldset])
&& ($plugin->fieldsets_paths[$file . $field_name .
$fieldset] == 2
|| $plugin->fieldsets_paths[$file . $field_name . $fieldset] ==
3))
{
if (!isset($plugin->add_rule_path[$file . $field_name .
$fieldset]))
{
$plugin->add_rule_path[$file . $field_name . $fieldset] =
"{$this->NamespacePrefix}\\Plugin\\{$Group}\\{$FileName}\\Rule";
}
if (!isset($plugin->add_field_path[$file . $field_name .
$fieldset]))
{
$plugin->add_field_path[$file . $field_name . $fieldset] =
"{$this->NamespacePrefix}\\Plugin\\{$Group}\\{$FileName}\\Field";
}
}
// add path to plugin rules and custom fields
if (isset($plugin->add_rule_path[$file . $field_name .
$fieldset])
|| isset($plugin->add_field_path[$file . $field_name .
$fieldset]))
{
$xml .= PHP_EOL . Indent::_(1) . '<!--'
. Line::_(__Line__, __Class__) . ' default paths of '
. $fieldset . ' fieldset points to the plugin -->';
$xml .= PHP_EOL . Indent::_(1) . '<fieldset
name="'
. $fieldset . '" label="' . $label .
'"';
if (isset($plugin->add_rule_path[$file . $field_name .
$fieldset]))
{
$xml .= PHP_EOL . Indent::_(2)
. 'addrulepath="' . $plugin->add_rule_path[$file
. $field_name . $fieldset] . '"';
}
if (isset($plugin->add_field_path[$file . $field_name .
$fieldset]))
{
$xml .= PHP_EOL . Indent::_(2)
. 'addfieldpath="' .
$plugin->add_field_path[$file . $field_name . $fieldset] .
'"';
}
$xml .= PHP_EOL . Indent::_(1) . '>';
}
else
{
$xml .= PHP_EOL . Indent::_(1) . '<fieldset
name="'
. $fieldset . '" label="' . $label .
'">';
}
// check if we have an inner field set
if (StringHelper::check($field_name_inner))
{
$xml .= PHP_EOL . Indent::_(1)
. '<fields name="'
. $field_name_inner . '">';
}
// add the placeholder of the fields
$xml .= Placefix::_h('FIELDSET_' . $file
. $field_name . $fieldset);
// check if we have an inner field set
if (StringHelper::check($field_name_inner))
{
$xml .= PHP_EOL . Indent::_(1)
. '</fields>';
}
$xml .= PHP_EOL . Indent::_(1)
. '</fieldset>';
}
$xml .= PHP_EOL . Indent::_(1) . '</fields>';
}
$xml .= PHP_EOL . '</form>';
// add xml to file
$this->file->write($file_details['path'], $xml);
$this->files->appendArray($plugin->key, $file_details);
// count the file created
$this->counter->file++;
}
}
}
/**
* set the sql stuff
*
* @param object $plugin The plugin object
*
* @return void
* @since 3.2.0
*/
protected function setSQL(object $plugin): void
{
if ($plugin->add_sql || $plugin->add_sql_uninstall)
{
// create SQL folder
$this->folder->create($plugin->folder_path .
'/sql');
// create mysql folder
$this->folder->create(
$plugin->folder_path . '/sql/mysql'
);
// now set the install file
if ($plugin->add_sql)
{
$this->file->write(
$plugin->folder_path . '/sql/mysql/install.sql',
$plugin->sql
);
// count the file created
$this->counter->file++;
}
// now set the uninstall file
if ($plugin->add_sql_uninstall)
{
$this->file->write(
$plugin->folder_path
. '/sql/mysql/uninstall.sql',
$plugin->sql_uninstall
);
// count the file created
$this->counter->file++;
}
}
}
/**
* set the files
*
* @param object $plugin The plugin object
*
* @return void
* @since 3.2.0
*/
protected function setFiles(object $plugin): void
{
if (isset($plugin->files) &&
ArrayHelper::check($plugin->files))
{
// add to component files
foreach ($plugin->files as $file)
{
// set the path finder
$file['target_type'] = $plugin->target_type;
$file['target_id'] = $plugin->id;
$this->component->appendArray('files', $file);
}
}
}
/**
* set the folders
*
* @param object $plugin The plugin object
*
* @return void
* @since 3.2.0
*/
protected function setFolders(object $plugin): void
{
if (isset($plugin->folders) &&
ArrayHelper::check($plugin->folders))
{
// add to component folders
foreach ($plugin->folders as $folder)
{
// set the path finder
$folder['target_type'] = $plugin->target_type;
$folder['target_id'] = $plugin->id;
$this->component->appendArray('folders', $folder);
}
}
}
/**
* set the urls
*
* @param object $plugin The plugin object
*
* @return void
* @since 3.2.0
*/
protected function setUrls(object &$plugin): void
{
if (isset($plugin->urls) &&
ArrayHelper::check($plugin->urls))
{
// add to component urls
foreach ($plugin->urls as &$url)
{
// should we add the local folder
if (isset($url['type']) && $url['type']
> 1
&& isset($url['url'])
&& StringHelper::check($url['url']))
{
// set file name
$fileName = basename((string)$url['url']);
// get the file contents
$data = FileHelper::getContent(
$url['url']
);
// build sub path
if (strpos($fileName, '.js') !== false)
{
$path = '/js';
}
elseif (strpos($fileName, '.css') !== false)
{
$path = '/css';
}
else
{
$path = '';
}
// create sub media folder path if not set
$this->folder->create(
$plugin->folder_path . $path
);
// set the path to plugin file
$url['path'] = $plugin->folder_path . $path
. '/' . $fileName; // we need this for later
// write data to path
$this->file->write($url['path'], $data);
// count the file created
$this->counter->file++;
}
}
}
}
}
src/Componentbuilder/Compiler/Joomlaplugin/JoomlaFive/index.html000064400000000054151162054160021106
0ustar00<html><body
bgcolor="#FFFFFF"></body></html>src/Componentbuilder/Compiler/Joomlaplugin/JoomlaFour/Data.php000064400000063716151162054160020533
0ustar00<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder
<https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights
reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
namespace VDM\Joomla\Componentbuilder\Compiler\Joomlaplugin\JoomlaFour;
use Joomla\CMS\Factory;
use Joomla\CMS\Filter\OutputFilter;
use VDM\Joomla\Componentbuilder\Compiler\Config;
use VDM\Joomla\Componentbuilder\Compiler\Customcode;
use VDM\Joomla\Componentbuilder\Compiler\Customcode\Gui;
use VDM\Joomla\Componentbuilder\Compiler\Placeholder;
use VDM\Joomla\Componentbuilder\Compiler\Language;
use VDM\Joomla\Componentbuilder\Compiler\Field;
use VDM\Joomla\Componentbuilder\Compiler\Field\Name as FieldName;
use VDM\Joomla\Componentbuilder\Compiler\Model\Filesfolders;
use VDM\Joomla\Utilities\ArrayHelper;
use VDM\Joomla\Utilities\String\ClassfunctionHelper;
use VDM\Joomla\Utilities\String\PluginHelper;
use VDM\Joomla\Utilities\JsonHelper;
use VDM\Joomla\Utilities\StringHelper;
use VDM\Joomla\Utilities\GetHelper;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Indent;
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\PluginDataInterface;
/**
* Joomla 4 Plug-in Data Class
*
* @since 5.0.2
*/
final class Data implements PluginDataInterface
{
/**
* Compiler Joomla Plug-in's Data
*
* @var array
* @since 3.2.0
*/
protected array $data = [];
/**
* The Configure Class.
*
* @var Config
* @since 5.0.2
*/
protected Config $config;
/**
* The Customcode Class.
*
* @var Customcode
* @since 5.0.2
*/
protected Customcode $customcode;
/**
* The Gui Class.
*
* @var Gui
* @since 5.0.2
*/
protected Gui $gui;
/**
* The Placeholder Class.
*
* @var Placeholder
* @since 5.0.2
*/
protected Placeholder $placeholder;
/**
* The Language Class.
*
* @var Language
* @since 5.0.2
*/
protected Language $language;
/**
* The Field Class.
*
* @var Field
* @since 5.0.2
*/
protected Field $field;
/**
* The Name Class.
*
* @var FieldName
* @since 5.0.2
*/
protected FieldName $fieldname;
/**
* The Filesfolders Class.
*
* @var Filesfolders
* @since 5.0.2
*/
protected Filesfolders $filesfolders;
/**
* Database object to query local DB
*
* @since 3.2.0
**/
protected $db;
/**
* Define the mappings of traits and classes to their respective methods
and services
*
* @var array
* @since 5.0.2
**/
protected array $service_checks = [
'DatabaseAwareTrait' => [
'trait' => 'Joomla\Database\DatabaseAwareTrait',
'class' =>
'Joomla__'.'_ae15e6b6_f7de_43ad_be4b_71499ae88f45___Power',
'method' => 'setDatabase',
'service' =>
'Joomla__'.'_7bd29d76_73c9_4c07_a5da_4f7a32aff78f___Power'
],
'UserFactoryAwareTrait' => [
'trait' =>
'Joomla\CMS\User\UserFactoryAwareTrait',
'class' =>
'Joomla__'.'_a6b2c321_5de3_4425_b05f_e5340965fb80___Power',
'method' => 'setUserFactory',
'service' =>
'Joomla__'.'_c2980d12_c3ef_4e23_b4a2_e6af1f5900a9___Power'
]
];
/**
* Constructor.
*
* @param Config $config The Config Class.
* @param Customcode $customcode The Customcode Class.
* @param Gui $gui The Gui Class.
* @param Placeholder $placeholder The Placeholder Class.
* @param Language $language The Language Class.
* @param Field $field The Field Class.
* @param FieldName $fieldname The Name Class.
* @param Filesfolders $filesfolders The Filesfolders Class.
*
* @since 5.0.2
*/
public function __construct(Config $config, Customcode $customcode, Gui
$gui,
Placeholder $placeholder, Language $language,
Field $field, FieldName $fieldname,
Filesfolders $filesfolders)
{
$this->config = $config;
$this->customcode = $customcode;
$this->gui = $gui;
$this->placeholder = $placeholder;
$this->language = $language;
$this->field = $field;
$this->fieldname = $fieldname;
$this->filesfolders = $filesfolders;
$this->db = Factory::getDbo();
}
/**
* Get the Joomla Plugin/s
*
* @param int|null $id the plugin id
*
* @return object|array|null if ID found it returns object, if no ID
given it returns all set
* @since 3.2.0
*/
public function get(int $id = null)
{
if (is_null($id) && $this->exists())
{
return $this->data;
}
elseif ($this->exists($id))
{
return $this->data[$id];
}
return null;
}
/**
* Check if the Joomla Plugin/s exists
*
* @param int|null $id the plugin id
*
* @return bool if ID found it returns true, if no ID given it returns
true if any are set
* @since 3.2.0
*/
public function exists(int $id = null): bool
{
if (is_null($id))
{
return ArrayHelper::check($this->data);
}
elseif (isset($this->data[$id]))
{
return true;
}
return $this->set($id);
}
/**
* Set the Joomla Plugin
*
* @param int $id the plugin id
*
* @return bool true on success
* @since 3.2.0
*/
public function set(int $id): bool
{
if (isset($this->data[$id]))
{
return true;
}
else
{
// Create a new query object.
$query = $this->db->getQuery(true);
$query->select('a.*');
$query->select(
$this->db->quoteName(
array(
'g.name',
'e.name',
'e.head',
'e.comment',
'e.id',
'f.addfiles',
'f.addfolders',
'f.addfilesfullpath',
'f.addfoldersfullpath',
'f.addurls',
'u.version_update',
'u.id'
), array(
'group',
'extends',
'class_head',
'comment',
'class_id',
'addfiles',
'addfolders',
'addfilesfullpath',
'addfoldersfullpath',
'addurls',
'version_update',
'version_update_id'
)
)
);
// from these tables
$query->from('#__componentbuilder_joomla_plugin AS a');
$query->join(
'LEFT', $this->db->quoteName(
'#__componentbuilder_joomla_plugin_group', 'g'
) . ' ON (' .
$this->db->quoteName('a.joomla_plugin_group')
. ' = ' . $this->db->quoteName('g.id') .
')'
);
$query->join(
'LEFT',
$this->db->quoteName('#__componentbuilder_class_extends',
'e')
. ' ON (' .
$this->db->quoteName('a.class_extends') . ' = '
. $this->db->quoteName('e.id') . ')'
);
$query->join(
'LEFT', $this->db->quoteName(
'#__componentbuilder_joomla_plugin_updates', 'u'
) . ' ON (' . $this->db->quoteName('a.id') .
' = '
. $this->db->quoteName('u.joomla_plugin') .
')'
);
$query->join(
'LEFT', $this->db->quoteName(
'#__componentbuilder_joomla_plugin_files_folders_urls',
'f'
) . ' ON (' . $this->db->quoteName('a.id') .
' = '
. $this->db->quoteName('f.joomla_plugin') .
')'
);
$query->where($this->db->quoteName('a.id') . ' =
' . (int) $id);
$query->where($this->db->quoteName('a.published') .
' >= 1');
$this->db->setQuery($query);
$this->db->execute();
if ($this->db->getNumRows())
{
// get the plugin data
$plugin = $this->db->loadObject();
// tweak system to set stuff to the plugin domain
$_backup_target = $this->config->build_target;
$_backup_lang = $this->config->lang_target;
$_backup_langPrefix = $this->config->lang_prefix;
// set some keys
$plugin->target_type = 'pLuG!n';
$plugin->key = $plugin->id . '_' .
$plugin->target_type;
// update to point to plugin
$this->config->build_target = $plugin->key;
$this->config->lang_target = $plugin->key;
// set version if not set
if (empty($plugin->plugin_version))
{
$plugin->plugin_version = '1.0.0';
}
// set GUI mapper
$guiMapper = array('table' => 'joomla_plugin',
'id' => (int) $id, 'type'
=> 'php');
// update the name if it has dynamic values
$plugin->name = $this->placeholder->update_(
$this->customcode->update($plugin->name)
);
// update the name if it has dynamic values
$plugin->code_name
= ClassfunctionHelper::safe(
$plugin->name
);
// set official name
$plugin->official_name = ucwords(
$plugin->group . ' - ' . $plugin->name
);
// set lang prefix
$plugin->lang_prefix = PluginHelper::safeLangPrefix(
$plugin->code_name,
$plugin->group
);
// set langPrefix
$this->config->lang_prefix = $plugin->lang_prefix;
// set plugin class name
$plugin->class_name = ucfirst(
$plugin->code_name
);
// set plugin context name
$plugin->context_name = strtolower((string)
$plugin->code_name
);
// set plugin namespace
$plugin->namespace = $plugin->code_name;
// set plugin group namespace
$plugin->group_namespace = ucfirst(
$plugin->group
);
// set plugin install class name
$plugin->installer_class_name
= PluginHelper::safeInstallClassName(
$plugin->code_name,
$plugin->group
);
// set plugin folder name
$plugin->folder_name
= PluginHelper::safeFolderName(
$plugin->code_name,
$plugin->group
);
// set the zip name
$plugin->zip_name = $plugin->folder_name . '_v' .
str_replace(
'.', '_', (string) $plugin->plugin_version
) . '__J' . $this->config->joomla_version;
// set plugin file name
$plugin->file_name = $plugin->context_name;
$plugin->class_file_name = $plugin->code_name;
// set plugin context
$plugin->context = $plugin->folder_name . '.' .
$plugin->id;
// set official_name lang strings
$this->language->set(
$plugin->key, $this->config->lang_prefix,
$plugin->official_name
);
// set some placeholder for this plugin
$this->placeholder->set('Plugin_name',
$plugin->official_name);
$this->placeholder->set('PLUGIN_NAME',
$plugin->official_name);
$this->placeholder->set('Plugin', ucfirst((string)
$plugin->code_name));
$this->placeholder->set('plugin', strtolower((string)
$plugin->code_name));
$this->placeholder->set('Plugin_group',
ucfirst((string) $plugin->group));
$this->placeholder->set('plugin_group',
strtolower((string) $plugin->group));
$this->placeholder->set('plugin.version',
$plugin->plugin_version);
$this->placeholder->set('VERSION',
$plugin->plugin_version);
$this->placeholder->set('plugin_version', str_replace(
'.', '_', (string) $plugin->plugin_version
));
// set description
$this->placeholder->set('DESCRIPTION', '');
if (!isset($plugin->description)
|| !StringHelper::check(
$plugin->description
))
{
$plugin->description = '';
}
else
{
$plugin->description = $this->placeholder->update_(
$this->customcode->update($plugin->description)
);
$this->language->set(
$plugin->key, $plugin->lang_prefix . '_DESCRIPTION',
$plugin->description
);
// set description
$this->placeholder->set('DESCRIPTION',
$plugin->description);
$plugin->description = '<p>' .
$plugin->description . '</p>';
}
// get author name
$project_author = $this->config->project_author;
// we can only set these if the component was passed
$plugin->xml_description = "<h1>" .
$plugin->official_name
. " (v." . $plugin->plugin_version
. ")</h1> <div style='clear:
both;'></div>"
. $plugin->description . "<p>Created by <a
href='" . trim(
(string) $this->config->project_website
) . "' target='_blank'>" . trim(
(string) OutputFilter::cleanText($project_author)
) . "</a><br /><small>Development started
"
. Factory::getDate($plugin->created)->format("jS F,
Y")
. "</small></p>";
// set xml discription
$this->language->set(
$plugin->key, $plugin->lang_prefix .
'_XML_DESCRIPTION',
$plugin->xml_description
);
// update the readme if set
if ($plugin->addreadme == 1 && !empty($plugin->readme))
{
$plugin->readme = $this->placeholder->update_(
$this->customcode->update(base64_decode((string)
$plugin->readme))
);
}
else
{
$plugin->addreadme = 0;
unset($plugin->readme);
}
// open some base64 strings
if (!empty($plugin->main_class_code))
{
// set GUI mapper field
$guiMapper['field'] = 'main_class_code';
// base64 Decode main_class_code.
$plugin->main_class_code = $this->gui->set(
$this->placeholder->update_(
$this->customcode->update(
base64_decode((string) $plugin->main_class_code)
)
),
$guiMapper
);
}
// set the head :)
if ($plugin->add_head == 1 && !empty($plugin->head))
{
// set GUI mapper field
$guiMapper['field'] = 'head';
// base64 Decode head.
$plugin->header = $this->gui->set(
$this->placeholder->update_(
$this->customcode->update(
base64_decode((string) $plugin->head)
)
),
$guiMapper
);
}
elseif (!empty($plugin->class_head))
{
// base64 Decode head.
$plugin->header = $this->gui->set(
$this->placeholder->update_(
$this->customcode->update(
base64_decode((string) $plugin->class_head)
)
),
array(
'table' => 'class_extends',
'field' => 'head',
'id' => (int) $plugin->class_id,
'type' => 'php')
);
}
unset($plugin->class_head);
// Check the plugin's code and header for each trait
foreach ($this->service_checks as $key => $info)
{
if (strpos($plugin->main_class_code, $key) !== false ||
strpos($plugin->main_class_code, $info['class']) !==
false ||
strpos($plugin->header, $info['trait']) !== false)
{
$service_provider[] = Indent::_(4) .
"\$plugin->{$info['method']}(\$container->get({$info['service']}::class));";
}
}
// Assign service provider if any services were added
if (!empty($service_provider))
{
$plugin->service_provider = implode(PHP_EOL, $service_provider);
}
// set the comment
if (!empty($plugin->comment))
{
// base64 Decode comment.
$plugin->comment = $this->gui->set(
$this->placeholder->update_(
$this->customcode->update(
base64_decode((string) $plugin->comment)
)
),
array(
'table' => 'class_extends',
'field' => 'comment',
'id' => (int) $plugin->class_id,
'type' => 'php')
);
}
// start the config array
$plugin->config_fields = [];
// create the form arrays
$plugin->form_files = [];
$plugin->fieldsets_label = [];
$plugin->fieldsets_paths = [];
$plugin->add_rule_path = [];
$plugin->add_field_path = [];
// set global fields rule to default component path
$plugin->fields_rules_paths = 1;
// set the fields data
$plugin->fields = (isset($plugin->fields)
&& JsonHelper::check($plugin->fields))
? json_decode((string) $plugin->fields, true) : null;
if (ArrayHelper::check($plugin->fields))
{
// ket global key
$key = $plugin->key;
$dynamic_fields = array('fieldset' =>
'basic',
'fields_name' =>
'params',
'file' =>
'config');
foreach ($plugin->fields as $n => &$form)
{
if (isset($form['fields'])
&& ArrayHelper::check(
$form['fields']
))
{
// make sure the dynamic_field is set to dynamic_value by default
foreach (
$dynamic_fields as $dynamic_field =>
$dynamic_value
)
{
if (!isset($form[$dynamic_field])
|| !StringHelper::check(
$form[$dynamic_field]
))
{
$form[$dynamic_field] = $dynamic_value;
}
else
{
if ('fields_name' === $dynamic_field
&& strpos((string) $form[$dynamic_field], '.')
!== false)
{
$form[$dynamic_field]
= $form[$dynamic_field];
}
else
{
$form[$dynamic_field]
= StringHelper::safe(
$form[$dynamic_field]
);
}
}
}
// check if field is external form file
if (!isset($form['plugin']) || $form['plugin']
!= 1)
{
// now build the form key
$unique = $form['file'] . $form['fields_name']
. $form['fieldset'];
}
else
{
// now build the form key
$unique = $form['fields_name']
. $form['fieldset'];
}
// set global fields rule path switchs
if ($plugin->fields_rules_paths == 1
&& isset($form['fields_rules_paths'])
&& $form['fields_rules_paths'] == 2)
{
$plugin->fields_rules_paths = 2;
}
// set where to path is pointing
$plugin->fieldsets_paths[$unique]
= $form['fields_rules_paths'];
// add the label if set to lang
if (isset($form['label'])
&& StringHelper::check(
$form['label']
))
{
$plugin->fieldsets_label[$unique]
= $this->language->key($form['label']);
}
// check for extra rule paths
if (isset($form['addrulepath'])
&& ArrayHelper::check($form['addrulepath']))
{
foreach ($form['addrulepath'] as $add_rule_path)
{
if (StringHelper::check($add_rule_path['path']))
{
$plugin->add_rule_path[$unique] =
$add_rule_path['path'];
}
}
}
// check for extra field paths
if (isset($form['addfieldpath'])
&& ArrayHelper::check($form['addfieldpath']))
{
foreach ($form['addfieldpath'] as $add_field_path)
{
if (StringHelper::check($add_field_path['path']))
{
$plugin->add_field_path[$unique] =
$add_field_path['path'];
}
}
}
// build the fields
$form['fields'] = array_map(
function ($field) use ($key, $unique) {
// make sure the alias and title is 0
$field['alias'] = 0;
$field['title'] = 0;
// set the field details
$this->field->set(
$field, $key, $key, $unique
);
// update the default if set
if (StringHelper::check(
$field['custom_value']
)
&& isset($field['settings']))
{
if (($old_default
= GetHelper::between(
$field['settings']->xml,
'default="', '"', false
)) !== false)
{
// replace old default
$field['settings']->xml
= str_replace(
'default="' . $old_default
. '"', 'default="'
. $field['custom_value'] . '"',
(string) $field['settings']->xml
);
}
else
{
// add the default (hmmm not ideal but okay it should work)
$field['settings']->xml
= 'default="'
. $field['custom_value'] . '" '
. $field['settings']->xml;
}
}
unset($field['custom_value']);
// return field
return $field;
}, array_values($form['fields'])
);
// check if field is external form file
if (!isset($form['plugin']) || $form['plugin']
!= 1)
{
// load the form file
if (!isset($plugin->form_files[$form['file']]))
{
$plugin->form_files[$form['file']]
= [];
}
if
(!isset($plugin->form_files[$form['file']][$form['fields_name']]))
{
$plugin->form_files[$form['file']][$form['fields_name']]
= [];
}
if
(!isset($plugin->form_files[$form['file']][$form['fields_name']][$form['fieldset']]))
{
$plugin->form_files[$form['file']][$form['fields_name']][$form['fieldset']]
= [];
}
// do some house cleaning (for fields)
foreach ($form['fields'] as $field)
{
// so first we lock the field name in
$this->fieldname->get(
$field, $plugin->key, $unique
);
// add the fields to the global form file builder
$plugin->form_files[$form['file']][$form['fields_name']][$form['fieldset']][]
= $field;
}
// remove form
unset($plugin->fields[$n]);
}
else
{
// load the config form
if
(!isset($plugin->config_fields[$form['fields_name']]))
{
$plugin->config_fields[$form['fields_name']]
= [];
}
if
(!isset($plugin->config_fields[$form['fields_name']][$form['fieldset']]))
{
$plugin->config_fields[$form['fields_name']][$form['fieldset']]
= [];
}
// do some house cleaning (for fields)
foreach ($form['fields'] as $field)
{
// so first we lock the field name in
$this->fieldname->get(
$field, $plugin->key, $unique
);
// add the fields to the config builder
$plugin->config_fields[$form['fields_name']][$form['fieldset']][]
= $field;
}
// remove form
unset($plugin->fields[$n]);
}
}
else
{
unset($plugin->fields[$n]);
}
}
}
unset($plugin->fields);
// set files and folders
$this->filesfolders->set($plugin);
// add PHP in plugin install
$plugin->add_install_script = true;
$addScriptMethods = [
'php_preflight',
'php_postflight',
'php_method',
'php_script'
];
$addScriptTypes = [
'install',
'update',
'uninstall',
'construct'
];
foreach ($addScriptMethods as $scriptMethod)
{
foreach ($addScriptTypes as $scriptType)
{
if (isset( $plugin->{'add_' . $scriptMethod .
'_' . $scriptType})
&& $plugin->{'add_' . $scriptMethod .
'_' . $scriptType} == 1
&& StringHelper::check(
$plugin->{$scriptMethod . '_' . $scriptType}
))
{
// set GUI mapper field
$guiMapper['field'] = $scriptMethod . '_' .
$scriptType;
$plugin->{$scriptMethod . '_' . $scriptType} =
$this->gui->set(
$this->placeholder->update_(
$this->customcode->update(
base64_decode(
(string) $plugin->{$scriptMethod . '_' .
$scriptType}
)
)
),
$guiMapper
);
}
else
{
unset($plugin->{$scriptMethod . '_' . $scriptType});
$plugin->{'add_' . $scriptMethod . '_' .
$scriptType} = 0;
}
}
}
// add_sql
if ($plugin->add_sql == 1
&& StringHelper::check($plugin->sql))
{
$plugin->sql = $this->placeholder->update_(
$this->customcode->update(base64_decode((string)
$plugin->sql))
);
}
else
{
unset($plugin->sql);
$plugin->add_sql = 0;
}
// add_sql_uninstall
if ($plugin->add_sql_uninstall == 1
&& StringHelper::check(
$plugin->sql_uninstall
))
{
$plugin->sql_uninstall = $this->placeholder->update_(
$this->customcode->update(
base64_decode((string) $plugin->sql_uninstall)
)
);
}
else
{
unset($plugin->sql_uninstall);
$plugin->add_sql_uninstall = 0;
}
// update the URL of the update_server if set
if ($plugin->add_update_server == 1
&& StringHelper::check(
$plugin->update_server_url
))
{
$plugin->update_server_url = $this->placeholder->update_(
$this->customcode->update($plugin->update_server_url)
);
}
// add the update/sales server FTP details if that is the expected
protocol
$serverArray = array('update_server',
'sales_server');
foreach ($serverArray as $server)
{
if ($plugin->{'add_' . $server} == 1
&& is_numeric(
$plugin->{$server}
)
&& $plugin->{$server} > 0)
{
// get the server protocol
$plugin->{$server . '_protocol'}
= GetHelper::var(
'server', (int) $plugin->{$server}, 'id',
'protocol'
);
}
else
{
$plugin->{$server} = 0;
// only change this for sales server (update server can be added
locally to the zip file)
if ('sales_server' === $server)
{
$plugin->{'add_' . $server} = 0;
}
$plugin->{$server . '_protocol'} = 0;
}
}
// old path (to remove)
$plugin->remove_file_paths = [];
$plugin->remove_file_paths[] =
"/plugins/{$plugin->group}/{$plugin->context_name}/{$plugin->file_name}.php";
// set the update server stuff (TODO)
// update_server_xml_path
// update_server_xml_file_name
// rest globals
$this->config->build_target = $_backup_target;
$this->config->lang_target = $_backup_lang;
$this->config->set('lang_prefix',
$_backup_langPrefix);
$this->placeholder->remove('Plugin_name');
$this->placeholder->remove('Plugin');
$this->placeholder->remove('plugin');
$this->placeholder->remove('Plugin_group');
$this->placeholder->remove('plugin_group');
$this->placeholder->remove('plugin.version');
$this->placeholder->remove('plugin_version');
$this->placeholder->remove('VERSION');
$this->placeholder->remove('DESCRIPTION');
$this->placeholder->remove('PLUGIN_NAME');
$this->data[$id] = $plugin;
return true;
}
}
return false;
}
}
src/Componentbuilder/Compiler/Joomlaplugin/JoomlaFour/Infusion.php000064400000024153151162054160021444
0ustar00<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder
<https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights
reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
namespace VDM\Joomla\Componentbuilder\Compiler\Joomlaplugin\JoomlaFour;
use VDM\Joomla\Componentbuilder\Compiler\Config;
use VDM\Joomla\Componentbuilder\Compiler\Placeholder;
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\HeaderInterface as
Header;
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\EventInterface as
Event;
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\PluginDataInterface as
Data;
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\GetScriptInterface as
InstallScript;
use
VDM\Joomla\Componentbuilder\Compiler\Interfaces\Architecture\Plugin\ExtensionInterface
as Extension;
use
VDM\Joomla\Componentbuilder\Compiler\Interfaces\Architecture\Plugin\ProviderInterface
as Provider;
use
VDM\Joomla\Componentbuilder\Interfaces\Architecture\Plugin\MainXMLInterface
as MainXML;
use VDM\Joomla\Componentbuilder\Compiler\Builder\ContentMulti;
use VDM\Joomla\Componentbuilder\Compiler\Builder\ContentOne;
use VDM\Joomla\Componentbuilder\Compiler\Creator\FieldsetExtension;
use VDM\Joomla\Utilities\ObjectHelper;
use VDM\Joomla\Utilities\ArrayHelper;
use VDM\Joomla\Componentbuilder\Interfaces\Plugin\InfusionInterface;
/**
* Joomla 4 Plugin Infusion Class
*
* @since 5.0.2
*/
final class Infusion implements InfusionInterface
{
/**
* The Config Class.
*
* @var Config
* @since 5.0.2
*/
protected Config $config;
/**
* The Placeholder Class.
*
* @var Placeholder
* @since 5.0.2
*/
protected Placeholder $placeholder;
/**
* The Header Class.
*
* @var Header
* @since 5.0.2
*/
protected Header $header;
/**
* The Event Class.
*
* @var Event
* @since 5.0.2
*/
protected Event $event;
/**
* The PluginData Class.
*
* @var Data
* @since 5.0.2
*/
protected Data $data;
/**
* The GetScript Class.
*
* @var InstallScript
* @since 5.0.2
*/
protected InstallScript $installscript;
/**
* The Extension Class.
*
* @var Extension
* @since 5.0.2
*/
protected Extension $extension;
/**
* The Provider Class.
*
* @var Provider
* @since 5.0.2
*/
protected Provider $provider;
/**
* The MainXML Class.
*
* @var MainXML
* @since 5.0.2
*/
protected MainXML $mainxml;
/**
* The Content Multi Class.
*
* @var ContentMulti
* @since 5.0.2
*/
protected ContentMulti $contentmulti;
/**
* The Content One Class.
*
* @var ContentOne
* @since 5.0.2
*/
protected ContentOne $contentone;
/**
* The Fieldset Extension Class.
*
* @var FieldsetExtension
* @since 5.0.2
*/
protected FieldsetExtension $fieldsetextension;
/**
* Constructor.
*
* @param Config $config The Config Class.
* @param Placeholder $placeholder The Placeholder Class.
* @param Header $header The HeaderInterface
Class.
* @param Event $event The EventInterface
Class.
* @param Data $data The PluginDataInterface
Class.
* @param InstallScript $installscript The GetScriptInterface
Class.
* @param Extension $extension The ExtensionInterface
Class.
* @param Provider $provider The ProviderInterface
Class.
* @param MainXML $mainxml The MainXMLInterface
Class.
* @param ContentMulti $contentmulti The ContentMulti
Class.
* @param ContentOne $contentone The ContentOne Class.
* @param FieldsetExtension $fieldsetextension The FieldsetExtension
Class.
*
* @since 5.0.2
*/
public function __construct(Config $config, Placeholder $placeholder,
Header $header,
Event $event, Data $data, InstallScript $installscript,
Extension $extension, Provider $provider,
MainXML $mainxml, ContentMulti $contentmulti,
ContentOne $contentone, FieldsetExtension $fieldsetextension)
{
$this->config = $config;
$this->placeholder = $placeholder;
$this->header = $header;
$this->event = $event;
$this->data = $data;
$this->installscript = $installscript;
$this->extension = $extension;
$this->provider = $provider;
$this->mainxml = $mainxml;
$this->contentmulti = $contentmulti;
$this->contentone = $contentone;
$this->fieldsetextension = $fieldsetextension;
}
/**
* Infuse the plugin data into the content.
*
* This method processes each plugin in the data set, triggering events
* before and after infusion, setting placeholders, and adding content
* such as headers, classes, and XML configurations.
*
* @return void
* @since 5.0.2
*/
public function set(): void
{
if (!$this->data->exists())
{
return;
}
foreach ($this->data->get() as $plugin)
{
if (!ObjectHelper::check($plugin))
{
continue;
}
$this->triggerBeforeInfusionEvent($plugin);
$this->setPlaceholders($plugin);
$this->buildPluginContent($plugin);
$this->triggerAfterInfusionEvent($plugin);
}
}
/**
* Trigger the event before infusing the plugin data.
*
* @param object $plugin The plugin object being processed.
*
* @return void
* @since 5.0.2
*/
protected function triggerBeforeInfusionEvent(&$plugin): void
{
$this->event->trigger('jcb_ce_onBeforeInfusePluginData',
[&$plugin]);
}
/**
* Set placeholders based on plugin data.
*
* @param object $plugin The plugin object being processed.
*
* @return void
* @since 5.0.2
*/
protected function setPlaceholders($plugin): void
{
$this->placeholder->set('PluginGroupNamespace',
$plugin->group_namespace ?? '');
$this->placeholder->set('PluginNamespace',
$plugin->namespace ?? '');
$this->config->build_target = $plugin->key;
$this->config->lang_target = $plugin->key;
$this->config->set('lang_prefix',
$plugin->lang_prefix);
}
/**
* Build and set the content related to the plugin.
*
* @param object $plugin The plugin object being processed.
*
* @return void
* @since 5.0.2
*/
protected function buildPluginContent($plugin): void
{
$this->setExtensionClassHeader($plugin);
$this->setExtensionClass($plugin);
$this->setProviderClassHeader($plugin);
$this->setProviderClass($plugin);
if ($plugin->add_install_script)
{
$this->setInstallClass($plugin);
}
if (isset($plugin->form_files) &&
ArrayHelper::check($plugin->form_files))
{
$this->setFieldsets($plugin);
}
$this->setMainXml($plugin);
}
/**
* Set the extension class header content.
*
* @param object $plugin The plugin object being processed.
*
* @return void
* @since 5.0.2
*/
protected function setExtensionClassHeader($plugin): void
{
$headerContent = trim(
$this->header->get('plugin.extension.header',
$plugin->class_name)
. PHP_EOL . ($plugin->header ?? '')
);
$this->contentmulti->set("{$plugin->key}|EXTENSION_CLASS_HEADER",
$this->placeholder->update($headerContent,
$this->contentone->allActive())
);
}
/**
* Set the extension class content.
*
* @param object $plugin The plugin object being processed.
*
* @return void
* @since 5.0.2
*/
protected function setExtensionClass($plugin): void
{
$extensionContent = $this->extension->get($plugin);
$this->contentmulti->set("{$plugin->key}|EXTENSION_CLASS",
$extensionContent);
}
/**
* Set the provider class header content.
*
* @param object $plugin The plugin object being processed.
*
* @return void
* @since 5.0.2
*/
protected function setProviderClassHeader($plugin): void
{
$providerHeader =
$this->header->get('plugin.provider.header',
$plugin->class_name);
$this->contentmulti->set("{$plugin->key}|PROVIDER_CLASS_HEADER",
$providerHeader);
}
/**
* Set the provider class content.
*
* @param object $plugin The plugin object being processed.
*
* @return void
* @since 5.0.2
*/
protected function setProviderClass($plugin): void
{
$providerContent = $this->provider->get($plugin);
$this->contentmulti->set("{$plugin->key}|PROVIDER_CLASS",
$providerContent);
}
/**
* Set the install script content, if needed.
*
* @param object $plugin The plugin object being processed.
*
* @return void
* @since 5.0.2
*/
protected function setInstallClass($plugin): void
{
$installContent = $this->installscript->get($plugin);
$this->contentmulti->set("{$plugin->key}|INSTALL_CLASS",
$installContent);
}
/**
* Set fieldset content based on form files.
*
* @param object $plugin The plugin object being processed.
*
* @return void
* @since 5.0.2
*/
protected function setFieldsets($plugin): void
{
foreach ($plugin->form_files as $file => $files)
{
foreach ($files as $field_name => $fieldsets)
{
foreach ($fieldsets as $fieldset => $fields)
{
$fieldsetContent = $this->fieldsetextension->get($plugin,
$fields);
$this->contentmulti->set(
"{$plugin->key}|FIELDSET_{$file}{$field_name}{$fieldset}",
$fieldsetContent
);
}
}
}
}
/**
* Set the main XML content for the plugin.
*
* @param object $plugin The plugin object being processed.
*
* @return void
* @since 5.0.2
*/
protected function setMainXml($plugin): void
{
$mainXmlContent = $this->mainxml->get($plugin);
$this->contentmulti->set("{$plugin->key}|MAINXML",
$mainXmlContent);
}
/**
* Trigger the event after infusing the plugin data.
*
* @param object $plugin The plugin object being processed.
*
* @return void
* @since 5.0.2
*/
protected function triggerAfterInfusionEvent(&$plugin): void
{
$this->event->trigger('jcb_ce_onAfterInfusePluginData',
[&$plugin]);
}
}
src/Componentbuilder/Compiler/Joomlaplugin/JoomlaFour/Structure.php000064400000053602151162054160021653
0ustar00<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder
<https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights
reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
namespace VDM\Joomla\Componentbuilder\Compiler\Joomlaplugin\JoomlaFour;
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\PluginDataInterface as
Plugin;
use VDM\Joomla\Componentbuilder\Compiler\Component;
use VDM\Joomla\Componentbuilder\Compiler\Config;
use VDM\Joomla\Componentbuilder\Compiler\Registry;
use VDM\Joomla\Componentbuilder\Compiler\Customcode\Dispenser;
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\EventInterface as
Event;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Counter;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Folder;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\File;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Files;
use VDM\Joomla\Componentbuilder\Compiler\Placeholder;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Indent;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Placefix;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Line;
use VDM\Joomla\Utilities\ArrayHelper;
use VDM\Joomla\Utilities\ObjectHelper;
use VDM\Joomla\Utilities\StringHelper;
use VDM\Joomla\Utilities\FileHelper;
use VDM\Joomla\Componentbuilder\Interfaces\Plugin\StructureInterface;
/**
* Joomla 4 Plugin Builder Class
*
* @since 5.0.2
*/
class Structure implements StructureInterface
{
/**
* The Data Class.
*
* @var Plugin
* @since 3.2.0
*/
protected Plugin $plugin;
/**
* The Component Class.
*
* @var Component
* @since 3.2.0
*/
protected Component $component;
/**
* The Config Class.
*
* @var Config
* @since 3.2.0
*/
protected Config $config;
/**
* The Registry Class.
*
* @var Registry
* @since 3.2.0
*/
protected Registry $registry;
/**
* The Dispenser Class.
*
* @var Dispenser
* @since 3.2.0
*/
protected Dispenser $dispenser;
/**
* The EventInterface Class.
*
* @var Event
* @since 3.2.0
*/
protected Event $event;
/**
* The Counter Class.
*
* @var Counter
* @since 3.2.0
*/
protected Counter $counter;
/**
* The Folder Class.
*
* @var Folder
* @since 3.2.0
*/
protected Folder $folder;
/**
* The File Class.
*
* @var File
* @since 3.2.0
*/
protected File $file;
/**
* The Files Class.
*
* @var Files
* @since 3.2.0
*/
protected Files $files;
/**
* The Placeholder Class.
*
* @var Placeholder
* @since 5.0.0
*/
protected Placeholder $placeholder;
/**
* The Namespace Prefix
*
* @var string
* @since 5.0.0
*/
protected string $NamespacePrefix;
/**
* The Component Namespace (in code)
*
* @var string
* @since 3.2.0
*/
protected string $ComponentNamespace;
/**
* Constructor.
*
* @param Plugin $plugin The Data Class.
* @param Component $component The Component Class.
* @param Config $config The Config Class.
* @param Registry $registry The Registry Class.
* @param Dispenser $dispenser The Dispenser Class.
* @param Event $event The EventInterface Class.
* @param Counter $counter The Counter Class.
* @param Folder $folder The Folder Class.
* @param File $file The File Class.
* @param Files $files The Files Class.
* @param Placeholder $placeholder The Placeholder Class.
*
* @since 3.2.0
*/
public function __construct(Plugin $plugin, Component $component, Config
$config,
Registry $registry, Dispenser $dispenser, Event $event,
Counter $counter, Folder $folder, File $file,
Files $files, Placeholder $placeholder)
{
$this->plugin = $plugin;
$this->component = $component;
$this->config = $config;
$this->registry = $registry;
$this->dispenser = $dispenser;
$this->event = $event;
$this->counter = $counter;
$this->folder = $folder;
$this->file = $file;
$this->files = $files;
$this->placeholder = $placeholder;
// set some global values
$this->NamespacePrefix =
$this->placeholder->get('NamespacePrefix');
$this->ComponentNamespace =
$this->placeholder->get('ComponentNamespace');
}
/**
* Build the Plugins files, folders, url's and config
*
* @return void
* @since 3.2.0
*/
public function build()
{
if ($this->plugin->exists())
{
// for plugin event TODO change event api signatures
$component_context = $this->config->component_context;
$plugins = $this->plugin->get();
// Trigger Event: jcb_ce_onBeforeSetPlugins
$this->event->trigger(
'jcb_ce_onBeforeBuildPlugins',
array(&$component_context, &$plugins)
);
foreach ($plugins as $plugin)
{
if (ObjectHelper::check($plugin)
&& isset($plugin->folder_name)
&& StringHelper::check($plugin->folder_name))
{
// plugin path
$this->pluginPath($plugin);
// create src folder
$this->folder->create($plugin->folder_path .
'/src');
// set the plugin paths
$this->registry->set('dynamic_paths.' .
$plugin->key, $plugin->folder_path);
// make sure there is no old build
$this->folder->remove($plugin->folder_path);
// creat the main component folder
$this->folder->create($plugin->folder_path);
// set main class file
$this->setMainClassFile($plugin);
// set service provider class file
$this->setServiceProviderClassFile($plugin);
// set main xml file
$this->setMainXmlFile($plugin);
// set install script if needed
$this->setInstallScript($plugin);
// set readme if found
$this->setReadme($plugin);
// set fields & rules folders if needed
if (isset($plugin->fields_rules_paths)
&& $plugin->fields_rules_paths == 2)
{
// create fields folder
$this->folder->create($plugin->folder_path .
'/src/Field');
// create rules folder
$this->folder->create($plugin->folder_path .
'/src/Rule');
}
// set forms folder if needed
$this->setForms($plugin);
// set SQL stuff if needed
$this->setSQL($plugin);
// create the language folder path
$this->folder->create($plugin->folder_path .
'/language');
// also create the lang tag folder path
$this->folder->create(
$plugin->folder_path . '/language/' .
$this->config->get('lang_tag', 'en-GB')
);
// check if this plugin has files
$this->setFiles($plugin);
// check if this plugin has folders
$this->setFolders($plugin);
// check if this plugin has urls
$this->setUrls($plugin);
}
}
}
}
/**
* get the plugin xml template
*
* @param object $plugin The plugin object
*
* @return string
* @since 3.2.0
*/
protected function getXML(object $plugin): string
{
$xml = '<?xml version="1.0"
encoding="utf-8"?>';
$xml .= PHP_EOL . '<extension type="plugin"
version="'
.
$this->config->joomla_versions[$this->config->joomla_version]['xml_version']
. '" group="'
. $plugin->group . '"
method="upgrade">';
$xml .= PHP_EOL . Indent::_(1) . '<name>' .
$plugin->lang_prefix
. '</name>';
$xml .= PHP_EOL . Indent::_(1) . '<creationDate>' .
Placefix::_h('BUILDDATE') . '</creationDate>';
$xml .= PHP_EOL . Indent::_(1) . '<author>' .
Placefix::_h('AUTHOR') . '</author>';
$xml .= PHP_EOL . Indent::_(1) . '<authorEmail>' .
Placefix::_h('AUTHOREMAIL') . '</authorEmail>';
$xml .= PHP_EOL . Indent::_(1) . '<authorUrl>' .
Placefix::_h('AUTHORWEBSITE') . '</authorUrl>';
$xml .= PHP_EOL . Indent::_(1) . '<copyright>' .
Placefix::_h('COPYRIGHT') . '</copyright>';
$xml .= PHP_EOL . Indent::_(1) . '<license>' .
Placefix::_h('LICENSE') . '</license>';
$xml .= PHP_EOL . Indent::_(1) . '<version>' .
$plugin->plugin_version
. '</version>';
$xml .= PHP_EOL . Indent::_(1) . '<namespace
path="src">' .
"{$this->NamespacePrefix}\\Plugin\\{$plugin->group_namespace}\\{$plugin->namespace}"
. '</namespace>';
$xml .= PHP_EOL . Indent::_(1) . '<description>' .
$plugin->lang_prefix
. '_XML_DESCRIPTION</description>';
$xml .= Placefix::_h('MAINXML');
$xml .= PHP_EOL . '</extension>';
return $xml;
}
/**
* set the plugin path
*
* @param object $plugin The plugin object
*
* @return void
* @since 3.2.0
*/
protected function pluginPath(object &$plugin): void
{
$plugin->folder_path =
$this->config->get('compiler_path',
JPATH_COMPONENT_ADMINISTRATOR . '/compiler') . '/'
. $plugin->folder_name;
}
/**
* set the main class path
*
* @param object $plugin The plugin object
*
* @return void
* @since 3.2.0
*/
protected function setMainClassFile(object $plugin): void
{
// create extension folder
$this->folder->create($plugin->folder_path .
'/src/Extension');
$file_details = [
'path' => $plugin->folder_path .
'/src/Extension/' . $plugin->class_file_name .
'.php',
'name' => $plugin->class_file_name . '.php',
'zip' => 'src/Extension/' .
$plugin->class_file_name . '.php'
];
$this->file->write(
$file_details['path'],
'<?php' . PHP_EOL . '// Plugin main class
template' .
PHP_EOL . Placefix::_h('BOM') . PHP_EOL .
"namespace
{$this->NamespacePrefix}\\Plugin\\{$plugin->group_namespace}\\{$plugin->namespace}\\Extension;"
.
PHP_EOL . PHP_EOL . Placefix::_h('EXTENSION_CLASS_HEADER') .
PHP_EOL . PHP_EOL . '// No direct access to this file' .
PHP_EOL .
"defined('_JEXEC') or die('Restricted
access');" .
PHP_EOL . PHP_EOL .
Placefix::_h('EXTENSION_CLASS')
);
$this->files->appendArray($plugin->key, $file_details);
// count the file created
$this->counter->file++;
}
/**
* set the service provider path
*
* @param object $plugin The plugin object
*
* @return void
* @since 3.2.0
*/
protected function setServiceProviderClassFile(object $plugin): void
{
// create services folder
$this->folder->create($plugin->folder_path .
'/services');
$file_details = [
'path' => $plugin->folder_path .
'/services/provider.php',
'name' => 'provider.php',
'zip' => 'services/provider.php'
];
$this->file->write(
$file_details['path'],
'<?php' . PHP_EOL . '// Plugin services provider class
template' .
PHP_EOL . Placefix::_h('BOM') . PHP_EOL .
PHP_EOL . '// No direct access to this file' . PHP_EOL .
"defined('_JEXEC') or die('Restricted
access');" .
PHP_EOL . PHP_EOL .
Placefix::_h('PROVIDER_CLASS_HEADER') .
Placefix::_h('PROVIDER_CLASS')
);
$this->files->appendArray($plugin->key, $file_details);
// count the file created
$this->counter->file++;
}
/**
* set the main xml file
*
* @param object $plugin The plugin object
*
* @return void
* @since 3.2.0
*/
protected function setMainXmlFile(object $plugin): void
{
$file_details = [
'path' => $plugin->folder_path . '/' .
$plugin->file_name . '.xml',
'name' => $plugin->file_name . '.xml',
'zip' => $plugin->file_name . '.xml'
];
$this->file->write(
$file_details['path'],
$this->getXML($plugin)
);
$this->files->appendArray($plugin->key, $file_details);
// count the file created
$this->counter->file++;
}
/**
* set the install script file
*
* @param object $plugin The plugin object
*
* @return void
* @since 3.2.0
*/
protected function setInstallScript(object $plugin): void
{
if ($plugin->add_install_script)
{
$file_details = [
'path' => $plugin->folder_path .
'/script.php',
'name' => 'script.php',
'zip' => 'script.php'
];
$this->file->write(
$file_details['path'],
'<?php' . PHP_EOL . '// Script template' .
PHP_EOL . Placefix::_h('BOM') . PHP_EOL .
PHP_EOL . '// No direct access to this file' . PHP_EOL .
"defined('_JEXEC') or die('Restricted
access');" . PHP_EOL .
Placefix::_h('INSTALL_CLASS')
);
$this->files->appendArray($plugin->key, $file_details);
// count the file created
$this->counter->file++;
}
}
/**
* set the readme file
*
* @param object $plugin The plugin object
*
* @return void
* @since 3.2.0
*/
protected function setReadme(object $plugin): void
{
if ($plugin->addreadme)
{
$file_details = [
'path' => $plugin->folder_path .
'/README.md',
'name' => 'README.md',
'zip' => 'README.md'
];
$this->file->write($file_details['path'],
$plugin->readme);
$this->files->appendArray($plugin->key, $file_details);
// count the file created
$this->counter->file++;
}
}
/**
* set the form files and folders
*
* @param object $plugin The plugin object
*
* @return void
* @since 3.2.0
*/
protected function setForms(object $plugin): void
{
if (isset($plugin->form_files)
&& ArrayHelper::check($plugin->form_files))
{
$Group = ucfirst((string) $plugin->group);
$FileName = $plugin->file_name;
// create forms folder
$this->folder->create($plugin->folder_path .
'/forms');
// set the template files
foreach ($plugin->form_files as $file => $fields)
{
// set file details
$file_details = [
'path' => $plugin->folder_path . '/forms/' .
$file . '.xml',
'name' => $file . '.xml',
'zip' => 'forms/' . $file . '.xml'
];
// build basic XML
$xml = '<?xml version="1.0"
encoding="utf-8"?>';
$xml .= PHP_EOL . '<!--' . Line::_(__Line__, __Class__)
. ' default paths of ' . $file
. ' form points to ' .
$this->config->component_code_name
. ' -->';
// search if we must add the component path
$add_component_path = false;
foreach ($fields as $field_name => $fieldsets)
{
if (!$add_component_path)
{
foreach ($fieldsets as $fieldset => $field)
{
if (!$add_component_path
&& isset($plugin->fieldsets_paths[$file . $field_name .
$fieldset])
&& $plugin->fieldsets_paths[$file. $field_name .
$fieldset] == 1)
{
$add_component_path = true;
}
}
}
}
// only add if part of the component field types path is required
if ($add_component_path)
{
$xml .= PHP_EOL . '<form';
$xml .= PHP_EOL . Indent::_(1)
. 'addruleprefix="' . $this->NamespacePrefix
. '\Component\\' . $this->ComponentNamespace
. '\Administrator\Rule"';
$xml .= PHP_EOL . Indent::_(1)
.'addfieldprefix="' . $this->NamespacePrefix
. '\Component\\' . $this->ComponentNamespace
. '\Administrator\Field"';
$xml .= PHP_EOL . '>';
}
else
{
$xml .= PHP_EOL . '<form>';
}
// add the fields
foreach ($fields as $field_name => $fieldsets)
{
// check if we have an double fields naming set
$field_name_inner = '';
$field_name_outer = $field_name;
if (strpos((string)$field_name, '.') !== false)
{
$field_names = explode('.', (string)$field_name);
if (count((array)$field_names) == 2)
{
$field_name_outer = $field_names[0];
$field_name_inner = $field_names[1];
}
}
$xml .= PHP_EOL . Indent::_(1)
. '<fields name="' . $field_name_outer
. '">';
foreach ($fieldsets as $fieldset => $field)
{
// default to the field set name
$label = $fieldset;
if (isset($plugin->fieldsets_label[$file . $field_name .
$fieldset]))
{
$label = $plugin->fieldsets_label[$file . $field_name .
$fieldset];
}
// add path to plugin rules and custom fields
if (isset($plugin->fieldsets_paths[$file . $field_name .
$fieldset])
&& ($plugin->fieldsets_paths[$file . $field_name .
$fieldset] == 2
|| $plugin->fieldsets_paths[$file . $field_name . $fieldset] ==
3))
{
if (!isset($plugin->add_rule_path[$file . $field_name .
$fieldset]))
{
$plugin->add_rule_path[$file . $field_name . $fieldset] =
"{$this->NamespacePrefix}\\Plugin\\{$Group}\\{$FileName}\\Rule";
}
if (!isset($plugin->add_field_path[$file . $field_name .
$fieldset]))
{
$plugin->add_field_path[$file . $field_name . $fieldset] =
"{$this->NamespacePrefix}\\Plugin\\{$Group}\\{$FileName}\\Field";
}
}
// add path to plugin rules and custom fields
if (isset($plugin->add_rule_path[$file . $field_name .
$fieldset])
|| isset($plugin->add_field_path[$file . $field_name .
$fieldset]))
{
$xml .= PHP_EOL . Indent::_(1) . '<!--'
. Line::_(__Line__, __Class__) . ' default paths of '
. $fieldset . ' fieldset points to the plugin -->';
$xml .= PHP_EOL . Indent::_(1) . '<fieldset
name="'
. $fieldset . '" label="' . $label .
'"';
if (isset($plugin->add_rule_path[$file . $field_name .
$fieldset]))
{
$xml .= PHP_EOL . Indent::_(2)
. 'addrulepath="' . $plugin->add_rule_path[$file
. $field_name . $fieldset] . '"';
}
if (isset($plugin->add_field_path[$file . $field_name .
$fieldset]))
{
$xml .= PHP_EOL . Indent::_(2)
. 'addfieldpath="' .
$plugin->add_field_path[$file . $field_name . $fieldset] .
'"';
}
$xml .= PHP_EOL . Indent::_(1) . '>';
}
else
{
$xml .= PHP_EOL . Indent::_(1) . '<fieldset
name="'
. $fieldset . '" label="' . $label .
'">';
}
// check if we have an inner field set
if (StringHelper::check($field_name_inner))
{
$xml .= PHP_EOL . Indent::_(1)
. '<fields name="'
. $field_name_inner . '">';
}
// add the placeholder of the fields
$xml .= Placefix::_h('FIELDSET_' . $file
. $field_name . $fieldset);
// check if we have an inner field set
if (StringHelper::check($field_name_inner))
{
$xml .= PHP_EOL . Indent::_(1)
. '</fields>';
}
$xml .= PHP_EOL . Indent::_(1)
. '</fieldset>';
}
$xml .= PHP_EOL . Indent::_(1) . '</fields>';
}
$xml .= PHP_EOL . '</form>';
// add xml to file
$this->file->write($file_details['path'], $xml);
$this->files->appendArray($plugin->key, $file_details);
// count the file created
$this->counter->file++;
}
}
}
/**
* set the sql stuff
*
* @param object $plugin The plugin object
*
* @return void
* @since 3.2.0
*/
protected function setSQL(object $plugin): void
{
if ($plugin->add_sql || $plugin->add_sql_uninstall)
{
// create SQL folder
$this->folder->create($plugin->folder_path .
'/sql');
// create mysql folder
$this->folder->create(
$plugin->folder_path . '/sql/mysql'
);
// now set the install file
if ($plugin->add_sql)
{
$this->file->write(
$plugin->folder_path . '/sql/mysql/install.sql',
$plugin->sql
);
// count the file created
$this->counter->file++;
}
// now set the uninstall file
if ($plugin->add_sql_uninstall)
{
$this->file->write(
$plugin->folder_path
. '/sql/mysql/uninstall.sql',
$plugin->sql_uninstall
);
// count the file created
$this->counter->file++;
}
}
}
/**
* set the files
*
* @param object $plugin The plugin object
*
* @return void
* @since 3.2.0
*/
protected function setFiles(object $plugin): void
{
if (isset($plugin->files) &&
ArrayHelper::check($plugin->files))
{
// add to component files
foreach ($plugin->files as $file)
{
// set the path finder
$file['target_type'] = $plugin->target_type;
$file['target_id'] = $plugin->id;
$this->component->appendArray('files', $file);
}
}
}
/**
* set the folders
*
* @param object $plugin The plugin object
*
* @return void
* @since 3.2.0
*/
protected function setFolders(object $plugin): void
{
if (isset($plugin->folders) &&
ArrayHelper::check($plugin->folders))
{
// add to component folders
foreach ($plugin->folders as $folder)
{
// set the path finder
$folder['target_type'] = $plugin->target_type;
$folder['target_id'] = $plugin->id;
$this->component->appendArray('folders', $folder);
}
}
}
/**
* set the urls
*
* @param object $plugin The plugin object
*
* @return void
* @since 3.2.0
*/
protected function setUrls(object &$plugin): void
{
if (isset($plugin->urls) &&
ArrayHelper::check($plugin->urls))
{
// add to component urls
foreach ($plugin->urls as &$url)
{
// should we add the local folder
if (isset($url['type']) && $url['type']
> 1
&& isset($url['url'])
&& StringHelper::check($url['url']))
{
// set file name
$fileName = basename((string)$url['url']);
// get the file contents
$data = FileHelper::getContent(
$url['url']
);
// build sub path
if (strpos($fileName, '.js') !== false)
{
$path = '/js';
}
elseif (strpos($fileName, '.css') !== false)
{
$path = '/css';
}
else
{
$path = '';
}
// create sub media folder path if not set
$this->folder->create(
$plugin->folder_path . $path
);
// set the path to plugin file
$url['path'] = $plugin->folder_path . $path
. '/' . $fileName; // we need this for later
// write data to path
$this->file->write($url['path'], $data);
// count the file created
$this->counter->file++;
}
}
}
}
}
src/Componentbuilder/Compiler/Joomlaplugin/JoomlaFour/index.html000064400000000054151162054160021130
0ustar00<html><body
bgcolor="#FFFFFF"></body></html>src/Componentbuilder/Compiler/Joomlaplugin/JoomlaThree/Data.php000064400000060143151162054160020656
0ustar00<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder
<https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights
reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
namespace VDM\Joomla\Componentbuilder\Compiler\Joomlaplugin\JoomlaThree;
use Joomla\CMS\Factory;
use Joomla\CMS\Filter\OutputFilter;
use VDM\Joomla\Componentbuilder\Compiler\Config;
use VDM\Joomla\Componentbuilder\Compiler\Customcode;
use VDM\Joomla\Componentbuilder\Compiler\Customcode\Gui;
use VDM\Joomla\Componentbuilder\Compiler\Placeholder;
use VDM\Joomla\Componentbuilder\Compiler\Language;
use VDM\Joomla\Componentbuilder\Compiler\Field;
use VDM\Joomla\Componentbuilder\Compiler\Field\Name as FieldName;
use VDM\Joomla\Componentbuilder\Compiler\Model\Filesfolders;
use VDM\Joomla\Utilities\ArrayHelper;
use VDM\Joomla\Utilities\String\ClassfunctionHelper;
use VDM\Joomla\Utilities\String\PluginHelper;
use VDM\Joomla\Utilities\JsonHelper;
use VDM\Joomla\Utilities\StringHelper;
use VDM\Joomla\Utilities\GetHelper;
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\PluginDataInterface;
/**
* Joomla 3 Plug-in Data Class
*
* @since 3.2.0
*/
final class Data implements PluginDataInterface
{
/**
* Compiler Joomla Plug-in's Data
*
* @var array
* @since 3.2.0
*/
protected array $data = [];
/**
* The Configure Class.
*
* @var Config
* @since 5.0.2
*/
protected Config $config;
/**
* The Customcode Class.
*
* @var Customcode
* @since 5.0.2
*/
protected Customcode $customcode;
/**
* The Gui Class.
*
* @var Gui
* @since 5.0.2
*/
protected Gui $gui;
/**
* The Placeholder Class.
*
* @var Placeholder
* @since 5.0.2
*/
protected Placeholder $placeholder;
/**
* The Language Class.
*
* @var Language
* @since 5.0.2
*/
protected Language $language;
/**
* The Field Class.
*
* @var Field
* @since 5.0.2
*/
protected Field $field;
/**
* The Name Class.
*
* @var FieldName
* @since 5.0.2
*/
protected FieldName $fieldname;
/**
* The Filesfolders Class.
*
* @var Filesfolders
* @since 5.0.2
*/
protected Filesfolders $filesfolders;
/**
* Database object to query local DB
*
* @since 3.2.0
**/
protected $db;
/**
* Constructor.
*
* @param Config $config The Config Class.
* @param Customcode $customcode The Customcode Class.
* @param Gui $gui The Gui Class.
* @param Placeholder $placeholder The Placeholder Class.
* @param Language $language The Language Class.
* @param Field $field The Field Class.
* @param FieldName $fieldname The Name Class.
* @param Filesfolders $filesfolders The Filesfolders Class.
*
* @since 5.0.2
*/
public function __construct(Config $config, Customcode $customcode, Gui
$gui,
Placeholder $placeholder, Language $language,
Field $field, FieldName $fieldname,
Filesfolders $filesfolders)
{
$this->config = $config;
$this->customcode = $customcode;
$this->gui = $gui;
$this->placeholder = $placeholder;
$this->language = $language;
$this->field = $field;
$this->fieldname = $fieldname;
$this->filesfolders = $filesfolders;
$this->db = Factory::getDbo();
}
/**
* Get the Joomla Plugin/s
*
* @param int|null $id the plugin id
*
* @return object|array|null if ID found it returns object, if no ID
given it returns all set
* @since 3.2.0
*/
public function get(int $id = null)
{
if (is_null($id) && $this->exists())
{
return $this->data;
}
elseif ($this->exists($id))
{
return $this->data[$id];
}
return null;
}
/**
* Check if the Joomla Plugin/s exists
*
* @param int|null $id the plugin id
*
* @return bool if ID found it returns true, if no ID given it returns
true if any are set
* @since 3.2.0
*/
public function exists(int $id = null): bool
{
if (is_null($id))
{
return ArrayHelper::check($this->data);
}
elseif (isset($this->data[$id]))
{
return true;
}
return $this->set($id);
}
/**
* Set the Joomla Plugin
*
* @param int $id the plugin id
*
* @return bool true on success
* @since 3.2.0
*/
public function set(int $id): bool
{
if (isset($this->data[$id]))
{
return true;
}
else
{
// Create a new query object.
$query = $this->db->getQuery(true);
$query->select('a.*');
$query->select(
$this->db->quoteName(
array(
'g.name',
'e.name',
'e.head',
'e.comment',
'e.id',
'f.addfiles',
'f.addfolders',
'f.addfilesfullpath',
'f.addfoldersfullpath',
'f.addurls',
'u.version_update',
'u.id'
), array(
'group',
'extends',
'class_head',
'comment',
'class_id',
'addfiles',
'addfolders',
'addfilesfullpath',
'addfoldersfullpath',
'addurls',
'version_update',
'version_update_id'
)
)
);
// from these tables
$query->from('#__componentbuilder_joomla_plugin AS a');
$query->join(
'LEFT', $this->db->quoteName(
'#__componentbuilder_joomla_plugin_group', 'g'
) . ' ON (' .
$this->db->quoteName('a.joomla_plugin_group')
. ' = ' . $this->db->quoteName('g.id') .
')'
);
$query->join(
'LEFT',
$this->db->quoteName('#__componentbuilder_class_extends',
'e')
. ' ON (' .
$this->db->quoteName('a.class_extends') . ' = '
. $this->db->quoteName('e.id') . ')'
);
$query->join(
'LEFT', $this->db->quoteName(
'#__componentbuilder_joomla_plugin_updates', 'u'
) . ' ON (' . $this->db->quoteName('a.id') .
' = '
. $this->db->quoteName('u.joomla_plugin') .
')'
);
$query->join(
'LEFT', $this->db->quoteName(
'#__componentbuilder_joomla_plugin_files_folders_urls',
'f'
) . ' ON (' . $this->db->quoteName('a.id') .
' = '
. $this->db->quoteName('f.joomla_plugin') .
')'
);
$query->where($this->db->quoteName('a.id') . ' =
' . (int) $id);
$query->where($this->db->quoteName('a.published') .
' >= 1');
$this->db->setQuery($query);
$this->db->execute();
if ($this->db->getNumRows())
{
// get the plugin data
$plugin = $this->db->loadObject();
// tweak system to set stuff to the plugin domain
$_backup_target = $this->config->build_target;
$_backup_lang = $this->config->lang_target;
$_backup_langPrefix = $this->config->lang_prefix;
// set some keys
$plugin->target_type = 'pLuG!n';
$plugin->key = $plugin->id . '_' .
$plugin->target_type;
// update to point to plugin
$this->config->build_target = $plugin->key;
$this->config->lang_target = $plugin->key;
// set version if not set
if (empty($plugin->plugin_version))
{
$plugin->plugin_version = '1.0.0';
}
// set GUI mapper
$guiMapper = array('table' => 'joomla_plugin',
'id' => (int) $id, 'type'
=> 'php');
// update the name if it has dynamic values
$plugin->name = $this->placeholder->update_(
$this->customcode->update($plugin->name)
);
// update the name if it has dynamic values
$plugin->code_name
= ClassfunctionHelper::safe(
$plugin->name
);
// set official name
$plugin->official_name = ucwords(
$plugin->group . ' - ' . $plugin->name
);
// set lang prefix
$plugin->lang_prefix = PluginHelper::safeLangPrefix(
$plugin->code_name,
$plugin->group
);
// set langPrefix
$this->config->lang_prefix = $plugin->lang_prefix;
// set plugin class name
$plugin->class_name
= PluginHelper::safeClassName(
$plugin->code_name,
$plugin->group
);
// set plugin install class name
$plugin->installer_class_name
= PluginHelper::safeInstallClassName(
$plugin->code_name,
$plugin->group
);
// set plugin folder name
$plugin->folder_name
= PluginHelper::safeFolderName(
$plugin->code_name,
$plugin->group
);
// set the zip name
$plugin->zip_name = $plugin->folder_name . '_v' .
str_replace(
'.', '_', (string) $plugin->plugin_version
) . '__J' . $this->config->joomla_version;
// set plugin file name
$plugin->file_name = strtolower((string) $plugin->code_name);
// set plugin context
$plugin->context = $plugin->folder_name . '.' .
$plugin->id;
// set official_name lang strings
$this->language->set(
$plugin->key, $this->config->lang_prefix,
$plugin->official_name
);
// set some placeholder for this plugin
$this->placeholder->set('Plugin_name',
$plugin->official_name);
$this->placeholder->set('PLUGIN_NAME',
$plugin->official_name);
$this->placeholder->set('Plugin', ucfirst((string)
$plugin->code_name));
$this->placeholder->set('plugin', strtolower((string)
$plugin->code_name));
$this->placeholder->set('Plugin_group',
ucfirst((string) $plugin->group));
$this->placeholder->set('plugin_group',
strtolower((string) $plugin->group));
$this->placeholder->set('plugin.version',
$plugin->plugin_version);
$this->placeholder->set('VERSION',
$plugin->plugin_version);
$this->placeholder->set('plugin_version', str_replace(
'.', '_', (string) $plugin->plugin_version
));
// set description
$this->placeholder->set('DESCRIPTION', '');
if (!isset($plugin->description)
|| !StringHelper::check(
$plugin->description
))
{
$plugin->description = '';
}
else
{
$plugin->description = $this->placeholder->update_(
$this->customcode->update($plugin->description)
);
$this->language->set(
$plugin->key, $plugin->lang_prefix . '_DESCRIPTION',
$plugin->description
);
// set description
$this->placeholder->set('DESCRIPTION',
$plugin->description);
$plugin->description = '<p>' .
$plugin->description . '</p>';
}
// get author name
$project_author = $this->config->project_author;
// we can only set these if the component was passed
$plugin->xml_description = "<h1>" .
$plugin->official_name
. " (v." . $plugin->plugin_version
. ")</h1> <div style='clear:
both;'></div>"
. $plugin->description . "<p>Created by <a
href='" . trim(
(string) $this->config->project_website
) . "' target='_blank'>" . trim(
(string) OutputFilter::cleanText($project_author)
) . "</a><br /><small>Development started
"
. Factory::getDate($plugin->created)->format("jS F,
Y")
. "</small></p>";
// set xml discription
$this->language->set(
$plugin->key, $plugin->lang_prefix .
'_XML_DESCRIPTION',
$plugin->xml_description
);
// update the readme if set
if ($plugin->addreadme == 1 && !empty($plugin->readme))
{
$plugin->readme = $this->placeholder->update_(
$this->customcode->update(base64_decode((string)
$plugin->readme))
);
}
else
{
$plugin->addreadme = 0;
unset($plugin->readme);
}
// open some base64 strings
if (!empty($plugin->main_class_code))
{
// set GUI mapper field
$guiMapper['field'] = 'main_class_code';
// base64 Decode main_class_code.
$plugin->main_class_code = $this->gui->set(
$this->placeholder->update_(
$this->customcode->update(
base64_decode((string) $plugin->main_class_code)
)
),
$guiMapper
);
}
// set the head :)
if ($plugin->add_head == 1 && !empty($plugin->head))
{
// set GUI mapper field
$guiMapper['field'] = 'head';
// base64 Decode head.
$plugin->header = $this->gui->set(
$this->placeholder->update_(
$this->customcode->update(
base64_decode((string) $plugin->head)
)
),
$guiMapper
);
}
elseif (!empty($plugin->class_head))
{
// base64 Decode head.
$plugin->header = $this->gui->set(
$this->placeholder->update_(
$this->customcode->update(
base64_decode((string) $plugin->class_head)
)
),
array(
'table' => 'class_extends',
'field' => 'head',
'id' => (int) $plugin->class_id,
'type' => 'php')
);
}
unset($plugin->class_head);
// set the comment
if (!empty($plugin->comment))
{
// base64 Decode comment.
$plugin->comment = $this->gui->set(
$this->placeholder->update_(
$this->customcode->update(
base64_decode((string) $plugin->comment)
)
),
array(
'table' => 'class_extends',
'field' => 'comment',
'id' => (int) $plugin->class_id,
'type' => 'php')
);
}
// start the config array
$plugin->config_fields = [];
// create the form arrays
$plugin->form_files = [];
$plugin->fieldsets_label = [];
$plugin->fieldsets_paths = [];
$plugin->add_rule_path = [];
$plugin->add_field_path = [];
// set global fields rule to default component path
$plugin->fields_rules_paths = 1;
// set the fields data
$plugin->fields = (isset($plugin->fields)
&& JsonHelper::check($plugin->fields))
? json_decode((string) $plugin->fields, true) : null;
if (ArrayHelper::check($plugin->fields))
{
// ket global key
$key = $plugin->key;
$dynamic_fields = array('fieldset' =>
'basic',
'fields_name' =>
'params',
'file' =>
'config');
foreach ($plugin->fields as $n => &$form)
{
if (isset($form['fields'])
&& ArrayHelper::check(
$form['fields']
))
{
// make sure the dynamic_field is set to dynamic_value by default
foreach (
$dynamic_fields as $dynamic_field =>
$dynamic_value
)
{
if (!isset($form[$dynamic_field])
|| !StringHelper::check(
$form[$dynamic_field]
))
{
$form[$dynamic_field] = $dynamic_value;
}
else
{
if ('fields_name' === $dynamic_field
&& strpos((string) $form[$dynamic_field], '.')
!== false)
{
$form[$dynamic_field]
= $form[$dynamic_field];
}
else
{
$form[$dynamic_field]
= StringHelper::safe(
$form[$dynamic_field]
);
}
}
}
// check if field is external form file
if (!isset($form['plugin']) || $form['plugin']
!= 1)
{
// now build the form key
$unique = $form['file'] . $form['fields_name']
. $form['fieldset'];
}
else
{
// now build the form key
$unique = $form['fields_name']
. $form['fieldset'];
}
// set global fields rule path switchs
if ($plugin->fields_rules_paths == 1
&& isset($form['fields_rules_paths'])
&& $form['fields_rules_paths'] == 2)
{
$plugin->fields_rules_paths = 2;
}
// set where to path is pointing
$plugin->fieldsets_paths[$unique]
= $form['fields_rules_paths'];
// add the label if set to lang
if (isset($form['label'])
&& StringHelper::check(
$form['label']
))
{
$plugin->fieldsets_label[$unique]
= $this->language->key($form['label']);
}
// check for extra rule paths
if (isset($form['addrulepath'])
&& ArrayHelper::check($form['addrulepath']))
{
foreach ($form['addrulepath'] as $add_rule_path)
{
if (StringHelper::check($add_rule_path['path']))
{
$plugin->add_rule_path[$unique] =
$add_rule_path['path'];
}
}
}
// check for extra field paths
if (isset($form['addfieldpath'])
&& ArrayHelper::check($form['addfieldpath']))
{
foreach ($form['addfieldpath'] as $add_field_path)
{
if (StringHelper::check($add_field_path['path']))
{
$plugin->add_field_path[$unique] =
$add_field_path['path'];
}
}
}
// build the fields
$form['fields'] = array_map(
function ($field) use ($key, $unique) {
// make sure the alias and title is 0
$field['alias'] = 0;
$field['title'] = 0;
// set the field details
$this->field->set(
$field, $key, $key, $unique
);
// update the default if set
if (StringHelper::check(
$field['custom_value']
)
&& isset($field['settings']))
{
if (($old_default
= GetHelper::between(
$field['settings']->xml,
'default="', '"', false
)) !== false)
{
// replace old default
$field['settings']->xml
= str_replace(
'default="' . $old_default
. '"', 'default="'
. $field['custom_value'] . '"',
(string) $field['settings']->xml
);
}
else
{
// add the default (hmmm not ideal but okay it should work)
$field['settings']->xml
= 'default="'
. $field['custom_value'] . '" '
. $field['settings']->xml;
}
}
unset($field['custom_value']);
// return field
return $field;
}, array_values($form['fields'])
);
// check if field is external form file
if (!isset($form['plugin']) || $form['plugin']
!= 1)
{
// load the form file
if (!isset($plugin->form_files[$form['file']]))
{
$plugin->form_files[$form['file']]
= [];
}
if
(!isset($plugin->form_files[$form['file']][$form['fields_name']]))
{
$plugin->form_files[$form['file']][$form['fields_name']]
= [];
}
if
(!isset($plugin->form_files[$form['file']][$form['fields_name']][$form['fieldset']]))
{
$plugin->form_files[$form['file']][$form['fields_name']][$form['fieldset']]
= [];
}
// do some house cleaning (for fields)
foreach ($form['fields'] as $field)
{
// so first we lock the field name in
$this->fieldname->get(
$field, $plugin->key, $unique
);
// add the fields to the global form file builder
$plugin->form_files[$form['file']][$form['fields_name']][$form['fieldset']][]
= $field;
}
// remove form
unset($plugin->fields[$n]);
}
else
{
// load the config form
if
(!isset($plugin->config_fields[$form['fields_name']]))
{
$plugin->config_fields[$form['fields_name']]
= [];
}
if
(!isset($plugin->config_fields[$form['fields_name']][$form['fieldset']]))
{
$plugin->config_fields[$form['fields_name']][$form['fieldset']]
= [];
}
// do some house cleaning (for fields)
foreach ($form['fields'] as $field)
{
// so first we lock the field name in
$this->fieldname->get(
$field, $plugin->key, $unique
);
// add the fields to the config builder
$plugin->config_fields[$form['fields_name']][$form['fieldset']][]
= $field;
}
// remove form
unset($plugin->fields[$n]);
}
}
else
{
unset($plugin->fields[$n]);
}
}
}
unset($plugin->fields);
// set files and folders
$this->filesfolders->set($plugin);
// add PHP in plugin install
$plugin->add_install_script = true;
$addScriptMethods = [
'php_preflight',
'php_postflight',
'php_method',
'php_script'
];
$addScriptTypes = [
'install',
'update',
'uninstall',
'construct'
];
foreach ($addScriptMethods as $scriptMethod)
{
foreach ($addScriptTypes as $scriptType)
{
if (isset( $plugin->{'add_' . $scriptMethod .
'_' . $scriptType})
&& $plugin->{'add_' . $scriptMethod .
'_' . $scriptType} == 1
&& StringHelper::check(
$plugin->{$scriptMethod . '_' . $scriptType}
))
{
// set GUI mapper field
$guiMapper['field'] = $scriptMethod . '_' .
$scriptType;
$plugin->{$scriptMethod . '_' . $scriptType} =
$this->gui->set(
$this->placeholder->update_(
$this->customcode->update(
base64_decode(
(string) $plugin->{$scriptMethod . '_' .
$scriptType}
)
)
),
$guiMapper
);
}
else
{
unset($plugin->{$scriptMethod . '_' . $scriptType});
$plugin->{'add_' . $scriptMethod . '_' .
$scriptType} = 0;
}
}
}
// add_sql
if ($plugin->add_sql == 1
&& StringHelper::check($plugin->sql))
{
$plugin->sql = $this->placeholder->update_(
$this->customcode->update(base64_decode((string)
$plugin->sql))
);
}
else
{
unset($plugin->sql);
$plugin->add_sql = 0;
}
// add_sql_uninstall
if ($plugin->add_sql_uninstall == 1
&& StringHelper::check(
$plugin->sql_uninstall
))
{
$plugin->sql_uninstall = $this->placeholder->update_(
$this->customcode->update(
base64_decode((string) $plugin->sql_uninstall)
)
);
}
else
{
unset($plugin->sql_uninstall);
$plugin->add_sql_uninstall = 0;
}
// update the URL of the update_server if set
if ($plugin->add_update_server == 1
&& StringHelper::check(
$plugin->update_server_url
))
{
$plugin->update_server_url = $this->placeholder->update_(
$this->customcode->update($plugin->update_server_url)
);
}
// add the update/sales server FTP details if that is the expected
protocol
$serverArray = array('update_server',
'sales_server');
foreach ($serverArray as $server)
{
if ($plugin->{'add_' . $server} == 1
&& is_numeric(
$plugin->{$server}
)
&& $plugin->{$server} > 0)
{
// get the server protocol
$plugin->{$server . '_protocol'}
= GetHelper::var(
'server', (int) $plugin->{$server}, 'id',
'protocol'
);
}
else
{
$plugin->{$server} = 0;
// only change this for sales server (update server can be added
locally to the zip file)
if ('sales_server' === $server)
{
$plugin->{'add_' . $server} = 0;
}
$plugin->{$server . '_protocol'} = 0;
}
}
// set the update server stuff (TODO)
// update_server_xml_path
// update_server_xml_file_name
// rest globals
$this->config->build_target = $_backup_target;
$this->config->lang_target = $_backup_lang;
$this->config->set('lang_prefix',
$_backup_langPrefix);
$this->placeholder->remove('Plugin_name');
$this->placeholder->remove('Plugin');
$this->placeholder->remove('plugin');
$this->placeholder->remove('Plugin_group');
$this->placeholder->remove('plugin_group');
$this->placeholder->remove('plugin.version');
$this->placeholder->remove('plugin_version');
$this->placeholder->remove('VERSION');
$this->placeholder->remove('DESCRIPTION');
$this->placeholder->remove('PLUGIN_NAME');
$this->data[$id] = $plugin;
return true;
}
}
return false;
}
}
src/Componentbuilder/Compiler/Joomlaplugin/JoomlaThree/Infusion.php000064400000021112151162054160021570
0ustar00<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder
<https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights
reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
namespace VDM\Joomla\Componentbuilder\Compiler\Joomlaplugin\JoomlaThree;
use VDM\Joomla\Componentbuilder\Compiler\Config;
use VDM\Joomla\Componentbuilder\Compiler\Placeholder;
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\HeaderInterface as
Header;
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\EventInterface as
Event;
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\PluginDataInterface as
Data;
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\GetScriptInterface as
InstallScript;
use
VDM\Joomla\Componentbuilder\Compiler\Interfaces\Architecture\Plugin\ExtensionInterface
as Extension;
use
VDM\Joomla\Componentbuilder\Interfaces\Architecture\Plugin\MainXMLInterface
as MainXML;
use VDM\Joomla\Componentbuilder\Compiler\Builder\ContentMulti;
use VDM\Joomla\Componentbuilder\Compiler\Creator\FieldsetExtension;
use VDM\Joomla\Utilities\ObjectHelper;
use VDM\Joomla\Utilities\ArrayHelper;
use VDM\Joomla\Componentbuilder\Interfaces\Plugin\InfusionInterface;
/**
* Joomla 3 Plugin Infusion Class
*
* @since 5.0.2
*/
final class Infusion implements InfusionInterface
{
/**
* The Config Class.
*
* @var Config
* @since 5.0.2
*/
protected Config $config;
/**
* The Placeholder Class.
*
* @var Placeholder
* @since 5.0.2
*/
protected Placeholder $placeholder;
/**
* The Header Class.
*
* @var Header
* @since 5.0.2
*/
protected Header $header;
/**
* The EventInterface Class.
*
* @var Event
* @since 5.0.2
*/
protected Event $event;
/**
* The Plugin Data Class.
*
* @var Data
* @since 5.0.2
*/
protected Data $data;
/**
* The Get Script Class.
*
* @var InstallScript
* @since 5.0.2
*/
protected InstallScript $installscript;
/**
* The Extension Class.
*
* @var Extension
* @since 5.0.2
*/
protected Extension $extension;
/**
* The Main XML Class.
*
* @var MainXML
* @since 5.0.2
*/
protected MainXML $mainxml;
/**
* The Content Multi Class.
*
* @var ContentMulti
* @since 5.0.2
*/
protected ContentMulti $contentmulti;
/**
* The Fieldset Extension Class.
*
* @var FieldsetExtension
* @since 5.0.2
*/
protected FieldsetExtension $fieldsetextension;
/**
* Constructor.
*
* @param Config $config The Config Class.
* @param Placeholder $placeholder The Placeholder Class.
* @param Header $header The HeaderInterface
Class.
* @param Event $event The EventInterface
Class.
* @param Data $data The PluginDataInterface
Class.
* @param InstallScript $installscript The GetScriptInterface
Class.
* @param Extension $extension The ExtensionInterface
Class.
* @param MainXML $mainxml The MainXMLInterface
Class.
* @param ContentMulti $contentmulti The ContentMulti
Class.
* @param FieldsetExtension $fieldsetextension The FieldsetExtension
Class.
*
* @since 5.0.2
*/
public function __construct(Config $config, Placeholder $placeholder,
Header $header,
Event $event, Data $data, InstallScript $installscript,
Extension $extension, MainXML $mainxml,
ContentMulti $contentmulti,
FieldsetExtension $fieldsetextension)
{
$this->config = $config;
$this->placeholder = $placeholder;
$this->header = $header;
$this->event = $event;
$this->data = $data;
$this->installscript = $installscript;
$this->extension = $extension;
$this->mainxml = $mainxml;
$this->contentmulti = $contentmulti;
$this->fieldsetextension = $fieldsetextension;
}
/**
* Infuse the plugin data into the content.
*
* This method processes each plugin in the data set, triggering events
* before and after infusion, setting placeholders, and adding content
* such as headers, classes, and XML configurations.
*
* @return void
* @since 5.0.2
*/
public function set(): void
{
if (!$this->data->exists())
{
return;
}
foreach ($this->data->get() as $plugin)
{
if (!ObjectHelper::check($plugin))
{
continue;
}
$this->triggerBeforeInfusionEvent($plugin);
$this->setPlaceholders($plugin);
$this->buildPluginContent($plugin);
$this->triggerAfterInfusionEvent($plugin);
}
}
/**
* Trigger the event before infusing the plugin data.
*
* @param object $plugin The plugin object being processed.
*
* @return void
* @since 5.0.2
*/
protected function triggerBeforeInfusionEvent(&$plugin): void
{
$this->event->trigger('jcb_ce_onBeforeInfusePluginData',
[&$plugin]);
}
/**
* Set placeholders based on plugin data.
*
* @param object $plugin The plugin object being processed.
*
* @return void
* @since 5.0.2
*/
protected function setPlaceholders($plugin): void
{
$this->placeholder->set('PluginGroupNamespace',
$plugin->group_namespace ?? '');
$this->placeholder->set('PluginNamespace',
$plugin->namespace ?? '');
$this->config->build_target = $plugin->key;
$this->config->lang_target = $plugin->key;
$this->config->set('lang_prefix',
$plugin->lang_prefix);
}
/**
* Build and set the content related to the plugin.
*
* @param object $plugin The plugin object being processed.
*
* @return void
* @since 5.0.2
*/
protected function buildPluginContent($plugin): void
{
$this->setExtensionClassHeader($plugin);
$this->setExtensionClass($plugin);
if ($plugin->add_install_script)
{
$this->setInstallClass($plugin);
}
if (isset($plugin->form_files) &&
ArrayHelper::check($plugin->form_files))
{
$this->setFieldsets($plugin);
}
$this->setMainXml($plugin);
}
/**
* Set the extension class header content.
*
* @param object $plugin The plugin object being processed.
*
* @return void
* @since 5.0.2
*/
protected function setExtensionClassHeader($plugin): void
{
$headerContent = trim(
$this->header->get('plugin.extension.header',
$plugin->class_name)
. PHP_EOL . ($plugin->header ?? '')
);
$this->contentmulti->set("{$plugin->key}|EXTENSION_CLASS_HEADER",
$headerContent);
}
/**
* Set the extension class content.
*
* @param object $plugin The plugin object being processed.
*
* @return void
* @since 5.0.2
*/
protected function setExtensionClass($plugin): void
{
$extensionContent = $this->extension->get($plugin);
$this->contentmulti->set("{$plugin->key}|EXTENSION_CLASS",
$extensionContent);
}
/**
* Set the install script content, if needed.
*
* @param object $plugin The plugin object being processed.
*
* @return void
* @since 5.0.2
*/
protected function setInstallClass($plugin): void
{
$installContent = $this->installscript->get($plugin);
$this->contentmulti->set("{$plugin->key}|INSTALL_CLASS",
$installContent);
}
/**
* Set fieldset content based on form files.
*
* @param object $plugin The plugin object being processed.
*
* @return void
* @since 5.0.2
*/
protected function setFieldsets($plugin): void
{
foreach ($plugin->form_files as $file => $files)
{
foreach ($files as $field_name => $fieldsets)
{
foreach ($fieldsets as $fieldset => $fields)
{
$fieldsetContent = $this->fieldsetextension->get($plugin,
$fields);
$this->contentmulti->set(
"{$plugin->key}|FIELDSET_{$file}{$field_name}{$fieldset}",
$fieldsetContent
);
}
}
}
}
/**
* Set the main XML content for the plugin.
*
* @param object $plugin The plugin object being processed.
*
* @return void
* @since 5.0.2
*/
protected function setMainXml($plugin): void
{
$mainXmlContent = $this->mainxml->get($plugin);
$this->contentmulti->set("{$plugin->key}|MAINXML",
$mainXmlContent);
}
/**
* Trigger the event after infusing the plugin data.
*
* @param object $plugin The plugin object being processed.
*
* @return void
* @since 5.0.2
*/
protected function triggerAfterInfusionEvent(&$plugin): void
{
$this->event->trigger('jcb_ce_onAfterInfusePluginData',
[&$plugin]);
}
}
src/Componentbuilder/Compiler/Joomlaplugin/JoomlaThree/Structure.php000064400000050173151162054160022007
0ustar00<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder
<https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights
reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
namespace VDM\Joomla\Componentbuilder\Compiler\Joomlaplugin\JoomlaThree;
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\PluginDataInterface as
Plugin;
use VDM\Joomla\Componentbuilder\Compiler\Component;
use VDM\Joomla\Componentbuilder\Compiler\Config;
use VDM\Joomla\Componentbuilder\Compiler\Registry;
use VDM\Joomla\Componentbuilder\Compiler\Customcode\Dispenser;
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\EventInterface as
Event;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Counter;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Folder;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\File;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Files;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Indent;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Placefix;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Line;
use VDM\Joomla\Utilities\ArrayHelper;
use VDM\Joomla\Utilities\ObjectHelper;
use VDM\Joomla\Utilities\StringHelper;
use VDM\Joomla\Utilities\FileHelper;
use VDM\Joomla\Componentbuilder\Interfaces\Plugin\StructureInterface;
/**
* Joomla 3 Plugin Builder Class
*
* @since 3.2.0
*/
class Structure implements StructureInterface
{
/**
* The Data Class.
*
* @var Plugin
* @since 3.2.0
*/
protected Plugin $plugin;
/**
* The Component Class.
*
* @var Component
* @since 3.2.0
*/
protected Component $component;
/**
* The Config Class.
*
* @var Config
* @since 3.2.0
*/
protected Config $config;
/**
* The Registry Class.
*
* @var Registry
* @since 3.2.0
*/
protected Registry $registry;
/**
* The Dispenser Class.
*
* @var Dispenser
* @since 3.2.0
*/
protected Dispenser $dispenser;
/**
* The EventInterface Class.
*
* @var Event
* @since 3.2.0
*/
protected Event $event;
/**
* The Counter Class.
*
* @var Counter
* @since 3.2.0
*/
protected Counter $counter;
/**
* The Folder Class.
*
* @var Folder
* @since 3.2.0
*/
protected Folder $folder;
/**
* The File Class.
*
* @var File
* @since 3.2.0
*/
protected File $file;
/**
* The Files Class.
*
* @var Files
* @since 3.2.0
*/
protected Files $files;
/**
* Constructor.
*
* @param Plugin $plugin The Data Class.
* @param Component $component The Component Class.
* @param Config $config The Config Class.
* @param Registry $registry The Registry Class.
* @param Dispenser $dispenser The Dispenser Class.
* @param Event $event The EventInterface Class.
* @param Counter $counter The Counter Class.
* @param Folder $folder The Folder Class.
* @param File $file The File Class.
* @param Files $files The Files Class.
*
* @since 3.2.0
*/
public function __construct(Plugin $plugin, Component $component, Config
$config,
Registry $registry, Dispenser $dispenser, Event $event,
Counter $counter, Folder $folder, File $file,
Files $files)
{
$this->plugin = $plugin;
$this->component = $component;
$this->config = $config;
$this->registry = $registry;
$this->dispenser = $dispenser;
$this->event = $event;
$this->counter = $counter;
$this->folder = $folder;
$this->file = $file;
$this->files = $files;
}
/**
* Build the Plugins files, folders, url's and config
*
* @return void
* @since 3.2.0
*/
public function build()
{
if ($this->plugin->exists())
{
// for plugin event TODO change event api signatures
$component_context = $this->config->component_context;
$plugins = $this->plugin->get();
// Trigger Event: jcb_ce_onBeforeSetPlugins
$this->event->trigger(
'jcb_ce_onBeforeBuildPlugins',
array(&$component_context, &$plugins)
);
foreach ($plugins as $plugin)
{
if (ObjectHelper::check($plugin)
&& isset($plugin->folder_name)
&& StringHelper::check($plugin->folder_name))
{
// plugin path
$this->pluginPath($plugin);
// set the plugin paths
$this->registry->set('dynamic_paths.' .
$plugin->key, $plugin->folder_path);
// make sure there is no old build
$this->folder->remove($plugin->folder_path);
// creat the main component folder
$this->folder->create($plugin->folder_path);
// set main class file
$this->setMainClassFile($plugin);
// set main xml file
$this->setMainXmlFile($plugin);
// set install script if needed
$this->setInstallScript($plugin);
// set readme if found
$this->setReadme($plugin);
// set fields & rules folders if needed
if (isset($plugin->fields_rules_paths)
&& $plugin->fields_rules_paths == 2)
{
// create fields folder
$this->folder->create($plugin->folder_path .
'/fields');
// create rules folder
$this->folder->create($plugin->folder_path .
'/rules');
}
// set forms folder if needed
$this->setForms($plugin);
// set SQL stuff if needed
$this->setSQL($plugin);
// creat the language folder path
$this->folder->create($plugin->folder_path .
'/language');
// also creat the lang tag folder path
$this->folder->create(
$plugin->folder_path . '/language/' .
$this->config->get('lang_tag', 'en-GB')
);
// check if this plugin has files
$this->setFiles($plugin);
// check if this plugin has folders
$this->setFolders($plugin);
// check if this plugin has urls
$this->setUrls($plugin);
}
}
}
}
/**
* get the plugin xml template
*
* @param object $plugin The plugin object
*
* @return string
* @since 3.2.0
*/
protected function getXML(object $plugin): string
{
$xml = '<?xml version="1.0"
encoding="utf-8"?>';
$xml .= PHP_EOL . '<extension type="plugin"
version="'
.
$this->config->joomla_versions[$this->config->joomla_version]['xml_version']
. '" group="'
. strtolower((string) $plugin->group) . '"
method="upgrade">';
$xml .= PHP_EOL . Indent::_(1) . '<name>' .
$plugin->lang_prefix
. '</name>';
$xml .= PHP_EOL . Indent::_(1) . '<creationDate>' .
Placefix::_h('BUILDDATE') . '</creationDate>';
$xml .= PHP_EOL . Indent::_(1) . '<author>' .
Placefix::_h('AUTHOR') . '</author>';
$xml .= PHP_EOL . Indent::_(1) . '<authorEmail>' .
Placefix::_h('AUTHOREMAIL') . '</authorEmail>';
$xml .= PHP_EOL . Indent::_(1) . '<authorUrl>' .
Placefix::_h('AUTHORWEBSITE') . '</authorUrl>';
$xml .= PHP_EOL . Indent::_(1) . '<copyright>' .
Placefix::_h('COPYRIGHT') . '</copyright>';
$xml .= PHP_EOL . Indent::_(1) . '<license>' .
Placefix::_h('LICENSE') . '</license>';
$xml .= PHP_EOL . Indent::_(1) . '<version>' .
$plugin->plugin_version
. '</version>';
$xml .= PHP_EOL . Indent::_(1) . '<description>' .
$plugin->lang_prefix
. '_XML_DESCRIPTION</description>';
$xml .= Placefix::_h('MAINXML');
$xml .= PHP_EOL . '</extension>';
return $xml;
}
/**
* set the plugin path
*
* @param object $plugin The plugin object
*
* @return void
* @since 3.2.0
*/
protected function pluginPath(object &$plugin): void
{
$plugin->folder_path =
$this->config->get('compiler_path',
JPATH_COMPONENT_ADMINISTRATOR . '/compiler') . '/'
. $plugin->folder_name;
}
/**
* set the main class path
*
* @param object $plugin The plugin object
*
* @return void
* @since 3.2.0
*/
protected function setMainClassFile(object $plugin): void
{
$file_details = [
'path' => $plugin->folder_path . '/' .
$plugin->file_name . '.php',
'name' => $plugin->file_name . '.php',
'zip' => $plugin->file_name . '.php'
];
$this->file->write(
$file_details['path'],
'<?php' . PHP_EOL . '// Plugin main class
template' .
PHP_EOL . Placefix::_h('BOM') . PHP_EOL .
PHP_EOL . '// No direct access to this file' . PHP_EOL .
"defined('_JEXEC') or die('Restricted
access');" . PHP_EOL .
PHP_EOL . Placefix::_h('EXTENSION_CLASS_HEADER') .
PHP_EOL . PHP_EOL . Placefix::_h('EXTENSION_CLASS')
);
$this->files->appendArray($plugin->key, $file_details);
// count the file created
$this->counter->file++;
}
/**
* set the main xml file
*
* @param object $plugin The plugin object
*
* @return void
* @since 3.2.0
*/
protected function setMainXmlFile(object $plugin): void
{
$file_details = [
'path' => $plugin->folder_path . '/' .
$plugin->file_name . '.xml',
'name' => $plugin->file_name . '.xml',
'zip' => $plugin->file_name . '.xml'
];
$this->file->write(
$file_details['path'],
$this->getXML($plugin)
);
$this->files->appendArray($plugin->key, $file_details);
// count the file created
$this->counter->file++;
}
/**
* set the install script file
*
* @param object $plugin The plugin object
*
* @return void
* @since 3.2.0
*/
protected function setInstallScript(object $plugin): void
{
if ($plugin->add_install_script)
{
$file_details = [
'path' => $plugin->folder_path .
'/script.php',
'name' => 'script.php',
'zip' => 'script.php'
];
$this->file->write(
$file_details['path'],
'<?php' . PHP_EOL . '// Script template' .
PHP_EOL . Placefix::_h('BOM') . PHP_EOL .
PHP_EOL . '// No direct access to this file' . PHP_EOL .
"defined('_JEXEC') or die('Restricted
access');" . PHP_EOL .
Placefix::_h('INSTALL_CLASS')
);
$this->files->appendArray($plugin->key, $file_details);
// count the file created
$this->counter->file++;
}
}
/**
* set the readme file
*
* @param object $plugin The plugin object
*
* @return void
* @since 3.2.0
*/
protected function setReadme(object $plugin): void
{
if ($plugin->addreadme)
{
$file_details = [
'path' => $plugin->folder_path .
'/README.md',
'name' => 'README.md',
'zip' => 'README.md'
];
$this->file->write($file_details['path'],
$plugin->readme);
$this->files->appendArray($plugin->key, $file_details);
// count the file created
$this->counter->file++;
}
}
/**
* set the form files and folders
*
* @param object $plugin The plugin object
*
* @return void
* @since 3.2.0
*/
protected function setForms(object $plugin): void
{
if (isset($plugin->form_files)
&& ArrayHelper::check($plugin->form_files))
{
// create forms folder
$this->folder->create($plugin->folder_path .
'/forms');
// set the template files
foreach ($plugin->form_files as $file => $fields)
{
// set file details
$file_details = [
'path' => $plugin->folder_path . '/forms/' .
$file . '.xml',
'name' => $file . '.xml',
'zip' => 'forms/' . $file . '.xml'
];
// build basic XML
$xml = '<?xml version="1.0"
encoding="utf-8"?>';
$xml .= PHP_EOL . '<!--' . Line::_(__Line__, __Class__)
. ' default paths of ' . $file
. ' form points to ' .
$this->config->component_code_name
. ' -->';
// search if we must add the component path
$add_component_path = false;
foreach ($fields as $field_name => $fieldsets)
{
if (!$add_component_path)
{
foreach ($fieldsets as $fieldset => $field)
{
if (!$add_component_path
&& isset($plugin->fieldsets_paths[$file . $field_name .
$fieldset])
&& $plugin->fieldsets_paths[$file. $field_name .
$fieldset] == 1)
{
$add_component_path = true;
}
}
}
}
// only add if part of the component field types path is required
if ($add_component_path)
{
$xml .= PHP_EOL . '<form';
if ($this->config->get('joomla_version', 3) == 3)
{
$xml .= PHP_EOL . Indent::_(1)
. 'addrulepath="/administrator/components/com_'
. $this->config->component_code_name
. '/models/rules"';
$xml .= PHP_EOL . Indent::_(1)
. 'addfieldpath="/administrator/components/com_'
. $this->config->component_code_name
. '/models/fields"';
}
else
{
$xml .= PHP_EOL . Indent::_(1)
. 'addruleprefix="' .
$this->config->namespace_prefix
. '\Component\\' .
StringHelper::safe($this->config->component_code_name,
'F')
. '\Administrator\Rule"';
$xml .= PHP_EOL . Indent::_(1)
.'addfieldprefix="' .
$this->config->namespace_prefix
. '\Component\\' .
StringHelper::safe($this->config->component_code_name,
'F')
. '\Administrator\Field"';
}
$xml .= PHP_EOL . '>';
}
else
{
$xml .= PHP_EOL . '<form>';
}
// add the fields
foreach ($fields as $field_name => $fieldsets)
{
// check if we have an double fields naming set
$field_name_inner = '';
$field_name_outer = $field_name;
if (strpos((string)$field_name, '.') !== false)
{
$field_names = explode('.', (string)$field_name);
if (count((array)$field_names) == 2)
{
$field_name_outer = $field_names[0];
$field_name_inner = $field_names[1];
}
}
$xml .= PHP_EOL . Indent::_(1)
. '<fields name="' . $field_name_outer
. '">';
foreach ($fieldsets as $fieldset => $field)
{
// default to the field set name
$label = $fieldset;
if (isset($plugin->fieldsets_label[$file . $field_name .
$fieldset]))
{
$label = $plugin->fieldsets_label[$file . $field_name .
$fieldset];
}
// add path to plugin rules and custom fields
if (isset($plugin->fieldsets_paths[$file . $field_name .
$fieldset])
&& ($plugin->fieldsets_paths[$file . $field_name .
$fieldset] == 2
|| $plugin->fieldsets_paths[$file . $field_name . $fieldset] ==
3))
{
if (!isset($plugin->add_rule_path[$file . $field_name .
$fieldset]))
{
$plugin->add_rule_path[$file . $field_name . $fieldset] =
'/plugins/' . strtolower((string)$plugin->group) .
'/'
. strtolower((string)$plugin->code_name) . '/rules';
}
if (!isset($plugin->add_field_path[$file . $field_name .
$fieldset]))
{
$plugin->add_field_path[$file . $field_name . $fieldset] =
'/plugins/' . strtolower((string)$plugin->group
) . '/' . strtolower((string)$plugin->code_name)
. '/fields';
}
}
// add path to plugin rules and custom fields
if (isset($plugin->add_rule_path[$file . $field_name .
$fieldset])
|| isset($plugin->add_field_path[$file . $field_name .
$fieldset]))
{
$xml .= PHP_EOL . Indent::_(1) . '<!--'
. Line::_(__Line__, __Class__) . ' default paths of '
. $fieldset . ' fieldset points to the plugin -->';
$xml .= PHP_EOL . Indent::_(1) . '<fieldset
name="'
. $fieldset . '" label="' . $label .
'"';
if (isset($plugin->add_rule_path[$file . $field_name .
$fieldset]))
{
$xml .= PHP_EOL . Indent::_(2)
. 'addrulepath="' . $plugin->add_rule_path[$file
. $field_name . $fieldset] . '"';
}
if (isset($plugin->add_field_path[$file . $field_name .
$fieldset]))
{
$xml .= PHP_EOL . Indent::_(2)
. 'addfieldpath="' .
$plugin->add_field_path[$file . $field_name . $fieldset] .
'"';
}
$xml .= PHP_EOL . Indent::_(1) . '>';
}
else
{
$xml .= PHP_EOL . Indent::_(1) . '<fieldset
name="'
. $fieldset . '" label="' . $label .
'">';
}
// check if we have an inner field set
if (StringHelper::check($field_name_inner))
{
$xml .= PHP_EOL . Indent::_(1)
. '<fields name="'
. $field_name_inner . '">';
}
// add the placeholder of the fields
$xml .= Placefix::_h('FIELDSET_' . $file
. $field_name . $fieldset);
// check if we have an inner field set
if (StringHelper::check($field_name_inner))
{
$xml .= PHP_EOL . Indent::_(1)
. '</fields>';
}
$xml .= PHP_EOL . Indent::_(1)
. '</fieldset>';
}
$xml .= PHP_EOL . Indent::_(1) . '</fields>';
}
$xml .= PHP_EOL . '</form>';
// add xml to file
$this->file->write($file_details['path'], $xml);
$this->files->appendArray($plugin->key, $file_details);
// count the file created
$this->counter->file++;
}
}
}
/**
* set the sql stuff
*
* @param object $plugin The plugin object
*
* @return void
* @since 3.2.0
*/
protected function setSQL(object $plugin): void
{
if ($plugin->add_sql || $plugin->add_sql_uninstall)
{
// create SQL folder
$this->folder->create($plugin->folder_path .
'/sql');
// create mysql folder
$this->folder->create(
$plugin->folder_path . '/sql/mysql'
);
// now set the install file
if ($plugin->add_sql)
{
$this->file->write(
$plugin->folder_path . '/sql/mysql/install.sql',
$plugin->sql
);
// count the file created
$this->counter->file++;
}
// now set the uninstall file
if ($plugin->add_sql_uninstall)
{
$this->file->write(
$plugin->folder_path
. '/sql/mysql/uninstall.sql',
$plugin->sql_uninstall
);
// count the file created
$this->counter->file++;
}
}
}
/**
* set the files
*
* @param object $plugin The plugin object
*
* @return void
* @since 3.2.0
*/
protected function setFiles(object $plugin): void
{
if (isset($plugin->files) &&
ArrayHelper::check($plugin->files))
{
// add to component files
foreach ($plugin->files as $file)
{
// set the path finder
$file['target_type'] = $plugin->target_type;
$file['target_id'] = $plugin->id;
$this->component->appendArray('files', $file);
}
}
}
/**
* set the folders
*
* @param object $plugin The plugin object
*
* @return void
* @since 3.2.0
*/
protected function setFolders(object $plugin): void
{
if (isset($plugin->folders) &&
ArrayHelper::check($plugin->folders))
{
// add to component folders
foreach ($plugin->folders as $folder)
{
// set the path finder
$folder['target_type'] = $plugin->target_type;
$folder['target_id'] = $plugin->id;
$this->component->appendArray('folders', $folder);
}
}
}
/**
* set the urls
*
* @param object $plugin The plugin object
*
* @return void
* @since 3.2.0
*/
protected function setUrls(object &$plugin): void
{
if (isset($plugin->urls) &&
ArrayHelper::check($plugin->urls))
{
// add to component urls
foreach ($plugin->urls as &$url)
{
// should we add the local folder
if (isset($url['type']) && $url['type']
> 1
&& isset($url['url'])
&& StringHelper::check($url['url']))
{
// set file name
$fileName = basename((string)$url['url']);
// get the file contents
$data = FileHelper::getContent(
$url['url']
);
// build sub path
if (strpos($fileName, '.js') !== false)
{
$path = '/js';
}
elseif (strpos($fileName, '.css') !== false)
{
$path = '/css';
}
else
{
$path = '';
}
// create sub media folder path if not set
$this->folder->create(
$plugin->folder_path . $path
);
// set the path to plugin file
$url['path'] = $plugin->folder_path . $path
. '/' . $fileName; // we need this for later
// write data to path
$this->file->write($url['path'], $data);
// count the file created
$this->counter->file++;
}
}
}
}
}
src/Componentbuilder/Compiler/Joomlaplugin/JoomlaThree/index.html000064400000000054151162054160021264
0ustar00<html><body
bgcolor="#FFFFFF"></body></html>src/Componentbuilder/Compiler/Language.php000064400000012560151162054160014657
0ustar00<?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;
use VDM\Joomla\Utilities\ArrayHelper;
use VDM\Joomla\Utilities\StringHelper;
use VDM\Joomla\Componentbuilder\Compiler\Factory as Compiler;
use VDM\Joomla\Componentbuilder\Compiler\Config;
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\LanguageInterface;
/**
* Compiler Language Content
*
* @since 3.2.0
*/
final class Language implements LanguageInterface
{
/**
* The language content
*
* @var array
* @since 3.2.0
**/
protected array $content = [];
/**
* Compiler Config
*
* @var Config
* @since 3.2.0
**/
protected Config $config;
/**
* Constructor.
*
* @param Config|null $config The compiler config
object.
*
* @since 3.2.0
*/
public function __construct(?Config $config = null)
{
$this->config = $config ?: Compiler::_('Config');
}
/**
* Get the language string key
*
* @param string $string The plan text string (English)
*
* @return string The key language string (all uppercase)
* @since 3.2.0
*/
public function key($string): string
{
// this is there to insure we don't break already added Language
strings
if (StringHelper::safe($string, 'U', '_', false,
false) === $string)
{
return false;
}
// build language key
$key_lang = $this->config->lang_prefix . '_' .
StringHelper::safe($string, 'U');
// set the language string
$this->set($this->config->lang_target, $key_lang, $string);
return $key_lang;
}
/**
* check if the language string exist
*
* @param string $target The target area for the language string
* @param string|null $language The language key string
*
* @return bool
* @since 3.2.0
*/
public function exist(string $target, ?string $language = null): bool
{
if ($language)
{
return isset($this->content[$target][$language]);
}
return isset($this->content[$target]);
}
/**
* get the language string
*
* @param string $target The target area for the language string
* @param string|null $language The language key string
*
* @return Mixed The language string found or empty string if none is
found
* @since 3.2.0
*/
public function get(string $target, string $language): string
{
if (isset($this->content[$target][$language]))
{
return $this->content[$target][$language];
}
return '';
}
/**
* get target array
*
* @param string $target The target area for the language string
*
* @return array The target array or empty array if none is found
* @since 3.2.0
*/
public function getTarget(string $target): array
{
if (isset($this->content[$target]) &&
ArrayHelper::check($this->content[$target]))
{
return $this->content[$target];
}
return [];
}
/**
* set target array
*
* @param string $target The target area for the language string
* @param array|null $content The language content string
*
* @return void
* @since 3.2.0
*/
public function setTarget(string $target, ?array $content)
{
$this->content[$target] = $content;
}
/**
* set the language content values to language content array
*
* @param string $target The target area for the language string
* @param string $language The language key string
* @param string $string The language string
* @param bool $addPrefix The switch to add langPrefix
*
* @return void
* @since 3.2.0
*/
public function set(string $target, string $language, string $string, bool
$addPrefix = false)
{
if ($addPrefix &&
empty($this->content[$target][$this->config->lang_prefix .
'_' . $language]))
{
$this->content[$target][$this->config->lang_prefix .
'_' . $language]
= $this->fix($string);
}
elseif (empty($this->content[$target][$language]))
{
$this->content[$target][$language] = $this->fix($string);
}
}
/**
* Removes all types of line breaks from a given string.
*
* This method is designed to strip out all kinds of new line characters
from the input string
* to ensure a single-line output. It takes into consideration different
operating systems'
* line endings, including the combination of Carriage Return and Line
Feed.
*
* @param string $string The input string possibly containing line
breaks.
*
* @return string The modified string with all line breaks removed.
* @since 3.2.0
*/
public function fix(string $string): string
{
if ($this->config->remove_line_breaks)
{
// Using a single str_replace call to handle all variations of line
breaks.
// The array includes \r\n (CR+LF used in Windows), \n (LF used in
Unix/Linux),
// and \r (CR used in old Macs) to cover all bases.
$search = [PHP_EOL, "\r\n", "\n", "\r"];
$string = str_replace($search, '', $string);
}
// Trim the string to remove any leading or trailing whitespace.
return trim($string);
}
}
src/Componentbuilder/Compiler/Language/Extractor.php000064400000016702151162054160016634
0ustar00<?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\Language;
use VDM\Joomla\Componentbuilder\Compiler\Config;
use VDM\Joomla\Componentbuilder\Compiler\Language;
use VDM\Joomla\Componentbuilder\Compiler\Placeholder;
use VDM\Joomla\Utilities\ArrayHelper;
use VDM\Joomla\Utilities\StringHelper;
use VDM\Joomla\Utilities\GetHelper;
/**
* Compiler Language Extractor
*
* @since 3.2.0
*/
final class Extractor
{
/**
* The lang keys for extensions
*
* @var array
* @since 3.2.0
**/
public array $langKeys = [];
/**
* The Language JS matching check
*
* @var array
* @since 3.2.0
**/
public array $langMismatch = [];
/**
* The Language SC matching check
*
* @var array
* @since 3.2.0
**/
public array $langMatch = [];
/**
* 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 Placeholder Class.
*
* @var Placeholder
* @since 3.2.0
*/
protected Placeholder $placeholder;
/**
* Constructor.
*
* @param Config $config The Config Class.
* @param Language $language The Language Class.
* @param Placeholder $placeholder The Placeholder Class.
*
* @since 3.2.0
*/
public function __construct(Config $config, Language $language,
Placeholder $placeholder)
{
$this->config = $config;
$this->language = $language;
$this->placeholder = $placeholder;
}
/**
* Extract Language Strings
*
* @param string $content The content
*
* @return string The content with the updated Language place holder
* @since 3.2.0
*/
public function engine(string $content): string
{
// get targets to search for
$lang_string_targets = array_filter(
$this->config->lang_string_targets, fn($get): bool =>
strpos($content, (string) $get) !== false
);
// check if we should continue
if (ArrayHelper::check($lang_string_targets))
{
// insure string is not broken
$content = $this->placeholder->update_($content);
// reset some buckets
$lang_holders = [];
$lang_check = [];
$lang_only = [];
$js_text = [];
$sc_text = [];
// first get the Joomla .JText._()
if (in_array('Joomla' . '.JText._(',
$lang_string_targets) || in_array('Joomla' .
'.Text._(', $lang_string_targets))
{
$js_text[] = GetHelper::allBetween(
$content, "Joomla" . ".JText._('",
"'"
);
$js_text[] = GetHelper::allBetween(
$content, 'Joomla' . '.JText._("',
'"'
);
$js_text[] = GetHelper::allBetween(
$content, "Joomla" . ".Text._('",
"'"
);
$js_text[] = GetHelper::allBetween(
$content, 'Joomla' . '.Text._("',
'"'
);
// combine into one array
$js_text = ArrayHelper::merge($js_text);
// we need to add a check to insure these JavaScript lang matchup
if (ArrayHelper::check(
$js_text
)) //<-- not really needed hmmm
{
// load the JS text to mismatch array
$lang_check[] = $js_text;
$this->langMismatch = ArrayHelper::merge(
array($js_text, $this->langMismatch)
);
}
}
// now get the JText: :script()
if (in_array('JText:' . ':script(',
$lang_string_targets)
|| in_array('Text:' . ':script(',
$lang_string_targets)
|| in_array('Joomla__' .
'_ba6326ef_cb79_4348_80f4_ab086082e3c5___Power:' .
':script(', $lang_string_targets))
{
$sc_text[] = GetHelper::allBetween(
$content, "JText:" . ":script('",
"'"
);
$sc_text[] = GetHelper::allBetween(
$content, 'JText:' . ':script("',
'"'
);
$sc_text[] = GetHelper::allBetween(
$content, "Text:" . ":script('",
"'"
);
$sc_text[] = GetHelper::allBetween(
$content, 'Text:' . ':script("',
'"'
);
$sc_text[] = GetHelper::allBetween(
$content, "Joomla__"
."_ba6326ef_cb79_4348_80f4_ab086082e3c5___Power:" .
":script('", "'"
);
$sc_text[] = GetHelper::allBetween(
$content, 'Joomla__' .
'_ba6326ef_cb79_4348_80f4_ab086082e3c5___Power:' .
':script("', '"'
);
// combine into one array
$sc_text = ArrayHelper::merge($sc_text);
// we need to add a check to insure these JavaScript lang matchup
if (ArrayHelper::check($sc_text))
{
// load the Script text to match array
$lang_check[] = $sc_text;
$this->langMatch = ArrayHelper::merge(
array($sc_text, $this->langMatch)
);
}
}
// now do the little trick for JustTEXT: :_('Just uppercase
text');
if (in_array('JustTEXT:' . ':_(',
$lang_string_targets))
{
$lang_only[] = GetHelper::allBetween(
$content, "JustTEXT:" . ":_('",
"')"
);
$lang_only[] = GetHelper::allBetween(
$content, 'JustTEXT:' . ':_("',
'")'
);
// merge lang only
$lang_only = ArrayHelper::merge($lang_only);
}
// set language data
foreach ($lang_string_targets as $lang_string_target)
{
// need some special treatment here
if ($lang_string_target === 'Joomla' . '.JText._('
|| $lang_string_target === 'JText:' . ':script('
|| $lang_string_target === 'Text:' . ':script('
|| $lang_string_target === 'Joomla__' .
'_ba6326ef_cb79_4348_80f4_ab086082e3c5___Power:' .
':script('
|| $lang_string_target === 'JustTEXT:' . ':_(')
{
continue;
}
$lang_check[] = GetHelper::allBetween(
$content, $lang_string_target . "'",
"'"
);
$lang_check[] = GetHelper::allBetween(
$content, $lang_string_target . '"',
'"'
);
}
// the normal loading of the language strings
$lang_check = ArrayHelper::merge($lang_check);
if (ArrayHelper::check(
$lang_check
)) //<-- not really needed hmmm
{
foreach ($lang_check as $string)
{
if ($key_lang = $this->language->key($string))
{
// load the language targets
foreach ($lang_string_targets as $lang_string_target)
{
// need some special treatment here
if ($lang_string_target === 'JustTEXT:' .
':_(')
{
continue;
}
$lang_holders[$lang_string_target . "'" . $string
. "'"]
= $lang_string_target . "'" . $key_lang .
"'";
$lang_holders[$lang_string_target . '"' . $string
. '"']
= $lang_string_target . '"' . $key_lang .
'"';
}
}
}
}
// the uppercase loading only (for arrays and other tricks)
if (ArrayHelper::check($lang_only))
{
foreach ($lang_only as $string)
{
if ($key_lang = $this->language->key($string))
{
// load the language targets
$lang_holders["JustTEXT:" . ":_('" . $string
. "')"]
= "'" . $key_lang . "'";
$lang_holders['JustTEXT:' . ':_("' . $string
. '")']
= '"' . $key_lang . '"';
}
}
}
// only continue if we have value to replace
if (ArrayHelper::check($lang_holders))
{
$content = $this->placeholder->update($content, $lang_holders);
}
}
return $content;
}
}
src/Componentbuilder/Compiler/Language/Fieldset.php000064400000017170151162054160016420
0ustar00<?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\Language;
use VDM\Joomla\Componentbuilder\Compiler\Language;
use VDM\Joomla\Componentbuilder\Compiler\Builder\MetaData;
use VDM\Joomla\Componentbuilder\Compiler\Builder\AccessSwitch;
use VDM\Joomla\Componentbuilder\Compiler\Builder\AccessSwitchList;
/**
* Compiler Language Fieldset
*
* @since 3.2.0
*/
final class Fieldset
{
/**
* The Language Class.
*
* @var Language
* @since 3.2.0
*/
protected Language $language;
/**
* The MetaData Class.
*
* @var MetaData
* @since 3.2.0
*/
protected MetaData $metadata;
/**
* The AccessSwitch Class.
*
* @var AccessSwitch
* @since 3.2.0
*/
protected AccessSwitch $accessswitch;
/**
* The AccessSwitchList Class.
*
* @var AccessSwitchList
* @since 3.2.0
*/
protected AccessSwitchList $accessswitchlist;
/**
* Constructor.
*
* @param Language $language The Language Class.
* @param MetaData $metadata The MetaData Class.
* @param AccessSwitch $accessswitch The AccessSwitch Class.
* @param AccessSwitchList $accessswitchlist The AccessSwitchList
Class.
*
* @since 3.2.0
*/
public function __construct(Language $language, MetaData $metadata,
AccessSwitch $accessswitch,
AccessSwitchList $accessswitchlist)
{
$this->language = $language;
$this->metadata = $metadata;
$this->accessswitch = $accessswitch;
$this->accessswitchlist = $accessswitchlist;
}
/**
* Set the fieldset language
*
* @param bool $access The access switch
* @param bool $metadata The metadata switch
* @param string $langTarget The language target
* @param string $langView The single language view name
* @param string $langViews The list language view name
* @param string $nameSingle The single view name
* @param string $nameList The list view name
* @param string $nameSingleCode The single view code name
* @param string $nameListCode The list view code name
*
* @return void
* @since 3.2.0
*/
public function set(bool $access, bool $metadata, string $langTarget,
string $langView, string $langViews,
string $nameSingle, string $nameList, string $nameSingleCode, string
$nameListCode): void
{
// add metadata to the view
if ($metadata)
{
$this->metadata->set($nameSingleCode, $nameListCode);
}
// add access to the view
if ($access)
{
$this->accessswitch->set($nameSingleCode, true);
$this->accessswitchlist->set($nameListCode, true);
}
// set default lang
$this->language->set(
$langTarget, $langView, $nameSingle
);
$this->language->set(
$langTarget, $langViews, $nameList
);
// set global item strings
$this->language->set(
$langTarget, $langViews . '_N_ITEMS_ARCHIVED',
"%s " . $nameList . " archived."
);
$this->language->set(
$langTarget, $langViews . '_N_ITEMS_ARCHIVED_1',
"%s " . $nameSingle . " archived."
);
$this->language->set(
$langTarget, $langViews . '_N_ITEMS_CHECKED_IN_0',
"No " . $nameSingle
. " successfully checked in."
);
$this->language->set(
$langTarget, $langViews . '_N_ITEMS_CHECKED_IN_1',
"%d " . $nameSingle
. " successfully checked in."
);
$this->language->set(
$langTarget, $langViews . '_N_ITEMS_CHECKED_IN_MORE',
"%d " . $nameList
. " successfully checked in."
);
$this->language->set(
$langTarget, $langViews . '_N_ITEMS_DELETED',
"%s " . $nameList . " deleted."
);
$this->language->set(
$langTarget, $langViews . '_N_ITEMS_DELETED_1',
"%s " . $nameSingle . " deleted."
);
$this->language->set(
$langTarget, $langViews . '_N_ITEMS_FEATURED',
"%s " . $nameList . " featured."
);
$this->language->set(
$langTarget, $langViews . '_N_ITEMS_FEATURED_1',
"%s " . $nameSingle . " featured."
);
$this->language->set(
$langTarget, $langViews . '_N_ITEMS_PUBLISHED',
"%s " . $nameList . " published."
);
$this->language->set(
$langTarget, $langViews . '_N_ITEMS_PUBLISHED_1',
"%s " . $nameSingle . " published."
);
$this->language->set(
$langTarget, $langViews . '_N_ITEMS_TRASHED',
"%s " . $nameList . " trashed."
);
$this->language->set(
$langTarget, $langViews . '_N_ITEMS_TRASHED_1',
"%s " . $nameSingle . " trashed."
);
$this->language->set(
$langTarget, $langViews . '_N_ITEMS_UNFEATURED',
"%s " . $nameList . " unfeatured."
);
$this->language->set(
$langTarget, $langViews . '_N_ITEMS_UNFEATURED_1',
"%s " . $nameSingle . " unfeatured."
);
$this->language->set(
$langTarget, $langViews . '_N_ITEMS_UNPUBLISHED',
"%s " . $nameList . " unpublished."
);
$this->language->set(
$langTarget, $langViews . '_N_ITEMS_UNPUBLISHED_1',
"%s " . $nameSingle . " unpublished."
);
$this->language->set(
$langTarget, $langViews . '_N_ITEMS_FAILED_PUBLISHING',
"%s " . $nameList . " failed publishing."
);
$this->language->set(
$langTarget, $langViews . '_N_ITEMS_FAILED_PUBLISHING_1',
"%s " . $nameSingle . " failed publishing."
);
$this->language->set(
$langTarget, $langViews . '_BATCH_OPTIONS',
"Batch process the selected " . $nameList
);
$this->language->set(
$langTarget, $langViews . '_BATCH_TIP',
"All changes will be applied to all selected "
. $nameList
);
// set some basic defaults
$this->language->set(
$langTarget, $langView . '_ERROR_UNIQUE_ALIAS',
"Another " . $nameSingle
. " has the same alias."
);
$this->language->set(
$langTarget, $langView . '_ERROR_UNIQUE_ALIAS_TRASHED',
"A trashed " . $nameSingle
. " has the same alias ."
);
$this->language->set(
$langTarget, $langView . '_CREATED_DATE_LABEL', "Created
Date"
);
$this->language->set(
$langTarget, $langView . '_CREATED_DATE_DESC',
"The date this " . $nameSingle
. " was created."
);
$this->language->set(
$langTarget, $langView . '_MODIFIED_DATE_LABEL',
"Modified Date"
);
$this->language->set(
$langTarget, $langView . '_MODIFIED_DATE_DESC',
"The date this " . $nameSingle
. " was modified."
);
$this->language->set(
$langTarget, $langView . '_CREATED_BY_LABEL', "Created
By"
);
$this->language->set(
$langTarget, $langView . '_CREATED_BY_DESC',
"The user that created this " . $nameSingle
. "."
);
$this->language->set(
$langTarget, $langView . '_MODIFIED_BY_LABEL', "Modified
By"
);
$this->language->set(
$langTarget, $langView . '_MODIFIED_BY_DESC',
"The last user that modified this "
. $nameSingle . "."
);
$this->language->set(
$langTarget, $langView . '_ORDERING_LABEL',
"Ordering"
);
$this->language->set(
$langTarget, $langView . '_VERSION_LABEL',
"Version"
);
$this->language->set(
$langTarget, $langView . '_VERSION_DESC',
"A count of the number of times this "
. $nameSingle . " has been revised."
);
$this->language->set(
$langTarget, $langView . '_SAVE_WARNING',
"Alias already existed so a number was added at the end. You can
re-edit the "
. $nameSingle . " to customise the alias."
);
}
}
src/Componentbuilder/Compiler/Language/Insert.php000064400000007172151162054160016126
0ustar00<?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\Language;
use Joomla\CMS\Factory;
/**
* Compiler Insert New Language Strings
*
* @since 5.0.2
*/
final class Insert
{
/**
* The items to insert
*
* @var array
* @since 5.0.2
**/
protected array $items = [];
/**
* Database object to query local DB
*
* @since 5.0.2
**/
protected $db;
/**
* Constructor.
*
* @since 5.0.2
*/
public function __construct()
{
$this->db = Factory::getDbo();
}
/**
* Sets a value in a multi-dimensional array within the `items` property.
*
* This method ensures that the array structure is properly initialized
before
* inserting the value at the specified target and counter position.
*
* @param string $target The key in the first dimension of the array.
* @param int $counter The key in the second dimension of the array.
* @param string $value The value to be inserted.
*
* @return void
* @since 5.0.2
*/
public function set(string $target, int $counter, string $value): void
{
// Ensure the target key exists in the items array
if (!isset($this->items[$target]))
{
$this->items[$target] = [];
}
// Ensure the counter key exists within the target array
if (!isset($this->items[$target][$counter]))
{
$this->items[$target][$counter] = [];
}
// Append the value to the array at the specified target and counter
position
$this->items[$target][$counter][] = $this->db->quote($value);
}
/**
* Store the language placeholders and execute the database insert
operation.
*
* This method checks if the target key exists in the `items` array and if
the count
* of its elements meets or exceeds the specified threshold (`$when`). If
the conditions
* are met, it constructs and executes a database insert query to store
the language
* placeholders. The array of items for the target is then cleared.
*
* @param string $target The target extension type.
* @param int $when The threshold count to determine when to update.
Default is 1.
*
* @return void
* @since 5.0.2
*/
public function execute(string $target, int $when = 1): void
{
if (isset($this->items[$target]) && count((array)
$this->items[$target]) >= $when)
{
// Create a new query object.
$query = $this->db->getQuery(true);
$continue = false;
// Insert columns.
$columns = array($target, 'source', 'published',
'created', 'created_by', 'version',
'access');
// Prepare the insert query.
$query->insert($this->db->quoteName('#__componentbuilder_language_translation'));
$query->columns($this->db->quoteName($columns));
foreach ($this->items[$target] as $values)
{
if (count((array) $values) == 7)
{
$query->values(implode(',', $values));
$continue = true;
}
else
{
// TODO: Handle line mismatch, this should not happen.
}
}
// Clear the values array.
$this->items[$target] = [];
if (!$continue)
{
// Ensure we don't continue if no values were loaded.
return;
}
// Set the query using our newly populated query object and execute it.
$this->db->setQuery($query);
$this->db->execute();
}
}
}
src/Componentbuilder/Compiler/Language/Multilingual.php000064400000003405151162054160017323
0ustar00<?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\Language;
use Joomla\CMS\Factory;
use VDM\Joomla\Utilities\ArrayHelper;
/**
* Compiler Language Multilingual
*
* @since 5.0.2
*/
final class Multilingual
{
/**
* Database object to query local DB
*
* @since 5.0.2
**/
protected $db;
/**
* Constructor.
*
* @since 5.0.2
*/
public function __construct()
{
$this->db = Factory::getDbo();
}
/**
* Get the other languages
*
* @param array $values The lang strings to get
*
* @return array
* @since 5.0.2
*/
public function get(array $values): ?array
{
// Create a new query object.
$query = $this->db->getQuery(true);
$query->from(
$this->db->quoteName(
'#__componentbuilder_language_translation', 'a'
)
);
if (ArrayHelper::check($values))
{
$query->select(
$this->db->quoteName(
array('a.id', 'a.translation',
'a.source', 'a.components',
'a.modules', 'a.plugins',
'a.published')
)
);
$query->where(
$this->db->quoteName('a.source') . ' IN (' .
implode(
',', array_map(
fn($a) => $this->db->quote($a), $values
)
) . ')'
);
$this->db->setQuery($query);
$this->db->execute();
if ($this->db->getNumRows())
{
return $this->db->loadAssocList('source');
}
}
return null;
}
}
src/Componentbuilder/Compiler/Language/Purge.php000064400000012512151162054160015736
0ustar00<?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\Language;
use Joomla\CMS\Factory;
use VDM\Joomla\Componentbuilder\Compiler\Language\Update;
use VDM\Joomla\Utilities\JsonHelper;
use VDM\Joomla\Utilities\ArrayHelper;
/**
* Compiler Remove Existing Language Strings
*
* @since 5.0.2
*/
final class Purge
{
/**
* The Update Class.
*
* @var Update
* @since 5.0.2
*/
protected Update $update;
/**
* Database object to query local DB
*
* @since 5.0.2
**/
protected $db;
/**
* Constructor.
*
* @param Update $update The Update Class.
*
* @since 5.0.2
*/
public function __construct(Update $update)
{
$this->update = $update;
$this->db = Factory::getDbo();
}
/**
* Purge the unused language strings.
*
* This method removes or updates language strings that are no longer
linked
* to the specified component. It checks if the strings are linked to
other
* extensions and either updates, archives, or deletes them based on the
* conditions.
*
* @param array $values The active strings.
* @param int $targetId The target component ID.
* @param string $target The target extension type (default is
'components').
*
* @return void
* @since 5.0.2
*/
public function execute(array $values, int $targetId, string $target =
'components'): void
{
$target_types = ['components' => 'components',
'modules' => 'modules', 'plugins' =>
'plugins'];
if (isset($target_types[$target]))
{
unset($target_types[$target]);
// Create a new query object.
$query = $this->db->getQuery(true);
$query->from($this->db->quoteName('#__componentbuilder_language_translation',
'a'))
->select($this->db->quoteName(['a.id',
'a.translation', 'a.components', 'a.modules',
'a.plugins']))
->where($this->db->quoteName('a.source') . '
NOT IN (' . implode(',', array_map(fn($a) =>
$this->db->quote($a), $values)) . ')')
->where($this->db->quoteName('a.published') .
' = 1');
$this->db->setQuery($query);
$this->db->execute();
if ($this->db->getNumRows())
{
$counterUpdate = 0;
$otherStrings = $this->db->loadAssocList();
$today = Factory::getDate()->toSql();
foreach ($otherStrings as $item)
{
if (JsonHelper::check($item[$target]))
{
$targets = (array) json_decode((string) $item[$target], true);
if (($key = array_search($targetId, $targets)) !== false)
{
unset($targets[$key]);
if (ArrayHelper::check($targets))
{
$this->update->set($item['id'], $target, $targets,
1, $today, $counterUpdate);
$counterUpdate++;
$this->update->execute(50);
}
else
{
$this->handleUnlinkedString($item, $target_types, $targets,
$today, $counterUpdate);
}
}
}
}
$this->update->execute();
}
}
}
/**
* Handle strings that are unlinked from the current component.
*
* This method checks if a string is linked to other extensions and either
updates,
* archives, or deletes it based on the conditions.
*
* @param array $item The language string item.
* @param array $targetTypes The target extension types.
* @param array $targets The targets to update.
* @param string $today The current date.
* @param int $counter The update counter.
*
* @return void
* @since 5.0.2
*/
protected function handleUnlinkedString(array $item, array $targetTypes,
array $targets, string $today, int &$counter): void
{
// the action (1 = remove, 2 = archive, 0 = do nothing)
$action_with_string = 1;
foreach ($targetTypes as $other_target)
{
if ($action_with_string &&
JsonHelper::check($item[$other_target]))
{
$other_targets = (array) json_decode((string) $item[$other_target],
true);
if (ArrayHelper::check($other_targets))
{
$action_with_string = 0;
}
}
}
if ($action_with_string &&
JsonHelper::check($item['translation']))
{
$translation = json_decode((string) $item['translation'],
true);
if (ArrayHelper::check($translation))
{
$this->update->set($item['id'], $targets, $targets, 2,
$today, $counter);
$counter++;
$this->update->execute(50);
$action_with_string = 2;
}
}
if ($action_with_string == 1)
{
$this->removeExitingLangString($item['id']);
}
}
/**
* Remove existing language translation strings.
*
* This method deletes a language string from the database based on its
ID.
*
* @param int $id The string ID to remove.
*
* @return void
* @since 5.0.2
*/
protected function removeExitingLangString(int $id): void
{
$query = $this->db->getQuery(true);
$query->delete($this->db->quoteName('#__componentbuilder_language_translation'))
->where($this->db->quoteName('id') . ' = '
. (int) $id);
$this->db->setQuery($query);
$this->db->execute();
}
}
src/Componentbuilder/Compiler/Language/Set.php000064400000020076151162054160015413
0ustar00<?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\Language;
use Joomla\CMS\Factory;
use VDM\Joomla\Componentbuilder\Compiler\Config;
use VDM\Joomla\Componentbuilder\Compiler\Language;
use VDM\Joomla\Componentbuilder\Compiler\Builder\Multilingual;
use VDM\Joomla\Componentbuilder\Compiler\Builder\Languages;
use VDM\Joomla\Componentbuilder\Compiler\Language\Insert;
use VDM\Joomla\Componentbuilder\Compiler\Language\Update;
use VDM\Joomla\Utilities\StringHelper;
use VDM\Joomla\Utilities\JsonHelper;
use VDM\Joomla\Utilities\ArrayHelper;
use VDM\Joomla\Utilities\MathHelper;
/**
* Compiler Set Language Strings
*
* @since 5.0.2
*/
final class Set
{
/**
* The Config Class.
*
* @var Config
* @since 5.0.2
*/
protected Config $config;
/**
* The Language Class.
*
* @var Language
* @since 5.0.2
*/
protected Language $language;
/**
* The Multilingual Class.
*
* @var Multilingual
* @since 5.0.2
*/
protected Multilingual $multilingual;
/**
* The Languages Class.
*
* @var Languages
* @since 5.0.2
*/
protected Languages $languages;
/**
* The Insert Class.
*
* @var Insert
* @since 5.0.2
*/
protected Insert $insert;
/**
* The Update Class.
*
* @var Update
* @since 5.0.2
*/
protected Update $update;
/**
* Constructor.
*
* @param Config $config The Config Class.
* @param Language $language The Language Class.
* @param Messages $messages The Language Messages Class.
* @param Multilingual $multilingual The Multilingual Class.
* @param Languages $languages The Languages Class.
* @param Insert $insert The Insert Class.
* @param Update $update The Update Class.
*
* @since 5.0.2
*/
public function __construct(Config $config, Language $language,
Multilingual $multilingual, Languages $languages,
Insert $insert, Update $update)
{
$this->config = $config;
$this->language = $language;
$this->multilingual = $multilingual;
$this->languages = $languages;
$this->insert = $insert;
$this->update = $update;
}
/**
* Set the current language values to the database.
*
* This method inserts or updates language strings in the database based
on the current state.
*
* @param array $strings The language strings to process.
* @param int $target_id The target component ID.
* @param string $target The target extension type (default is
'components').
*
* @return void
* @since 5.0.2
*/
public function execute(array $strings, int $target_id, string $target =
'components'): void
{
$counterInsert = 0;
$counterUpdate = 0;
$today = Factory::getDate()->toSql();
$langTag = $this->config->get('lang_tag',
'en-GB');
$multiLangString = $this->multilingual->get($target, []);
foreach ($this->languages->get("{$target}.{$langTag}") as
$area => $placeholders)
{
foreach ($placeholders as $placeholder => $string)
{
if (StringHelper::check($string))
{
$this->processString(
$string, $strings, $area, $placeholder, $multiLangString, $target,
$target_id, $today, $counterInsert, $counterUpdate
);
}
}
}
$this->multilingual->set($target, $multiLangString);
$this->update->execute();
$this->insert->execute($target);
}
/**
* Process an individual language string for database update or insert.
*
* @param string $string The language string to process.
* @param array $strings The language strings array.
* @param string $area The targeted area.
* @param string $placeholder The placeholder.
* @param array &$multiLangString The multilingual string array.
* @param string $target The target extension type.
* @param int $target_id The target component ID.
* @param string $today The current date.
* @param int &$counterInsert The insert counter.
* @param int &$counterUpdate The update counter.
*
* @return void
* @since 5.0.2
*/
protected function processString(string $string, array &$strings,
string $area,
string $placeholder, array &$multiLangString, string $target,
int $target_id, string $today, int &$counterInsert, int
&$counterUpdate): void
{
$remove = false;
if (isset($multiLangString[$string]))
{
if (isset($multiLangString[$string]['translation']) &&
JsonHelper::check($multiLangString[$string]['translation']))
{
$multiLangString[$string]['translation'] =
json_decode((string) $multiLangString[$string]['translation'],
true);
}
if (isset($multiLangString[$string]['translation']) &&
ArrayHelper::check($multiLangString[$string]['translation']))
{
foreach ($multiLangString[$string]['translation'] as
$translations)
{
if (isset($translations['language']) &&
isset($translations['translation']))
{
$multiLangTag = $translations['language'];
$this->languages->set("{$target}.{$multiLangTag}.{$area}.{$placeholder}",
$this->language->fix($translations['translation']));
}
}
}
else
{
$remove = true;
}
}
if (StringHelper::check($string) && ($key = array_search($string,
$strings)) !== false)
{
$this->updateOrInsertString($string, $multiLangString, $target,
$target_id, $today, $counterInsert, $counterUpdate);
if ($remove)
{
unset($multiLangString[$string]);
}
unset($strings[$key]);
}
}
/**
* Update or insert a language string in the database.
*
* @param string $string The language string to update or
insert.
* @param array &$multiLangString The multilingual string array.
* @param string $target The target extension type.
* @param int $target_id The target component ID.
* @param string $today The current date.
* @param int &$counterInsert The insert counter.
* @param int &$counterUpdate The update counter.
*
* @return void
* @since 5.0.2
*/
protected function updateOrInsertString(string $string, array
&$multiLangString, string $target, int $target_id, string $today, int
&$counterInsert, int &$counterUpdate): void
{
if (isset($multiLangString[$string]))
{
$id = $multiLangString[$string]['id'];
$targets = $this->getTargets($multiLangString[$string], $target,
$target_id);
$this->update->set($id, $target, $targets, 1, $today,
$counterUpdate);
$counterUpdate++;
$this->update->execute(50);
}
else
{
$this->insert->set($target, $counterInsert,
json_encode([$target_id]));
$this->insert->set($target, $counterInsert, $string);
$this->insert->set($target, $counterInsert, 1);
$this->insert->set($target, $counterInsert, $today);
$this->insert->set($target, $counterInsert, 1);
$this->insert->set($target, $counterInsert, 1);
$this->insert->set($target, $counterInsert, 1);
$counterInsert++;
$this->insert->execute($target, 100);
}
}
/**
* Get targets for a given string.
*
* @param array $multiLangString The multilingual string array.
* @param string $target The target extension type.
* @param int $target_id The target component ID.
*
* @return array The updated targets array.
* @since 5.0.2
*/
protected function getTargets(array $multiLangString, string $target, int
$target_id): array
{
if (JsonHelper::check($multiLangString[$target]))
{
$targets = (array) json_decode((string) $multiLangString[$target],
true);
if (!in_array($target_id, $targets))
{
$targets[] = $target_id;
}
}
else
{
$targets = [$target_id];
}
return $targets;
}
}
src/Componentbuilder/Compiler/Language/Translation.php000064400000005216151162054160017155
0ustar00<?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\Language;
use VDM\Joomla\Componentbuilder\Compiler\Config;
use VDM\Joomla\Componentbuilder\Compiler\Builder\LanguageMessages as
Messages;
/**
* Compiler Language Translation Checker
*
* @since 5.0.2
*/
final class Translation
{
/**
* The Config Class.
*
* @var Config
* @since 5.0.2
*/
protected Config $config;
/**
* The Language Messages Class.
*
* @var Messages
* @since 5.0.2
*/
protected Messages $messages;
/**
* Constructor.
*
* @param Config $config The Config Class.
* @param Messages $messages The Language Messages Class.
*
* @since 5.0.2
*/
public function __construct(Config $config, Messages $messages)
{
$this->config = $config;
$this->messages = $messages;
}
/**
* Check if a translation should be added.
*
* This method determines if a translation should be included based on the
percentage
* of translated strings and logs the decision.
*
* @param string $tag The language tag.
* @param array $languageStrings The active language strings.
* @param int $total The total number of strings.
* @param string $file_name The file name.
*
* @return bool Returns true if the translation should be added; false
otherwise.
* @since 5.0.2
*/
public function check(string &$tag, array &$languageStrings, int
&$total, string &$file_name): bool
{
$langTag = $this->config->get('lang_tag',
'en-GB');
if ($langTag !== $tag)
{
$langStringNr = count($languageStrings);
$percentage = ($langStringNr / $total) * 100;
$stringName = ($langStringNr == 1) ? "(string $tag
translated)" : "(strings $tag translated)";
if (!$this->config->get('debug_line_nr', false))
{
if ($percentage < $this->config->percentage_language_add)
{
$this->messages->set(
"exclude.$file_name",
"<b>$total</b>(total " . $langTag . "
strings) only <b>$langStringNr</b> $stringName =
$percentage"
);
return false;
}
}
$this->messages->set(
"include.$file_name",
"<b>$total</b>(total " . $langTag . "
strings) and <b>$langStringNr</b> $stringName =
$percentage"
);
}
return true;
}
}
src/Componentbuilder/Compiler/Language/Update.php000064400000007327151162054160016106
0ustar00<?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\Language;
use Joomla\CMS\Factory;
/**
* Compiler Update Existing Language Strings
*
* @since 5.0.2
*/
final class Update
{
/**
* The items to update
*
* @var array
* @since 5.0.2
**/
protected array $items = [];
/**
* Database object to query local DB
*
* @since 5.0.2
**/
protected $db;
/**
* User object
*
* @since 5.0.2
**/
protected $user;
/**
* Constructor.
*
* @since 5.0.2
*/
public function __construct()
{
$this->db = Factory::getDbo();
$this->user = Factory::getUser();
}
/**
* Add a language string to the existing language strings array for
updating.
*
* This method prepares and stores the update information for a language
string
* in the `items` array, which is later used by the `execute` method to
update
* the database.
*
* @param int $id The ID of the language string.
* @param string $target The target field to be updated.
* @param array $targets The new values for the target field.
* @param int $published The published state.
* @param string $today The current date.
* @param int $counter The counter for the items array.
*
* @return void
* @since 5.0.2
*/
public function set(int $id, string $target, array $targets, int
$published, string $today, int $counter): void
{
// Start the bucket for this language item.
$this->items[$counter] = [];
$this->items[$counter]['id'] = (int) $id;
// Prepare the conditions for the update query.
$this->items[$counter]['conditions'] = [];
$this->items[$counter]['conditions'][] =
$this->db->quoteName('id') . ' = ' .
$this->db->quote($id);
// Prepare the fields for the update query.
$this->items[$counter]['fields'] = [];
$this->items[$counter]['fields'][] =
$this->db->quoteName($target) . ' = ' .
$this->db->quote(json_encode($targets));
$this->items[$counter]['fields'][] =
$this->db->quoteName('published') . ' = ' .
$this->db->quote($published);
$this->items[$counter]['fields'][] =
$this->db->quoteName('modified') . ' = ' .
$this->db->quote($today);
$this->items[$counter]['fields'][] =
$this->db->quoteName('modified_by') . ' = ' .
$this->db->quote((int) $this->user->id);
}
/**
* Update the language placeholders in the database.
*
* This method updates the language placeholders in the database if the
number of items
* meets or exceeds the specified threshold (`$when`). It constructs and
executes an
* update query for each set of values in the `items` array.
*
* @param int $when The threshold count to determine when to update.
Default is 1.
*
* @return void
* @since 5.0.2
*/
public function execute(int $when = 1): void
{
if (count((array) $this->items) >= $when)
{
foreach ($this->items as $values)
{
// Create a new query object.
$query = $this->db->getQuery(true);
// Prepare the update query.
$query->update($this->db->quoteName('#__componentbuilder_language_translation'))
->set($values['fields'])
->where($values['conditions']);
// Set the query using our newly populated query object and execute
it.
$this->db->setQuery($query);
$this->db->execute();
}
// Clear the items array.
$this->items = [];
}
}
}
src/Componentbuilder/Compiler/Language/index.html000064400000000054151162054160016136
0ustar00<html><body
bgcolor="#FFFFFF"></body></html>src/Componentbuilder/Compiler/Library/Data.php000064400000022030151162054160015402
0ustar00<?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\Library;
use Joomla\CMS\Factory;
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\Customcode;
use VDM\Joomla\Componentbuilder\Compiler\Customcode\Gui;
use VDM\Joomla\Componentbuilder\Compiler\Field\Data as FieldData;
use VDM\Joomla\Componentbuilder\Compiler\Model\Filesfolders;
use VDM\Joomla\Utilities\ArrayHelper;
use VDM\Joomla\Utilities\JsonHelper;
use VDM\Joomla\Utilities\StringHelper;
/**
* Library Data Class
*
* @since 3.2.0
*/
class Data
{
/**
* Compiler Config
*
* @var Config
* @since 3.2.0
*/
protected Config $config;
/**
* The compiler registry
*
* @var Registry
* @since 3.2.0
*/
protected Registry $registry;
/**
* Compiler Customcode
*
* @var Customcode
* @since 3.2.0
*/
protected Customcode $customcode;
/**
* Compiler Customcode in Gui
*
* @var Gui
* @since 3.2.0
**/
protected Gui $gui;
/**
* Compiler Field Data
*
* @var FieldData
* @since 3.2.0
*/
protected FieldData $field;
/**
* Compiler Files Folders
*
* @var Filesfolders
* @since 3.2.0
*/
protected Filesfolders $filesFolders;
/**
* Database object to query local DB
*
* @since 3.2.0
**/
protected $db;
/**
* Constructor
*
* @param Config|null $config The compiler config
object.
* @param Registry|null $registry The compiler
registry object.
* @param Customcode|null $customcode The compiler
customcode object.
* @param Gui|null $gui The compiler
customcode gui.
* @param FieldData|null $field The compiler field
data object.
* @param Filesfolders|null $filesFolders The compiler files
folders object.
*
* @since 3.2.0
*/
public function __construct(?Config $config = null, ?Registry $registry =
null,
?Customcode $customcode = null, ?Gui $gui = null,
?FieldData $field = null, ?Filesfolders $filesFolders = null)
{
$this->config = $config ?: Compiler::_('Config');
$this->registry = $registry ?: Compiler::_('Registry');
$this->customcode = $customcode ?:
Compiler::_('Customcode');
$this->gui = $gui ?: Compiler::_('Customcode.Gui');
$this->field = $field ?: Compiler::_('Field.Data');
$this->filesFolders = $filesFolders ?:
Compiler::_('Model.Filesfolders');
$this->db = Factory::getDbo();
}
/**
* Get Media Library Data and store globally in registry
*
* @param int $id the library id
*
* @return object|bool object on success
* @since 3.2.0
*/
public function get(int $id)
{
// check if the lib has already been set
if (!$this->registry->exists("builder.libraries.$id"))
{
// get some switches
$uikit = $this->config->get('uikit', 0);
$footable_version =
$this->config->get('footable_version', 0);
// make sure we should continue and that the lib is not already being
loaded
switch ($id)
{
case 1: // No Library
return false;
break;
case 3: // Uikit v3
if (2 == $uikit || 3 == $uikit)
{
// already being loaded
$this->registry->set("builder.libraries.$id",
false);
}
break;
case 4: // Uikit v2
if (2 == $uikit || 1 == $uikit)
{
// already being loaded
$this->registry->set("builder.libraries.$id",
false);
}
break;
case 5: // FooTable v2
if (2 == $footable_version)
{
// already being loaded
$this->registry->set("builder.libraries.$id",
false);
}
break;
case 6: // FooTable v3
if (3 == $footable_version)
{
// already being loaded
$this->registry->set("builder.libraries.$id",
false);
}
break;
}
}
// check if the lib has already been set
if (!$this->registry->exists("builder.libraries.$id"))
{
$query = $this->db->getQuery(true);
$query->select('a.*');
$query->select(
$this->db->quoteName(
array(
'a.id',
'a.name',
'a.how',
'a.type',
'a.addconditions',
'b.addconfig',
'c.addfiles',
'c.addfolders',
'c.addfilesfullpath',
'c.addfoldersfullpath',
'c.addurls',
'a.php_setdocument'
), array(
'id',
'name',
'how',
'type',
'addconditions',
'addconfig',
'addfiles',
'addfolders',
'addfilesfullpath',
'addfoldersfullpath',
'addurls',
'php_setdocument'
)
)
);
// from these tables
$query->from('#__componentbuilder_library AS a');
$query->join(
'LEFT',
$this->db->quoteName('#__componentbuilder_library_config',
'b')
. ' ON (' . $this->db->quoteName('a.id') .
' = '
. $this->db->quoteName('b.library') . ')'
);
$query->join(
'LEFT', $this->db->quoteName(
'#__componentbuilder_library_files_folders_urls',
'c'
) . ' ON (' . $this->db->quoteName('a.id') .
' = '
. $this->db->quoteName('c.library') . ')'
);
$query->where($this->db->quoteName('a.id') . ' =
' . (int) $id);
$query->where($this->db->quoteName('a.target') .
' = 1');
// Reset the query using our newly populated query object.
$this->db->setQuery($query);
// Load the results as a list of stdClass objects
$library = $this->db->loadObject();
// check if this lib uses build-in behaviour
if ($library->how == 4)
{
// fall back on build-in features
$buildin = [
3 => ['uikit' => 3],
4 => ['uikit' => 1],
5 => ['footable_version' => 2, 'footable'
=> true],
6 => ['footable_version' => 3, 'footable'
=> true]
];
if (isset($buildin[$library->id])
&& ArrayHelper::check(
$buildin[$library->id]
))
{
// set the lib switch
foreach ($buildin[$library->id] as $lib => $val)
{
// ---- we are targeting these ----
// $this->config->uikit
// $this->config->footable_version
// $this->config->footable
$this->config->set($lib, $val);
}
// since we are falling back on build-in feature
$library->how = 0;
}
else
{
// since we did not find build in behaviour we must load always.
$library->how = 1;
}
}
// check if this lib has dynamic behaviour
if ($library->how > 0)
{
// set files and folders
$this->filesFolders->set($library);
// add config fields only if needed
if ($library->how > 1)
{
// set the config data
$library->addconfig = (isset($library->addconfig)
&& JsonHelper::check(
$library->addconfig
)) ? json_decode((string) $library->addconfig, true) : null;
if (ArrayHelper::check($library->addconfig))
{
$library->config = array_map(
function ($array) {
$array['alias'] = 0;
$array['title'] = 0;
$array['settings'] = $this->field->get(
$array['field']
);
return $array;
}, array_values($library->addconfig)
);
}
}
// if this lib is controlled by custom script
if (3 == $library->how)
{
// set Needed PHP
if (isset($library->php_setdocument)
&& StringHelper::check(
$library->php_setdocument
))
{
$library->document = $this->gui->set(
$this->customcode->update(
base64_decode((string) $library->php_setdocument)
),
array(
'table' => 'library',
'field' => 'php_setdocument',
'id' => (int) $id,
'type' => 'php')
);
}
}
// if this lib is controlled by conditions
elseif (2 == $library->how)
{
// set the addconditions data
$library->addconditions = (isset($library->addconditions)
&& JsonHelper::check(
$library->addconditions
)) ? json_decode((string) $library->addconditions, true) : null;
if (ArrayHelper::check(
$library->addconditions
))
{
$library->conditions = array_values(
$library->addconditions
);
}
}
unset($library->php_setdocument);
unset($library->addconditions);
unset($library->addconfig);
// load to global lib
$this->registry->set("builder.libraries.$id",
$library);
}
else
{
$this->registry->set("builder.libraries.$id", false);
}
}
// if set return
return $this->registry->get("builder.libraries.$id",
false);
}
}
src/Componentbuilder/Compiler/Library/Structure.php000064400000017324151162054160016543
0ustar00<?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\Library;
use Joomla\CMS\Filesystem\Folder as JoomlaFolder;
use VDM\Joomla\Componentbuilder\Compiler\Config;
use VDM\Joomla\Componentbuilder\Compiler\Registry;
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\EventInterface as
Event;
use VDM\Joomla\Componentbuilder\Compiler\Component;
use VDM\Joomla\Componentbuilder\Compiler\Builder\ContentOne as Content;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Counter;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Paths;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Folder;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\File;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Indent;
use VDM\Joomla\Utilities\ObjectHelper;
use VDM\Joomla\Utilities\ArrayHelper;
use VDM\Joomla\Utilities\StringHelper;
use VDM\Joomla\Utilities\FileHelper;
/**
* Library Structure Builder Class
*
* @since 3.2.0
*/
class Structure
{
/**
* The Config Class.
*
* @var Config
* @since 3.2.0
*/
protected Config $config;
/**
* The Registry Class.
*
* @var Registry
* @since 3.2.0
*/
protected Registry $registry;
/**
* The EventInterface Class.
*
* @var Event
* @since 3.2.0
*/
protected Event $event;
/**
* The Component Class.
*
* @var Component
* @since 3.2.0
*/
protected Component $component;
/**
* The ContentOne Class.
*
* @var Content
* @since 3.2.0
*/
protected Content $content;
/**
* The Counter Class.
*
* @var Counter
* @since 3.2.0
*/
protected Counter $counter;
/**
* The Paths Class.
*
* @var Paths
* @since 3.2.0
*/
protected Paths $paths;
/**
* The Folder Class.
*
* @var Folder
* @since 3.2.0
*/
protected Folder $folder;
/**
* The File Class.
*
* @var File
* @since 3.2.0
*/
protected File $file;
/**
* Constructor.
*
* @param Config $config The Config Class.
* @param Registry $registry The Registry Class.
* @param Event $event The EventInterface 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 Folder $folder The Folder Class.
* @param File $file The File Class.
*
* @since 3.2.0
*/
public function __construct(Config $config, Registry $registry, Event
$event,
Component $component, Content $content, Counter $counter,
Paths $paths, Folder $folder, File $file)
{
$this->config = $config;
$this->registry = $registry;
$this->event = $event;
$this->component = $component;
$this->content = $content;
$this->counter = $counter;
$this->paths = $paths;
$this->folder = $folder;
$this->file = $file;
}
/**
* Build the Libraries files, folders, url's and config
*
* @return void
* @since 3.2.0
*/
public function build()
{
if (($libraries_ =
$this->registry->get('builder.libraries')) !== null)
{
// for plugin event TODO change event api signatures
$component_context = $this->config->component_context;
// Trigger Event: jcb_ce_onBeforeSetLibraries
$this->event->trigger(
'jcb_ce_onBeforeSetLibraries',
array(&$component_context, &$libraries_)
);
// creat the main component folder
if (!JoomlaFolder::exists($this->paths->component_path))
{
JoomlaFolder::create($this->paths->component_path);
// count the folder created
$this->counter->folder++;
$this->file->html('');
}
// create media path if not set
$this->folder->create($this->paths->component_path .
'/media');
foreach ($libraries_ as $id => &$library)
{
if (ObjectHelper::check($library))
{
// check if this lib has files
if (isset($library->files)
&& ArrayHelper::check($library->files))
{
// add to component files
foreach ($library->files as $file)
{
$this->component->appendArray('files', $file);
}
}
// check if this lib has folders
if (isset($library->folders)
&& ArrayHelper::check(
$library->folders
))
{
// add to component folders
foreach ($library->folders as $folder)
{
$this->component->appendArray('folders', $folder);
}
}
// check if this lib has urls
if (isset($library->urls)
&& ArrayHelper::check($library->urls))
{
// build media folder path
$libFolder = strtolower(
preg_replace(
'/\s+/', '-',
(string) StringHelper::safe(
$library->name, 'filename', ' ', false
)
)
);
$mediaPath = '/media/' . $libFolder;
// should we add the local folder
$addLocalFolder = false;
// add to component urls
foreach ($library->urls as $n => &$url)
{
if (isset($url['type']) && $url['type']
> 1
&& isset($url['url'])
&& StringHelper::check(
$url['url']
))
{
// create media/lib path if not set
$this->folder->create(
$this->paths->component_path . $mediaPath
);
// add local folder
$addLocalFolder = true;
// set file name
$fileName = basename((string) $url['url']);
// get the file contents
$data = FileHelper::getContent(
$url['url']
);
// build sub path
if (strpos($fileName, '.js') !== false)
{
$path = '/js';
}
elseif (strpos($fileName, '.css') !== false)
{
$path = '/css';
}
else
{
$path = '';
}
// create sub media path if not set
$this->folder->create(
$this->paths->component_path . $mediaPath . $path
);
// set the path to library file
$url['path'] = $mediaPath . $path . '/'
. $fileName; // we need this for later
// set full path
$path = $this->paths->component_path .
$url['path'];
// write data to path
$this->file->write($path, $data);
// count the file created
$this->counter->file++;
}
}
// only add if local
if ($addLocalFolder)
{
// add folder to xml of media folders
$this->content->add('EXSTRA_MEDIA_FOLDERS',
PHP_EOL . Indent::_(2) . "<folder>"
. $libFolder . "</folder>");
}
}
// if config fields are found load into component config (avoiding
duplicates)
if (isset($library->how) && $library->how > 1
&& isset($library->config)
&& ArrayHelper::check($library->config))
{
foreach ($library->config as $cofig)
{
$found = array_filter(
$this->component->get('config'),
fn($item) => $item['field'] ==
$cofig['field']
);
// set the config data if not found
if (!ArrayHelper::check($found))
{
$this->component->appendArray('config', $cofig);
}
}
}
// update the global value just in case for now
$this->registry->set("builder.libraries.$id",
$library);
}
}
}
}
}
src/Componentbuilder/Compiler/Library/index.html000064400000000054151162054160016017
0ustar00<html><body
bgcolor="#FFFFFF"></body></html>src/Componentbuilder/Compiler/Model/Adminviews.php000064400000011340151162054160016275
0ustar00<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder
<https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights
reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
namespace VDM\Joomla\Componentbuilder\Compiler\Model;
use VDM\Joomla\Componentbuilder\Compiler\Config;
use VDM\Joomla\Componentbuilder\Compiler\Adminview\Data as Admin;
use VDM\Joomla\Componentbuilder\Compiler\Builder\SiteEditView;
use VDM\Joomla\Componentbuilder\Compiler\Builder\AdminFilterType;
use VDM\Joomla\Utilities\JsonHelper;
use VDM\Joomla\Utilities\ArrayHelper;
use VDM\Joomla\Utilities\ObjectHelper;
/**
* Model Admin Views Class
*
* @since 3.2.0
*/
class Adminviews
{
/**
* The Config Class.
*
* @var Config
* @since 3.2.0
*/
protected Config $config;
/**
* The Data Class.
*
* @var Admin
* @since 3.2.0
*/
protected Admin $admin;
/**
* The SiteEditView Class.
*
* @var SiteEditView
* @since 3.2.0
*/
protected SiteEditView $siteeditview;
/**
* The AdminFilterType Class.
*
* @var AdminFilterType
* @since 3.2.0
*/
protected AdminFilterType $adminfiltertype;
/**
* Constructor.
*
* @param Config $config The Config Class.
* @param Admin $admin The Data Class.
* @param SiteEditView $siteeditview The SiteEditView Class.
* @param AdminFilterType $adminfiltertype The AdminFilterType Class.
*
* @since 3.2.0
*/
public function __construct(Config $config, Admin $admin, SiteEditView
$siteeditview, AdminFilterType $adminfiltertype)
{
$this->config = $config;
$this->admin = $admin;
$this->siteeditview = $siteeditview;
$this->adminfiltertype = $adminfiltertype;
}
/**
* Set admin view data
*
* @param object $item The extension data
*
* @return void
* @since 3.2.0
*/
public function set(object &$item)
{
$item->addadmin_views = (isset($item->addadmin_views)
&& JsonHelper::check($item->addadmin_views))
? json_decode((string) $item->addadmin_views, true) : null;
if (ArrayHelper::check($item->addadmin_views))
{
$this->config->lang_target = 'admin';
$this->config->build_target = 'admin';
// sort the views according to order
usort(
$item->addadmin_views, function ($a, $b) {
if ($a['order'] != 0 && $b['order'] != 0)
{
return $a['order'] <=> $b['order'];
}
elseif ($b['order'] != 0 && $a['order'] ==
0)
{
return 1;
}
elseif ($a['order'] != 0 && $b['order'] ==
0)
{
return 0;
}
return 1;
}
);
// build the admin_views settings
$item->admin_views = array_map(
function ($array) {
$array = array_map(
function ($value) {
if (!ArrayHelper::check($value)
&& !ObjectHelper::check($value)
&& strval($value) === strval(intval($value)))
{
return (int) $value;
}
return $value;
}, $array
);
// check if we must add to site
if (isset($array['edit_create_site_view'])
&& is_numeric($array['edit_create_site_view'])
&& $array['edit_create_site_view'] > 0)
{
$this->siteeditview->set($array['adminview'], true);
$this->config->lang_target = 'both';
}
// set the import/export option for this view
if (isset($array['port']) &&
$array['port'])
{
$this->config->set('add_eximport', true);
}
// set the history tracking option for this view
if (isset($array['history']) &&
$array['history'])
{
$this->config->set('set_tag_history', true);
}
// set the custom field integration for this view
if (isset($array['joomla_fields']) &&
$array['joomla_fields'])
{
$this->config->set('set_joomla_fields', true);
}
// has become a legacy issue, can't remove this
$array['view'] = $array['adminview'];
// get the admin settings/data
$array['settings'] = $this->admin->get(
$array['view']
);
// set the filter option for this view | Side (old) [default for now]
$this->adminfiltertype->set($array['settings']->name_list_code,
1);
if (isset($array['filter'])
&& is_numeric(
$array['filter']
) && $array['filter'] > 0)
{
$this->adminfiltertype->set($array['settings']->name_list_code,
(int) $array['filter']);
}
return $array;
}, array_values($item->addadmin_views)
);
}
}
}
src/Componentbuilder/Compiler/Model/Ajaxadmin.php000064400000007660151162054160016075
0ustar00<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder
<https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights
reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
namespace VDM\Joomla\Componentbuilder\Compiler\Model;
use VDM\Joomla\Componentbuilder\Compiler\Config;
use VDM\Joomla\Componentbuilder\Compiler\Builder\SiteEditView;
use VDM\Joomla\Componentbuilder\Compiler\Customcode\Dispenser;
use VDM\Joomla\Utilities\JsonHelper;
use VDM\Joomla\Utilities\ArrayHelper;
use VDM\Joomla\Utilities\StringHelper;
/**
* Model Admin Ajax Class
*
* @since 3.2.0
*/
class Ajaxadmin
{
/**
* The gui mapper array
*
* @var array
* @since 3.2.0
*/
protected array $guiMapper = [
'table' => 'admin_view',
'id' => null,
'field' => null,
'type' => 'php'
];
/**
* The Config Class.
*
* @var Config
* @since 3.2.0
*/
protected Config $config;
/**
* The SiteEditView Class.
*
* @var SiteEditView
* @since 3.2.0
*/
protected SiteEditView $siteeditview;
/**
* The Dispenser Class.
*
* @var Dispenser
* @since 3.2.0
*/
protected Dispenser $dispenser;
/**
* Constructor.
*
* @param Config $config The Config Class.
* @param SiteEditView $siteeditview The SiteEditView Class.
* @param Dispenser $dispenser The Dispenser Class.
*
* @since 3.2.0
*/
public function __construct(Config $config, SiteEditView $siteeditview,
Dispenser $dispenser)
{
$this->config = $config;
$this->siteeditview = $siteeditview;
$this->dispenser = $dispenser;
}
/**
* Set Ajax Code
*
* @param object $item The item data
* @param string $table The table
*
* @return void
* @since 3.2.0
*/
public function set(object &$item, string $table =
'admin_view')
{
// set some gui mapper values
$this->guiMapper['table'] = $table;
$this->guiMapper['id'] = (int) $item->id;
if (isset($item->add_php_ajax) && $item->add_php_ajax ==
1)
{
// insure the token is added to edit view at least
$this->dispenser->hub['token'][$item->name_single_code]
= true;
$add_ajax_site = false;
if ($this->siteeditview->exists($item->id))
{
// we should add this site ajax to front ajax
$add_ajax_site = true;
$this->config->set('add_site_ajax', true);
}
// check if controller input as been set
$item->ajax_input = (isset($item->ajax_input)
&& JsonHelper::check($item->ajax_input))
? json_decode((string) $item->ajax_input, true) : null;
if (ArrayHelper::check($item->ajax_input))
{
if ($add_ajax_site)
{
$this->dispenser->hub['site']['ajax_controller'][$item->name_single_code]
= array_values($item->ajax_input);
}
$this->dispenser->hub['admin']['ajax_controller'][$item->name_single_code]
= array_values($item->ajax_input);
$this->config->set('add_ajax', true);
unset($item->ajax_input);
}
if (StringHelper::check($item->php_ajaxmethod))
{
// make sure we are still in PHP
$this->guiMapper['type'] = 'php';
// update GUI mapper field
$this->guiMapper['field'] = 'php_ajaxmethod';
$this->dispenser->set(
$item->php_ajaxmethod,
'admin',
'ajax_model',
$item->name_single_code,
$this->guiMapper
);
if ($add_ajax_site)
{
$this->dispenser->set(
$item->php_ajaxmethod,
'site',
'ajax_model',
$item->name_single_code,
$this->guiMapper,
false,
false
);
}
// switch ajax on
$this->config->set('add_ajax', true);
// unset anyway
unset($item->php_ajaxmethod);
}
}
}
}
src/Componentbuilder/Compiler/Model/Ajaxcustomview.php000064400000006652151162054160017212
0ustar00<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder
<https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights
reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
namespace VDM\Joomla\Componentbuilder\Compiler\Model;
use VDM\Joomla\Componentbuilder\Compiler\Factory as Compiler;
use VDM\Joomla\Componentbuilder\Compiler\Config;
use VDM\Joomla\Componentbuilder\Compiler\Customcode\Dispenser;
use VDM\Joomla\Utilities\JsonHelper;
use VDM\Joomla\Utilities\ArrayHelper;
use VDM\Joomla\Utilities\StringHelper;
/**
* Model Custom Ajax Custom View Class
*
* @since 3.2.0
*/
class Ajaxcustomview
{
/**
* The gui mapper array
*
* @var array
* @since 3.2.0
*/
protected array $guiMapper = [
'table' => 'site_view',
'id' => null,
'field' => null,
'type' => 'php'
];
/**
* Compiler Config
*
* @var Config
* @since 3.2.0
*/
protected Config $config;
/**
* Compiler Customcode Dispenser
*
* @var Dispenser
* @since 3.2.0
*/
protected Dispenser $dispenser;
/**
* Constructor
*
* @param Config|null $config The compiler config object.
* @param Dispenser|null $dispenser The compiler customcode
dispenser
*
* @since 3.2.0
*/
public function __construct(?Config $config = null, ?Dispenser $dispenser
= null)
{
$this->config = $config ?: Compiler::_('Config');
$this->dispenser = $dispenser ?:
Compiler::_('Customcode.Dispenser');
}
/**
* Set Ajax Code
*
* @param object $item The item data
* @param string $table The table
*
* @return void
* @since 3.2.0
*/
public function set(object &$item, string $table =
'site_view')
{
// add_Ajax for this view
if (isset($item->add_php_ajax) && $item->add_php_ajax ==
1)
{
// set some gui mapper values
$this->guiMapper['table'] = $table;
$this->guiMapper['id'] = (int) $item->id;
// ajax target (since we only have two options really)
if ('site' === $this->config->build_target)
{
$target = 'site';
}
else
{
$target = 'admin';
}
$add_ajax_site = false;
// check if controller input as been set
$item->ajax_input = (isset($item->ajax_input)
&& JsonHelper::check($item->ajax_input))
? json_decode((string) $item->ajax_input, true) : null;
if (ArrayHelper::check($item->ajax_input))
{
$this->dispenser->hub[$target]['ajax_controller'][$item->code]
= array_values($item->ajax_input);
$add_ajax_site = true;
}
unset($item->ajax_input);
// load the ajax class mathods (if set)
if (StringHelper::check($item->php_ajaxmethod))
{
// set field
$this->guiMapper['field'] = 'php_ajaxmethod';
$this->dispenser->set(
$item->php_ajaxmethod,
$target,
'ajax_model',
$item->code,
$this->guiMapper
);
$add_ajax_site = true;
}
unset($item->php_ajaxmethod);
// should ajax be set
if ($add_ajax_site)
{
// turn on ajax area
if ('site' === $this->config->build_target)
{
$this->config->set('add_site_ajax', true);
}
else
{
$this->config->set('add_ajax', true);
}
}
}
}
}
src/Componentbuilder/Compiler/Model/Conditions.php000064400000011233151162054160016301
0ustar00<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder
<https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights
reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
namespace VDM\Joomla\Componentbuilder\Compiler\Model;
use VDM\Joomla\Componentbuilder\Compiler\Factory as Compiler;
use VDM\Joomla\Componentbuilder\Compiler\Field\TypeName;
use VDM\Joomla\Componentbuilder\Compiler\Field\Name as FieldName;
use VDM\Joomla\Componentbuilder\Compiler\Field\Groups as FieldGroups;
use VDM\Joomla\Utilities\ArrayHelper;
use VDM\Joomla\Utilities\GetHelper;
use VDM\Joomla\Utilities\StringHelper;
use VDM\Joomla\Utilities\JsonHelper;
/**
* Model Conditions Class
*
* @since 3.2.0
*/
class Conditions
{
/**
* Compiler Type Name
*
* @var TypeName
* @since 3.2.0
*/
protected TypeName $typeName;
/**
* Compiler Field Name
*
* @var FieldName
* @since 3.2.0
*/
protected FieldName $fieldName;
/**
* Compiler Field Groups
*
* @var FieldGroups
* @since 3.2.0
*/
protected FieldGroups $fieldGroups;
/**
* Constructor
*
* @param TypeName|null $typeName The compiler type name object.
* @param FieldName|null $fieldName The compiler field name
object.
* @param FieldGroups|null $fieldGroups The compiler field groups
object.
*
* @since 3.2.0
*/
public function __construct(?TypeName $typeName = null, ?FieldName
$fieldName = null, ?FieldGroups $fieldGroups = null)
{
$this->typeName = $typeName ?:
Compiler::_('Field.Type.Name');
$this->fieldName = $fieldName ?: Compiler::_('Field.Name');
$this->fieldGroups = $fieldGroups ?:
Compiler::_('Field.Groups');
}
/**
* Set the conditions
*
* @param object $item The view data
*
* @return void
* @since 3.2.0
*/
public function set(object &$item)
{
$item->addconditions = (isset($item->addconditions)
&& JsonHelper::check($item->addconditions))
? json_decode((string) $item->addconditions, true) : null;
if (ArrayHelper::check($item->addconditions))
{
$item->conditions = [];
$ne = 0;
foreach ($item->addconditions as $nr => $conditionValue)
{
if (ArrayHelper::check(
$conditionValue['target_field']
) && ArrayHelper::check($item->fields))
{
foreach ( $conditionValue['target_field'] as $fieldKey =>
$fieldId)
{
foreach ($item->fields as $fieldValues)
{
if ((int) $fieldValues['field'] == (int) $fieldId)
{
// load the field details
$required = GetHelper::between(
$fieldValues['settings']->xml,
'required="', '"'
);
$required = ($required === 'true'
|| $required === '1') ? 'yes' :
'no';
$filter = GetHelper::between(
$fieldValues['settings']->xml,
'filter="', '"'
);
$filter = StringHelper::check(
$filter
) ? $filter : 'none';
// set the field name
$conditionValue['target_field'][$fieldKey] = [
'name' => $this->fieldName->get(
$fieldValues, $item->name_list_code
),
'type' => $this->typeName->get(
$fieldValues
),
'required' => $required,
'filter' => $filter
];
break;
}
}
}
}
// load match field
if (ArrayHelper::check($item->fields)
&& isset($conditionValue['match_field']))
{
foreach ($item->fields as $fieldValue)
{
if ((int) $fieldValue['field'] == (int)
$conditionValue['match_field'])
{
// set the type
$type = $this->typeName->get($fieldValue);
// set the field details
$conditionValue['match_name'] =
$this->fieldName->get(
$fieldValue, $item->name_list_code
);
$conditionValue['match_type'] = $type;
$conditionValue['match_xml'] =
$fieldValue['settings']->xml;
// if custom field load field being extended
if (!$this->fieldGroups->check($type))
{
$conditionValue['match_extends'] = GetHelper::between(
$fieldValue['settings']->xml,
'extends="', '"'
);
}
else
{
$conditionValue['match_extends'] = '';
}
break;
}
}
}
// set condition values
$item->conditions[$ne] = $conditionValue;
$ne++;
}
}
unset($item->addconditions);
}
}
src/Componentbuilder/Compiler/Model/Createdate.php000064400000002542151162054160016234
0ustar00<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder
<https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights
reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
namespace VDM\Joomla\Componentbuilder\Compiler\Model;
use Joomla\CMS\Factory;
use VDM\Joomla\Utilities\StringHelper;
/**
* Model - Get Create Date
*
* @since 3.2.0
*/
class Createdate
{
/**
* Get the create date of an item
*
* @param mixed $item The item data
*
* @return string The create data
* @since 3.2.0
*/
public function get(&$item): string
{
if (is_array($item) && isset($item['settings'])
&& isset($item['settings']->created)
&&
StringHelper::check($item['settings']->created))
{
// first set the main date
$date = strtotime((string) $item['settings']->created);
}
elseif (is_object($item) && isset($item->created)
&& StringHelper::check($item->created))
{
// first set the main date
$date = strtotime((string) $item->created);
}
else
{
// first set the main date
$date = strtotime("now");
}
return Factory::getDate($date)->format('jS F, Y');
}
}
src/Componentbuilder/Compiler/Model/Cssadminview.php000064400000003437151162054160016633
0ustar00<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder
<https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights
reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
namespace VDM\Joomla\Componentbuilder\Compiler\Model;
use VDM\Joomla\Componentbuilder\Compiler\Factory as Compiler;
use VDM\Joomla\Componentbuilder\Compiler\Customcode\Dispenser;
use VDM\Joomla\Utilities\StringHelper;
/**
* Model CSS Admin View Class
*
* @since 3.2.0
*/
class Cssadminview
{
/**
* The areas add array
*
* @var array
* @since 3.2.0
*/
protected array $areas = [
'css_view', 'css_views'
];
/**
* Compiler Customcode Dispenser
*
* @var Dispenser
* @since 3.2.0
*/
protected Dispenser $dispenser;
/**
* Constructor
*
* @param Dispenser|null $dispenser The compiler customcode
dispenser
*
* @since 3.2.0
*/
public function __construct(?Dispenser $dispenser = null)
{
$this->dispenser = $dispenser ?:
Compiler::_('Customcode.Dispenser');
}
/**
* Set Admin View Css
*
* @param object $item The item data
*
* @return void
* @since 3.2.0
*/
public function set(object &$item)
{
foreach ($this->areas as $area)
{
if (isset($item->{'add_' . $area})
&& $item->{'add_' . $area} == 1
&& StringHelper::check($item->{$area}))
{
$this->dispenser->set(
$item->{$area},
$area,
$item->name_single_code,
null,
['prefix' => PHP_EOL],
true,
true,
true
);
unset($item->{$area});
}
}
}
}
src/Componentbuilder/Compiler/Model/Csscustomview.php000064400000003231151162054160017045
0ustar00<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder
<https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights
reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
namespace VDM\Joomla\Componentbuilder\Compiler\Model;
use VDM\Joomla\Componentbuilder\Compiler\Factory as Compiler;
use VDM\Joomla\Componentbuilder\Compiler\Customcode;
use VDM\Joomla\Utilities\StringHelper;
/**
* Model Css Custom View Class
*
* @since 3.2.0
*/
class Csscustomview
{
/**
* The areas add array
*
* @var array
* @since 3.2.0
*/
protected array $areas = ['css_document', 'css'];
/**
* Compiler Customcode Class
*
* @var Customcode
* @since 3.2.0
*/
protected Customcode $customcode;
/**
* Constructor
*
* @param Customcode|null $customcode The compiler customcode
object.
*
* @since 3.2.0
*/
public function __construct(?Customcode $customcode = null)
{
$this->customcode = $customcode ?:
Compiler::_('Customcode');
}
/**
* Set Css code
*
* @param object $item The item data
*
* @return void
* @since 3.2.0
*/
public function set(object &$item)
{
foreach ($this->areas as $area)
{
if (isset($item->{'add_' . $area})
&& $item->{'add_' . $area} == 1
&& StringHelper::check($item->{$area}))
{
$item->{$area} = $this->customcode->update(
base64_decode((string) $item->{$area})
);
}
}
}
}
src/Componentbuilder/Compiler/Model/Customadminviews.php000064400000005367151162054160017544
0ustar00<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder
<https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights
reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
namespace VDM\Joomla\Componentbuilder\Compiler\Model;
use VDM\Joomla\Componentbuilder\Compiler\Factory as Compiler;
use VDM\Joomla\Componentbuilder\Compiler\Customview\Data as Customview;
use VDM\Joomla\Componentbuilder\Compiler\Config;
use VDM\Joomla\Utilities\JsonHelper;
use VDM\Joomla\Utilities\ArrayHelper;
use VDM\Joomla\Utilities\ObjectHelper;
/**
* Model Custom Admin Views Class
*
* @since 3.2.0
*/
class Customadminviews
{
/**
* Component custom admin view Data
*
* @var Customview
* @since 3.2.0
**/
protected Customview $customadmin;
/**
* Compiler Config
*
* @var Config
* @since 3.2.0
**/
protected Config $config;
/**
* Constructor
*
* @param Customview|null $customadmin The custom admin view data
object.
* @param Config|null $config The compiler config object.
*
* @since 3.2.0
*/
public function __construct(?Customview $customadmin = null, ?Config
$config = null)
{
$this->customadmin = $customadmin ?:
Compiler::_('Customview.Data');
$this->config = $config ?: Compiler::_('Config');
}
/**
* Set custom admin view data
*
* @param object $item The item data
*
* @return void
* @since 3.2.0
*/
public function set(object &$item)
{
$item->addcustom_admin_views =
(isset($item->addcustom_admin_views)
&& JsonHelper::check($item->addcustom_admin_views))
? json_decode((string) $item->addcustom_admin_views, true) : null;
if (ArrayHelper::check($item->addcustom_admin_views))
{
$this->config->lang_target = 'admin';
$this->config->build_target = 'custom_admin';
// build the site_views settings
$item->custom_admin_views = array_map(
function ($array) {
// has become a legacy issue, can't remove this
$array['view'] = $array['customadminview'];
$array['settings'] = $this->customadmin->get(
$array['view'], 'custom_admin_view'
);
return array_map(
function ($value) {
if (!ArrayHelper::check($value)
&& !ObjectHelper::check($value)
&& strval($value) === strval(intval($value)))
{
return (int) $value;
}
return $value;
}, $array
);
}, array_values($item->addcustom_admin_views)
);
// unset original value
unset($item->addcustom_admin_views);
}
}
}
src/Componentbuilder/Compiler/Model/Customalias.php000064400000005055151162054160016461
0ustar00<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder
<https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights
reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
namespace VDM\Joomla\Componentbuilder\Compiler\Model;
use VDM\Joomla\Componentbuilder\Compiler\Builder\CustomAlias as
BuilderCustomAlias;
use VDM\Joomla\Componentbuilder\Compiler\Field\Name as FieldName;
use VDM\Joomla\Utilities\JsonHelper;
use VDM\Joomla\Utilities\ArrayHelper;
/**
* Model Custom Alias Class
*
* @since 3.2.0
*/
class Customalias
{
/**
* The BuilderCustomAlias Class.
*
* @var BuilderCustomAlias
* @since 3.2.0
*/
protected BuilderCustomAlias $customalias;
/**
* The Name Class.
*
* @var FieldName
* @since 3.2.0
*/
protected FieldName $fieldname;
/**
* Constructor.
*
* @param BuilderCustomAlias $customalias The CustomAlias Class.
* @param FieldName $fieldname The Name Class.
*
* @since 3.2.0
*/
public function __construct(BuilderCustomAlias $customalias, FieldName
$fieldname)
{
$this->customalias = $customalias;
$this->fieldname = $fieldname;
}
/**
* Set activate alias builder
*
* @param object $item The item data
*
* @return void
* @since 3.2.0
*/
public function set(object &$item)
{
if (!$this->customalias->get($item->name_single_code)
&& isset($item->alias_builder_type) && 2 ==
$item->alias_builder_type
&& isset($item->alias_builder) &&
JsonHelper::check($item->alias_builder))
{
// get the aliasFields
$alias_fields = (array) json_decode((string) $item->alias_builder,
true);
// get the active fields
$alias_fields = (array) array_filter(
$item->fields, function ($field) use ($alias_fields) {
// check if field is in view fields
if (in_array($field['field'], $alias_fields))
{
return true;
}
return false;
}
);
// check if all is well
if (ArrayHelper::check($alias_fields))
{
// load the field names
$this->customalias->set($item->name_single_code,
(array) array_map(
function ($field) use (&$item) {
return $this->fieldname->get(
$field, $item->name_list_code
);
}, $alias_fields
)
);
}
}
// unset
unset($item->alias_builder);
}
}
src/Componentbuilder/Compiler/Model/Custombuttons.php000064400000007322151162054160017065
0ustar00<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder
<https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights
reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
namespace VDM\Joomla\Componentbuilder\Compiler\Model;
use VDM\Joomla\Componentbuilder\Compiler\Factory as Compiler;
use VDM\Joomla\Componentbuilder\Compiler\Customcode;
use VDM\Joomla\Componentbuilder\Compiler\Customcode\Gui;
use VDM\Joomla\Componentbuilder\Compiler\Templatelayout\Data as
Templatelayout;
use VDM\Joomla\Utilities\StringHelper;
use VDM\Joomla\Utilities\JsonHelper;
use VDM\Joomla\Utilities\ArrayHelper;
/**
* Model Custom Buttons Class
*
* @since 3.2.0
*/
class Custombuttons
{
/**
* The areas add array
*
* @var array
* @since 3.2.0
*/
protected array $areas = [
'php_model',
'php_controller',
'php_model_list',
'php_controller_list'
];
/**
* The gui mapper array
*
* @var array
* @since 3.2.0
*/
protected array $guiMapper = [
'table' => 'admin_view',
'id' => null,
'field' => null,
'type' => 'php'
];
/**
* Compiler Customcode
*
* @var Customcode
* @since 3.2.0
*/
protected Customcode $customcode;
/**
* Compiler Customcode in Gui
*
* @var Gui
* @since 3.2.0
**/
protected Gui $gui;
/**
* Compiler Template Layout
*
* @var Templatelayout
* @since 3.2.0
*/
protected Templatelayout $templateLayout;
/**
* Constructor
*
* @param Customcode|null $customcode The compiler
customcode object.
* @param Gui|null $gui The compiler
customcode gui.
* @param Templatelayout|null $templateLayout The compiler template
layout object.
*
* @since 3.2.0
*/
public function __construct(?Customcode $customcode = null, ?Gui $gui =
null,
?Templatelayout $templateLayout = null)
{
$this->customcode = $customcode ?:
Compiler::_('Customcode');
$this->gui = $gui ?: Compiler::_('Customcode.Gui');
$this->templateLayout = $templateLayout ?:
Compiler::_('Templatelayout.Data');
}
/**
* Set Custom Buttons and Model/Controllers
*
* @param object $item The item data
* @param object $table The table
*
* @return void
* @since 3.2.0
*/
public function set(object &$item, string $table =
'admin_view')
{
if (isset($item->add_custom_button)
&& $item->add_custom_button == 1)
{
// set some gui mapper values
$this->guiMapper['table'] = $table;
$this->guiMapper['id'] = (int) $item->id;
// get the code
$code = $item->name_single_code ?? $item->code ??
'error';
// set for the code
foreach ($this->areas as $area)
{
if (isset($item->{$area})
&& StringHelper::check(
$item->{$area}
))
{
// set field
$this->guiMapper['field'] = $area;
$item->{$area} = $this->gui->set(
$this->customcode->update(
base64_decode((string) $item->{$area})
),
$this->guiMapper
);
// check if we have template or layouts to load
$this->templateLayout->set(
$item->{$area}, $code
);
}
}
// set the button array
$item->custom_button = (isset($item->custom_button)
&& JsonHelper::check($item->custom_button))
? json_decode((string) $item->custom_button, true) : null;
if (ArrayHelper::check($item->custom_button))
{
$item->custom_buttons = array_values($item->custom_button);
}
unset($item->custom_button);
}
}
}
src/Componentbuilder/Compiler/Model/Customimportscripts.php000064400000005623151162054160020313
0ustar00<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder
<https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights
reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
namespace VDM\Joomla\Componentbuilder\Compiler\Model;
use VDM\Joomla\Componentbuilder\Compiler\Factory as Compiler;
use VDM\Joomla\Componentbuilder\Compiler\Customcode\Dispenser;
use VDM\Joomla\Utilities\StringHelper;
use VDM\Joomla\Utilities\Component\Helper;
/**
* Model Custom Import Scripts Class
*
* @since 3.2.0
*/
class Customimportscripts
{
/**
* The areas add array
*
* @var array
* @since 3.2.0
*/
protected array $areas = [
'php_import_ext',
'php_import_display',
'php_import',
'php_import_setdata',
'php_import_save',
'php_import_headers',
'html_import_view'
];
/**
* The gui mapper array
*
* @var array
* @since 3.2.0
*/
protected array $guiMapper = [
'table' => 'admin_view',
'id' => null,
'field' => null,
'type' => 'php'
];
/**
* Compiler Customcode Dispenser
*
* @var Dispenser
* @since 3.2.0
*/
protected Dispenser $dispenser;
/**
* Constructor
*
* @param Dispenser|null $dispenser The compiler customcode
dispenser
*
* @since 3.2.0
*/
public function __construct(?Dispenser $dispenser = null)
{
$this->dispenser = $dispenser ?:
Compiler::_('Customcode.Dispenser');
}
/**
* Set Custom Import Scripts
*
* @param object $item The item data
* @param string $table The table
*
* @return void
* @since 3.2.0
*/
public function set(object &$item, string $table =
'admin_view')
{
// set custom import scripts
if (isset($item->add_custom_import)
&& $item->add_custom_import == 1)
{
// set some gui mapper values
$this->guiMapper['table'] = $table;
$this->guiMapper['id'] = (int) $item->id;
foreach ($this->areas as $area)
{
if (isset($item->$area)
&& StringHelper::check($item->$area))
{
// update GUI mapper field
$this->guiMapper['field'] = $area;
$this->guiMapper['type'] = 'php';
// Make sure html gets HTML comment for placeholder
if ('html_import_view' === $area)
{
$this->guiMapper['type'] = 'html';
}
$this->dispenser->set(
$item->$area,
$area,
'import_' . $item->name_list_code,
null,
$this->guiMapper
);
unset($item->$area);
}
else
{
// load the default TODO: convert getDynamicScripts to a class
$this->dispenser->hub[$area]['import_' .
$item->name_list_code]
= Helper::_('getDynamicScripts', [$area, true]);
}
}
}
}
}
src/Componentbuilder/Compiler/Model/Dynamicget.php000064400000034111151162054160016254
0ustar00<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder
<https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights
reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
namespace VDM\Joomla\Componentbuilder\Compiler\Model;
use VDM\Joomla\Componentbuilder\Compiler\Config;
use VDM\Joomla\Componentbuilder\Compiler\Builder\SiteDynamicGet;
use VDM\Joomla\Componentbuilder\Compiler\Builder\SiteMainGet;
use VDM\Joomla\Componentbuilder\Compiler\Customcode;
use VDM\Joomla\Componentbuilder\Compiler\Customcode\Gui;
use VDM\Joomla\Componentbuilder\Compiler\Placeholder;
use VDM\Joomla\Componentbuilder\Compiler\Dynamicget\Selection;
use VDM\Joomla\Utilities\GetHelper;
use VDM\Joomla\Utilities\StringHelper;
use VDM\Joomla\Utilities\ArrayHelper;
/**
* Model Dynamic Get Class
*
* @since 3.2.0
*/
class Dynamicget
{
/**
* The joint types
*
* @var array
* @since 3.2.0
*/
protected array $jointer = [
1 => 'LEFT',
2 => 'LEFT OUTER',
3 => 'INNER',
4 => 'RIGHT',
5 => 'RIGHT OUTER'
];
/**
* The operator types
*
* @var array
* @since 3.2.0
*/
protected array $operator = [
1 => '=',
2 => '!=',
3 => '<>',
4 => '>',
5 => '<',
6 => '>=',
7 => '<=',
8 => '!<',
9 => '!>',
10 => 'IN',
11 => 'NOT IN'
];
/**
* The gui mapper array
*
* @var array
* @since 3.2.0
*/
protected array $guiMapper = [
'table' => 'dynamic_get',
'id' => null,
'field' => null,
'type' => 'php'
];
/**
* The Config Class.
*
* @var Config
* @since 3.2.0
*/
protected Config $config;
/**
* The SiteDynamicGet Class.
*
* @var SiteDynamicGet
* @since 3.2.0
*/
protected SiteDynamicGet $sitedynamicget;
/**
* The SiteMainGet Class.
*
* @var SiteMainGet
* @since 3.2.0
*/
protected SiteMainGet $sitemainget;
/**
* The Customcode Class.
*
* @var Customcode
* @since 3.2.0
*/
protected Customcode $customcode;
/**
* The Gui Class.
*
* @var Gui
* @since 3.2.0
*/
protected Gui $gui;
/**
* The Placeholder Class.
*
* @var Placeholder
* @since 3.2.0
*/
protected Placeholder $placeholder;
/**
* The Selection Class.
*
* @var Selection
* @since 3.2.0
*/
protected Selection $selection;
/**
* Constructor.
*
* @param Config $config The Config Class.
* @param SiteDynamicGet $sitedynamicget The SiteDynamicGet Class.
* @param SiteMainGet $sitemainget The SiteMainGet Class.
* @param Customcode $customcode The Customcode Class.
* @param Gui $gui The Gui Class.
* @param Placeholder $placeholder The Placeholder Class.
* @param Selection $selection The Selection Class.
*
* @since 3.2.0
*/
public function __construct(Config $config, SiteDynamicGet
$sitedynamicget,
SiteMainGet $sitemainget, Customcode $customcode, Gui $gui,
Placeholder $placeholder, Selection $selection)
{
$this->config = $config;
$this->sitedynamicget = $sitedynamicget;
$this->sitemainget = $sitemainget;
$this->customcode = $customcode;
$this->gui = $gui;
$this->placeholder = $placeholder;
$this->selection = $selection;
}
/**
* Set Dynamic Get
*
* @param object $item The item data
* @param string $view_code The view code name
* @param string $context The context for events
*
* @return void
* @since 3.2.0
*/
public function set(object &$item, string $view_code, string
$context)
{
// reset buckets
$item->main_get = [];
$item->custom_get = [];
// should joined and other tweaks be added
$add_tweaks_joints = true;
// set source data
switch ($item->main_source)
{
case 1:
// check if auto sync is set
if ($item->select_all == 1)
{
$item->view_selection = '*';
}
// set the view data
$item->main_get[0]['selection'] =
$this->selection->get(
$item->key, $view_code,
$item->view_selection,
$item->view_table_main, 'a', 'view'
);
$item->main_get[0]['as'] = 'a';
$item->main_get[0]['key'] = $item->key;
$item->main_get[0]['context'] = $context;
unset($item->view_selection);
break;
case 2:
// check if auto sync is set
if ($item->select_all == 1)
{
$item->db_selection = '*';
}
// set the database data
$item->main_get[0]['selection'] =
$this->selection->get(
$item->key, $view_code,
$item->db_selection,
$item->db_table_main, 'a', 'db'
);
$item->main_get[0]['as'] = 'a';
$item->main_get[0]['key'] = $item->key;
$item->main_get[0]['context'] = $context;
unset($item->db_selection);
break;
case 3:
// set GUI mapper field
$this->guiMapper['field'] = 'php_custom_get';
// get the custom query
$customQueryString
= $this->gui->set(
$this->customcode->update(
base64_decode((string) $item->php_custom_get)
),
$this->guiMapper
);
// get the table name
$_searchQuery
= GetHelper::between(
$customQueryString, '$query->from(', ')'
);
if (StringHelper::check(
$_searchQuery
)
&& strpos((string) $_searchQuery, '#__') !== false)
{
$_queryName = GetHelper::between(
$_searchQuery, '#__', "'"
);
if (!StringHelper::check(
$_queryName
))
{
$_queryName = GetHelper::between(
$_searchQuery, '#__', '"'
);
}
}
// set to blank if not found
if (!isset($_queryName)
|| !StringHelper::check(
$_queryName
))
{
$_queryName = '';
}
// set custom script
$item->main_get[0]['selection'] = [
'select' => $customQueryString,
'from' => '', 'table' =>
'', 'type' => '',
'name' => $_queryName];
$item->main_get[0]['as'] = 'a';
$item->main_get[0]['key'] = $item->key;
$item->main_get[0]['context'] = $context;
// do not add
$add_tweaks_joints = false;
break;
}
// only add if main source is not custom
if ($add_tweaks_joints)
{
// set join_view_table details
$item->join_view_table = json_decode(
(string) $item->join_view_table, true
);
if (ArrayHelper::check(
$item->join_view_table
))
{
// start the part of a table bucket
$_part_of_a = [];
// build relationship
$_relationship = array_map(
function ($op) use (&$_part_of_a) {
$bucket = [];
// array(on_field_as, on_field)
$bucket['on_field'] = array_map(
'trim',
explode('.', (string) $op['on_field'])
);
// array(join_field_as, join_field)
$bucket['join_field'] = array_map(
'trim',
explode('.', (string) $op['join_field'])
);
// triget filed that has table a relationship
if ($op['row_type'] == 1
&& ($bucket['on_field'][0] === 'a'
|| isset($_part_of_a[$bucket['on_field'][0]])
|| isset($_part_of_a[$bucket['join_field'][0]])))
{
$_part_of_a[$op['as']] = $op['as'];
}
return $bucket;
}, $item->join_view_table
);
// loop joints
foreach ($item->join_view_table as $nr => &$option)
{
if (StringHelper::check(
$option['selection']
))
{
// convert the type
$option['type']
= $this->jointer[$option['type']];
// convert the operator
$option['operator']
= $this->operator[$option['operator']];
// get the on field values
$on_field
= $_relationship[$nr]['on_field'];
// get the join field values
$join_field
= $_relationship[$nr]['join_field'];
// set selection
$option['selection']
= $this->selection->get(
$item->key,
$view_code,
$option['selection'],
$option['view_table'],
$option['as'],
'view',
$option['row_type']
);
$option['key'] = $item->key;
$option['context'] = $context;
// load to the getters
if ($option['row_type'] == 1)
{
$item->main_get[] = $option;
if ($on_field[0] === 'a'
|| isset($_part_of_a[$join_field[0]])
|| isset($_part_of_a[$on_field[0]]))
{
$this->sitemainget->set(
$this->config->build_target . '.' . $view_code .
'.' .
$option['as'], $option['as']
);
}
else
{
$this->sitedynamicget->set(
$this->config->build_target . '.' . $view_code .
'.' .
$option['as'] . '.' . $join_field[1],
$on_field[0]
);
}
}
elseif ($option['row_type'] == 2)
{
$item->custom_get[] = $option;
if ($on_field[0] != 'a')
{
$this->sitedynamicget->set(
$this->config->build_target . '.' . $view_code .
'.' .
$option['as'] . '.' . $join_field[1],
$on_field[0]
);
}
}
}
unset($item->join_view_table[$nr]);
}
}
unset($item->join_view_table);
// set join_db_table details
$item->join_db_table = json_decode(
(string) $item->join_db_table, true
);
if (ArrayHelper::check($item->join_db_table))
{
// start the part of a table bucket
$_part_of_a = [];
// build relationship
$_relationship = array_map(
function ($op) use (&$_part_of_a) {
$bucket = [];
// array(on_field_as, on_field)
$bucket['on_field'] = array_map(
'trim',
explode('.', (string) $op['on_field'])
);
// array(join_field_as, join_field)
$bucket['join_field'] = array_map(
'trim',
explode('.', (string) $op['join_field'])
);
// triget filed that has table a relationship
if ($op['row_type'] == 1
&& ($bucket['on_field'][0] === 'a'
|| isset($_part_of_a[$bucket['on_field'][0]])
|| isset($_part_of_a[$bucket['join_field'][0]])))
{
$_part_of_a[$op['as']] = $op['as'];
}
return $bucket;
}, $item->join_db_table
);
// loop joints
foreach ($item->join_db_table as $nr => &$option1)
{
if (StringHelper::check($option1['selection']))
{
// convert the type
$option1['type'] =
$this->jointer[$option1['type']];
// convert the operator
$option1['operator'] =
$this->operator[$option1['operator']];
// get the on field values
$on_field = $_relationship[$nr]['on_field'];
// get the join field values
$join_field = $_relationship[$nr]['join_field'];
// set selection
$option1['selection'] = $this->selection->get(
$item->key,
$view_code,
$option1['selection'],
$option1['db_table'],
$option1['as'],
'db',
$option1['row_type']
);
$option1['key'] = $item->key;
$option1['context'] = $context;
// load to the getters
if ($option1['row_type'] == 1)
{
$item->main_get[] = $option1;
if ($on_field[0] === 'a'
|| isset($_part_of_a[$join_field[0]])
|| isset($_part_of_a[$on_field[0]]))
{
$this->sitemainget->set(
$this->config->build_target . '.' . $view_code .
'.' .
$option1['as'], $option1['as']
);
}
else
{
$this->sitedynamicget->set(
$this->config->build_target . '.' . $view_code .
'.' .
$option1['as'] . '.' . $join_field[1],
$on_field[0]
);
}
}
elseif ($option1['row_type'] == 2)
{
$item->custom_get[] = $option1;
if ($on_field[0] != 'a')
{
$this->sitedynamicget->set(
$this->config->build_target . '.' . $view_code .
'.' .
$option1['as'] . '.' . $join_field[1],
$on_field[0]
);
}
}
}
unset($item->join_db_table[$nr]);
}
}
unset($item->join_db_table);
// set filter details
$item->filter = json_decode(
(string) $item->filter, true
);
if (ArrayHelper::check($item->filter))
{
foreach ($item->filter as $nr => &$option2)
{
if (isset($option2['operator']))
{
$option2['operator'] =
$this->operator[$option2['operator']];
$option2['state_key'] = $this->placeholder->update_(
$this->customcode->update(
$option2['state_key']
)
);
$option2['key'] = $item->key;
}
else
{
unset($item->filter[$nr]);
}
}
}
// set where details
$item->where = json_decode((string) $item->where, true);
if (ArrayHelper::check($item->where))
{
foreach ($item->where as $nr => &$option3)
{
if (isset($option3['operator']))
{
$option3['operator'] =
$this->operator[$option3['operator']];
}
else
{
unset($item->where[$nr]);
}
}
}
else
{
unset($item->where);
}
// set order details
$item->order = json_decode((string) $item->order, true);
if (!ArrayHelper::check($item->order))
{
unset($item->order);
}
// set grouping
$item->group = json_decode((string) $item->group, true);
if (!ArrayHelper::check($item->group))
{
unset($item->group);
}
// set global details
$item->global = json_decode(
(string) $item->global, true
);
if (!ArrayHelper::check($item->global))
{
unset($item->global);
}
}
else
{
// when we have a custom query script we do not add the dynamic options
unset($item->join_view_table);
unset($item->join_db_table);
unset($item->filter);
unset($item->where);
unset($item->order);
unset($item->group);
unset($item->global);
}
}
}
src/Componentbuilder/Compiler/Model/Fields.php000064400000024006151162054160015400
0ustar00<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder
<https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights
reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
namespace VDM\Joomla\Componentbuilder\Compiler\Model;
use Joomla\CMS\Factory;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Application\CMSApplication;
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\HistoryInterface;
use VDM\Joomla\Componentbuilder\Compiler\Customcode;
use VDM\Joomla\Componentbuilder\Compiler\Field;
use VDM\Joomla\Componentbuilder\Compiler\Field\Name as FieldName;
use VDM\Joomla\Componentbuilder\Compiler\Field\Groups as FieldGroups;
use VDM\Joomla\Componentbuilder\Compiler\Model\Updatesql;
use VDM\Joomla\Utilities\JsonHelper;
use VDM\Joomla\Utilities\ArrayHelper;
use VDM\Joomla\Utilities\ObjectHelper;
/**
* Model Fields Class
*
* @since 3.2.0
*/
class Fields
{
/**
* Compiler Config
*
* @var Config
* @since 3.2.0
*/
protected Config $config;
/**
* The compiler registry
*
* @var Registry
* @since 3.2.0
*/
protected Registry $registry;
/**
* Compiler History
*
* @var HistoryInterface
* @since 3.2.0
*/
protected HistoryInterface $history;
/**
* Compiler Customcode
*
* @var Customcode
* @since 3.2.0
*/
protected Customcode $customcode;
/**
* Compiler Field
*
* @var Field
* @since 3.2.0
*/
protected Field $field;
/**
* Compiler Field Name
*
* @var FieldName
* @since 3.2.0
*/
protected FieldName $fieldName;
/**
* Compiler Field Groups
*
* @var FieldGroups
* @since 3.2.0
*/
protected FieldGroups $fieldGroups;
/**
* Compiler Update Sql
*
* @var UpdateSql
* @since 3.2.0
*/
protected UpdateSql $updateSql;
/**
* Application object.
*
* @var CMSApplication
* @since 3.2.0
**/
protected CMSApplication $app;
/**
* Constructor
*
* @param Config|null $config The compiler config
object.
* @param Registry|null $registry The compiler
registry object.
* @param HistoryInterface|null $history The compiler history
object.
* @param Customcode|null $customcode The compiler
customcode object.
* @param Field|null $field The compiler field
object.
* @param FieldName|null $fieldName The compiler field
name object.
* @param FieldGroups|null $fieldGroups The compiler field
groups object.
* @param UpdateSql|null $updateSql The compiler field
name object.
* @param CMSApplication|null $app The app object.
*
* @since 3.2.0
*/
public function __construct(?Config $config = null, ?Registry $registry =
null,
?HistoryInterface $history = null, ?Customcode $customcode = null,
?Field $field = null, ?FieldName $fieldName = null, ?FieldGroups
$fieldGroups = null,
?UpdateSql $updateSql = null, ?CMSApplication $app = null)
{
$this->config = $config ?: Compiler::_('Config');
$this->registry = $registry ?: Compiler::_('Registry');
$this->history = $history ?: Compiler::_('History');
$this->customcode = $customcode ?:
Compiler::_('Customcode');
$this->field = $field ?: Compiler::_('Field');
$this->fieldName = $fieldName ?: Compiler::_('Field.Name');
$this->fieldGroups = $fieldGroups ?:
Compiler::_('Field.Groups');
$this->updateSql = $updateSql ?:
Compiler::_('Model.Updatesql');
$this->app = $app ?: Factory::getApplication();
}
/**
* Set fields
*
* @param object $item The view data
*
* @return void
* @since 3.2.0
*/
public function set(object &$item)
{
$item->fields = [];
$item->addfields = (isset($item->addfields)
&& JsonHelper::check($item->addfields))
? json_decode((string) $item->addfields, true) : null;
if (ArrayHelper::check($item->addfields))
{
$ignore_fields = [];
$default_fields = $this->config->default_fields;
// load the field data
$item->fields = array_map(
function ($field) use (
&$item, &$ignore_fields, &$default_fields
) {
// set the field details
$this->field->set(
$field, $item->name_single_code,
$item->name_list_code
);
// check if this field is a default field OR
// check if this is none database related field
if (in_array($field['base_name'], $default_fields)
|| $this->fieldGroups->check($field['type_name'],
'spacer')
|| (isset($field['list']) &&
$field['list'] == 2)) // 2 = none database
{
$ignore_fields[$field['field']] =
$field['field'];
}
// return field
return $field;
}, array_values($item->addfields)
);
// build update SQL
if ($old_view = $this->history->get(
'admin_fields', $item->addfields_id
))
{
// add new fields were added
if (isset($old_view->addfields)
&& JsonHelper::check(
$old_view->addfields
))
{
$this->updateSql->set(
json_decode((string) $old_view->addfields, true),
$item->addfields, 'field', $item->name_single_code,
$ignore_fields
);
}
// clear this data
unset($old_view);
}
// sort the fields according to order
usort(
$item->fields, function ($a, $b) {
if (isset($a['order_list']) &&
isset($b['order_list']))
{
if ($a['order_list'] != 0 &&
$b['order_list'] != 0)
{
return $a['order_list'] <=>
$b['order_list'];
}
elseif ($b['order_list'] != 0 &&
$a['order_list'] == 0)
{
return 1;
}
elseif ($a['order_list'] != 0 &&
$b['order_list'] == 0)
{
return -1;
}
return 1;
}
return 0;
}
);
// do some house cleaning (for fields)
foreach ($item->fields as $field)
{
// so first we lock the field name in
$field_name = $this->fieldName->get(
$field, $item->name_list_code
);
// check if the field changed since the last compilation
// (default fields never change and are always added)
if (!isset($ignore_fields[$field['field']])
&& ObjectHelper::check(
$field['settings']->history
))
{
// check if the datatype changed
if (isset($field['settings']->history->datatype))
{
$this->updateSql->set(
$field['settings']->history->datatype,
$field['settings']->datatype,
'field.datatype',
$item->name_single_code . '.' . $field_name
);
}
// check if the datatype lenght changed
if (isset($field['settings']->history->datalenght)
&&
isset($field['settings']->history->datalenght_other))
{
$this->updateSql->set(
$field['settings']->history->datalenght
. $field['settings']->history->datalenght_other,
$field['settings']->datalenght
. $field['settings']->datalenght_other,
'field.lenght',
$item->name_single_code . '.' . $field_name
);
}
// check if the name changed
if (isset($field['settings']->history->xml)
&& JsonHelper::check(
$field['settings']->history->xml
))
{
// only run if this is not an alias or a tag
if ((!isset($field['alias']) ||
!$field['alias'])
&& 'tag' !==
$field['settings']->type_name)
{
// build temp field bucket
$tmpfield = [];
$tmpfield['settings'] = new \stdClass();
// convert the xml json string to normal string
$tmpfield['settings']->xml
= $this->customcode->update(
json_decode(
(string) $field['settings']->history->xml
)
);
// add properties from current field as it is generic
$tmpfield['settings']->properties
= $field['settings']->properties;
// add the old name
$tmpfield['settings']->name
= $field['settings']->history->name;
// add the field type from current field since it is generic
$tmpfield['settings']->type_name
= $field['settings']->type_name;
// get the old name
$old_field_name = $this->fieldName->get(
$tmpfield
);
// only run this if not a multi field
if ($this->registry->get('unique.names.' .
$item->name_list_code . '.names.' . $field_name) === null)
{
// this only works when the field is
// not multiple of the same field
$this->updateSql->set(
$old_field_name, $field_name,
'field.name',
$item->name_single_code . '.'
. $field_name
);
}
elseif ($old_field_name !== $field_name)
{
// give a notice atleast that the multi fields
// could have changed and no DB update was done
$this->app->enqueueMessage(
Text::_('COM_COMPONENTBUILDER_HR_HTHREEFIELD_NOTICEHTHREE'),
'Notice'
);
$this->app->enqueueMessage(
Text::sprintf(
'You have a field called <b>%s</b> that has been
added multiple times to the <b>%s</b> view, the name of that
field has changed to <b>%s</b>. Normaly we would automaticly
add the update SQL to your component, but with multiple fields this does
not work automaticly since it could be that noting changed and it just
seems like it did. Therefore you will have to do this manualy if it actualy
did change!',
$field_name,
$item->name_single_code,
$old_field_name
), 'Notice'
);
}
// remove tmp
unset($tmpfield);
}
}
}
}
}
unset($item->addfields);
}
}
src/Componentbuilder/Compiler/Model/Filesfolders.php000064400000003362151162054160016615
0ustar00<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder
<https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights
reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
namespace VDM\Joomla\Componentbuilder\Compiler\Model;
use VDM\Joomla\Utilities\JsonHelper;
use VDM\Joomla\Utilities\ArrayHelper;
/**
* Model Files & Folders Class
*
* @since 3.2.0
*/
class Filesfolders
{
/**
* Compiler Files Folders
*
* @var array
* @since 3.2.0
*/
protected array $keys = [
'files' => 'files',
'folders' => 'folders',
'urls' => 'urls',
'filesfullpath' => 'files',
'foldersfullpath' => 'folders'
];
/**
* Set the file and folder data
*
* @param object $item The item data
*
* @return void
* @since 3.2.0
*/
public function set(object &$item)
{
foreach ($this->keys as $target => $value)
{
// set the add target data
$item->{'add' . $target} =
(isset($item->{'add' . $target}) &&
JsonHelper::check($item->{'add' . $target})) ?
json_decode((string) $item->{'add' . $target}, true) :
null;
// only continue if there are values
if (ArrayHelper::check($item->{'add' . $target}))
{
if (isset($item->{$value})
&& ArrayHelper::check($item->{$value}))
{
foreach ($item->{'add' . $target} as $taget)
{
$item->{$value}[] = $taget;
}
}
else
{
$item->{$value} = array_values(
$item->{'add' . $target}
);
}
}
unset($item->{'add' . $target});
}
}
}
src/Componentbuilder/Compiler/Model/Historyadminview.php000064400000006450151162054160017542
0ustar00<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder
<https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights
reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
namespace VDM\Joomla\Componentbuilder\Compiler\Model;
use VDM\Joomla\Componentbuilder\Compiler\Factory as Compiler;
use VDM\Joomla\Componentbuilder\Compiler\Config;
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\HistoryInterface;
use VDM\Joomla\Componentbuilder\Compiler\Model\Updatesql;
use VDM\Joomla\Utilities\StringHelper;
/**
* Model Admin View History Class
*
* @since 3.2.0
*/
class Historyadminview
{
/**
* The compiler Config
*
* @var Config
* @since 3.2.0
*/
protected Config $config;
/**
* The compiler history
*
* @var HistoryInterface
* @since 3.2.0
*/
protected HistoryInterface $history;
/**
* The compiler update sql
*
* @var Updatesql
* @since 3.2.0
*/
protected Updatesql $updatesql;
/**
* Constructor
*
* @param Config|null $config The compiler config
object.
* @param HistoryInterface|null $history The compiler history
object.
* @param Updatesql|null $updatesql The compiler updatesql
object.
*
* @since 3.2.0
*/
public function __construct(?Config $config = null, ?HistoryInterface
$history = null,
?Updatesql $updatesql = null)
{
$this->config = $config ?: Compiler::_('Config');
$this->history = $history ?: Compiler::_('History');
$this->updatesql = $updatesql ?:
Compiler::_('Model.Updatesql');
}
/**
* check if an update SQL is needed
*
* @param object $item The item data
*
* @return void
* @since 3.2.0
*/
public function set(object &$item)
{
if (($old = $this->history->get('admin_view',
$item->id)) !== null)
{
// check if the view name changed
if (StringHelper::check($old->name_single))
{
$this->updatesql->set(
StringHelper::safe(
$old->name_single
), $item->name_single_code, 'table_name',
$item->name_single_code
);
}
// loop the mysql table settings
foreach ($this->config->mysql_table_keys as $mysql_table_key =>
$mysql_table_val)
{
// check if the table engine changed
if (isset($old->{'mysql_table_' . $mysql_table_key})
&& isset($item->{'mysql_table_' .
$mysql_table_key}))
{
$this->updatesql->set(
$old->{'mysql_table_' . $mysql_table_key},
$item->{'mysql_table_' . $mysql_table_key},
'table_' . $mysql_table_key, $item->name_single_code
);
}
// check if there is no history on table engine, and it changed from
the default/global
elseif (isset($item->{'mysql_table_' . $mysql_table_key})
&& StringHelper::check(
$item->{'mysql_table_' . $mysql_table_key}
)
&& !is_numeric(
$item->{'mysql_table_' . $mysql_table_key}
))
{
$this->updatesql->set(
$mysql_table_val['default'],
$item->{'mysql_table_' . $mysql_table_key},
'table_' . $mysql_table_key, $item->name_single_code
);
}
}
}
}
}
src/Componentbuilder/Compiler/Model/Historycomponent.php000064400000007356151162054160017567
0ustar00<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder
<https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights
reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
namespace VDM\Joomla\Componentbuilder\Compiler\Model;
use VDM\Joomla\Componentbuilder\Compiler\Factory as Compiler;
use VDM\Joomla\Componentbuilder\Compiler\Config;
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\HistoryInterface;
use VDM\Joomla\Componentbuilder\Compiler\Model\Updatesql;
use VDM\Joomla\Utilities\StringHelper;
use VDM\Joomla\Utilities\ObjectHelper;
use VDM\Joomla\Utilities\JsonHelper;
/**
* Model Component History Class
*
* @since 3.2.0
*/
class Historycomponent
{
/**
* The compiler Config
*
* @var Config
* @since 3.2.0
*/
protected Config $config;
/**
* The compiler history
*
* @var HistoryInterface
* @since 3.2.0
*/
protected HistoryInterface $history;
/**
* The compiler update sql
*
* @var Updatesql
* @since 3.2.0
*/
protected Updatesql $updatesql;
/**
* Constructor
*
* @param Config|null $config The compiler config
object.
* @param HistoryInterface|null $history The compiler history
object.
* @param Updatesql|null $updatesql The compiler updatesql
object.
*
* @since 3.2.0
*/
public function __construct(?Config $config = null, ?HistoryInterface
$history = null,
?Updatesql $updatesql = null)
{
$this->config = $config ?: Compiler::_('Config');
$this->history = $history ?: Compiler::_('History');
$this->updatesql = $updatesql ?:
Compiler::_('Model.Updatesql');
}
/**
* check if an update SQL is needed
*
* @param object $item The item data
*
* @return void
* @since 3.2.0
*/
public function set(object &$item)
{
// update SQL for admin views
$this->setAdminView($item);
// update SQL for component
$this->setComponent($item);
}
/**
* check if an update SQL is needed
*
* @param object $item The item data
*
* @return void
* @since 3.2.0
*/
private function setAdminView(object $item)
{
$old_admin_views = null;
if (isset($item->addadmin_views_id))
{
$old_admin_views = $this->history->get(
'component_admin_views', $item->addadmin_views_id
);
}
// add new views if found
if ($old_admin_views && ObjectHelper::check($old_admin_views))
{
if (isset($old_admin_views->addadmin_views)
&& JsonHelper::check(
$old_admin_views->addadmin_views
))
{
$this->updatesql->set(
json_decode((string) $old_admin_views->addadmin_views, true),
$item->addadmin_views, 'adminview'
);
}
}
}
/**
* Set the component history
*
* @param object $item The item data
*
* @return void
* @since 3.2.0
*/
private function setComponent(object &$item)
{
$old_component = null;
if (isset($this->config->component_id))
{
$old_component = $this->history->get(
'joomla_component', $this->config->component_id
);
}
// check if a new version was manually set
if ($old_component && ObjectHelper::check($old_component))
{
$old_component_version = preg_replace(
'/^v/i', '', (string)
$old_component->component_version
);
if ($old_component_version != $this->config->component_version)
{
// yes, this is a new version, this mean there may
// be manual sql and must be checked and updated
$item->old_component_version
= $old_component_version;
}
}
}
}
src/Componentbuilder/Compiler/Model/Javascriptadminview.php000064400000005506151162054160020210
0ustar00<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder
<https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights
reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
namespace VDM\Joomla\Componentbuilder\Compiler\Model;
use VDM\Joomla\Componentbuilder\Compiler\Factory as Compiler;
use VDM\Joomla\Componentbuilder\Compiler\Customcode\Dispenser;
use VDM\Joomla\Utilities\StringHelper;
/**
* Model Admin View Javascript Class
*
* @since 3.2.0
*/
class Javascriptadminview
{
/**
* The scripter add array
*
* @var array
* @since 3.2.0
*/
protected array $scripter = [
'javascript_view_file',
'javascript_view_footer',
'javascript_views_file',
'javascript_views_footer'
];
/**
* The gui mapper array
*
* @var array
* @since 3.2.0
*/
protected array $guiMapper = [
'table' => 'admin_view',
'id' => null,
'field' => null,
'type' => 'js',
'prefix' => PHP_EOL
];
/**
* Compiler Customcode Dispenser
*
* @var Dispenser
* @since 3.2.0
*/
protected Dispenser $dispenser;
/**
* Constructor
*
* @param Dispenser|null $dispenser The compiler customcode
dispenser
*
* @since 3.2.0
*/
public function __construct(?Dispenser $dispenser = null)
{
$this->dispenser = $dispenser ?:
Compiler::_('Customcode.Dispenser');
}
/**
* Set Admin View Javascript
*
* @param object $item The item data
* @param object $table The table
*
* @return void
* @since 3.2.0
*/
public function set(object &$item, string $table =
'admin_view')
{
// set some gui mapper values
$this->guiMapper['table'] = $table;
$this->guiMapper['id'] = (int) $item->id;
foreach ($this->scripter as $scripter)
{
if (isset($item->{'add_' . $scripter})
&& $item->{'add_' . $scripter} == 1
&& StringHelper::check($item->$scripter))
{
$scripter_target = str_replace(
'javascript_', '', (string) $scripter
);
// update GUI mapper field
$this->guiMapper['field'] = $scripter;
$this->dispenser->set(
$item->{$scripter},
$scripter_target,
$item->name_single_code,
null,
$this->guiMapper,
true,
true,
true
);
// check if a token must be set
if ((strpos((string) $item->$scripter, "token") !== false
|| strpos(
(string) $item->$scripter, "task=ajax"
) !== false) &&
!$this->dispenser->hub['token'][$item->name_single_code])
{
$this->dispenser->hub['token'][$item->name_single_code]
= true;
}
unset($item->{$scripter});
}
}
}
}
src/Componentbuilder/Compiler/Model/Javascriptcustomview.php000064400000005005151162054160020424
0ustar00<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder
<https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights
reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
namespace VDM\Joomla\Componentbuilder\Compiler\Model;
use VDM\Joomla\Componentbuilder\Compiler\Factory as Compiler;
use VDM\Joomla\Componentbuilder\Compiler\Customcode;
use VDM\Joomla\Componentbuilder\Compiler\Customcode\Gui;
use VDM\Joomla\Utilities\StringHelper;
/**
* Model Javascript Custom View Class
*
* @since 3.2.0
*/
class Javascriptcustomview
{
/**
* The areas add array
*
* @var array
* @since 3.2.0
*/
protected array $areas = [
'javascript_file',
'js_document'
];
/**
* The gui mapper array
*
* @var array
* @since 3.2.0
*/
protected array $guiMapper = [
'table' => null,
'id' => null,
'field' => null,
'type' => 'js'
];
/**
* Compiler Customcode
*
* @var Customcode
* @since 3.2.0
*/
protected Customcode $customcode;
/**
* Compiler Customcode in Gui
*
* @var Gui
* @since 3.2.0
**/
protected Gui $gui;
/**
* Constructor
*
* @param Customcode|null $customcode The compiler customcode
object.
* @param Gui|null $gui The compiler customcode
gui.
*
* @since 3.2.0
*/
public function __construct(?Customcode $customcode = null, ?Gui $gui =
null)
{
$this->customcode = $customcode ?:
Compiler::_('Customcode');
$this->gui = $gui ?: Compiler::_('Customcode.Gui');
}
/**
* Set Javascript code
*
* @param object $item The item data
* @param string $table The table
*
* @return void
* @since 3.2.0
*/
public function set(object &$item, string $table =
'site_view')
{
// set some gui mapper values
$this->guiMapper['table'] = $table;
$this->guiMapper['id'] = (int) $item->id;
foreach ($this->areas as $area)
{
if (isset($item->{'add_' . $area})
&& $item->{'add_' . $area} == 1
&& StringHelper::check($item->{$area}))
{
// update GUI mapper field
$this->guiMapper['field'] = $area;
$item->{$area} = $this->gui->set(
$this->customcode->update(
base64_decode((string) $item->{$area})
),
$this->guiMapper
);
}
}
}
}
src/Componentbuilder/Compiler/Model/JoomlaFive/Customtabs.php000064400000015121151162054160020347
0ustar00<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder
<https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights
reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
namespace VDM\Joomla\Componentbuilder\Compiler\Model\JoomlaFive;
use VDM\Joomla\Componentbuilder\Compiler\Config;
use VDM\Joomla\Componentbuilder\Compiler\Builder\CustomTabs as
BuilderCustomTabs;
use VDM\Joomla\Componentbuilder\Compiler\Language;
use VDM\Joomla\Componentbuilder\Compiler\Placeholder;
use VDM\Joomla\Componentbuilder\Compiler\Customcode;
use VDM\Joomla\Utilities\JsonHelper;
use VDM\Joomla\Utilities\ArrayHelper;
use VDM\Joomla\Utilities\StringHelper;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Indent;
use
VDM\Joomla\Componentbuilder\Compiler\Interfaces\Model\CustomtabsInterface;
/**
* Model Custom Tabs Class
*
* @since 3.2.0
*/
final class Customtabs implements CustomtabsInterface
{
/**
* The Config Class.
*
* @var Config
* @since 3.2.0
*/
protected Config $config;
/**
* The CustomTabs Class.
*
* @var BuilderCustomTabs
* @since 3.2.0
*/
protected BuilderCustomTabs $buildercustomtabs;
/**
* The Language Class.
*
* @var Language
* @since 3.2.0
*/
protected Language $language;
/**
* The Placeholder Class.
*
* @var Placeholder
* @since 3.2.0
*/
protected Placeholder $placeholder;
/**
* The Customcode Class.
*
* @var Customcode
* @since 3.2.0
*/
protected Customcode $customcode;
/**
* Constructor.
*
* @param Config $config The Config Class.
* @param BuilderCustomTabs $buildercustomtabs The CustomTabs Class.
* @param Language $language The Language Class.
* @param Placeholder $placeholder The Placeholder Class.
* @param Customcode $customcode The Customcode Class.
*
* @since 3.2.0
*/
public function __construct(Config $config, BuilderCustomTabs
$buildercustomtabs, Language $language, Placeholder $placeholder,
Customcode $customcode)
{
$this->config = $config;
$this->buildercustomtabs = $buildercustomtabs;
$this->language = $language;
$this->placeholder = $placeholder;
$this->customcode = $customcode;
}
/**
* Set custom tabs
*
* @param object $item The view data
*
* @return void
* @since 3.2.0
*/
public function set(object &$item)
{
$item->customtabs = (isset($item->customtabs)
&& JsonHelper::check($item->customtabs))
? json_decode((string) $item->customtabs, true) : null;
if (ArrayHelper::check($item->customtabs))
{
// get the name
$name = $item->name_single_code;
// setup custom tabs to global data sets
$this->buildercustomtabs->set($name,
array_map(
function ($tab) use (&$name) {
// set the view name
$tab['view'] = $name;
// load the dynamic data
$tab['html'] = $this->placeholder->update_(
$this->customcode->update($tab['html'])
);
// set the tab name
$tab['name'] = (isset($tab['name'])
&& StringHelper::check(
$tab['name']
)) ? $tab['name'] : 'Tab';
// set lang
$tab['lang'] = $this->config->lang_prefix .
'_'
. StringHelper::safe(
$tab['view'], 'U'
) . '_' . StringHelper::safe(
$tab['name'], 'U'
);
$this->language->set(
'both', $tab['lang'], $tab['name']
);
// set code name
$tab['code'] = StringHelper::safe(
$tab['name']
);
// check if the permissions for the tab should be added
$_tab = '';
if (isset($tab['permission'])
&& $tab['permission'] == 1)
{
$_tab = Indent::_(1);
}
// check if the php of the tab is set, if not load it now
if (strpos((string) $tab['html'], 'uitab.addTab')
=== false
&& strpos((string) $tab['html'],
'uitab.endTab')
=== false)
{
// add the tab
$tmp = PHP_EOL . $_tab . Indent::_(1)
. "<?php echo Html::_('uitab.addTab',
'"
. $tab['view'] . "Tab', '" .
$tab['code']
. "', JT" . "ext::_('" .
$tab['lang']
. "', true)); ?>";
$tmp .= PHP_EOL . $_tab . Indent::_(2)
. '<div class="row">';
$tmp .= PHP_EOL . $_tab . Indent::_(3)
. '<div class="col-md-12">';
$tmp .= PHP_EOL . $_tab . Indent::_(4) . implode(
PHP_EOL . $_tab . Indent::_(4),
(array) explode(PHP_EOL, trim((string) $tab['html']))
);
$tmp .= PHP_EOL . $_tab . Indent::_(3) . '</div>';
$tmp .= PHP_EOL . $_tab . Indent::_(2) . '</div>';
$tmp .= PHP_EOL . $_tab . Indent::_(1)
. "<?php echo Html::_('uitab.endTab');
?>";
// update html
$tab['html'] = $tmp;
}
else
{
$tab['html'] = PHP_EOL . $_tab . Indent::_(1)
. implode(
PHP_EOL . $_tab . Indent::_(1),
(array) explode(PHP_EOL, trim((string) $tab['html']))
);
}
// add the permissions if needed
if (isset($tab['permission'])
&& $tab['permission'] == 1)
{
$tmp = PHP_EOL . Indent::_(1)
. "<?php if (\$this->canDo->get('"
. $tab['view'] . "." . $tab['code']
. ".viewtab')) : ?>";
$tmp .= $tab['html'];
$tmp .= PHP_EOL . Indent::_(1) . "<?php endif; ?>";
// update html
$tab['html'] = $tmp;
// set lang for permissions
$tab['lang_permission'] = $tab['lang']
. '_TAB_PERMISSION';
$tab['lang_permission_desc'] = $tab['lang']
. '_TAB_PERMISSION_DESC';
$tab['lang_permission_title']
= $this->placeholder->get('Views') . ' View
'
. $tab['name'] . ' Tab';
$this->language->set(
'both', $tab['lang_permission'],
$tab['lang_permission_title']
);
$this->language->set(
'both', $tab['lang_permission_desc'],
'Allow the users in this group to view '
. $tab['name'] . ' Tab of '
. $this->placeholder->get('views')
);
// set the sort key
$tab['sortKey']
= StringHelper::safe(
$tab['lang_permission_title']
);
}
// return tab
return $tab;
}, array_values($item->customtabs)
)
);
}
unset($item->customtabs);
}
}
src/Componentbuilder/Compiler/Model/JoomlaFive/index.html000064400000000054151162054160017506
0ustar00<html><body
bgcolor="#FFFFFF"></body></html>src/Componentbuilder/Compiler/Model/JoomlaFour/Customtabs.php000064400000015121151162054160020371
0ustar00<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder
<https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights
reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
namespace VDM\Joomla\Componentbuilder\Compiler\Model\JoomlaFour;
use VDM\Joomla\Componentbuilder\Compiler\Config;
use VDM\Joomla\Componentbuilder\Compiler\Builder\CustomTabs as
BuilderCustomTabs;
use VDM\Joomla\Componentbuilder\Compiler\Language;
use VDM\Joomla\Componentbuilder\Compiler\Placeholder;
use VDM\Joomla\Componentbuilder\Compiler\Customcode;
use VDM\Joomla\Utilities\JsonHelper;
use VDM\Joomla\Utilities\ArrayHelper;
use VDM\Joomla\Utilities\StringHelper;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Indent;
use
VDM\Joomla\Componentbuilder\Compiler\Interfaces\Model\CustomtabsInterface;
/**
* Model Custom Tabs Class
*
* @since 3.2.0
*/
final class Customtabs implements CustomtabsInterface
{
/**
* The Config Class.
*
* @var Config
* @since 3.2.0
*/
protected Config $config;
/**
* The CustomTabs Class.
*
* @var BuilderCustomTabs
* @since 3.2.0
*/
protected BuilderCustomTabs $buildercustomtabs;
/**
* The Language Class.
*
* @var Language
* @since 3.2.0
*/
protected Language $language;
/**
* The Placeholder Class.
*
* @var Placeholder
* @since 3.2.0
*/
protected Placeholder $placeholder;
/**
* The Customcode Class.
*
* @var Customcode
* @since 3.2.0
*/
protected Customcode $customcode;
/**
* Constructor.
*
* @param Config $config The Config Class.
* @param BuilderCustomTabs $buildercustomtabs The CustomTabs Class.
* @param Language $language The Language Class.
* @param Placeholder $placeholder The Placeholder Class.
* @param Customcode $customcode The Customcode Class.
*
* @since 3.2.0
*/
public function __construct(Config $config, BuilderCustomTabs
$buildercustomtabs, Language $language, Placeholder $placeholder,
Customcode $customcode)
{
$this->config = $config;
$this->buildercustomtabs = $buildercustomtabs;
$this->language = $language;
$this->placeholder = $placeholder;
$this->customcode = $customcode;
}
/**
* Set custom tabs
*
* @param object $item The view data
*
* @return void
* @since 3.2.0
*/
public function set(object &$item)
{
$item->customtabs = (isset($item->customtabs)
&& JsonHelper::check($item->customtabs))
? json_decode((string) $item->customtabs, true) : null;
if (ArrayHelper::check($item->customtabs))
{
// get the name
$name = $item->name_single_code;
// setup custom tabs to global data sets
$this->buildercustomtabs->set($name,
array_map(
function ($tab) use (&$name) {
// set the view name
$tab['view'] = $name;
// load the dynamic data
$tab['html'] = $this->placeholder->update_(
$this->customcode->update($tab['html'])
);
// set the tab name
$tab['name'] = (isset($tab['name'])
&& StringHelper::check(
$tab['name']
)) ? $tab['name'] : 'Tab';
// set lang
$tab['lang'] = $this->config->lang_prefix .
'_'
. StringHelper::safe(
$tab['view'], 'U'
) . '_' . StringHelper::safe(
$tab['name'], 'U'
);
$this->language->set(
'both', $tab['lang'], $tab['name']
);
// set code name
$tab['code'] = StringHelper::safe(
$tab['name']
);
// check if the permissions for the tab should be added
$_tab = '';
if (isset($tab['permission'])
&& $tab['permission'] == 1)
{
$_tab = Indent::_(1);
}
// check if the php of the tab is set, if not load it now
if (strpos((string) $tab['html'], 'uitab.addTab')
=== false
&& strpos((string) $tab['html'],
'uitab.endTab')
=== false)
{
// add the tab
$tmp = PHP_EOL . $_tab . Indent::_(1)
. "<?php echo Html::_('uitab.addTab',
'"
. $tab['view'] . "Tab', '" .
$tab['code']
. "', JT" . "ext::_('" .
$tab['lang']
. "', true)); ?>";
$tmp .= PHP_EOL . $_tab . Indent::_(2)
. '<div class="row">';
$tmp .= PHP_EOL . $_tab . Indent::_(3)
. '<div class="col-md-12">';
$tmp .= PHP_EOL . $_tab . Indent::_(4) . implode(
PHP_EOL . $_tab . Indent::_(4),
(array) explode(PHP_EOL, trim((string) $tab['html']))
);
$tmp .= PHP_EOL . $_tab . Indent::_(3) . '</div>';
$tmp .= PHP_EOL . $_tab . Indent::_(2) . '</div>';
$tmp .= PHP_EOL . $_tab . Indent::_(1)
. "<?php echo Html::_('uitab.endTab');
?>";
// update html
$tab['html'] = $tmp;
}
else
{
$tab['html'] = PHP_EOL . $_tab . Indent::_(1)
. implode(
PHP_EOL . $_tab . Indent::_(1),
(array) explode(PHP_EOL, trim((string) $tab['html']))
);
}
// add the permissions if needed
if (isset($tab['permission'])
&& $tab['permission'] == 1)
{
$tmp = PHP_EOL . Indent::_(1)
. "<?php if (\$this->canDo->get('"
. $tab['view'] . "." . $tab['code']
. ".viewtab')) : ?>";
$tmp .= $tab['html'];
$tmp .= PHP_EOL . Indent::_(1) . "<?php endif; ?>";
// update html
$tab['html'] = $tmp;
// set lang for permissions
$tab['lang_permission'] = $tab['lang']
. '_TAB_PERMISSION';
$tab['lang_permission_desc'] = $tab['lang']
. '_TAB_PERMISSION_DESC';
$tab['lang_permission_title']
= $this->placeholder->get('Views') . ' View
'
. $tab['name'] . ' Tab';
$this->language->set(
'both', $tab['lang_permission'],
$tab['lang_permission_title']
);
$this->language->set(
'both', $tab['lang_permission_desc'],
'Allow the users in this group to view '
. $tab['name'] . ' Tab of '
. $this->placeholder->get('views')
);
// set the sort key
$tab['sortKey']
= StringHelper::safe(
$tab['lang_permission_title']
);
}
// return tab
return $tab;
}, array_values($item->customtabs)
)
);
}
unset($item->customtabs);
}
}
src/Componentbuilder/Compiler/Model/JoomlaFour/index.html000064400000000054151162054160017530
0ustar00<html><body
bgcolor="#FFFFFF"></body></html>src/Componentbuilder/Compiler/Model/JoomlaThree/Customtabs.php000064400000015175151162054160020536
0ustar00<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder
<https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights
reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
namespace VDM\Joomla\Componentbuilder\Compiler\Model\JoomlaThree;
use VDM\Joomla\Componentbuilder\Compiler\Config;
use VDM\Joomla\Componentbuilder\Compiler\Builder\CustomTabs as
BuilderCustomTabs;
use VDM\Joomla\Componentbuilder\Compiler\Language;
use VDM\Joomla\Componentbuilder\Compiler\Placeholder;
use VDM\Joomla\Componentbuilder\Compiler\Customcode;
use VDM\Joomla\Utilities\JsonHelper;
use VDM\Joomla\Utilities\ArrayHelper;
use VDM\Joomla\Utilities\StringHelper;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Indent;
use
VDM\Joomla\Componentbuilder\Compiler\Interfaces\Model\CustomtabsInterface;
/**
* Model Custom Tabs Class
*
* @since 3.2.0
*/
final class Customtabs implements CustomtabsInterface
{
/**
* The Config Class.
*
* @var Config
* @since 3.2.0
*/
protected Config $config;
/**
* The CustomTabs Class.
*
* @var BuilderCustomTabs
* @since 3.2.0
*/
protected BuilderCustomTabs $buildercustomtabs;
/**
* The Language Class.
*
* @var Language
* @since 3.2.0
*/
protected Language $language;
/**
* The Placeholder Class.
*
* @var Placeholder
* @since 3.2.0
*/
protected Placeholder $placeholder;
/**
* The Customcode Class.
*
* @var Customcode
* @since 3.2.0
*/
protected Customcode $customcode;
/**
* Constructor.
*
* @param Config $config The Config Class.
* @param BuilderCustomTabs $buildercustomtabs The CustomTabs Class.
* @param Language $language The Language Class.
* @param Placeholder $placeholder The Placeholder Class.
* @param Customcode $customcode The Customcode Class.
*
* @since 3.2.0
*/
public function __construct(Config $config, BuilderCustomTabs
$buildercustomtabs, Language $language, Placeholder $placeholder,
Customcode $customcode)
{
$this->config = $config;
$this->buildercustomtabs = $buildercustomtabs;
$this->language = $language;
$this->placeholder = $placeholder;
$this->customcode = $customcode;
}
/**
* Set custom tabs
*
* @param object $item The view data
*
* @return void
* @since 3.2.0
*/
public function set(object &$item)
{
$item->customtabs = (isset($item->customtabs)
&& JsonHelper::check($item->customtabs))
? json_decode((string) $item->customtabs, true) : null;
if (ArrayHelper::check($item->customtabs))
{
// get the name
$name = $item->name_single_code;
// setup custom tabs to global data sets
$this->buildercustomtabs->set($name,
array_map(
function ($tab) use (&$name) {
// set the view name
$tab['view'] = $name;
// load the dynamic data
$tab['html'] = $this->placeholder->update_(
$this->customcode->update($tab['html'])
);
// set the tab name
$tab['name'] = (isset($tab['name'])
&& StringHelper::check(
$tab['name']
)) ? $tab['name'] : 'Tab';
// set lang
$tab['lang'] = $this->config->lang_prefix .
'_'
. StringHelper::safe(
$tab['view'], 'U'
) . '_' . StringHelper::safe(
$tab['name'], 'U'
);
$this->language->set(
'both', $tab['lang'], $tab['name']
);
// set code name
$tab['code'] = StringHelper::safe(
$tab['name']
);
// check if the permissions for the tab should be added
$_tab = '';
if (isset($tab['permission'])
&& $tab['permission'] == 1)
{
$_tab = Indent::_(1);
}
// check if the php of the tab is set, if not load it now
if (strpos((string) $tab['html'],
'bootstrap.addTab') === false
&& strpos((string) $tab['html'],
'bootstrap.endTab')
=== false)
{
// add the tab
$tmp = PHP_EOL . $_tab . Indent::_(1)
. "<?php echo Html::_('bootstrap.addTab',
'"
. $tab['view'] . "Tab', '" .
$tab['code']
. "', JT" . "ext::_('" .
$tab['lang']
. "', true)); ?>";
$tmp .= PHP_EOL . $_tab . Indent::_(2)
. '<div class="row-fluid
form-horizontal-desktop">';
$tmp .= PHP_EOL . $_tab . Indent::_(3)
. '<div class="span12">';
$tmp .= PHP_EOL . $_tab . Indent::_(4) . implode(
PHP_EOL . $_tab . Indent::_(4),
(array) explode(PHP_EOL, trim((string) $tab['html']))
);
$tmp .= PHP_EOL . $_tab . Indent::_(3) . '</div>';
$tmp .= PHP_EOL . $_tab . Indent::_(2) . '</div>';
$tmp .= PHP_EOL . $_tab . Indent::_(1)
. "<?php echo Html::_('bootstrap.endTab');
?>";
// update html
$tab['html'] = $tmp;
}
else
{
$tab['html'] = PHP_EOL . $_tab . Indent::_(1)
. implode(
PHP_EOL . $_tab . Indent::_(1),
(array) explode(PHP_EOL, trim((string) $tab['html']))
);
}
// add the permissions if needed
if (isset($tab['permission'])
&& $tab['permission'] == 1)
{
$tmp = PHP_EOL . Indent::_(1)
. "<?php if (\$this->canDo->get('"
. $tab['view'] . "." . $tab['code']
. ".viewtab')) : ?>";
$tmp .= $tab['html'];
$tmp .= PHP_EOL . Indent::_(1) . "<?php endif; ?>";
// update html
$tab['html'] = $tmp;
// set lang for permissions
$tab['lang_permission'] = $tab['lang']
. '_TAB_PERMISSION';
$tab['lang_permission_desc'] = $tab['lang']
. '_TAB_PERMISSION_DESC';
$tab['lang_permission_title']
= $this->placeholder->get('Views') . ' View
'
. $tab['name'] . ' Tab';
$this->language->set(
'both', $tab['lang_permission'],
$tab['lang_permission_title']
);
$this->language->set(
'both', $tab['lang_permission_desc'],
'Allow the users in this group to view '
. $tab['name'] . ' Tab of '
. $this->placeholder->get('views')
);
// set the sort key
$tab['sortKey']
= StringHelper::safe(
$tab['lang_permission_title']
);
}
// return tab
return $tab;
}, array_values($item->customtabs)
)
);
}
unset($item->customtabs);
}
}
src/Componentbuilder/Compiler/Model/JoomlaThree/index.html000064400000000054151162054160017664
0ustar00<html><body
bgcolor="#FFFFFF"></body></html>src/Componentbuilder/Compiler/Model/Joomlamodules.php000064400000003714151162054160017007
0ustar00<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder
<https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights
reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
namespace VDM\Joomla\Componentbuilder\Compiler\Model;
use VDM\Joomla\Componentbuilder\Compiler\Factory as Compiler;
use VDM\Joomla\Componentbuilder\Compiler\Joomlamodule\Data as Module;
use VDM\Joomla\Utilities\ArrayHelper;
use VDM\Joomla\Utilities\JsonHelper;
/**
* Model Joomla Modules Class
*
* @since 3.2.0
*/
class Joomlamodules
{
/**
* Compiler Joomla Module Data Class
*
* @var Module
* @since 3.2.0
*/
protected Module $module;
/**
* Constructor
*
* @param Module|null $module The compiler Joomla module data
object.
*
* @since 3.2.0
*/
public function __construct(?Module $module = null)
{
$this->module = $module ?:
Compiler::_('Joomlamodule.Data');
}
/**
* Set Joomla Module
*
* @param object $item The item data
*
* @return void
* @since 3.2.0
*/
public function set(object &$item)
{
// get all modules
$item->addjoomla_modules = (isset($item->addjoomla_modules)
&& JsonHelper::check($item->addjoomla_modules))
? json_decode((string) $item->addjoomla_modules, true) : null;
if (ArrayHelper::check($item->addjoomla_modules))
{
$joomla_modules = array_map(
function ($array) use (&$item) {
// only load the modules whose target association calls for it
if (!isset($array['target']) || $array['target']
!= 2)
{
return $this->module->set(
$array['module'], $item
);
}
return null;
}, array_values($item->addjoomla_modules)
);
}
unset($item->addjoomla_modules);
}
}
src/Componentbuilder/Compiler/Model/Joomlaplugins.php000064400000003732151162054160017020
0ustar00<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder
<https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights
reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
namespace VDM\Joomla\Componentbuilder\Compiler\Model;
use VDM\Joomla\Componentbuilder\Compiler\Factory as Compiler;
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\PluginDataInterface as
Plugin;
use VDM\Joomla\Utilities\ArrayHelper;
use VDM\Joomla\Utilities\JsonHelper;
/**
* Model Joomla Plugins Class
*
* @since 3.2.0
*/
class Joomlaplugins
{
/**
* Compiler Joomla Plugin Data Class
*
* @var Plugin
* @since 3.2.0
*/
protected Plugin $plugin;
/**
* Constructor
*
* @param Plugin|null $plugin The compiler Joomla plugin data
object.
*
* @since 3.2.0
*/
public function __construct(?Plugin $plugin = null)
{
$this->plugin = $plugin ?:
Compiler::_('Joomlaplugin.Data');
}
/**
* Set Joomla Plugins
*
* @param object $item The item data
*
* @return void
* @since 3.2.0
*/
public function set(object &$item)
{
// get all plugins
$item->addjoomla_plugins = (isset($item->addjoomla_plugins)
&& JsonHelper::check($item->addjoomla_plugins))
? json_decode((string) $item->addjoomla_plugins, true) : null;
if (ArrayHelper::check($item->addjoomla_plugins))
{
$joomla_plugins = array_map(
function ($array) use (&$item) {
// only load the plugins whose target association calls for it
if (!isset($array['target']) || $array['target']
!= 2)
{
return $this->plugin->set(
$array['plugin'], $item
);
}
return null;
}, array_values($item->addjoomla_plugins)
);
}
unset($item->addjoomla_plugins);
}
}
src/Componentbuilder/Compiler/Model/Libraries.php000064400000005517151162054160016114
0ustar00<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder
<https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights
reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
namespace VDM\Joomla\Componentbuilder\Compiler\Model;
use VDM\Joomla\Componentbuilder\Compiler\Factory as Compiler;
use VDM\Joomla\Componentbuilder\Compiler\Config;
use VDM\Joomla\Componentbuilder\Compiler\Builder\LibraryManager;
use VDM\Joomla\Componentbuilder\Compiler\Library\Data as Library;
use VDM\Joomla\Utilities\JsonHelper;
use VDM\Joomla\Utilities\ArrayHelper;
/**
* Model Libraries Class
*
* @since 3.2.0
*/
class Libraries
{
/**
* The Config Class.
*
* @var Config
* @since 3.2.0
*/
protected Config $config;
/**
* The LibraryManager Class.
*
* @var LibraryManager
* @since 3.2.0
*/
protected LibraryManager $librarymanager;
/**
* The Data Class.
*
* @var Library
* @since 3.2.0
*/
protected Library $library;
/**
* Constructor.
*
* @param Config $config The Config Class.
* @param LibraryManager $librarymanager The LibraryManager Class.
* @param Library $library The Data Class.
*
* @since 3.2.0
*/
public function __construct(Config $config, LibraryManager
$librarymanager, Library $library)
{
$this->config = $config;
$this->librarymanager = $librarymanager;
$this->library = $library;
}
/**
* Set Libraries
*
* @param string $key The key mapper
* @param object $item The item data
* @param string|null $target The area being targeted
*
* @return void
* @since 3.2.0
*/
public function set(string $key, object &$item, string $target =
null)
{
// set the target
$target = $target ?: $this->config->build_target;
// make sure json become array
if (JsonHelper::check($item->libraries))
{
$item->libraries = json_decode((string) $item->libraries, true);
}
// if we have an array add it
if (ArrayHelper::check($item->libraries))
{
foreach ($item->libraries as $library)
{
if (!$this->librarymanager->exists($target . '.' . $key
. '.' . (int) $library)
&& $this->library->get((int) $library))
{
$this->librarymanager->set($target . '.' . $key .
'.' . (int) $library, true);
}
}
}
elseif (is_numeric($item->libraries)
&& !$this->librarymanager->exists($target . '.'
. $key . '.' . (int) $item->libraries)
&& $this->library->get((int) $item->libraries))
{
$this->librarymanager->set($target . '.' . $key .
'.' . (int) $item->libraries, true);
}
}
}
src/Componentbuilder/Compiler/Model/Linkedviews.php000064400000003323151162054160016455
0ustar00<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder
<https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights
reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
namespace VDM\Joomla\Componentbuilder\Compiler\Model;
use VDM\Joomla\Componentbuilder\Compiler\Factory as Compiler;
use VDM\Joomla\Componentbuilder\Compiler\Registry;
use VDM\Joomla\Utilities\JsonHelper;
use VDM\Joomla\Utilities\ArrayHelper;
/**
* Model Linked Views Class
*
* @since 3.2.0
*/
class Linkedviews
{
/**
* The compiler registry
*
* @var Registry
* @since 3.2.0
*/
protected Registry $registry;
/**
* Constructor
*
* @param Registry|null $registry The compiler registry object.
*
* @since 3.2.0
*/
public function __construct(?Registry $registry = null)
{
$this->registry = $registry ?: Compiler::_('Registry');
}
/**
* Set the linked views
*
* @param object $item The view data
*
* @return void
* @since 3.2.0
*/
public function set(object &$item)
{
$item->addlinked_views = (isset($item->addlinked_views)
&& JsonHelper::check($item->addlinked_views))
? json_decode((string) $item->addlinked_views, true) : null;
if (ArrayHelper::check($item->addlinked_views))
{
// setup linked views to global data sets
$this->registry->set('builder.linked_admin_views.' .
$item->name_single_code,
array_values(
$item->addlinked_views
)
);
}
unset($item->addlinked_views);
}
}
src/Componentbuilder/Compiler/Model/Loader.php000064400000011651151162054160015402
0ustar00<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder
<https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights
reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
namespace VDM\Joomla\Componentbuilder\Compiler\Model;
use VDM\Joomla\Componentbuilder\Compiler\Config;
use VDM\Joomla\Componentbuilder\Compiler\Builder\FootableScripts;
use VDM\Joomla\Componentbuilder\Compiler\Builder\GoogleChart;
use VDM\Joomla\Componentbuilder\Compiler\Builder\GetModule;
use VDM\Joomla\Componentbuilder\Compiler\Builder\UikitComp;
use VDM\Joomla\Utilities\Component\Helper;
/**
* Model Auto Loader Class
*
* @since 3.2.0
*/
class Loader
{
/**
* The Config Class.
*
* @var Config
* @since 3.2.0
*/
protected Config $config;
/**
* The FootableScripts Class.
*
* @var FootableScripts
* @since 3.2.0
*/
protected FootableScripts $footablescripts;
/**
* The GoogleChart Class.
*
* @var GoogleChart
* @since 3.2.0
*/
protected GoogleChart $googlechart;
/**
* The GetModule Class.
*
* @var GetModule
* @since 3.2.0
*/
protected GetModule $getmodule;
/**
* The UikitComp Class.
*
* @var UikitComp
* @since 3.2.0
*/
protected UikitComp $uikitcomp;
/**
* Constructor.
*
* @param Config $config The Config Class.
* @param FootableScripts $footablescripts The FootableScripts Class.
* @param GoogleChart $googlechart The GoogleChart Class.
* @param GetModule $getmodule The GetModule Class.
* @param UikitComp $uikitcomp The UikitComp Class.
*
* @since 3.2.0
*/
public function __construct(Config $config, FootableScripts
$footablescripts,
GoogleChart $googlechart, GetModule $getmodule, UikitComp $uikitcomp)
{
$this->config = $config;
$this->footablescripts = $footablescripts;
$this->googlechart = $googlechart;
$this->getmodule = $getmodule;
$this->uikitcomp = $uikitcomp;
}
/**
* Automatically load some stuff
*
* @param string $key The key mapper
* @param string $content The content to search through
* @param string|null $target The area being targeted
*
* @return void
* @since 3.2.0
*/
public function set(string $key, string $content, ?string $target = null)
{
// set the target
$target = $target ?: $this->config->build_target;
// check for footable
if (!$this->footablescripts->exists($target . '.' .
$key))
{
if ($this->getFootableScripts($content))
{
$this->footablescripts->set($target . '.' . $key,
true);
$this->config->set('footable', true);
}
}
// check for google chart
if (!$this->googlechart->exists($target . '.' . $key))
{
if ($this->getGoogleChart($content))
{
$this->googlechart->set($target . '.' . $key, true);
$this->config->set('google_chart', true);
}
}
// check for get module
if (!$this->getmodule->exists($target . '.' . $key))
{
if ($this->getGetModule($content))
{
$this->getmodule->set($target . '.' . $key, true);
}
}
}
/**
* Automatically load uikit version 2 data files
*
* @param string $key The key mapper
* @param string $content The content to search through
*
* @return void
* @since 3.2.0
*/
public function uikit(string $key, string $content)
{
// get/set uikit state
$uikit = false;
$uikit_ = $this->config->get('uikit', 0);
// add uikit if required
if (2 == $uikit_ || 1 == $uikit_)
{
$uikit = true;
}
// load uikit
if ($uikit)
{
// set uikit to views TODO: convert this getUikitComp to a class
if (($found = Helper::_('getUikitComp',
[$content, $this->uikitcomp->get($key, [])]
)) !== false)
{
$this->uikitcomp->set($key, $found);
}
}
}
/**
* Check for footable scripts
*
* @param string $content The content to check
*
* @return boolean True if found
* @since 3.2.0
*/
protected function getFootableScripts(string &$content): bool
{
return strpos($content, 'footable') !== false;
}
/**
* Check for getModules script
*
* @param string $content The content to check
*
* @return boolean True if found
* @since 3.2.0
*/
protected function getGetModule(string &$content): bool
{
return strpos($content, 'this->getModules(') !== false;
}
/**
* Check for get Google Chart script
*
* @param string $content The content to check
*
* @return boolean True if found
* @since 3.2.0
*/
protected function getGoogleChart(string &$content): bool
{
return strpos($content, 'Chartbuilder(') !== false;
}
}
src/Componentbuilder/Compiler/Model/Modifieddate.php000064400000011101151162054160016540
0ustar00<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder
<https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights
reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
namespace VDM\Joomla\Componentbuilder\Compiler\Model;
use Joomla\CMS\Factory;
use VDM\Joomla\Utilities\StringHelper;
use VDM\Joomla\Utilities\ArrayHelper;
use VDM\Joomla\Utilities\ObjectHelper;
/**
* Model - Get Modified Date
*
* @since 3.2.0
*/
class Modifieddate
{
/**
* The array of last modified dates
*
* @var array
* @since 3.2.0
*/
protected array $last = [];
/**
* Get the last modified date of an item
*
* @param array $item The item data
*
* @return string The modified date
* @since 3.2.0
*/
public function get(array $item): string
{
$key = $this->getKey($item);
if (!isset($this->last[$key]))
{
$date = max($this->getDate($item), $this->getModified($item));
$this->last[$key] = Factory::getDate($date)->format(
'jS F, Y'
);
}
return $this->last[$key];
}
/**
* Get the last modified date of an item
*
* @param array|object $item The item data
*
* @return int The modified date as int
* @since 3.2.0
*/
protected function getDate($item): int
{
if (is_array($item) && isset($item['settings'])
&& isset($item['settings']->modified)
&&
StringHelper::check($item['settings']->modified)
&& '0000-00-00 00:00:00' !==
$item['settings']->modified)
{
return strtotime((string) $item['settings']->modified);
}
elseif (is_object($item) && isset($item->modified)
&& StringHelper::check($item->modified)
&& '0000-00-00 00:00:00' !== $item->modified)
{
return strtotime((string) $item->modified);
}
return strtotime("now");
}
/**
* Get the last modified date of an item's sub items
*
* @param array|object $item The item data
*
* @return int The modified date as int
* @since 3.2.0
*/
protected function getModified($item): int
{
$date = 0;
// if not settings is found
if (!is_array($item) || !isset($item['settings']) ||
!ObjectHelper::check($item['settings']))
{
return $date;
}
// check if we have fields
if (isset($item['settings']->fields) &&
ArrayHelper::check($item['settings']->fields))
{
foreach ($item['settings']->fields as $field)
{
if (isset($field['settings'])
&& ObjectHelper::check($field['settings'])
&& isset($field['settings']->modified)
&&
StringHelper::check($field['settings']->modified)
&& '0000-00-00 00:00:00' !==
$field['settings']->modified)
{
$modified = strtotime((string)
$field['settings']->modified);
$date = max($date, $modified);
}
}
}
// check if we have a main dynamic get
elseif (isset($item['settings']->main_get)
&&
ObjectHelper::check($item['settings']->main_get)
&& isset($item['settings']->main_get->modified)
&&
StringHelper::check($item['settings']->main_get->modified)
&& '0000-00-00 00:00:00' !==
$item['settings']->main_get->modified)
{
$modified = strtotime((string)
$item['settings']->main_get->modified);
$date = max($date, $modified);
}
return $date;
}
/**
* Get the key for an item
*
* @param array|object $item The item data
*
* @return string The key
* @since 3.2.0
*/
protected function getKey($item): string
{
if (is_array($item))
{
return $this->getKeyFromArray($item);
}
elseif (is_object($item))
{
return $this->getKeyFromObject($item);
}
return 'error';
}
/**
* Get the key for an item (array)
*
* @param array $item The item data
*
* @return string The key
* @since 3.2.0
*/
protected function getKeyFromArray(array $item): string
{
if (isset($item['adminview']))
{
return $item['adminview'] . 'admin';
}
elseif (isset($item['siteview']))
{
return $item['siteview'] . 'site';
}
elseif (isset($item['customadminview']))
{
return $item['customadminview'] . 'customadmin';
}
return 'error';
}
/**
* Get the key for an item (object)
*
* @param object $item The item data
*
* @return string The key
* @since 3.2.0
*/
protected function getKeyFromObject(object $item): string
{
if (isset($item->key))
{
return $item->key;
}
return 'error';
}
}
src/Componentbuilder/Compiler/Model/Mysqlsettings.php000064400000004276151162054160017067
0ustar00<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder
<https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights
reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
namespace VDM\Joomla\Componentbuilder\Compiler\Model;
use VDM\Joomla\Componentbuilder\Compiler\Config;
use VDM\Joomla\Componentbuilder\Compiler\Builder\MysqlTableSetting;
use VDM\Joomla\Utilities\StringHelper;
/**
* Model MySQL Settings Class
*
* @since 3.2.0
*/
class Mysqlsettings
{
/**
* The Config Class.
*
* @var Config
* @since 3.2.0
*/
protected Config $config;
/**
* The MysqlTableSetting Class.
*
* @var MysqlTableSetting
* @since 3.2.0
*/
protected MysqlTableSetting $mysqltablesetting;
/**
* Constructor.
*
* @param Config $config The Config Class.
* @param MysqlTableSetting $mysqltablesetting The MysqlTableSetting
Class.
*
* @since 3.2.0
*/
public function __construct(Config $config, MysqlTableSetting
$mysqltablesetting)
{
$this->config = $config;
$this->mysqltablesetting = $mysqltablesetting;
}
/**
* Set MySQL table settings
*
* @param object $item The item data
*
* @return void
* @since 3.2.0
*/
public function set(object &$item)
{
foreach ($this->config->mysql_table_keys as $mysql_table_key =>
$mysql_table_val)
{
if (isset($item->{'mysql_table_' . $mysql_table_key})
&& StringHelper::check($item->{'mysql_table_' .
$mysql_table_key})
&& !is_numeric($item->{'mysql_table_' .
$mysql_table_key}))
{
$this->mysqltablesetting->set($item->name_single_code .
'.' .
$mysql_table_key, $item->{'mysql_table_' .
$mysql_table_key}
);
}
else
{
$this->mysqltablesetting->set($item->name_single_code .
'.' .
$mysql_table_key, $mysql_table_val['default']
);
}
// remove the table values since we moved to another object
unset($item->{'mysql_table_' . $mysql_table_key});
}
}
}
src/Componentbuilder/Compiler/Model/Permissions.php000064400000003017151162054160016504
0ustar00<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder
<https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights
reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
namespace VDM\Joomla\Componentbuilder\Compiler\Model;
use VDM\Joomla\Utilities\JsonHelper;
use VDM\Joomla\Utilities\ArrayHelper;
/**
* Model Permissions Class
*
* @since 3.2.0
*/
class Permissions
{
/**
* Set the local tabs
*
* @param object $item The view data
*
* @return void
* @since 3.2.0
*/
public function set(object &$item)
{
$item->addpermissions = (isset($item->addpermissions)
&& JsonHelper::check($item->addpermissions))
? json_decode((string) $item->addpermissions, true) : null;
if (ArrayHelper::check($item->addpermissions))
{
if (isset($item->addpermissions["action"]) &&
is_array($item->addpermissions["action"])
&& isset($item->addpermissions["implementation"])
&& is_array($item->addpermissions["implementation"]))
{
foreach ($item->addpermissions["action"] as $k =>
$action)
{
$item->permissions[] = ['action' => $action,
'implementation' =>
$item->addpermissions["implementation"][$k]];
}
}
else
{
$item->permissions = array_values($item->addpermissions);
}
}
unset($item->addpermissions);
}
}
src/Componentbuilder/Compiler/Model/Phpadminview.php000064400000006056151162054160016632
0ustar00<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder
<https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights
reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
namespace VDM\Joomla\Componentbuilder\Compiler\Model;
use VDM\Joomla\Componentbuilder\Compiler\Factory as Compiler;
use VDM\Joomla\Componentbuilder\Compiler\Customcode\Dispenser;
use VDM\Joomla\Componentbuilder\Compiler\Templatelayout\Data as
Templatelayout;
/**
* Model PHP Admin View Class
*
* @since 3.2.0
*/
class Phpadminview
{
/**
* The areas add array
*
* @var array
* @since 3.2.0
*/
protected array $areas = [
'php_getitem',
'php_before_save',
'php_save',
'php_getform',
'php_postsavehook',
'php_getitems',
'php_getitems_after_all',
'php_getlistquery',
'php_allowadd',
'php_allowedit',
'php_before_cancel',
'php_after_cancel',
'php_before_delete',
'php_after_delete',
'php_before_publish',
'php_after_publish',
'php_batchcopy',
'php_batchmove',
'php_document'
];
/**
* The gui mapper array
*
* @var array
* @since 3.2.0
*/
protected array $guiMapper = [
'table' => 'admin_view',
'id' => null,
'field' => null,
'type' => 'php'
];
/**
* Compiler Customcode Dispenser
*
* @var Dispenser
* @since 3.2.0
*/
protected Dispenser $dispenser;
/**
* Compiler Template Layout Data
*
* @var Templatelayout
* @since 3.2.0
*/
protected Templatelayout $templateLayout;
/**
* Constructor
*
* @param Dispenser|null $dispenser The compiler
customcode dispenser
* @param Templatelayout|null $templateLayout The template layout
data
*
* @since 3.2.0
*/
public function __construct(?Dispenser $dispenser = null, ?Templatelayout
$templateLayout = null)
{
$this->dispenser = $dispenser ?:
Compiler::_('Customcode.Dispenser');
$this->templateLayout = $templateLayout ?:
Compiler::_('Templatelayout.Data');
}
/**
* Set PHP code
*
* @param object $item The item data
* @param string $table The table
*
* @return void
* @since 3.2.0
*/
public function set(object &$item, string $table =
'admin_view')
{
// set some gui mapper values
$this->guiMapper['table'] = $table;
$this->guiMapper['id'] = (int) $item->id;
foreach ($this->areas as $area)
{
if (isset($item->{'add_' . $area})
&& $item->{'add_' . $area} == 1)
{
// update GUI mapper field
$this->guiMapper['field'] = $area;
$this->dispenser->set(
$item->{$area},
$area,
$item->name_single_code,
null,
$this->guiMapper
);
// check if we have template or layouts to load
$this->templateLayout->set(
$item->{$area}, $item->name_single_code
);
unset($item->{$area});
}
}
}
}
src/Componentbuilder/Compiler/Model/Phpcustomview.php000064400000007054151162054160017053
0ustar00<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder
<https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights
reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
namespace VDM\Joomla\Componentbuilder\Compiler\Model;
use VDM\Joomla\Componentbuilder\Compiler\Factory as Compiler;
use VDM\Joomla\Componentbuilder\Compiler\Customcode;
use VDM\Joomla\Componentbuilder\Compiler\Customcode\Gui;
use VDM\Joomla\Componentbuilder\Compiler\Model\Loader;
use VDM\Joomla\Componentbuilder\Compiler\Templatelayout\Data as
Templatelayout;
use VDM\Joomla\Utilities\StringHelper;
/**
* Model PHP Custom View Class
*
* @since 3.2.0
*/
class Phpcustomview
{
/**
* The areas add array
*
* @var array
* @since 3.2.0
*/
protected array $areas = [
'php_view',
'php_jview',
'php_jview_display',
'php_document'
];
/**
* The gui mapper array
*
* @var array
* @since 3.2.0
*/
protected array $guiMapper = [
'table' => null,
'id' => null,
'field' => null,
'type' => 'php'
];
/**
* Compiler Customcode
*
* @var Customcode
* @since 3.2.0
*/
protected Customcode $customcode;
/**
* Compiler Customcode in Gui
*
* @var Gui
* @since 3.2.0
**/
protected Gui $gui;
/**
* Compiler Auto Loader
*
* @var Loader
* @since 3.2.0
*/
protected Loader $loader;
/**
* Compiler Template Layout Data
*
* @var Templatelayout
* @since 3.2.0
*/
protected Templatelayout $templateLayout;
/**
* Constructor
*
* @param Customcode|null $customcode The compiler customcode
object.
* @param Gui|null $gui The compiler customcode
gui.
* @param Loader|null $loader The compiler loader
object.
* @param Templatelayout|null $templateLayout The template layout
data.
*
* @since 3.2.0
*/
public function __construct(?Customcode $customcode = null, ?Gui $gui =
null,
?Loader $loader = null, ?Templatelayout $templateLayout = null)
{
$this->customcode = $customcode ?:
Compiler::_('Customcode');
$this->gui = $gui ?: Compiler::_('Customcode.Gui');
$this->loader = $loader ?: Compiler::_('Model.Loader');
$this->templateLayout = $templateLayout ?:
Compiler::_('Templatelayout.Data');
}
/**
* Set PHP code
*
* @param object $item The item data
* @param string $table The table
*
* @return void
* @since 3.2.0
*/
public function set(object &$item, string $table =
'site_view')
{
// set some gui mapper values
$this->guiMapper['table'] = $table;
$this->guiMapper['id'] = (int) $item->id;
foreach ($this->areas as $area)
{
if (isset($item->{'add_' . $area})
&& $item->{'add_' . $area} == 1
&& StringHelper::check($item->$area))
{
// update GUI mapper field
$this->guiMapper['field'] = $area;
$item->{$area} = $this->gui->set(
$this->customcode->update(
base64_decode((string) $item->{$area})
),
$this->guiMapper
);
// check if we have template or layouts to load
$this->templateLayout->set(
$item->{$area}, $item->code
);
// auto loaders
$this->loader->set($item->code, $item->{$area});
// set uikit version 2
$this->loader->uikit($item->code, $item->{$area});
}
}
}
}
src/Componentbuilder/Compiler/Model/Relations.php000064400000012140151162054160016126
0ustar00<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder
<https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights
reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
namespace VDM\Joomla\Componentbuilder\Compiler\Model;
use VDM\Joomla\Componentbuilder\Compiler\Config;
use VDM\Joomla\Componentbuilder\Compiler\Language;
use VDM\Joomla\Componentbuilder\Compiler\Customcode;
use VDM\Joomla\Componentbuilder\Compiler\Builder\ListJoin;
use VDM\Joomla\Componentbuilder\Compiler\Builder\ListHeadOverride;
use VDM\Joomla\Componentbuilder\Compiler\Builder\FieldRelations;
use VDM\Joomla\Utilities\JsonHelper;
use VDM\Joomla\Utilities\ArrayHelper;
use VDM\Joomla\Utilities\StringHelper;
/**
* Model Relations Class
*
* @since 3.2.0
*/
class Relations
{
/**
* 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 Customcode Class.
*
* @var Customcode
* @since 3.2.0
*/
protected Customcode $customcode;
/**
* The ListJoin Class.
*
* @var ListJoin
* @since 3.2.0
*/
protected ListJoin $listjoin;
/**
* The ListHeadOverride Class.
*
* @var ListHeadOverride
* @since 3.2.0
*/
protected ListHeadOverride $listheadoverride;
/**
* The FieldRelations Class.
*
* @var FieldRelations
* @since 3.2.0
*/
protected FieldRelations $fieldrelations;
/**
* Constructor.
*
* @param Config $config The Config Class.
* @param Language $language The Language Class.
* @param Customcode $customcode The Customcode Class.
* @param ListJoin $listjoin The ListJoin Class.
* @param ListHeadOverride $listheadoverride The ListHeadOverride
Class.
* @param FieldRelations $fieldrelations The FieldRelations
Class.
*
* @since 3.2.0
*/
public function __construct(Config $config, Language $language, Customcode
$customcode, ListJoin $listjoin,
ListHeadOverride $listheadoverride, FieldRelations $fieldrelations)
{
$this->config = $config;
$this->language = $language;
$this->customcode = $customcode;
$this->listjoin = $listjoin;
$this->listheadoverride = $listheadoverride;
$this->fieldrelations = $fieldrelations;
}
/**
* Set the relations
*
* @param object $item The view data
*
* @return void
* @since 3.2.0
*/
public function set(object &$item)
{
$item->addrelations = (isset($item->addrelations)
&& JsonHelper::check($item->addrelations))
? json_decode((string) $item->addrelations, true) : null;
if (ArrayHelper::check($item->addrelations))
{
foreach ($item->addrelations as $nr => $relationsValue)
{
// only add if list view field is selected and joined fields are set
if (isset($relationsValue['listfield'])
&& is_numeric(
$relationsValue['listfield']
)
&& $relationsValue['listfield'] > 0
&& isset($relationsValue['area'])
&& is_numeric($relationsValue['area'])
&& $relationsValue['area'] > 0)
{
// do a dynamic update on the set values
if (isset($relationsValue['set'])
&& StringHelper::check(
$relationsValue['set']
))
{
$relationsValue['set'] = $this->customcode->update(
$relationsValue['set']
);
}
// load the field relations
$this->fieldrelations->set($item->name_list_code .
'.' . (int) $relationsValue['listfield']
. '.' . (int) $relationsValue['area'],
$relationsValue);
// load the list joints
if (isset($relationsValue['joinfields'])
&& ArrayHelper::check(
$relationsValue['joinfields']
))
{
foreach ($relationsValue['joinfields'] as $join)
{
$this->listjoin->set($item->name_list_code . '.'
. (int) $join, (int) $join);
}
}
// set header over-ride
if (isset($relationsValue['column_name'])
&& StringHelper::check(
$relationsValue['column_name']
))
{
$check_column_name = trim(
strtolower((string) $relationsValue['column_name'])
);
// confirm it should really make the over ride
if ('default' !== $check_column_name)
{
$column_name_lang = $this->config->lang_prefix .
'_'
. StringHelper::safe(
$item->name_list_code, 'U'
) . '_' . StringHelper::safe(
$relationsValue['column_name'], 'U'
);
$this->language->set(
'admin', $column_name_lang,
$relationsValue['column_name']
);
$this->listheadoverride->
set($item->name_list_code . '.' . (int)
$relationsValue['listfield'],
$column_name_lang
);
}
}
}
}
}
unset($item->addrelations);
}
}
src/Componentbuilder/Compiler/Model/Router.php000064400000022106151162054160015451
0ustar00<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder
<https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights
reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
namespace VDM\Joomla\Componentbuilder\Compiler\Model;
use VDM\Joomla\Componentbuilder\Compiler\Config;
use VDM\Joomla\Componentbuilder\Compiler\Customcode\Dispenser;
use VDM\Joomla\Componentbuilder\Compiler\Builder\Router as Builder;
use VDM\Joomla\Utilities\ArrayHelper;
use VDM\Joomla\Utilities\StringHelper;
use VDM\Joomla\Utilities\JsonHelper;
/**
* Model Component Site Router Class
*
* @since 3.2.0
*/
class Router
{
/**
* The Config Class.
*
* @var Config
* @since 3.2.0
*/
protected Config $config;
/**
* The Dispenser Class.
*
* @var Dispenser
* @since 3.2.0
*/
protected Dispenser $dispenser;
/**
* The Router Class.
*
* @var Builder
* @since 3.2.0
*/
protected Builder $builder;
/**
* The gui mapper array
*
* @var array
* @since 3.2.0
*/
protected array $guiMapper = [
'table' => 'component_router',
'id' => null,
'field' => null,
'type' => 'php'
];
/**
* The field targets
*
* @var array
* @since 3.2.0
*/
protected array $targets = [
'before' => 'constructor_before_parent',
'after' => 'constructor_after_parent',
'method' => 'methods'
];
/**
* Constructor.
*
* @param Config $config The Config Class.
* @param Dispenser $dispenser The Dispenser Class.
* @param Builder $builder The Router Class.
*
* @since 3.2.0
*/
public function __construct(Config $config, Dispenser $dispenser, Builder
$builder)
{
$this->config = $config;
$this->dispenser = $dispenser;
$this->builder = $builder;
}
/**
* Set Router
*
* @param object $item The item data
*
* @return void
* @since 3.2.0
*/
public function set(object &$item)
{
$this->config->lang_target = 'site';
foreach ($this->targets as $target)
{
// add the code
if ($item->{"router_mode_{$target}"} == 3
&&
StringHelper::check($item->{"router_{$target}_code"}))
{
// update GUI mapper field
$this->guiMapper['field'] = "{$target}_code";
$this->dispenser->set(
$item->{"router_{$target}_code"},
"_site_router_",
$target,
null,
$this->guiMapper
);
}
unset($item->{"router_{$target}_code"});
}
// get the site views
$views = $this->getSiteViews($item->site_views ?? [],
$item->admin_views ?? []);
$edit_views = $this->getSiteEditViews($item->admin_views);
// get the edit site views
$this->builder->set('views',
ArrayHelper::merge([$views, $edit_views])
);
if ($item->router_mode_constructor_before_parent == 2
&&
JsonHelper::check($item->router_constructor_before_parent_manual))
{
// build and validate the constructor before parent call code
$this->builder->set('manual',
json_decode($item->router_constructor_before_parent_manual)
);
}
// clear the data from the item
foreach ($this->targets as $key => $target)
{
// set the modes
$this->builder->set("mode_{$key}",
(int) $item->{"router_mode_{$target}"}
);
unset($item->{"router_mode_{$target}"});
}
unset($item->router_constructor_before_parent_manual);
}
/**
* Get the array of site views with additional details.
*
* This method processes each site view to enrich it with additional
details such as the associated table,
* alias keys, and other relevant information. The enrichment is based on
the view's settings and the admin views.
*
* @param array $siteViews The site views to be processed.
* @param array $adminViews The admin views used for fetching additional
data.
*
* @return array An array of objects, each representing a site view with
enriched details.
* @since 3.2.0
*/
protected function getSiteViews(array $siteViews, array $adminViews):
array
{
return array_map(function ($view) use ($adminViews) {
// Attempt to get the main selection details from the view's
settings.
$selection =
$this->getMainSelection($view['settings']->main_get->main_get
?? null);
// We can only work with ID if the [main get] is a [getItem] dynamicGet
for this site view.
$key = ($view['settings']->main_get->gettype == 1) ?
'id' : null;
$view_selected = $selection['view'] ?? null;
$name_selected = $selection['name'] ?? null;
// Construct the enriched view object.
return (object) [
'view' => $view['settings']->code,
'View' => $view['settings']->Code,
'stable' => ($view_selected ===
$view['settings']->code), // sanity check
'target_view' => $view_selected,
'table' => $selection['table'] ?? null,
'table_name' => $name_selected,
'alias' => $this->getSiteViewAliasKey($name_selected,
$adminViews),
'key' => $key,
'form' => false
];
}, $siteViews);
}
/**
* Get the array of site edit views
*
* This method processes the provided admin views to extract and return an
array of site edit views.
* Each site edit view is constructed based on specific conditions from
the admin view's settings.
*
* @param array|null $views The admin views to process.
*
* @return array An array of site edit views, each as an object with view,
table, alias, key, and form properties.
* @since 3.2.0
*/
protected function getSiteEditViews(?array $views): array
{
$siteEditViews = [];
// Return early if no views are provided.
if (empty($views))
{
return $siteEditViews;
}
foreach ($views as $view)
{
// Check if the view is marked for edit/create on the site.
if (!empty($view['edit_create_site_view']))
{
$siteEditViews[] = (object) [
'view' =>
$view['settings']->name_single_code,
'View' =>
StringHelper::safe($view['settings']->name_single_code,
'F'),
'stable' => true,
'target_view' =>
$view['settings']->name_single_code,
'table' => '#__' .
$this->config->component_code_name . '_' .
$view['settings']->name_single_code,
'alias' =>
$this->getSiteEditViewAliasKey($view['settings']->fields ??
null),
'key' => 'id',
'form' => true
];
}
}
return $siteEditViews;
}
/**
* Get the site edit view alias key value
*
* This method fetches the alias keys for a given site edit view by
matching the view name
* against a list of admin views. It processes the admin views to find a
match and then
* retrieves the alias keys from the matched view's settings.
*
* @param string|null $viewName The view name to match.
* @param array $adminViews The admin views to search within.
*
* @return string|null The alias key for the site edit view, or null if
not found.
* @since 3.2.0
*/
protected function getSiteViewAliasKey(?string $viewName, array
$adminViews): ?string
{
// Return early if no view name is provided or admin views are empty.
if ($viewName === null || empty($adminViews))
{
return null;
}
foreach ($adminViews as $view)
{
// Check if the current view matches the specified view name and has
fields defined.
if ($view['settings']->name_single_code === $viewName
&& is_array($view['settings']->fields ?? null))
{
// If a match is found, retrieve and return the site edit view alias
keys.
return
$this->getSiteEditViewAliasKey($view['settings']->fields);
}
}
// Return an empty array if no matching view is found.
return null;
}
/**
* Get the site view alias key value
*
* @param array|null $fields The main get object
*
* @return string|null
* @since 3.2.0
*/
protected function getSiteEditViewAliasKey(?array $fields): ?string
{
if ($fields !== null)
{
foreach ($fields as $field)
{
if (isset($field['alias']) &&
$field['alias'] && $field['type_name'] ===
'text')
{
return $field['base_name'];
}
}
}
return null;
}
/**
* Get the view (main selection) table and view name value
* from the main get object
*
* @param array|null $gets The main get objects
*
* @return array
* @since 3.2.0
*/
protected function getMainSelection(?array $gets): array
{
if ($gets !== null)
{
foreach ($gets as $get)
{
// get the main table
if (isset($get['as'])
&& $get['as'] === 'a'
&& isset($get['selection'])
&& ArrayHelper::check($get['selection'])
&&
isset($get['selection']['select_gets'])
&&
ArrayHelper::check($get['selection']['select_gets'])
&& isset($get['selection']['name'])
&& isset($get['selection']['table']))
{
$name = $get['selection']['name'];
$view = $get['selection']['view'];
$table = $get['selection']['table'];
return ['table' => $table, 'view' => $view,
'name' => $name];
}
}
}
return [];
}
}
src/Componentbuilder/Compiler/Model/Siteviews.php000064400000005106151162054160016154
0ustar00<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder
<https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights
reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
namespace VDM\Joomla\Componentbuilder\Compiler\Model;
use VDM\Joomla\Componentbuilder\Compiler\Factory as Compiler;
use VDM\Joomla\Componentbuilder\Compiler\Customview\Data as Customview;
use VDM\Joomla\Componentbuilder\Compiler\Config;
use VDM\Joomla\Utilities\JsonHelper;
use VDM\Joomla\Utilities\ArrayHelper;
use VDM\Joomla\Utilities\ObjectHelper;
/**
* Model Site Views Class
*
* @since 3.2.0
*/
class Siteviews
{
/**
* Component Site view Data
*
* @var Customview
* @since 3.2.0
**/
protected Customview $site;
/**
* Compiler Config
*
* @var Config
* @since 3.2.0
**/
protected Config $config;
/**
* Constructor
*
* @param Customview|null $site The site view data object.
* @param Config|null $config The compiler config object.
*
* @since 3.2.0
*/
public function __construct(?Customview $site = null, ?Config $config =
null)
{
$this->site = $site ?: Compiler::_('Customview.Data');
$this->config = $config ?: Compiler::_('Config');
}
/**
* Set site view data
*
* @param object $item The item data
*
* @return void
* @since 3.2.0
*/
public function set(object &$item)
{
$item->addsite_views = (isset($item->addsite_views)
&& JsonHelper::check($item->addsite_views))
? json_decode((string) $item->addsite_views, true) : null;
if (ArrayHelper::check($item->addsite_views))
{
$this->config->lang_target = 'site';
$this->config->build_target = 'site';
// build the site_views settings
$item->site_views = array_map(
function ($array) {
// has become a legacy issue, can't remove this
$array['view'] = $array['siteview'];
$array['settings'] = $this->site->get(
$array['view']
);
return array_map(
function ($value) {
if (!ArrayHelper::check($value)
&& !ObjectHelper::check($value)
&& strval($value) === strval(intval($value)))
{
return (int) $value;
}
return $value;
}, $array
);
}, array_values($item->addsite_views)
);
// unset original value
unset($item->addsite_views);
}
}
}
src/Componentbuilder/Compiler/Model/Sql.php000064400000004102151162054160014724
0ustar00<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder
<https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights
reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
namespace VDM\Joomla\Componentbuilder\Compiler\Model;
use VDM\Joomla\Componentbuilder\Compiler\Customcode\Dispenser;
use VDM\Joomla\Componentbuilder\Compiler\Model\Sqldump;
/**
* Model Sql Class
*
* @since 3.2.0
*/
class Sql
{
/**
* Compiler Customcode Dispenser
*
* @var Dispenser
* @since 3.2.0
*/
protected Dispenser $dispenser;
/**
* Compiler SQL Dump
*
* @var Sqldump
* @since 3.2.0
*/
protected Sqldump $dump;
/**
* Constructor
*
* @param Dispenser $dispenser The compiler customcode dispenser.
* @param Sqldump $dump The compiler SQL dump.
*
* @since 3.2.0
*/
public function __construct(Dispenser $dispenser, Sqldump $dump)
{
$this->dispenser = $dispenser;
$this->dump = $dump;
}
/**
* Set sql
*
* @param object $item The item data
*
* @return void
* @since 3.2.0
*/
public function set(object &$item)
{
if (isset($item->add_sql) && $item->add_sql == 1 &&
isset($item->source))
{
if ($item->source == 1 && isset($item->tables) &&
($string = $this->dump->get(
$item->tables, $item->name_single_code, $item->id
)) !== null)
{
// build and add the SQL dump
// we add this directly to avoid
// dynamic set behaviour
// TODO: create a function in dispenser to manage these
$this->dispenser->hub['sql'][$item->name_single_code]
= $string;
}
elseif ($item->source == 2 && isset($item->sql))
{
// add the SQL dump string
$this->dispenser->set(
$item->sql,
'sql',
$item->name_single_code
);
}
}
unset($item->tables);
unset($item->sql);
}
}
src/Componentbuilder/Compiler/Model/Sqldump.php000064400000016547151162054160015632
0ustar00<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder
<https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights
reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
namespace VDM\Joomla\Componentbuilder\Compiler\Model;
use Joomla\CMS\Factory;
use VDM\Joomla\Componentbuilder\Compiler\Registry;
use VDM\Joomla\Utilities\ArrayHelper;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Placefix;
use VDM\Joomla\Utilities\StringHelper;
/**
* SQL Dump Class
*
* @since 3.2.0
*/
class Sqldump
{
/**
* The compiler registry
*
* @var Registry
* @since 3.2.0
*/
protected Registry $registry;
/**
* Database object to query local DB
*
* @since 3.2.0
**/
protected $db;
/**
* Constructor
*
* @param Registry $registry The compiler registry object.
* @since 3.2.0
*/
public function __construct(Registry $registry)
{
$this->registry = $registry;
$this->db = Factory::getDbo();
}
/**
* Get SQL Dump
*
* @param array $tables The tables to use in build
* @param string $view The target view/table to dump in
* @param int $view_id The id of the target view
*
* @return string|null The data found with the alias
* @since 3.2.0
*/
public function get(array $tables, string $view, int $view_id): ?string
{
// first build a query statement to get all the data (insure it must be
added - check the tweaking)
if (ArrayHelper::check($tables)
&& $this->registry-> // default is to add
get('builder.sql_tweak.' . (int) $view_id . '.add',
true))
{
$counter = 'a';
// Create a new query object.
$query = $this->db->getQuery(true);
// switch to only trigger the run of the query if we have tables to
query
$run_query = false;
foreach ($tables as $table)
{
if (isset($table['table']))
{
if ($counter === 'a')
{
// the main table fields
if (strpos((string) $table['sourcemap'], PHP_EOL) !==
false)
{
$fields = explode(PHP_EOL, (string) $table['sourcemap']);
if (ArrayHelper::check($fields))
{
// reset array buckets
$sourceArray = [];
$targetArray = [];
foreach ($fields as $field)
{
if (strpos($field, "=>") !== false)
{
list($source, $target) = explode(
"=>", $field
);
$sourceArray[] = $counter . '.' . trim(
$source
);
$targetArray[] = trim($target);
}
}
if (ArrayHelper::check(
$sourceArray
)
&& ArrayHelper::check(
$targetArray
))
{
// add to query
$query->select(
$this->db->quoteName(
$sourceArray, $targetArray
)
);
$query->from(
'#__' . $table['table'] . ' AS a'
);
$run_query = true;
}
// we may need to filter the selection
if (($ids_ = $this->registry->
get('builder.sql_tweak.' . (int) $view_id .
'.where', null)) !== null)
{
// add to query the where filter
$query->where(
'a.id IN (' . $ids_ . ')'
);
}
}
}
}
else
{
// the other tables
if (strpos((string) $table['sourcemap'], PHP_EOL) !==
false)
{
$fields = explode(PHP_EOL, (string) $table['sourcemap']);
if (ArrayHelper::check($fields))
{
// reset array buckets
$sourceArray = [];
$targetArray = [];
foreach ($fields as $field)
{
if (strpos($field, "=>") !== false)
{
list($source, $target) = explode(
"=>", $field
);
$sourceArray[] = $counter . '.' . trim(
$source
);
$targetArray[] = trim($target);
}
if (strpos($field, "==") !== false)
{
list($aKey, $bKey) = explode(
"==", $field
);
// add to query
$query->join(
'LEFT', $this->db->quoteName(
'#__' . $table['table'],
$counter
) . ' ON (' . $this->db->quoteName(
'a.' . trim($aKey)
) . ' = ' . $this->db->quoteName(
$counter . '.' . trim($bKey)
) . ')'
);
}
}
if (ArrayHelper::check(
$sourceArray
)
&& ArrayHelper::check(
$targetArray
))
{
// add to query
$query->select(
$this->db->quoteName(
$sourceArray, $targetArray
)
);
}
}
}
}
$counter++;
}
else
{
// see where
// var_dump($view);
// jexit();
}
}
// check if we should run query
if ($run_query)
{
// now get the data
$this->db->setQuery($query);
$this->db->execute();
if ($this->db->getNumRows())
{
// get the data
$data = $this->db->loadObjectList();
// start building the MySql dump
$dump = "--";
$dump .= PHP_EOL . "-- Dumping data for table `#__"
. Placefix::_("component") . "_" . $view
. "`";
$dump .= PHP_EOL . "--";
$dump .= PHP_EOL . PHP_EOL . "INSERT INTO `#__" .
Placefix::_("component") . "_" . $view . "`
(";
foreach ($data as $line)
{
$comaSet = 0;
foreach ($line as $fieldName => $fieldValue)
{
if ($comaSet == 0)
{
$dump .= $this->db->quoteName($fieldName);
}
else
{
$dump .= ", " . $this->db->quoteName(
$fieldName
);
}
$comaSet++;
}
break;
}
$dump .= ") VALUES";
$coma = 0;
foreach ($data as $line)
{
if ($coma == 0)
{
$dump .= PHP_EOL . "(";
}
else
{
$dump .= "," . PHP_EOL . "(";
}
$comaSet = 0;
foreach ($line as $fieldName => $fieldValue)
{
if ($comaSet == 0)
{
$dump .= $this->escape($fieldValue);
}
else
{
$dump .= ", " . $this->escape(
$fieldValue
);
}
$comaSet++;
}
$dump .= ")";
$coma++;
}
$dump .= ";";
// return build dump query
return $dump;
}
}
}
return null;
}
/**
* Escape the values for a SQL dump
*
* @param string|array $value the value to escape
*
* @return string|array on success with escaped string
* @since 3.2.0
*/
protected function escape($value)
{
// if array then return mapped
if (ArrayHelper::check($value))
{
return array_map(__METHOD__, $value);
}
// if string make sure it is correctly escaped
if (StringHelper::check($value) && !is_numeric($value))
{
return $this->db->quote($value);
}
// if empty value return place holder
if (empty($value))
{
return "''";
}
// if not array or string then return number
return $value;
}
}
src/Componentbuilder/Compiler/Model/Sqltweaking.php000064400000007633151162054160016472
0ustar00<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder
<https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights
reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
namespace VDM\Joomla\Componentbuilder\Compiler\Model;
use VDM\Joomla\Componentbuilder\Compiler\Registry;
use VDM\Joomla\Utilities\JsonHelper;
use VDM\Joomla\Utilities\ArrayHelper;
use VDM\Joomla\Utilities\ObjectHelper;
/**
* Model Sql Tweaking Class
*
* @since 3.2.0
*/
class Sqltweaking
{
/**
* Compiler registry
*
* @var Registry
* @since 3.2.0
*/
protected Registry $registry;
/**
* Constructor
*
* @param Registry $registry The compiler registry object.
*
* @since 3.2.0
*/
public function __construct(Registry $registry)
{
$this->registry = $registry;
}
/**
* Set sql tweaking if needed
*
* @param object $item The extension data
*
* @return void
* @since 3.2.0
*/
public function set(object &$item)
{
// set the sql_tweak data
$item->sql_tweak = (isset($item->sql_tweak)
&& JsonHelper::check($item->sql_tweak))
? json_decode((string) $item->sql_tweak, true) : null;
if (ArrayHelper::check($item->sql_tweak))
{
// build the tweak settings
$this->tweak(
array_map(
fn($array) => array_map(
function ($value) {
if (!ArrayHelper::check($value)
&& !ObjectHelper::check(
$value
)
&& strval($value) === strval(
intval($value)
))
{
return (int) $value;
}
return $value;
}, $array
), array_values($item->sql_tweak)
)
);
}
unset($item->sql_tweak);
}
/**
* To limit the SQL Demo data build in the views
*
* @param array $settings Tweaking array.
*
* @return void
* @since 3.2.0
*/
protected function tweak($settings)
{
if (ArrayHelper::check($settings))
{
foreach ($settings as $setting)
{
// should sql dump be added
if (1 == $setting['add_sql'])
{
// add sql (by option)
if (2 == $setting['add_sql_options'])
{
// rest always
$id_array = [];
// by id (first remove backups)
$ids = $setting['ids'];
// now get the ids
if (strpos((string) $ids, ',') !== false)
{
$id_array = (array) array_map(
'trim', explode(',', (string) $ids)
);
}
else
{
$id_array[] = trim((string) $ids);
}
$id_array_new = [];
// check for ranges
foreach ($id_array as $key => $id)
{
if (strpos($id, '=>') !== false)
{
$id_range = (array) array_map(
'trim', explode('=>', $id)
);
unset($id_array[$key]);
// build range
if (count((array) $id_range) == 2)
{
$range = range(
$id_range[0], $id_range[1]
);
$id_array_new = [...$id_array_new, ...$range];
}
}
}
if (ArrayHelper::check($id_array_new))
{
$id_array = [...$id_array_new, ...$id_array];
}
// final fixing to array
if (ArrayHelper::check($id_array))
{
// unique
$id_array = array_unique($id_array, SORT_NUMERIC);
// sort
sort($id_array, SORT_NUMERIC);
// now set it to global
$this->registry->
set('builder.sql_tweak.' . (int)
$setting['adminview'] . '.where',
implode(',', $id_array));
}
}
}
else
{
// do not add sql dump options
$this->registry->
set('builder.sql_tweak.' . (int)
$setting['adminview'] . '.add', false);
}
}
}
}
}
src/Componentbuilder/Compiler/Model/Tabs.php000064400000003051151162054160015060
0ustar00<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder
<https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights
reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
namespace VDM\Joomla\Componentbuilder\Compiler\Model;
use VDM\Joomla\Utilities\JsonHelper;
use VDM\Joomla\Utilities\ArrayHelper;
/**
* Model Tabs Class
*
* @since 3.2.0
*/
class Tabs
{
/**
* Set the local tabs
*
* @param object $item The view data
*
* @return void
* @since 3.2.0
*/
public function set(object &$item)
{
$item->addtabs = (isset($item->addtabs)
&& JsonHelper::check($item->addtabs))
? json_decode((string) $item->addtabs, true) : null;
if (ArrayHelper::check($item->addtabs))
{
$nr = 1;
foreach ($item->addtabs as $tab)
{
$item->tabs[$nr] = trim((string) $tab['name']);
$nr++;
}
}
// if Details tab is not set, then set it here
if (!isset($item->tabs[1]))
{
$item->tabs[1] = 'Details';
}
// always make sure that publishing is lowercase
if (($removeKey = array_search(
'publishing', array_map('strtolower',
$item->tabs)
)) !== false)
{
$item->tabs[$removeKey] = 'publishing';
}
// make sure to set the publishing tab (just in case we need it)
$item->tabs[15] = 'publishing';
unset($item->addtabs);
}
}
src/Componentbuilder/Compiler/Model/Updateserver.php000064400000004357151162054160016652
0ustar00<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder
<https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights
reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
namespace VDM\Joomla\Componentbuilder\Compiler\Model;
use VDM\Joomla\Utilities\ArrayHelper;
use VDM\Joomla\Utilities\JsonHelper;
use VDM\Joomla\Utilities\StringHelper;
/**
* Model Joomla Update Server Class
*
* @since 3.2.0
*/
class Updateserver
{
/**
* Set version updates
*
* @param object $item The item data
*
* @return void
* @since 3.2.0
*/
public function set(object &$item)
{
// set the version updates
$item->version_update = (isset($item->version_update)
&& JsonHelper::check($item->version_update))
? json_decode((string) $item->version_update, true) : null;
if (ArrayHelper::check($item->version_update))
{
$item->version_update = array_values(
$item->version_update
);
// set the change log details
$this->changelog($item);
}
}
/**
* Set changelog values to component changelog
*
* @param object $item The item data
*
* @return void
* @since 3.2.0
*/
protected function changelog(object &$item)
{
// set the version updates
$bucket = [];
foreach ($item->version_update as $update)
{
if (isset($update['change_log']) &&
StringHelper::check($update['change_log'])
&& isset($update['version']) &&
StringHelper::check($update['version']))
{
$bucket[] = [
'version' => $update['version'],
'change_log' => '# v' .
$update['version'] . PHP_EOL . PHP_EOL .
$update['change_log']
];
}
}
// Sort bucket by version, newest at the top
usort($bucket, function ($a, $b) {
return version_compare($b['version'],
$a['version']);
});
// Extract change logs from sorted bucket
$sorted_change_logs = array_column($bucket, 'change_log');
if (ArrayHelper::check($sorted_change_logs))
{
$item->changelog = implode(PHP_EOL . PHP_EOL, $sorted_change_logs);
}
}
}
src/Componentbuilder/Compiler/Model/Updatesql.php000064400000013107151162054160016134
0ustar00<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder
<https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights
reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
namespace VDM\Joomla\Componentbuilder\Compiler\Model;
use VDM\Joomla\Componentbuilder\Compiler\Registry;
use VDM\Joomla\Utilities\ArrayHelper;
use VDM\Joomla\Utilities\StringHelper;
use VDM\Joomla\Utilities\GetHelper;
/**
* Model Update sql Class
*
* @since 3.2.0
*/
class Updatesql
{
/**
* The admin view names
*
* @var array
* @since 3.2.0
*/
protected array $name = [];
/**
* The compiler registry
*
* @var Registry
* @since 3.2.0
*/
protected Registry $registry;
/**
* Constructor
*
* @param Registry $registry The compiler registry object.
*
* @since 3.2.0
*/
public function __construct(Registry $registry)
{
$this->registry = $registry;
}
/**
* check if an update SQL is needed
*
* @param mixed $old The old values
* @param mixed $new The new values
* @param string $type The type of values
* @param mixed $key The id/key where values changed
* @param array|null $ignore The ids to ignore
*
* @return void
* @since 3.2.0
*/
public function set($old, $new, string $type, $key = null, ?array $ignore
= null)
{
// check if there were new items added
if (ArrayHelper::check($new) && ArrayHelper::check($old))
{
// check if this is old repeatable field
if (isset($new[$type]))
{
foreach ($new[$type] as $item)
{
$newItem = true;
// check if this is an id to ignore
if (ArrayHelper::check($ignore)
&& in_array(
$item, $ignore
))
{
// don't add ignored ids
$newItem = false;
}
// check if this is old repeatable field
elseif (isset($old[$type])
&& ArrayHelper::check($old[$type]))
{
if (!in_array($item, $old[$type]))
{
// we have a new item, lets add to SQL
$this->add($type, $item, $key);
}
// add only once
$newItem = false;
}
elseif (!isset($old[$type]))
{
// we have new values
foreach ($old as $oldItem)
{
if (isset($oldItem[$type]))
{
if ($oldItem[$type] == $item[$type])
{
$newItem = false;
break;
}
}
else
{
$newItem = false;
break;
}
}
}
else
{
$newItem = false;
}
// add if new
if ($newItem)
{
// we have a new item, lets add to SQL
$this->add($type, $item[$type], $key);
}
}
}
else
{
foreach ($new as $item)
{
if (isset($item[$type]))
{
// search to see if this is a new value
$newItem = true;
// check if this is an id to ignore
if (ArrayHelper::check($ignore)
&& in_array($item[$type], $ignore))
{
// don't add ignored ids
$newItem = false;
}
// check if this is old repeatable field
elseif (isset($old[$type])
&& ArrayHelper::check($old[$type]))
{
if (in_array($item[$type], $old[$type]))
{
$newItem = false;
}
}
elseif (!isset($old[$type]))
{
// we have new values
foreach ($old as $oldItem)
{
if (isset($oldItem[$type]))
{
if ($oldItem[$type] == $item[$type])
{
$newItem = false;
break;
}
}
else
{
$newItem = false;
break;
}
}
}
else
{
$newItem = false;
}
// add if new
if ($newItem)
{
// we have a new item, lets add to SQL
$this->add($type, $item[$type], $key);
}
}
}
}
}
elseif ($key && ((StringHelper::check($new) &&
StringHelper::check($old))
|| (is_numeric($new) && is_numeric($old))) && $new !==
$old)
{
// set at key
$this->registry->set('builder.update_sql.' . $type .
'.' . $key, ['old' => $old, 'new' =>
$new]);
}
}
/**
* Set the add sql
*
* @param string $type The type of values
* @param int $item The item id to add
* @param mixed $key The id/key where values changed
*
* @return void
* @since 3.2.0
*/
protected function add(string $type, int $item, $key = null)
{
// add key if found
if ($key)
{
$this->registry->set('builder.add_sql.' . $type .
'.' . $key . '.' . $item, $item);
}
else
{
// convert admin view id to name
if ('adminview' === $type)
{
$this->registry->set('builder.add_sql.' . $type .
'.' . $this->name($item),
$item
);
}
else
{
$this->registry->set('builder.add_sql.' . $type,
$item);
}
}
}
/**
* Get the Admin view table name
*
* @param int $id The item id to add
*
* @return string the admin view code name
* @since 3.2.0
*/
protected function name(int $id): string
{
// get name if not set
if (!isset($this->name[$id]))
{
$this->name[$id] = StringHelper::safe(
GetHelper::var('admin_view', $id, 'id',
'name_single')
);
}
return $this->name[$id] ?? 'error';
}
}
src/Componentbuilder/Compiler/Model/Whmcs.php000064400000003124151162054160015251
0ustar00<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder
<https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights
reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
namespace VDM\Joomla\Componentbuilder\Compiler\Model;
use VDM\Joomla\Utilities\StringHelper;
/**
* Model Whmcs Class
*
* @since 3.2.0
*/
class Whmcs
{
/**
* Set whmcs links if needed
*
* @param object $item The extension data
*
* @return void
* @since 3.2.0
*/
public function set(object &$item)
{
if (1 == $item->add_license
&& (!isset($item->whmcs_buy_link)
|| !StringHelper::check(
$item->whmcs_buy_link
)))
{
// update with the whmcs url
if (isset($item->whmcs_url)
&& StringHelper::check($item->whmcs_url))
{
$item->whmcs_buy_link = $item->whmcs_url;
}
// use the company website
elseif (isset($item->website)
&& StringHelper::check($item->website))
{
$item->whmcs_buy_link = $item->website;
$item->whmcs_url = rtrim((string) $item->website,
'/')
. '/whmcs';
}
// none set
else
{
$item->whmcs_buy_link = '#';
$item->whmcs_url = '#';
}
}
// since the license details are not set clear
elseif (0 == $item->add_license)
{
$item->whmcs_key = '';
$item->whmcs_buy_link = '';
$item->whmcs_url = '';
}
}
}
src/Componentbuilder/Compiler/Model/index.html000064400000000054151162054160015453
0ustar00<html><body
bgcolor="#FFFFFF"></body></html>src/Componentbuilder/Compiler/Placeholder.php000064400000025307151162054160015361
0ustar00<?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;
use VDM\Joomla\Utilities\ArrayHelper;
use VDM\Joomla\Componentbuilder\Compiler\Factory as Compiler;
use VDM\Joomla\Componentbuilder\Compiler\Config;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Placefix;
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\PlaceholderInterface;
/**
* Compiler Placeholder
*
* @since 3.2.0
*/
class Placeholder implements PlaceholderInterface
{
/**
* The active placeholders
*
* @var array
* @since 3.2.0
**/
public array $active = [];
/**
* Compiler Config
*
* @var Config
* @since 3.2.0
**/
protected Config $config;
/**
* Constructor.
*
* @param Config|null $config The compiler config object.
*
* @since 3.2.0
*/
public function __construct(?Config $config = null)
{
$this->config = $config ?: Compiler::_('Config');
}
/**
* Set content
*
* @param string $key The main string key
* @param mixed $value The values to set
* @param bool $hash Add the hash around the key
*
* @return void
* @since 3.2.0
*/
public function set(string $key, $value, bool $hash = true)
{
if ($hash)
{
$this->set_($key, $value);
$this->set_h($key, $value);
}
else
{
$this->active[$key] = $value;
}
}
/**
* Get content by key
*
* @param string $key The main string key
*
* @return mixed
* @since 3.2.0
*/
public function get(string $key)
{
return $this->active[$key] ?? $this->get_($key) ??
$this->get_h($key) ?? null;
}
/**
* Does key exist at all in any variation
*
* @param string $key The main string key
*
* @return bool
* @since 3.2.0
*/
public function exist(string $key): bool
{
return isset($this->active[$key]) || $this->exist_($key) ||
$this->exist_h($key);
}
/**
* Add content
*
* @param string $key The main string key
* @param mixed $value The values to set
* @param bool $hash Add the hash around the key
*
* @return void
* @since 3.2.0
*/
public function add(string $key, $value, bool $hash = true)
{
if ($hash)
{
$this->add_($key, $value);
$this->add_h($key, $value);
}
elseif (isset($this->active[$key]))
{
$this->active[$key] .= $value;
}
else
{
$this->active[$key] = $value;
}
}
/**
* Remove content
*
* @param string $key The main string key
*
* @return void
* @since 3.2.0
*/
public function remove(string $key)
{
if (isset($this->active[$key]))
{
unset($this->active[$key]);
}
else
{
$this->remove_($key);
$this->remove_h($key);
}
}
/**
* Set content with [ [ [ ... ] ] ] hash
*
* @param string $key The main string key
* @param mixed $value The values to set
*
* @return void
* @since 3.2.0
*/
public function set_(string $key, $value)
{
$this->active[Placefix::_($key)] = $value;
}
/**
* Get content with [ [ [ ... ] ] ] hash
*
* @param string $key The main string key
*
* @return mixed
* @since 3.2.0
*/
public function get_(string $key)
{
return $this->active[Placefix::_($key)] ?? null;
}
/**
* Does key exist with [ [ [ ... ] ] ] hash
*
* @param string $key The main string key
*
* @return bool
* @since 3.2.0
*/
public function exist_(string $key): bool
{
return isset($this->active[Placefix::_($key)]);
}
/**
* Add content with [ [ [ ... ] ] ] hash
*
* @param string $key The main string key
* @param mixed $value The values to set
*
* @return void
* @since 3.2.0
*/
public function add_(string $key, $value)
{
if (isset($this->active[Placefix::_($key)]))
{
$this->active[Placefix::_($key)] .= $value;
}
else
{
$this->active[Placefix::_($key)] = $value;
}
}
/**
* Remove content with [ [ [ ... ] ] ] hash
*
* @param string $key The main string key
*
* @return void
* @since 3.2.0
*/
public function remove_(string $key)
{
if ($this->exist_($key))
{
unset($this->active[Placefix::_($key)]);
}
}
/**
* Set content with # # # hash
*
* @param string $key The main string key
* @param mixed $value The values to set
*
* @return void
* @since 3.2.0
*/
public function set_h(string $key, $value)
{
$this->active[Placefix::_h($key)] = $value;
}
/**
* Get content with # # # hash
*
* @param string $key The main string key
*
* @return mixed
* @since 3.2.0
*/
public function get_h(string $key)
{
return $this->active[Placefix::_h($key)] ?? null;
}
/**
* Does key exist with # # # hash
*
* @param string $key The main string key
*
* @return bool
* @since 3.2.0
*/
public function exist_h(string $key): bool
{
return isset($this->active[Placefix::_h($key)]);
}
/**
* Add content with # # # hash
*
* @param string $key The main string key
* @param mixed $value The values to set
*
* @return void
* @since 3.2.0
*/
public function add_h(string $key, $value)
{
if ($this->exist_h($key))
{
$this->active[Placefix::_h($key)] .= $value;
}
else
{
$this->active[Placefix::_h($key)] = $value;
}
}
/**
* Remove content with # # # hash
*
* @param string $key The main string key
*
* @return void
* @since 3.2.0
*/
public function remove_h(string $key)
{
if ($this->exist_h($key))
{
unset($this->active[Placefix::_h($key)]);
}
}
/**
* Set a type of placeholder with set of values
*
* @param string $key The main string for placeholder key
* @param array $values The values to add
*
* @return void
* @since 3.2.0
*/
public function setType(string $key, array $values)
{
// always fist reset the type
$this->clearType($key);
// only add if there are values
if (ArrayHelper::check($values))
{
$number = 0;
foreach ($values as $value)
{
$this->set($key . $number, $value);
$number++;
}
}
}
/**
* Remove a type of placeholder by main key
*
* @param string $key The main string for placeholder key
*
* @return void
* @since 3.2.0
*/
public function clearType(string $key)
{
$keys = [Placefix::_($key), Placefix::_h($key), $key];
foreach ($keys as $_key)
{
$this->active = array_filter(
$this->active,
fn(string $k) => preg_replace('/\d/', '', $k)
!== $_key,
ARRAY_FILTER_USE_KEY
);
}
}
/**
* Update the data with the placeholders
*
* @param string $data The actual data
* @param array $placeholder The placeholders
* @param int $action The action to use
*
* THE ACTION OPTIONS ARE
* 1 -> Just replace (default)
* 2 -> Check if data string has placeholders
* 3 -> Remove placeholders not in data string
*
* @return string
* @since 3.2.0
*/
public function update(string $data, array $placeholder, int $action = 1):
string
{
// make sure the placeholders is an array
if (!ArrayHelper::check($placeholder))
{
return $data;
}
// continue with the work of replacement
if (1 == $action) // <-- just replace (default)
{
return str_replace(
array_keys($placeholder), array_values($placeholder), $data
);
}
elseif (2 == $action) // <-- check if data string has placeholders
{
$replace = false;
foreach (array_keys($placeholder) as $key)
{
if (strpos($data, $key) !== false)
{
$replace = true;
break;
}
}
// only replace if the data has these placeholder values
if ($replace)
{
return str_replace(
array_keys($placeholder), array_values($placeholder), $data
);
}
}
elseif (3 == $action) // <-- remove placeholders not in data string
{
$replace = $placeholder;
foreach (array_keys($replace) as $key)
{
if (strpos($data, $key) === false)
{
unset($replace[$key]);
}
}
// only replace if the data has these placeholder values
if (ArrayHelper::check($replace))
{
return str_replace(
array_keys($replace), array_values($replace), $data
);
}
}
return $data;
}
/**
* Update the data with the active placeholders
*
* @param string $data The actual data
*
* @return string
* @since 3.2.0
*/
public function update_(string $data): string
{
// just replace the placeholders in data
return str_replace(
array_keys($this->active), array_values($this->active), $data
);
}
/**
* return the placeholders for inserted and replaced code
*
* @param int $type The type of placement
* @param int|null $id The code id in the system
*
* @return array with start and end keys
* @since 3.2.0
*/
public function keys(int $type, ?int $id = null): array
{
switch ($type)
{
case 11:
//***[REPLACED$$$$]***//**1**/
if ($this->config->get('add_placeholders', false) ===
true)
{
return [
'start' => '/***[REPLACED$$$$]***//**' . $id .
'**/',
'end' => '/***[/REPLACED$$$$]***/'
];
}
break;
case 12:
//***[INSERTED$$$$]***//**1**/
if ($this->config->get('add_placeholders', false) ===
true)
{
return [
'start' => '/***[INSERTED$$$$]***//**' . $id .
'**/',
'end' => '/***[/INSERTED$$$$]***/'
];
}
break;
case 21:
//<!--[REPLACED$$$$]--><!--1-->
if ($this->config->get('add_placeholders', false) ===
true)
{
return [
'start' =>
'<!--[REPLACED$$$$]--><!--' . $id . '-->',
'end' => '<!--[/REPLACED$$$$]-->'
];
}
break;
case 22:
//<!--[INSERTED$$$$]--><!--1-->
if ($this->config->get('add_placeholders', false) ===
true)
{
return [
'start' =>
'<!--[INSERTED$$$$]--><!--' . $id . '-->',
'end' => '<!--[/INSERTED$$$$]-->'
];
}
break;
case 33:
return ['start' => Placefix::h(), 'end' =>
Placefix::h()];
break;
case 66:
return ['start' => Placefix::b(), 'end' =>
Placefix::d()];
break;
}
return [ 'start' => "", 'end' =>
""];
}
}
src/Componentbuilder/Compiler/Placeholder/Reverse.php000064400000031343151162054170016772
0ustar00<?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\Placeholder;
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;
use VDM\Joomla\Componentbuilder\Compiler\Language;
use VDM\Joomla\Componentbuilder\Compiler\Language\Extractor;
use VDM\Joomla\Componentbuilder\Compiler\Power\Extractor as Power;
use VDM\Joomla\Componentbuilder\Compiler\JoomlaPower\Extractor as
JoomlaPower;
/**
* Compiler Placeholder Reverse
*
* @since 3.2.0
*/
class Reverse
{
/**
* Compiler Config
*
* @var Config
* @since 3.2.0
**/
protected Config $config;
/**
* Compiler Placeholder
*
* @var Placeholder
* @since 3.2.0
**/
protected Placeholder $placeholder;
/**
* Compiler Language
*
* @var Language
* @since 3.2.0
**/
protected Language $language;
/**
* Compiler Language Extractor
*
* @var Extractor
* @since 3.2.0
**/
protected Extractor $extractor;
/**
* Super Power Extractor
*
* @var Power
* @since 3.2.0
**/
protected Power $power;
/**
* Joomla Power Extractor
*
* @var Power
* @since 3.2.1
**/
protected JoomlaPower $joomla;
/**
* Constructor.
*
* @param Config $config The compiler config object.
* @param Placeholder $placeholder The compiler placeholder object.
* @param Language $language The compiler language object.
* @param Extractor $extractor The compiler language extractor
object.
* @param Power $power The compiler power extractor object.
*
* @since 3.2.0
*/
public function __construct(
Config $config, Placeholder $placeholder,
Language $language, Extractor $extractor,
Power $power, JoomlaPower $joomla)
{
$this->config = $config;
$this->placeholder = $placeholder;
$this->language = $language;
$this->extractor = $extractor;
$this->power = $power;
$this->joomla = $joomla;
}
/**
* Reverse Engineer the dynamic placeholders (TODO hmmmm this is not
ideal)
*
* @param string $string The string to reverse
* @param array $placeholders The values to search for
* @param string $target The target path type
* @param int|null $id The custom code id
* @param string $field The field name
* @param string $table The table name
* @param array|null $useStatements The file use statements (needed
for super powers)
*
* @return string
* @since 3.2.0
*/
public function engine(string $string, array &$placeholders,
string $target, ?int $id = null, string $field = 'code',
string $table = 'custom_code', ?array $useStatements = null):
string
{
// get local code if set
if ($id > 0 && $code = base64_decode(
(string) GetHelper::var($table, $id, 'id', $field)
))
{
$string = $this->setReverse(
$string, $code, $target, $useStatements
);
}
return $this->placeholder->update($string, $placeholders, 2);
}
/**
* Reverse engineer the dynamic language, and super powers
*
* @param string $updateString The string to update
* @param string $string The string to use language update
* @param string $target The target path type
* @param array|null $useStatements The file use statements (needed
for super powers)
*
* @return string
* @since 3.2.0
*/
protected function setReverse(string $updateString, string $string,
string $target, ?array $useStatements): string
{
// we have to reverse engineer of powers
$updateString = $this->reverseSuperPowers($updateString, $string,
$useStatements);
$updateString = $this->reverseJoomlaPowers($updateString, $string,
$useStatements);
// reverse engineer the language strings
$updateString = $this->reverseLanguage($updateString, $string,
$target);
// reverse engineer the custom code (if possible)
// $updateString = $this->reverseCustomCode($updateString, $string);
// TODO - we would like to also reverse basic customcode
return $updateString;
}
/**
* Set the super powers keys for the reveres process
*
* @param string $updateString The string to update
* @param string $string The string to use for super power
update
* @param array|null $useStatements The file use statements (needed
for super powers)
*
* @return string
* @since 3.2.0
*/
protected function reverseSuperPowers(string $updateString, string
$string,
?array $useStatements): string
{
// only if we have use statements can we reverse engineer this
if ($useStatements !== null && ($powers =
$this->power->reverse($string)) !== null &&
($reverse = $this->getReversePower($powers, $useStatements,
'Super')) !== null)
{
return $this->placeholder->update($updateString, $reverse);
}
return $updateString;
}
/**
* Set the joomla powers keys for the reveres process
*
* @param string $updateString The string to update
* @param string $string The string to use for super power
update
* @param array|null $useStatements The file use statements (needed
for super powers)
*
* @return string
* @since 3.2.0
*/
protected function reverseJoomlaPowers(string $updateString, string
$string,
?array $useStatements): string
{
// only if we have use statements can we reverse engineer this
if ($useStatements !== null && ($powers =
$this->joomla->reverse($string)) !== null &&
($reverse = $this->getReversePower($powers, $useStatements,
'Joomla')) !== null)
{
return $this->placeholder->update($updateString, $reverse);
}
return $updateString;
}
/**
* Set the super powers keys for the reveres process
*
* @param array $powers The powers found in the database text
* @param array $useStatements The file use statements
* @param string $target The power target type
*
* @return array|null
* @since 3.2.0
*/
protected function getReversePower(array $powers, array $useStatements,
string $target): ?array
{
$matching_statements = [];
foreach ($useStatements as $use_statement)
{
$namespace = substr($use_statement, 4, -1); // remove 'use '
and ';'
$class_name = '';
// Check for 'as' alias
if (strpos($namespace, ' as ') !== false)
{
list($namespace, $class_name) = explode(' as ', $namespace);
}
// If there is no 'as' alias, get the class name from the last
'\'
if (empty($class_name))
{
$last_slash = strrpos($namespace, '\\');
if ($last_slash !== false)
{
$class_name = substr($namespace, $last_slash + 1);
}
}
// Check if the namespace is in the powers array
if (in_array($namespace, $powers))
{
$guid = array_search($namespace, $powers);
$matching_statements[$class_name] =
$target . '_'.'_'.'_' .
str_replace('-', '_', $guid) .
'_'.'_'.'_Power';
}
}
if ($matching_statements !== [])
{
return $matching_statements;
}
return null;
}
/**
* Set the language strings for the reveres process
*
* @param string $updateString The string to update
* @param string $string The string to use language update
* @param string $target The target path type
*
* @return string
* @since 3.2.0
*/
protected function reverseLanguage(string $updateString, string $string,
string $target): string
{
// get targets to search for
$lang_string_targets = array_filter(
$this->config->lang_string_targets,
fn($get): bool => strpos($string, (string) $get) !== false
);
// check if we should continue
if (ArrayHelper::check($lang_string_targets))
{
// start lang holder
$lang_holders = [];
// set the lang for both since we don't know what area is being
targeted
$_tmp = $this->config->lang_target;
// set the lang based on target
if (strpos($target, 'module') !== false)
{
// backup lang prefix
$_tmp_lang_prefix = $this->config->lang_prefix;
// set the new lang prefix
$lang_prefix = strtoupper(
str_replace('module', 'mod', $target)
);
$this->config->set('lang_prefix', $lang_prefix);
// now set the lang
if
(isset($this->extractor->langKeys[$this->config->lang_prefix]))
{
$this->config->lang_target =
$this->extractor->langKeys[$this->config->lang_prefix];
}
else
{
$this->config->lang_target = 'module';
}
}
elseif (strpos($target, 'plugin') !== false)
{
// backup lang prefix
$_tmp_lang_prefix = $this->config->lang_prefix;
// set the new lang prefix
$lang_prefix = strtoupper(
str_replace('plugin', 'plg', $target)
);
$this->config->set('lang_prefix', $lang_prefix);
// now set the lang
if
(isset($this->extractor->langKeys[$this->config->lang_prefix]))
{
$this->config->lang_target =
$this->extractor->langKeys[$this->config->lang_prefix];
}
else
{
$this->config->lang_target = 'plugin';
}
}
else
{
$this->config->lang_target = 'both';
}
// set language data
foreach ($lang_string_targets as $lang_string_target)
{
$lang_check[] = GetHelper::allBetween(
$string, $lang_string_target . "'", "'"
);
$lang_check[] = GetHelper::allBetween(
$string, $lang_string_target . '"', '"'
);
}
// merge arrays
$lang_array = ArrayHelper::merge($lang_check);
// continue only if strings were found
if (ArrayHelper::check(
$lang_array
)) //<-- not really needed hmmm
{
foreach ($lang_array as $lang)
{
$_key_lang = StringHelper::safe($lang, 'U');
// this is there to insure we dont break already added Language
strings
if ($_key_lang === $lang)
{
continue;
}
// build lang key
$key_lang = $this->config->lang_prefix . '_' .
$_key_lang;
// set lang content string
$this->language->set($this->config->lang_target,
$key_lang, $lang);
// reverse the placeholders
foreach ($lang_string_targets as $lang_string_target)
{
$lang_holders[$lang_string_target . "'" . $key_lang .
"'"]
= $lang_string_target . "'" . $lang .
"'";
$lang_holders[$lang_string_target . '"' . $key_lang .
'"']
= $lang_string_target . '"' . $lang .
'"';
}
}
// return the found placeholders
$updateString = $this->placeholder->update(
$updateString, $lang_holders
);
}
// reset the lang
$this->config->lang_target = $_tmp;
// also rest the lang prefix if set
if (isset($_tmp_lang_prefix))
{
$lang_prefix = $_tmp_lang_prefix;
$this->config->set('lang_prefix', $_tmp_lang_prefix);
}
}
return $updateString;
}
/**
* Set the custom code placeholder for the reveres process
*
* @param string $updateString The string to update
* @param string $string The string to use for super power
update
*
* @return string
* @since 3.2.0
*/
protected function reverseCustomCode(string $updateString, string
$string): string
{
// check if content has custom code place holder
if (strpos($string, '[CUSTO' . 'MCODE=') !== false)
{
$found = GetHelper::allBetween(
$string, '[CUSTO' . 'MCODE=', ']'
);
$bucket = [];
if (ArrayHelper::check($found))
{
foreach ($found as $key)
{
// we only update those without args
if (is_numeric($key) && $get_func_name = GetHelper::var(
'custom_code', $key, 'id',
'function_name'
))
{
$bucket[$get_func_name] = (int) $key;
}
elseif (StringHelper::check($key)
&& strpos((string) $key, '+') === false)
{
$get_func_name = trim((string) $key);
if (isset($bucket[$get_func_name]) || !$found_local =
GetHelper::var(
'custom_code', $get_func_name, 'function_name',
'id'
))
{
continue;
}
$bucket[$get_func_name] = (int) $found_local;
}
}
// TODO - we need to now get the customcode
// search and replace the customcode with the placeholder
}
}
return $updateString;
}
}
src/Componentbuilder/Compiler/Placeholder/index.html000064400000000054151162054170016636
0ustar00<html><body
bgcolor="#FFFFFF"></body></html>src/Componentbuilder/Compiler/Power.php000064400000077324151162054170014242
0ustar00<?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;
use Joomla\CMS\Factory;
use Joomla\CMS\Application\CMSApplication;
use Joomla\CMS\Language\Text;
use VDM\Joomla\Utilities\ArrayHelper;
use VDM\Joomla\Utilities\StringHelper;
use VDM\Joomla\Utilities\JsonHelper;
use VDM\Joomla\Utilities\GuidHelper;
use VDM\Joomla\Utilities\String\ClassfunctionHelper;
use VDM\Joomla\Utilities\String\NamespaceHelper;
use VDM\Joomla\Componentbuilder\Compiler\Config;
use VDM\Joomla\Componentbuilder\Compiler\Placeholder;
use VDM\Joomla\Componentbuilder\Compiler\Customcode;
use VDM\Joomla\Componentbuilder\Compiler\Customcode\Gui;
use VDM\Joomla\Componentbuilder\Power\Remote\Get as Superpower;
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\PowerInterface;
/**
* Compiler Power
*
* @since 3.2.0
*/
class Power implements PowerInterface
{
/**
* All loaded powers
*
* @var array
* @since 3.2.0
**/
public array $active = [];
/**
* All power namespaces
*
* @var array
* @since 3.2.0
**/
public array $namespace = [];
/**
* All composer namespaces
*
* @var array
* @since 3.2.0
**/
public array $composer = [];
/**
* All super powers of this build
*
* @var array
* @since 3.2.0
**/
public array $superpowers = [];
/**
* Old super powers found in the local repos
*
* @var array
* @since 3.2.0
**/
public array $old_superpowers = [];
/**
* The url to the power, if there is an error.
*
* @var string
* @since 3.2.0
**/
protected string $fixUrl;
/**
* The state of all loaded powers
*
* @var array
* @since 3.2.0
**/
protected array $state = [];
/**
* The state of retry to loaded powers
*
* @var array
* @since 3.2.0
**/
protected array $retry = [];
/**
* 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 Customcode Class.
*
* @var Customcode
* @since 3.2.0
*/
protected Customcode $customcode;
/**
* The Gui Class.
*
* @var Gui
* @since 3.2.0
*/
protected Gui $gui;
/**
* The Super Class.
*
* @var Superpower
* @since 3.2.0
*/
protected Superpower $superpower;
/**
* Database object to query local DB
*
* @since 3.2.0
**/
protected $db;
/**
* Database object to query local DB
*
* @since 3.2.0
**/
protected $app;
/**
* Constructor.
*
* @param Config $config The Config Class.
* @param Placeholder $placeholder The Placeholder Class.
* @param Customcode $customcode The Customcode Class.
* @param Gui $gui The Gui Class.
* @param Superpower $superpower The Super Class.
*
* @since 3.2.0
*/
public function __construct(Config $config, Placeholder $placeholder,
Customcode $customcode, Gui $gui, Superpower $superpower)
{
$this->config = $config;
$this->placeholder = $placeholder;
$this->customcode = $customcode;
$this->gui = $gui;
$this->superpower = $superpower;
$this->db = Factory::getDbo();
$this->app = Factory::getApplication();
}
/**
* load all the powers linked to this component
*
* @param array $guids The global unique ids of the linked powers
*
* @return void
* @since 3.2.0
*/
public function load(array $guids)
{
if (ArrayHelper::check($guids))
{
foreach ($guids as $guid => $build)
{
$this->get($guid, $build);
}
}
}
/**
* Get a power
*
* @param string $guid The global unique id of the power
* @param int $build Force build switch (to override global
switch)
*
* @return object|null
* @since 3.2.0
*/
public function get(string $guid, int $build = 0): ?object
{
if (($this->config->get('add_power', true) || $build ==
1) && $this->set($guid))
{
return $this->active[$guid];
}
return null;
}
/**
* Set a power
*
* @param string $guid The global unique id of the power
*
* @return bool true on successful setting of a power
* @since 3.2.0
*/
private function set(string $guid): bool
{
// check if we have been here before
if ($this->isPowerSet($guid))
{
return $this->state[$guid];
}
elseif ($this->isGuidValid($guid))
{
// get the power data
$this->active[$guid] = $this->getPowerData($guid);
if (is_object($this->active[$guid]))
{
// make sure that in recursion we
// don't try to load this power again
// since during the load of a power we also load
// all powers linked to it
$this->state[$guid] = true;
// make sure to add any language strings found to all language files
// since we can't know where this is used at this point
$tmp_lang_target = $this->config->lang_target;
$this->config->lang_target = 'both';
// we set the fix url if needed
$this->fixUrl
=
'"index.php?option=com_componentbuilder&view=powers&task=power.edit&id='
. $this->active[$guid]->id . '"
target="_blank"';
// set some keys
$this->active[$guid]->target_type = 'P0m3R!';
$this->active[$guid]->key =
$this->active[$guid]->id . '_' .
$this->active[$guid]->target_type;
// reserve some values for the linker
$this->active[$guid]->unchanged_namespace =
$this->active[$guid]->namespace;
$this->active[$guid]->unchanged_description =
$this->active[$guid]->description;
// now set the name
$this->active[$guid]->name = $this->placeholder->update_(
$this->customcode->update($this->active[$guid]->name)
);
// now set the code_name and class name
$this->active[$guid]->code_name =
$this->active[$guid]->class_name = ClassfunctionHelper::safe(
$this->active[$guid]->name
);
// set official name
$this->active[$guid]->official_name = StringHelper::safe(
$this->active[$guid]->name, 'W'
);
// set name space
if (!$this->setNamespace($guid))
{
$this->state[$guid] = false;
unset($this->active[$guid]);
// reset back to starting value
$this->config->lang_target = $tmp_lang_target;
return false;
}
// load use ids
$use = [];
$as = [];
// set extra classes
$this->setLoadSelection($guid);
// set use classes
$this->setUseSelection($guid, $use, $as);
// set implement interfaces
$this->setImplements($guid, $use);
// set extend class
$this->setExtend($guid, $use, $as);
// set GUI mapper
$guiMapper = [
'table' => 'power',
'id' => (int) $this->active[$guid]->id,
'type' => 'php'
];
// add the licensing template
$this->setLicensingTemplate($guid, $guiMapper);
// add the header script
$this->setHeader($guid, $guiMapper);
// set composer
$this->setComposer($guid);
// now set the description
$this->active[$guid]->description =
(StringHelper::check($this->active[$guid]->description)) ?
$this->placeholder->update_(
$this->customcode->update($this->active[$guid]->description),
) : '';
// add the main code if set
$this->setMainClassCode($guid, $guiMapper);
// load the use classes
$this->setUseAs($guid, $use, $as);
// reset back to starting value
$this->config->lang_target = $tmp_lang_target;
// set the approved super power values
$this->setSuperPowers($guid);
return true;
}
}
// we failed to get the power,
// so we raise an error message
// only if guid is valid
if ($this->isGuidValid($guid))
{
// now we search for it via the super power paths
if (empty($this->retry[$guid]) &&
$this->superpower->item($guid, ['remote',
'local']))
{
// we found it and it was loaded into the database
unset($this->state[$guid]);
unset($this->active[$guid]);
// we make sure that this retry only happen once! (just in-case...)
$this->retry[$guid] = true;
// so we try to load it again
return $this->set($guid);
}
$this->app->enqueueMessage(
Text::sprintf('COM_COMPONENTBUILDER_PPOWER_BGUIDSB_NOT_FOUNDP',
$guid),
'Error'
);
}
// let's not try again
$this->state[$guid] = false;
return false;
}
/**
* Check if the power is already set
*
* @param string $guid The global unique id of the power
*
* @return bool true if the power is already set
* @since 3.2.0
*/
private function isPowerSet(string $guid): bool
{
return isset($this->state[$guid]);
}
/**
* Validate the GUID
*
* @param string $guid The global unique id of the power
*
* @return bool true if the GUID is valid
* @since 3.2.0
*/
private function isGuidValid(string $guid): bool
{
return GuidHelper::valid($guid);
}
/**
* Get the power data from the database
*
* @param string $guid The global unique id of the power
*
* @return object|null The power data
* @since 3.2.0
*/
private function getPowerData(string $guid): ?object
{
$query = $this->db->getQuery(true);
$query->select('a.*');
$query->from('#__componentbuilder_power AS a');
$query->where($this->db->quoteName('a.guid') . '
= ' . $this->db->quote($guid));
$this->db->setQuery($query);
$this->db->execute();
if ($this->db->getNumRows())
{
return $this->db->loadObject();
}
return null;
}
/**
* Set the namespace for this power
*
* @param string $guid The global unique id of the power
*
* @return bool
* @since 3.2.0
*/
private function setNamespace(string $guid): bool
{
// set namespace
$this->active[$guid]->namespace =
$this->placeholder->update_(
$this->active[$guid]->namespace
);
// validate namespace
if (strpos($this->active[$guid]->namespace, '\\') ===
false)
{
// we raise an error message
$this->app->enqueueMessage(
Text::sprintf('COM_COMPONENTBUILDER_HTHREES_NAMESPACE_ERROR_SHTHREEPYOU_MUST_ATLEAST_HAVE_TWO_SECTIONS_IN_YOUR_NAMESPACE_YOU_JUST_HAVE_ONE_THIS_IS_AN_UNACCEPTABLE_ACTION_PLEASE_SEE_A_HREFS_PSRFOURA_FOR_MORE_INFOPPTHIS_S_WAS_THEREFORE_REMOVED_A_HREFSCLICK_HEREA_TO_FIX_THIS_ISSUEP',
ucfirst((string) $this->active[$guid]->type),
$this->active[$guid]->name, $this->active[$guid]->namespace,
'"https://www.php-fig.org/psr/psr-4/"
target="_blank"', $this->active[$guid]->type,
$this->fixUrl),
'Error'
);
// we break out here
return false;
}
// setup the path array
$path_array = (array) explode('\\',
$this->active[$guid]->namespace);
// make sure all sub folders in src dir is set and remove all characters
that will not work in folders naming
$this->active[$guid]->namespace =
$this->getCleanNamespace(str_replace('.', '\\',
$this->active[$guid]->namespace));
// make sure it has two or more
if (ArrayHelper::check($path_array) <= 1)
{
// we raise an error message
$this->app->enqueueMessage(
Text::sprintf('COM_COMPONENTBUILDER_HTHREES_NAMESPACE_ERROR_SHTHREEPYOU_MUST_ATLEAST_HAVE_TWO_SECTIONS_IN_YOUR_NAMESPACE_YOU_JUST_HAVE_ONE_S_THIS_IS_AN_UNACCEPTABLE_ACTION_PLEASE_SEE_A_HREFS_PSRFOURA_FOR_MORE_INFOPPTHIS_S_WAS_THEREFORE_REMOVED_A_HREFSCLICK_HEREA_TO_FIX_THIS_ISSUEP',
ucfirst((string) $this->active[$guid]->type),
$this->active[$guid]->name, $this->active[$guid]->namespace,
'"https://www.php-fig.org/psr/psr-4/"
target="_blank"', $this->active[$guid]->type,
$this->fixUrl),
'Error'
);
// we break out here
return false;
}
// get the file and class name (the last value in array)
$file_name = array_pop($path_array);
// src array bucket
$src_array = [];
// do we have src folders
if (strpos($file_name, '.') !== false)
{
// we have src folders in the namespace
$src_array = (array) explode('.', $file_name);
// get the file and class name (the last value in array)
$this->active[$guid]->file_name = array_pop($src_array);
// namespace array
$namespace_array = array_merge($path_array, $src_array);
}
else
{
// set the file name
$this->active[$guid]->file_name = $file_name;
// namespace array
$namespace_array = $path_array;
}
// the last value is the same as the class name
if ($this->active[$guid]->file_name !==
$this->active[$guid]->class_name)
{
// we raise an error message
$this->app->enqueueMessage(
Text::sprintf('COM_COMPONENTBUILDER_PS_NAMING_MISMATCH_ERROR_SPPTHE_S_NAME_IS_BSB_AND_THE_ENDING_FILE_NAME_IN_THE_NAMESPACE_IS_BSB_THIS_IS_BAD_CONVENTION_PLEASE_SEE_A_HREFS_PSRFOURA_FOR_MORE_INFOPPA_HREFSCLICK_HEREA_TO_FIX_THIS_ISSUEP',
ucfirst((string) $this->active[$guid]->type),
$this->active[$guid]->name, $this->active[$guid]->type,
$this->active[$guid]->class_name,
$this->active[$guid]->file_name,
'"https://www.php-fig.org/psr/psr-4/"
target="_blank"',
$this->fixUrl),
'Error'
);
// we break out here
return false;
}
// make sure the arrays are namespace safe
$path_array =
array_map(
fn($val) => $this->getCleanNamespace($val),
$path_array
);
$namespace_array =
array_map(
fn($val) => $this->getCleanNamespace($val),
$namespace_array
);
// set the actual class namespace
$this->active[$guid]->_namespace = implode('\\',
$namespace_array);
// get the parent folder (the first value in array)
$prefix_folder = implode('.', $path_array);
// set global namespaces for autoloader
$this->namespace[$prefix_folder] = $path_array;
// make sub folders if still found
$sub_folder = '';
if (ArrayHelper::check($src_array))
{
// make sure the arrays are namespace safe
$sub_folder = '/' . implode('/',
array_map(
fn($val) => $this->getCleanNamespace($val),
$src_array
)
);
}
// now we set the paths
$this->active[$guid]->path_jcb =
$this->config->get('jcb_powers_path',
'libraries/jcb_powers');
$this->active[$guid]->path_parent =
$this->active[$guid]->path_jcb . '/' . $prefix_folder;
$this->active[$guid]->path =
$this->active[$guid]->path_parent . '/src' . $sub_folder;
return true;
}
/**
* Set Use Classes
*
* @param string $guid The global unique id of the power
* @param array $use The use array
* @param array $as The use as array
*
* @return void
* @since 3.2.0
*/
private function setUseSelection(string $guid, array &$use, array
&$as)
{
// check if we have use selection
$this->active[$guid]->use_selection =
(isset($this->active[$guid]->use_selection)
&& JsonHelper::check(
$this->active[$guid]->use_selection
)) ? json_decode((string) $this->active[$guid]->use_selection,
true) : null;
if (ArrayHelper::check($this->active[$guid]->use_selection))
{
$use = array_values(array_map(function ($u) use(&$as) {
// track the AS options
$as[$u['use']] = empty($u['as']) ?
'default' : (string) $u['as'];
// return the guid
return $u['use'];
}, $this->active[$guid]->use_selection));
}
else
{
$this->active[$guid]->use_selection = null;
}
}
/**
* Load Extra Classes
*
* @param string $guid The global unique id of the power
*
* @return void
* @since 3.2.0
*/
private function setLoadSelection(string $guid)
{
// check if we have load selection
$this->active[$guid]->load_selection =
(isset($this->active[$guid]->load_selection)
&& JsonHelper::check(
$this->active[$guid]->load_selection
)) ? json_decode((string) $this->active[$guid]->load_selection,
true) : null;
if (ArrayHelper::check($this->active[$guid]->load_selection))
{
// load use ids
array_map(
// just load it directly and be done with it
fn($power) => $this->set($power['load']),
$this->active[$guid]->load_selection
);
}
else
{
$this->active[$guid]->load_selection = null;
}
}
/**
* Set Composer Linked Use and Access Point
*
* @param string $guid The global unique id of the power
*
* @return void
* @since 3.2.0
*/
private function setComposer(string $guid)
{
// does this have composer powers
$_composer = (isset($this->active[$guid]->composer)
&& JsonHelper::check(
$this->active[$guid]->composer
)) ? json_decode((string) $this->active[$guid]->composer, true) :
null;
unset($this->active[$guid]->composer);
if (ArrayHelper::check($_composer))
{
// reserve composer values for the linker
$this->active[$guid]->unchanged_composer = $_composer;
foreach ($_composer as $composer)
{
if (isset($composer['access_point']) &&
StringHelper::check($composer['access_point']) &&
isset($composer['namespace']) &&
ArrayHelper::check($composer['namespace']))
{
foreach ($composer['namespace'] as $_namespace)
{
// make sure we have a valid namespace
if (isset($_namespace['use']) &&
StringHelper::check($_namespace['use']) &&
strpos((string) $_namespace['use'], '\\') !==
false)
{
// add the namespace to this access point
$as = 'default';
if (strpos((string) $_namespace['use'], ' as ')
!== false)
{
$namespace_as = explode(' as ', (string)
$_namespace['use']);
// make sure the AS value is set
if (count($namespace_as) == 2)
{
$as = trim(trim($namespace_as[1], ';'));
}
$namespace = $this->getCleanNamespace($namespace_as[0]);
}
else
{
// trim possible use or ; added to the namespace
$namespace =
$this->getCleanNamespace($_namespace['use']);
}
// check if still valid
if (!StringHelper::check($namespace))
{
continue;
}
// add to the header of the class
$this->addToHeader($guid, $this->getUseNamespace($namespace,
$as));
// add composer namespaces for autoloader
$this->composer[$namespace] =
$composer['access_point'];
}
}
}
}
}
else
{
// reserve composer values for the linker
$this->active[$guid]->unchanged_composer = '';
}
}
/**
* Set Implements Interface classes
*
* @param string $guid The global unique id of the power
* @param array $use The use array
*
* @return void
* @since 3.2.0
*/
private function setImplements(string $guid, array &$use)
{
// see if we have implements
$this->active[$guid]->implement_names = [];
// does this implement
$this->active[$guid]->implements =
(isset($this->active[$guid]->implements)
&& JsonHelper::check(
$this->active[$guid]->implements
)) ? json_decode((string) $this->active[$guid]->implements, true)
: null;
if ($this->active[$guid]->implements)
{
foreach ($this->active[$guid]->implements as $implement)
{
if ($implement == -1
&&
StringHelper::check($this->active[$guid]->implements_custom))
{
// reserve implements custom for the linker
$this->active[$guid]->unchanged_implements_custom =
$this->active[$guid]->implements_custom;
$this->active[$guid]->implement_names[] =
$this->placeholder->update_(
$this->customcode->update($this->active[$guid]->implements_custom)
);
// just add this once
unset($this->active[$guid]->implements_custom);
}
// does this extend existing
elseif (GuidHelper::valid($implement))
{
// check if it was set
if ($this->set($implement))
{
// get the name
$this->active[$guid]->implement_names[] =
$this->get($implement, 1)->class_name;
// add to use
$use[] = $implement;
}
}
}
}
}
/**
* Set Extend
*
* @param string $guid The global unique id of the power
* @param array $use The use array
* @param array $as The use as array
*
* @return void
* @since 3.2.0
*/
private function setExtend(string $guid, array &$use, array &$as)
{
// build the interface extends details
if ($this->active[$guid]->type === 'interface')
{
$this->setExtendInterface($guid, $use, $as);
}
else
{
$this->setExtendClass($guid, $use, $as);
}
}
/**
* Set Extend Class
*
* @param string $guid The global unique id of the power
* @param array $use The use array
* @param array $as The use as array
*
* @return void
* @since 3.2.0
*/
private function setExtendClass(string $guid, array &$use, array
&$as)
{
// we first check for custom extending options
if ($this->active[$guid]->extends == -1
&&
StringHelper::check($this->active[$guid]->extends_custom))
{
// reserve extends custom for the linker
$this->active[$guid]->unchanged_extends_custom =
$this->active[$guid]->extends_custom;
$this->active[$guid]->extends_name =
$this->placeholder->update_(
$this->customcode->update($this->active[$guid]->extends_custom)
);
// just add once
unset($this->active[$guid]->extends_custom);
}
// does this extend existing
elseif (GuidHelper::valid($this->active[$guid]->extends))
{
// check if it was set
if ($this->set($this->active[$guid]->extends))
{
// get the name
$this->active[$guid]->extends_name =
$this->get($this->active[$guid]->extends, 1)->class_name;
// add to use
$use[] = $this->active[$guid]->extends;
// add padding if the two names are the same
if ($this->active[$guid]->extends_name ===
$this->active[$guid]->class_name)
{
$this->active[$guid]->extends_name =
$as[$this->active[$guid]->extends]
= 'Extending' . $this->active[$guid]->class_name;
}
}
}
// reset it not found
else
{
$this->active[$guid]->extends = '';
$this->active[$guid]->extends_custom = '';
}
// always rest these for normal classes
$this->active[$guid]->extendsinterfaces = null;
$this->active[$guid]->extendsinterfaces_custom = '';
}
/**
* Set Extend Interface
*
* @param string $guid The global unique id of the power
* @param array $use The use array
* @param array $as The use as array
*
* @return void
* @since 3.2.2
*/
private function setExtendInterface(string $guid, array &$use, array
&$as)
{
// does this extends interfaces
$this->active[$guid]->extendsinterfaces =
(isset($this->active[$guid]->extendsinterfaces)
&& JsonHelper::check(
$this->active[$guid]->extendsinterfaces
)) ? json_decode((string)$this->active[$guid]->extendsinterfaces,
true) : null;
if (ArrayHelper::check($this->active[$guid]->extendsinterfaces))
{
$bucket = [];
foreach ($this->active[$guid]->extendsinterfaces as $extend)
{
// we first check for custom extending options
if ($extend == -1
&&
isset($this->active[$guid]->extendsinterfaces_custom)
&&
StringHelper::check($this->active[$guid]->extendsinterfaces_custom))
{
// reserve extends custom for the linker
$this->active[$guid]->unchanged_extendsinterfaces_custom =
$this->active[$guid]->extendsinterfaces_custom;
$bucket[] = $this->placeholder->update_(
$this->customcode->update($this->active[$guid]->extendsinterfaces_custom)
);
// just add once
unset($this->active[$guid]->extendsinterfaces_custom);
}
// does this extend existing
elseif (GuidHelper::valid($extend))
{
// check if it was set
if ($this->set($extend))
{
$extends_name = $this->get($extend, 1)->class_name;
// add to use
$use[] = $extend;
// add padding if the two names are the same
if ($extends_name === $this->active[$guid]->class_name)
{
$extends_name = $as[$extend]
= 'Extending' . $extends_name;
}
// get the name
$bucket[] = $extends_name;
}
}
}
if ($bucket !== [])
{
$this->active[$guid]->extends_name = implode(', ',
$bucket);
}
}
else
{
$this->active[$guid]->extendsinterfaces = null;
$this->active[$guid]->extendsinterfaces_custom = '';
}
// always rest these for interfaces
$this->active[$guid]->extends = '';
$this->active[$guid]->extends_custom = '';
}
/**
* Set Extra Use Classes
*
* @param string $guid The global unique id of the power
* @param array $use The use array
* @param array $as The use as array
*
* @return void
* @since 3.2.0
*/
private function setUseAs(string $guid, array $use, array $as)
{
// now add all the extra use statements
if (ArrayHelper::check($use))
{
foreach (array_unique($use) as $u)
{
if ($this->set($u))
{
// get the namespace
$namespace = $this->get($u, 1)->namespace;
// check if it has an AS option
if (isset($as[$u]) && StringHelper::check($as[$u]))
{
// add to the header of the class
$this->addToHeader($guid, $this->getUseNamespace($namespace,
$as[$u]));
}
else
{
// add to the header of the class
$this->addToHeader($guid, $this->getUseNamespace($namespace));
}
}
}
}
}
/**
* Get Clean Namespace without use or ; as part of the name space
*
* @param string $namespace The actual name space
* @param bool $removeNumbers The switch to remove numbers
*
* @return string
* @since 3.2.0
*/
private function getCleanNamespace(string $namespace): string
{
// trim possible (use) or (;) or (starting or ending \) added to the
namespace
return NamespaceHelper::safe(str_replace(['use ',
';'], '', $namespace));
}
/**
* Get [use Namespace\Class;]
*
* @param string $namespace The actual name space
* @param string $as The use as name (default is none)
*
* @return string
* @since 3.2.0
*/
private function getUseNamespace(string $namespace, string $as =
'default'): string
{
// check if it has an AS option
if ($as !== 'default')
{
return 'use ' . $namespace . ' as ' . $as .
';';
}
return 'use ' . $namespace . ';';
}
/**
* Add to class header
*
* @param string $guid The global unique id of the power
* @param string $string The string to add to header
*
* @return void
* @since 3.2.0
*/
private function addToHeader(string $guid, string $string)
{
// check if it is already added manually
if (isset($this->active[$guid]->head) &&
strpos((string) $this->active[$guid]->head, $string) === false)
{
$this->active[$guid]->head .= $string . PHP_EOL;
}
}
/**
* Set the power licensing template
*
* @param string $guid The global unique id of the power
* @param array $guiMapper The gui mapper array
*
* @return void
* @since 3.2.0
*/
private function setLicensingTemplate(string $guid, array $guiMapper):
void
{
if ($this->active[$guid]->add_licensing_template == 2 &&
StringHelper::check($this->active[$guid]->licensing_template))
{
// set GUI mapper field
$guiMapper['field'] = 'licensing_template';
// reserve licensing template for the linker
$this->active[$guid]->unchanged_licensing_template =
base64_decode(
(string) $this->active[$guid]->licensing_template
);
// base64 Decode code
$this->active[$guid]->licensing_template = $this->gui->set(
$this->placeholder->update_(
$this->customcode->update(
$this->active[$guid]->unchanged_licensing_template
)
),
$guiMapper
);
}
else
{
$this->active[$guid]->add_licensing_template = 1;
$this->active[$guid]->licensing_template = '';
$this->active[$guid]->unchanged_licensing_template =
'';
}
}
/**
* Set the power header script
*
* @param string $guid The global unique id of the power
* @param array $guiMapper The gui mapper array
*
* @return void
* @since 3.2.0
*/
private function setHeader(string $guid, array $guiMapper): void
{
if ($this->active[$guid]->add_head == 1)
{
// set GUI mapper field
$guiMapper['field'] = 'head';
// reserve header for the linker
$this->active[$guid]->unchanged_head = base64_decode(
(string) $this->active[$guid]->head
);
// base64 Decode code
$this->active[$guid]->head = $this->gui->set(
$this->placeholder->update_(
$this->customcode->update(
$this->active[$guid]->unchanged_head
)
),
$guiMapper
) . PHP_EOL;
}
else
{
$this->active[$guid]->head = '';
$this->active[$guid]->unchanged_head = '';
}
}
/**
* Set the power main class code
*
* @param string $guid The global unique id of the power
* @param array $guiMapper The gui mapper array
*
* @return void
* @since 3.2.0
*/
private function setMainClassCode(string $guid, array $guiMapper): void
{
if (StringHelper::check($this->active[$guid]->main_class_code))
{
// reserve main class code for the linker
$this->active[$guid]->unchanged_main_class_code = base64_decode(
(string) $this->active[$guid]->main_class_code
);
// set GUI mapper field
$guiMapper['field'] = 'main_class_code';
// base64 Decode code
$this->active[$guid]->main_class_code = $this->gui->set(
$this->placeholder->update_(
$this->customcode->update(
$this->active[$guid]->unchanged_main_class_code
)
),
$guiMapper
);
}
else
{
$this->active[$guid]->unchanged_main_class_code = '';
$this->active[$guid]->main_class_code = '';
}
}
/**
* Set the super powers of this power
*
* @param string $guid The global unique id of the power
*
* @return void
* @since 3.2.0
*/
private function setSuperPowers(string $guid): void
{
// set the approved super power values
if ($this->config->add_super_powers &&
$this->active[$guid]->approved == 1)
{
$this->active[$guid]->approved_paths =
(isset($this->active[$guid]->approved_paths)
&& JsonHelper::check(
$this->active[$guid]->approved_paths
)) ? json_decode((string) $this->active[$guid]->approved_paths,
true) : null;
if (ArrayHelper::check($this->active[$guid]->approved_paths))
{
$global_path = $this->config->local_powers_repository_path;
// update all paths
$this->active[$guid]->super_power_paths =
array_map(function($path) use($global_path, $guid) {
// remove branch
if (($pos = strpos($path, ':')) !== false)
{
$path = substr($path, 0, $pos);
}
// set the repo path
$repo = $global_path . '/' . $path;
// set SuperPowerKey (spk)
$spk = 'Super---' . str_replace('-',
'_', $guid) . '---Power';
// set the global super power
$this->superpowers[$repo][$guid] = [
'name' => $this->active[$guid]->code_name,
'type' => $this->active[$guid]->type,
'namespace' => $this->active[$guid]->_namespace,
'code' => 'src/' . $guid .
'/code.php',
'power' => 'src/' . $guid .
'/code.power',
'settings' => 'src/' . $guid .
'/settings.json',
'path' => 'src/' . $guid,
'spk' => $spk,
'guid' => $guid
];
return $repo . '/src/' . $guid;
}, array_values($this->active[$guid]->approved_paths));
return;
}
}
// reset all to avoid any misunderstanding down steam
$this->active[$guid]->super_power_paths = null;
$this->active[$guid]->approved_paths = null;
$this->active[$guid]->approved = null;
}
}
src/Componentbuilder/Compiler/Power/Autoloader.php000064400000047107151162054170016335
0ustar00<?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\Power;
use VDM\Joomla\Componentbuilder\Compiler\Power;
use VDM\Joomla\Componentbuilder\Compiler\Config;
use VDM\Joomla\Componentbuilder\Compiler\Builder\ContentOne as Content;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Line;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Indent;
use VDM\Joomla\Utilities\ArrayHelper;
/**
* Compiler Autoloader
*
* @since 3.2.0
*/
class Autoloader
{
/**
* The Power Class.
*
* @var Power
* @since 3.2.0
*/
protected Power $power;
/**
* The Config Class.
*
* @var Config
* @since 3.2.0
*/
protected Config $config;
/**
* The ContentOne Class.
*
* @var Content
* @since 3.2.0
*/
protected Content $content;
/**
* Installer Class Autoloader
*
* @var string
* @since 5.0.2
**/
protected string $installerhelper = '';
/**
* Helper Class Autoloader
*
* @var string
* @since 3.2.0
**/
protected string $helper = '';
/**
* Constructor.
*
* @param Power $power The Power Class.
* @param Config $config The Config Class.
* @param Content $content The Content One Class.
*
* @since 3.2.0
*/
public function __construct(Power $power, Config $config, Content
$content)
{
$this->power = $power;
$this->config = $config;
$this->content = $content;
// reset all autoloaders power placeholders
$this->content->set('ADMIN_POWER_HELPER', '');
$this->content->set('SITE_POWER_HELPER', '');
$this->content->set('INSTALLER_POWER_HELPER',
'');
$this->content->set('PLUGIN_POWER_AUTOLOADER',
'');
$this->content->set('SITE_PLUGIN_POWER_AUTOLOADER',
'');
$this->content->set('POWER_AUTOLOADER', '');
$this->content->set('ONE_POWER_AUTOLOADER',
'');
$this->content->set('TWO_POWER_AUTOLOADER',
'');
$this->content->set('THREE_POWER_AUTOLOADER',
'');
$this->content->set('FOUR_POWER_AUTOLOADER',
'');
$this->content->set('SITE_POWER_AUTOLOADER',
'');
$this->content->set('SITE_ONE_POWER_AUTOLOADER',
'');
$this->content->set('SITE_TWO_POWER_AUTOLOADER',
'');
$this->content->set('SITE_THREE_POWER_AUTOLOADER',
'');
$this->content->set('SITE_FOUR_POWER_AUTOLOADER',
'');
$this->content->set('INSTALLER_POWER_AUTOLOADER_ARRAY',
'');
}
/**
* Set the autoloader into the active content array
*
* @return void
* @since 3.2.0
*/
public function setFiles()
{
// for plugins
$this->content->set('PLUGIN_POWER_AUTOLOADER', PHP_EOL .
PHP_EOL . $this->getAutoloaderFile(2));
$this->content->set('SITE_PLUGIN_POWER_AUTOLOADER',
PHP_EOL . PHP_EOL . $this->getAutoloaderFile(2,
'JPATH_SITE'));
// for site spaced special cases
$this->content->set('SITE_ONE_POWER_AUTOLOADER',
$this->getAutoloaderFile(1, 'JPATH_SITE'));
$this->content->set('SITE_TWO_POWER_AUTOLOADER',
$this->getAutoloaderFile(2, 'JPATH_SITE'));
$this->content->set('SITE_THREE_POWER_AUTOLOADER',
$this->getAutoloaderFile(3, 'JPATH_SITE'));
$this->content->set('SITE_FOUR_POWER_AUTOLOADER',
$this->getAutoloaderFile(4, 'JPATH_SITE'));
// for admin spaced special cases
$this->content->set('ONE_POWER_AUTOLOADER',
$this->getAutoloaderFile(1));
$this->content->set('TWO_POWER_AUTOLOADER',
$this->getAutoloaderFile(2));
$this->content->set('THREE_POWER_AUTOLOADER',
$this->getAutoloaderFile(3));
$this->content->set('FOUR_POWER_AUTOLOADER',
$this->getAutoloaderFile(4));
// to add to custom files
$this->content->add('POWER_AUTOLOADER',
$this->getAutoloaderFile(0));
$this->content->add('SITE_POWER_AUTOLOADER',
$this->getAutoloaderFile(0, 'JPATH_SITE'));
// to add to install file
$this->content->add('INSTALLER_POWER_AUTOLOADER_ARRAY',
$this->getAutoloaderInstallArray());
}
/**
* Set the autoloader into the active content array
*
* @return void
* @since 3.2.0
*/
public function set()
{
// make sure we only load this once
if (ArrayHelper::check($this->power->namespace) &&
!$this->content->isString('ADMIN_POWER_HELPER'))
{
/* ********************** IMPORTANT SORT NOTICE
*****************************************
* make sure the name space values are sorted from the longest string
to the shortest
* so that the search do not mistakenly match a shorter namespace
before a longer one
* that has the same short namespace for example:
* NameSpace\SubName\Sub <- will always match first
* NameSpace\SubName\SubSubName
* Should the shorter namespace be listed [first] it will match both
of these:
* NameSpace\SubName\Sub\ClassName
* ^^^^^^^^^^^^^^^^^^^^^^
* NameSpace\SubName\SubSubName\ClassName
* ^^^^^^^^^^^^^^^^^^^^^^
**
*********************************************************************************************/
uksort($this->power->namespace, fn($a, $b) => strlen((string)
$b) - strlen((string) $a));
// load to admin helper class
$this->content->add('ADMIN_POWER_HELPER',
$this->getAutoloaderCode());
// load to site helper class if needed
$this->content->add('SITE_POWER_HELPER',
$this->getAutoloaderCode());
// load to installer helper class if needed
$this->content->add('INSTALLER_POWER_HELPER',
$this->getAutoloaderInstallerCode());
}
}
/**
* Get autoloader code
*
* @return string
* @since 3.2.0
*/
private function getAutoloaderCode(): string
{
// check if it was already build
if (!empty($this->helper))
{
return $this->helper;
}
// load the code
$code = [];
// add the composer stuff here
if (($script = $this->getComposer()) !== null)
{
$code[] = $script;
}
// get the helper autoloader
if (($script = $this->getAutoloader()) !== null)
{
$code[] = $script;
}
// if we have any
if (!empty($code))
{
$this->helper = PHP_EOL . PHP_EOL . implode(PHP_EOL . PHP_EOL,
$code);
}
return $this->helper;
}
/**
* Get autoloader file
*
* @param int $tabSpace The dynamic tab spacer
* @param string $area The target area
*
* @return string|null
* @since 3.2.1
*/
private function getAutoloaderFile(int $tabSpace, string $area =
'JPATH_ADMINISTRATOR'): ?string
{
// we start building the autoloader file loader
$autoload_file = [];
$autoload_file[] = Indent::_($tabSpace) . '//'
. Line::_(__Line__, __Class__) . " The power autoloader for this
project ($area) area.";
$autoload_file[] = Indent::_($tabSpace) . "\$power_autoloader =
$area . '/components/com_"
. $this->config->get('component_code_name',
'ERROR') . '/'
. $this->config->get('component_autoloader_path',
'ERROR') . "';";
$autoload_file[] = Indent::_($tabSpace) . 'if
(file_exists($power_autoloader))';
$autoload_file[] = Indent::_($tabSpace) . '{';
$autoload_file[] = Indent::_($tabSpace) . Indent::_(1) .
'require_once $power_autoloader;';
$autoload_file[] = Indent::_($tabSpace) . '}';
return implode(PHP_EOL, $autoload_file);
}
/**
* Get autoloader code
*
* @return string|null
* @since 3.2.0
*/
private function getAutoloader(): ?string
{
if (($size = ArrayHelper::check($this->power->namespace)) > 0)
{
// we start building the spl_autoload_register function call
$autoload_method = [];
$autoload_method[] = '//'
. Line::_(__Line__, __Class__) . ' register additional
namespace';
$autoload_method[] = 'spl_autoload_register(function ($class)
{';
$autoload_method[] = Indent::_(1) . '//'
. Line::_(__Line__, __Class__) . ' project-specific base
directories and namespace prefix';
$autoload_method[] = Indent::_(1) . '$search = [';
// counter to manage the comma in the actual array
$counter = 1;
foreach ($this->power->namespace as $base_dir => $prefix)
{
// don't add the ending comma on last value
if ($size == $counter)
{
$autoload_method[] = Indent::_(2) . "'" .
$this->config->get('jcb_powers_path',
'libraries/jcb_powers') . "/$base_dir' =>
'" . implode('\\\\', $prefix) . "'";
}
else
{
$autoload_method[] = Indent::_(2) . "'" .
$this->config->get('jcb_powers_path',
'libraries/jcb_powers') . "/$base_dir' =>
'" . implode('\\\\', $prefix) . "',";
}
$counter++;
}
$autoload_method[] = Indent::_(1) . '];';
$autoload_method[] = Indent::_(1) . '// Start the search and load
if found';
$autoload_method[] = Indent::_(1) . '$found = false;';
$autoload_method[] = Indent::_(1) . '$found_base_dir =
"";';
$autoload_method[] = Indent::_(1) . '$found_len = 0;';
$autoload_method[] = Indent::_(1) . 'foreach ($search as $base_dir
=> $prefix)';
$autoload_method[] = Indent::_(1) . '{';
$autoload_method[] = Indent::_(2) . '//'
. Line::_(__Line__, __Class__) . ' does the class use the
namespace prefix?';
$autoload_method[] = Indent::_(2) . '$len =
strlen($prefix);';
$autoload_method[] = Indent::_(2) . 'if (strncmp($prefix, $class,
$len) === 0)';
$autoload_method[] = Indent::_(2) . '{';
$autoload_method[] = Indent::_(3) . '//'
. Line::_(__Line__, __Class__) . ' we have a match so load the
values';
$autoload_method[] = Indent::_(3) . '$found = true;';
$autoload_method[] = Indent::_(3) . '$found_base_dir =
$base_dir;';
$autoload_method[] = Indent::_(3) . '$found_len = $len;';
$autoload_method[] = Indent::_(3) . '//'
. Line::_(__Line__, __Class__) . ' done here';
$autoload_method[] = Indent::_(3) . 'break;';
$autoload_method[] = Indent::_(2) . '}';
$autoload_method[] = Indent::_(1) . '}';
$autoload_method[] = Indent::_(1) . '//'
. Line::_(__Line__, __Class__) . ' check if we found a
match';
$autoload_method[] = Indent::_(1) . 'if (!$found)';
$autoload_method[] = Indent::_(1) . '{';
$autoload_method[] = Indent::_(2) . '//'
. Line::_(__Line__, __Class__) . ' not found so move to the next
registered autoloader';
$autoload_method[] = Indent::_(2) . 'return;';
$autoload_method[] = Indent::_(1) . '}';
$autoload_method[] = Indent::_(1) . '//'
. Line::_(__Line__, __Class__) . ' get the relative class
name';
$autoload_method[] = Indent::_(1) . '$relative_class =
substr($class, $found_len);';
$autoload_method[] = Indent::_(1) . '//'
. Line::_(__Line__, __Class__) . ' replace the namespace prefix
with the base directory, replace namespace';
$autoload_method[] = Indent::_(1) . '// separators with directory
separators in the relative class name, append';
$autoload_method[] = Indent::_(1) . '// with .php';
$autoload_method[] = Indent::_(1) . "\$file = JPATH_ROOT .
'/' . \$found_base_dir . '/src' .
str_replace('\\\\', '/', \$relative_class) .
'.php';";
$autoload_method[] = Indent::_(1) . '//'
. Line::_(__Line__, __Class__) . ' if the file exists, require
it';
$autoload_method[] = Indent::_(1) . 'if
(file_exists($file))';
$autoload_method[] = Indent::_(1) . '{';
$autoload_method[] = Indent::_(2) . 'require $file;';
$autoload_method[] = Indent::_(1) . '}';
$autoload_method[] = '});';
return implode(PHP_EOL, $autoload_method);
}
return null;
}
/**
* Get the composer autoloader routine
*
* @return string|null
* @since 3.2.0
*/
private function getComposer(): ?string
{
if (ArrayHelper::check($this->power->composer))
{
// load the composer routine
$composer_routine = [];
// counter to manage the comma in the actual array
$add_once = [];
foreach ($this->power->composer as $access_point)
{
// don't add the ending comma on last value
if (empty($add_once[$access_point]))
{
$composer_routine[] = "\$composer_autoloader = JPATH_LIBRARIES .
'/$access_point';";
$composer_routine[] = 'if
(file_exists($composer_autoloader))';
$composer_routine[] = "{";
$composer_routine[] = Indent::_(1) . 'require_once
$composer_autoloader;';
$composer_routine[] = "}";
$add_once[$access_point] = true;
}
}
// this is just about the [autoloader or autoloaders] in the comment ;)
if (count($add_once) == 1)
{
array_unshift($composer_routine, '//'
. Line::_(__Line__, __Class__) . ' add the autoloader for the
composer classes');
}
else
{
array_unshift($composer_routine, '//'
. Line::_(__Line__, __Class__) . ' add the autoloaders for the
composer classes');
}
return implode(PHP_EOL, $composer_routine);
}
return null;
}
/**
* Get autoloaders for install file
*
* @return string
* @since 5.0.2
*/
private function getAutoloaderInstallArray(): string
{
// we start building the autoloader file loader
$autoload_file = [];
$autoload_file[] = PHP_EOL . Indent::_(3) . "__DIR__ . '/"
.
$this->config->get('component_installer_autoloader_path',
'ERROR') . "',";
$autoload_file[] = Indent::_(3) . "JPATH_ADMINISTRATOR .
'/components/com_"
. $this->config->get('component_code_name',
'ERROR') . '/'
. $this->config->get('component_autoloader_path',
'ERROR') . "'" . PHP_EOL . Indent::_(2);
return implode(PHP_EOL, $autoload_file);
}
/**
* Get installer autoloader code
*
* @return string
* @since 5.0.2
*/
private function getAutoloaderInstallerCode(): string
{
// check if it was already build
if (!empty($this->installerhelper))
{
return $this->installerhelper;
}
// load the code
$code = [];
// add the composer stuff here
// if (($script = $this->getInstallerComposer()) !== null)
// {
// $code[] = $script;
// }
// get the helper autoloader
if (($script = $this->getInstallerAutoloader()) !== null)
{
$code[] = $script;
}
// if we have any
if (!empty($code))
{
$this->installerhelper = PHP_EOL . PHP_EOL . implode(PHP_EOL .
PHP_EOL, $code);
}
return $this->installerhelper;
}
/**
* Get autoloader code
*
*
* @return string|null
* @since 3.2.0
*/
private function getInstallerAutoloader(): ?string
{
if (($size = ArrayHelper::check($this->power->namespace)) > 0)
{
// we start building the spl_autoload_register function call
$autoload_method = [];
$autoload_method[] = '//'
. Line::_(__Line__, __Class__) . ' register additional
namespace';
$autoload_method[] = 'spl_autoload_register(function ($class)
{';
$autoload_method[] = Indent::_(1) . '//'
. Line::_(__Line__, __Class__) . ' project-specific base
directories and namespace prefix';
$autoload_method[] = Indent::_(1) . '$search = [';
// counter to manage the comma in the actual array
$counter = 1;
foreach ($this->power->namespace as $base_dir => $prefix)
{
// don't add the ending comma on last value
if ($size == $counter)
{
$autoload_method[] = Indent::_(2) . "'" .
$this->config->get('jcb_powers_path',
'libraries/jcb_powers') . "/$base_dir' =>
'" . implode('\\\\', $prefix) . "'";
}
else
{
$autoload_method[] = Indent::_(2) . "'" .
$this->config->get('jcb_powers_path',
'libraries/jcb_powers') . "/$base_dir' =>
'" . implode('\\\\', $prefix) . "',";
}
$counter++;
}
$autoload_method[] = Indent::_(1) . '];';
$autoload_method[] = Indent::_(1) . '// Start the search and load
if found';
$autoload_method[] = Indent::_(1) . '$found = false;';
$autoload_method[] = Indent::_(1) . '$found_base_dir =
"";';
$autoload_method[] = Indent::_(1) . '$found_len = 0;';
$autoload_method[] = Indent::_(1) . 'foreach ($search as $base_dir
=> $prefix)';
$autoload_method[] = Indent::_(1) . '{';
$autoload_method[] = Indent::_(2) . '//'
. Line::_(__Line__, __Class__) . ' does the class use the
namespace prefix?';
$autoload_method[] = Indent::_(2) . '$len =
strlen($prefix);';
$autoload_method[] = Indent::_(2) . 'if (strncmp($prefix, $class,
$len) === 0)';
$autoload_method[] = Indent::_(2) . '{';
$autoload_method[] = Indent::_(3) . '//'
. Line::_(__Line__, __Class__) . ' we have a match so load the
values';
$autoload_method[] = Indent::_(3) . '$found = true;';
$autoload_method[] = Indent::_(3) . '$found_base_dir =
$base_dir;';
$autoload_method[] = Indent::_(3) . '$found_len = $len;';
$autoload_method[] = Indent::_(3) . '//'
. Line::_(__Line__, __Class__) . ' done here';
$autoload_method[] = Indent::_(3) . 'break;';
$autoload_method[] = Indent::_(2) . '}';
$autoload_method[] = Indent::_(1) . '}';
$autoload_method[] = Indent::_(1) . '//'
. Line::_(__Line__, __Class__) . ' check if we found a
match';
$autoload_method[] = Indent::_(1) . 'if (!$found)';
$autoload_method[] = Indent::_(1) . '{';
$autoload_method[] = Indent::_(2) . '//'
. Line::_(__Line__, __Class__) . ' not found so move to the next
registered autoloader';
$autoload_method[] = Indent::_(2) . 'return;';
$autoload_method[] = Indent::_(1) . '}';
$autoload_method[] = Indent::_(1) . '//'
. Line::_(__Line__, __Class__) . ' get the relative class
name';
$autoload_method[] = Indent::_(1) . '$relative_class =
substr($class, $found_len);';
$autoload_method[] = Indent::_(1) . '//'
. Line::_(__Line__, __Class__) . ' replace the namespace prefix
with the base directory, replace namespace';
$autoload_method[] = Indent::_(1) . '// separators with directory
separators in the relative class name, append';
$autoload_method[] = Indent::_(1) . '// with .php';
$autoload_method[] = Indent::_(1) . "\$file = __DIR__ .
'/' . \$found_base_dir . '/src' .
str_replace('\\\\', '/', \$relative_class) .
'.php';";
$autoload_method[] = Indent::_(1) . '//'
. Line::_(__Line__, __Class__) . ' if the file exists, require
it';
$autoload_method[] = Indent::_(1) . 'if
(file_exists($file))';
$autoload_method[] = Indent::_(1) . '{';
$autoload_method[] = Indent::_(2) . 'require $file;';
$autoload_method[] = Indent::_(1) . '}';
$autoload_method[] = '});';
return implode(PHP_EOL, $autoload_method);
}
return null;
}
/**
* Get the composer autoloader routine (NOT READY)
*
*
* @return string|null
* @since 3.2.0
*/
private function getInstallerComposer(): ?string
{
if (ArrayHelper::check($this->power->composer))
{
// load the composer routine
$composer_routine = [];
// counter to manage the comma in the actual array
$add_once = [];
foreach ($this->power->composer as $access_point)
{
// don't add the ending comma on last value
if (empty($add_once[$access_point]))
{
$composer_routine[] = "\$composer_autoloader = __DIR__ .
'/libraries/$access_point';";
$composer_routine[] = 'if
(file_exists($composer_autoloader))';
$composer_routine[] = "{";
$composer_routine[] = Indent::_(1) . 'require_once
$composer_autoloader;';
$composer_routine[] = "}";
$add_once[$access_point] = true;
}
}
// this is just about the [autoloader or autoloaders] in the comment ;)
if (count($add_once) == 1)
{
array_unshift($composer_routine, '//'
. Line::_(__Line__, __Class__) . ' add the autoloader for the
composer classes');
}
else
{
array_unshift($composer_routine, '//'
. Line::_(__Line__, __Class__) . ' add the autoloaders for the
composer classes');
}
return implode(PHP_EOL, $composer_routine);
}
return null;
}
}
src/Componentbuilder/Compiler/Power/Extractor.php000064400000012402151162054170016177
0ustar00<?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\Power;
use Joomla\CMS\Factory;
use VDM\Joomla\Utilities\GuidHelper;
use
VDM\Joomla\Componentbuilder\Compiler\Interfaces\Power\ExtractorInterface;
/**
* Compiler Power Extractor
* @since 3.2.0
*/
class Extractor implements ExtractorInterface
{
/**
* The pattern to get the powers
*
* @var string
* @since 3.2.0
**/
protected string $pattern =
'/Super_'.'_'.'_[a-zA-Z0-9_]+_'.'_'.'_Power/';
/**
* The pattern to get the Front
*
* @var string
* @since 3.2.1
**/
protected string $_pattern = 'Super';
/**
* The pattern to get the Back
*
* @var string
* @since 3.2.1
**/
protected string $pattern_ = 'Power';
/**
* The Table
*
* @var string
* @since 3.2.1
**/
protected string $table = 'power';
/**
* Powers GUID's
*
* @var array
* @since 3.2.0
**/
protected array $powers = [];
/**
* Database object to query local DB
*
* @since 3.2.0
**/
protected $db;
/**
* Constructor
*
* @since 3.2.0
*/
public function __construct()
{
$this->db = Factory::getDbo();
}
/**
* Get Super Powers from the code string
*
* @param string $code The code
*
* @return array|null
* @since 3.2.0
*/
public function get_(): ?array
{
return $this->powers !== [] ? $this->powers : null;
}
/**
* Get Super Powers from the code string
*
* @param string $code The code
*
* @return array|null
* @since 3.2.0
*/
public function get(string $code): ?array
{
$matches = [];
preg_match_all($this->pattern, $code, $matches);
$found = $matches[0];
if (!empty($found))
{
return $this->map($found);
}
return null;
}
/**
* Get Super Powers from the code string
*
* @param string $code The code
*
* @return array|null
* @since 3.2.0
*/
public function reverse(string $code): ?array
{
$matches = [];
preg_match_all($this->pattern, $code, $matches);
$found = $matches[0];
if (!empty($found) && ($guids = $this->filter($found)) !==
null)
{
return $this->namespaces($guids);
}
return null;
}
/**
* Get Super Powers from the code string and load it
*
* @param string $code The code
*
* @return void
* @since 3.2.0
*/
public function search(string $code): void
{
$matches = [];
preg_match_all($this->pattern, $code, $matches);
$found = $matches[0];
if (!empty($found))
{
$this->load($found);
}
}
/**
* Load the Super Powers found
*
* @param array $found The found Super Powers
*
* @return void
* @since 3.2.0
*/
protected function load(array $found)
{
foreach ($found as $super_power)
{
$guid = str_replace([], '', $super_power);
$guid = str_replace('_', '-', $guid);
if (GuidHelper::valid($guid))
{
$this->powers[$guid] = 1; // 1 force the power to be added
}
}
}
/**
* Map the Super Powers to GUIDs
*
* @param array $found The found Super Powers
*
* @return array
* @since 3.2.0
*/
protected function map(array $found): ?array
{
$guids = [];
foreach ($found as $super_power)
{
$guid = str_replace([$this->_pattern . '___',
'___' . $this->pattern_], '', $super_power);
$guid = str_replace('_', '-', $guid);
if (GuidHelper::valid($guid))
{
$guids[$super_power] = $guid;
}
}
return $guids !== [] ? $guids : null;
}
/**
* Filter the Super Powers to GUIDs
*
* @param array $found The found Super Powers
*
* @return array
* @since 3.2.0
*/
protected function filter(array $found): ?array
{
$guids = [];
foreach ($found as $super_power)
{
$guid = str_replace([$this->_pattern . '___',
'___' . $this->pattern_], '', $super_power);
$guid = str_replace('_', '-', $guid);
if (GuidHelper::valid($guid))
{
$guids[$guid] = $guid;
}
}
return $guids !== [] ? array_values($guids) : null;
}
/**
* Get the complete namespace strings of the guids passed as an array.
*
* @param array $guids The guids to filter the results
*
* @return array|null The result namespaces with their guids
* @since 3.2.0
**/
protected function namespaces(array $guids): ?array
{
$query = $this->db->getQuery(true);
$query->select(
'DISTINCT REPLACE('
. $this->db->quoteName('namespace')
. ', ".", "\\\") AS full_namespace, '
. $this->db->quoteName('guid')
)
->from($this->db->quoteName('#__componentbuilder_' .
$this->table))
->where($this->db->quoteName('guid') . ' IN
(' . implode(',', array_map([$this->db,
'quote'], $guids)) . ')');
$this->db->setQuery($query);
$this->db->execute();
if ($this->db->getNumRows())
{
return $this->db->loadAssocList('guid',
'full_namespace');
}
return null;
}
}
src/Componentbuilder/Compiler/Power/Infusion.php000064400000026560151162054170016030
0ustar00<?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\Power;
use VDM\Joomla\Componentbuilder\Compiler\Config;
use VDM\Joomla\Componentbuilder\Compiler\Power;
use VDM\Joomla\Componentbuilder\Compiler\Builder\ContentOne as Content;
use VDM\Joomla\Componentbuilder\Compiler\Builder\ContentMulti as Contents;
use VDM\Joomla\Componentbuilder\Power\Parser;
use VDM\Joomla\Interfaces\Readme\ItemInterface as ItemReadme;
use VDM\Joomla\Interfaces\Readme\MainInterface as MainReadme;
use VDM\Joomla\Componentbuilder\Compiler\Placeholder;
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\EventInterface as
Event;
use VDM\Joomla\Utilities\StringHelper;
use VDM\Joomla\Utilities\ArrayHelper;
use VDM\Joomla\Utilities\ObjectHelper;
/**
* Compiler Power Infusion
* @since 3.2.0
*/
final class Infusion
{
/**
* The Config Class.
*
* @var Config
* @since 3.2.0
*/
protected Config $config;
/**
* The Power Class.
*
* @var Power
* @since 3.2.0
*/
protected Power $power;
/**
* The ContentOne Class.
*
* @var Content
* @since 3.2.0
*/
protected Content $content;
/**
* The ContentMulti Class.
*
* @var Contents
* @since 3.2.0
*/
protected Contents $contents;
/**
* The Parser Class.
*
* @var Parser
* @since 3.2.0
*/
protected Parser $parser;
/**
* The Readme Class.
*
* @var ItemReadme
* @since 3.2.0
*/
protected ItemReadme $itemreadme;
/**
* The Readme Class.
*
* @var MainReadme
* @since 3.2.0
*/
protected MainReadme $mainreadme;
/**
* The Placeholder Class.
*
* @var Placeholder
* @since 3.2.0
*/
protected Placeholder $placeholder;
/**
* The EventInterface Class.
*
* @var Event
* @since 3.2.0
*/
protected Event $event;
/**
* Power linker values
*
* @var array
* @since 3.2.0
**/
protected array $linker = [
'add_head' => 'add_head',
'unchanged_description' => 'description',
'extends' => 'extends',
'unchanged_extends_custom' => 'extends_custom',
'extendsinterfaces' => 'extendsinterfaces',
'unchanged_extendsinterfaces_custom' =>
'extendsinterfaces_custom',
'guid' => 'guid',
'unchanged_head' => 'head',
'use_selection' => 'use_selection',
'implements' => 'implements',
'unchanged_implements_custom' =>
'implements_custom',
'load_selection' => 'load_selection',
'name' => 'name',
'power_version' => 'power_version',
'system_name' => 'system_name',
'type' => 'type',
'unchanged_namespace' => 'namespace',
'unchanged_composer' => 'composer',
'add_licensing_template' =>
'add_licensing_template',
'unchanged_licensing_template' =>
'licensing_template'
];
/**
* Power Infusion Tracker
*
* @var array
* @since 3.2.0
**/
protected array $done = [];
/**
* Power Content Infusion Tracker
*
* @var array
* @since 3.2.0
**/
protected array $content_done = [];
/**
* Path Infusion Tracker
*
* @var array
* @since 3.2.0
**/
protected array $path_done = [];
/**
* Constructor.
*
* @param Config $config The Config Class.
* @param Power $power The Power Class.
* @param Content $content The ContentOne Class.
* @param Contents $contents The ContentMulti Class.
* @param Parser $parser The Parser Class.
* @param ItemReadme $itemreadme The Readme Class.
* @param MainReadme $mainreadme The Readme Class.
* @param Placeholder $placeholder The Placeholder Class.
* @param Event $event The EventInterface Class.
*
* @since 3.2.0
*/
public function __construct(Config $config, Power $power, Content
$content,
Contents $contents, Parser $parser, ItemReadme $itemreadme,
MainReadme $mainreadme, Placeholder $placeholder,
Event $event)
{
$this->config = $config;
$this->power = $power;
$this->content = $content;
$this->contents = $contents;
$this->parser = $parser;
$this->itemreadme = $itemreadme;
$this->mainreadme = $mainreadme;
$this->placeholder = $placeholder;
$this->event = $event;
}
/**
* Infuse the powers data with the content
*
* @return void
* @since 3.2.0
*/
public function set()
{
// parse all powers main code
$this->parsePowers();
// set the powers
$this->setSuperPowers();
// set the powers
$this->setPowers();
}
/**
* We parse the powers to get the class map of all methods
*
* @return void
* @since 3.2.0
*/
private function parsePowers()
{
// we only do this if super powers are active
if ($this->config->add_super_powers &&
ArrayHelper::check($this->power->superpowers))
{
foreach ($this->power->active as $guid => &$power)
{
if (isset($this->done[$guid]))
{
continue;
}
if (ObjectHelper::check($power) &&
isset($power->main_class_code) &&
StringHelper::check($power->main_class_code))
{
// only parse those approved
if ($power->approved == 1)
{
$power->main_class_code =
$this->placeholder->update($power->main_class_code,
$this->content->allActive());
$power->parsed_class_code =
$this->parser->code($power->main_class_code);
}
}
// do each power just once
$this->done[$guid] = true;
}
}
}
/**
* Set the Super Powers details
*
* @return void
* @since 3.2.0
*/
private function setSuperPowers()
{
// infuse super powers details if set
if ($this->config->add_super_powers &&
ArrayHelper::check($this->power->superpowers))
{
foreach ($this->power->superpowers as $path => $powers)
{
if (isset($this->path_done[$path]))
{
continue;
}
$key = StringHelper::safe($path);
// Trigger Event: jcb_ce_onBeforeInfuseSuperPowerDetails
$this->event->trigger(
'jcb_ce_onBeforeInfuseSuperPowerDetails', [&$path,
&$key, &$powers]
);
// we add and all missing powers
if (isset($this->power->old_superpowers[$path]))
{
$this->mergePowers($powers,
$this->power->old_superpowers[$path]);
}
// POWERREADME
$this->contents->set("{$key}|POWERREADME",
$this->mainreadme->get($powers));
// sort all powers
$this->sortPowers($powers);
// POWERINDEX
$this->contents->set("{$key}|POWERINDEX",
$this->index($powers));
// Trigger Event: jcb_ce_onAfterInfuseSuperPowerDetails
$this->event->trigger(
'jcb_ce_onAfterInfuseSuperPowerDetails', [&$path,
&$key, &$powers]
);
// do each path just once
$this->path_done[$path] = true;
}
}
}
/**
* Merge the old missing powers found in local repository back into the
index
*
* @return void
* @since 3.2.0
*/
private function mergePowers(array &$powers, array &$old)
{
foreach ($old as $guid => $values)
{
if (!isset($powers[$guid]))
{
$powers[$guid] = $values;
}
}
}
/**
* Sort Powers
*
* @return void
* @since 3.2.0
*/
private function sortPowers(array &$powers)
{
ksort($powers, SORT_STRING);
}
/**
* Set the Powers code
*
* @return void
* @since 3.2.0
*/
private function setPowers()
{
// infuse powers data if set
if (ArrayHelper::check($this->power->active))
{
foreach ($this->power->active as $guid => $power)
{
if (isset($this->content_done[$guid]))
{
continue;
}
if (ObjectHelper::check($power))
{
// Trigger Event: jcb_ce_onBeforeInfusePowerData
$this->event->trigger(
'jcb_ce_onBeforeInfusePowerData', [&$power]
);
// POWERCODE
$this->contents->set("{$power->key}|POWERCODE",
$this->code($power));
// CODEPOWER
$this->contents->set("{$power->key}|CODEPOWER",
$this->raw($power));
// POWERLINKER
$this->contents->set("{$power->key}|POWERLINKER",
$this->linker($power));
// POWERLINKER
$this->contents->set("{$power->key}|POWERREADME",
$this->itemreadme->get($power));
// Trigger Event: jcb_ce_onAfterInfusePowerData
$this->event->trigger(
'jcb_ce_onAfterInfusePowerData', [&$power]
);
}
// do each power just once
$this->content_done[$guid] = true;
}
}
}
/**
* Build the Super Power Index
*
* @param array $powers All powers of this super power.
*
* @return string
* @since 3.2.0
*/
private function index(array &$powers): string
{
return json_encode($powers, JSON_PRETTY_PRINT);
}
/**
* Get the Power code
*
* @param object $power A power object.
*
* @return string
* @since 3.2.0
*/
private function code(object &$power): string
{
$code = [];
// set the name space
$code[] = 'namespace ' . $power->_namespace . ';'
. PHP_EOL;
// check if we have header data
if (isset($power->head) &&
StringHelper::check($power->head))
{
$code[] = PHP_EOL . $power->head;
}
// add description if set
if (isset($power->description) &&
StringHelper::check($power->description))
{
// check if this is escaped
if (strpos((string) $power->description, '/*') === false)
{
// make this description escaped
$power->description = '/**' . PHP_EOL . ' * ' .
implode(PHP_EOL . ' * ', explode(PHP_EOL, (string)
$power->description)) . PHP_EOL . ' */';
}
$code[] = PHP_EOL . $power->description;
}
// build power declaration
$declaration = $power->type . ' ' . $power->class_name;
// check if we have extends
if (isset($power->extends_name) &&
StringHelper::check($power->extends_name))
{
$declaration .= ' extends ' . $power->extends_name;
}
// check if we have implements
if (isset($power->implement_names) &&
ArrayHelper::check($power->implement_names))
{
$declaration .= ' implements ' . implode(', ',
$power->implement_names);
}
$code[] = $declaration;
$code[] = '{';
// add the main code if set
if (isset($power->main_class_code) &&
StringHelper::check($power->main_class_code))
{
$code[] = $power->main_class_code;
}
$code[] = '}' . PHP_EOL;
return $this->placeholder->update(implode(PHP_EOL, $code),
$this->content->allActive());
}
/**
* Get the Raw (unchanged) Power code
*
* @param object $power A power object.
*
* @return string
* @since 3.2.0
*/
private function raw(object &$power): string
{
// add the raw main code if set
if (isset($power->unchanged_main_class_code) &&
StringHelper::check($power->unchanged_main_class_code))
{
return $power->unchanged_main_class_code;
}
return '';
}
/**
* Get the Power Linker
*
* @param object $power A power object.
*
* @return string
* @since 3.2.0
*/
private function linker(object &$power): string
{
$linker = [];
// set the linking values
foreach ($power as $key => $value)
{
if (isset($this->linker[$key]))
{
$linker[$this->linker[$key]] = $value;
}
}
return json_encode($linker, JSON_PRETTY_PRINT);
}
}
src/Componentbuilder/Compiler/Power/Injector.php000064400000044245151162054170016013
0ustar00<?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\Power;
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\PowerInterface as
Power;
use
VDM\Joomla\Componentbuilder\Compiler\Interfaces\Power\ExtractorInterface as
Extractor;
use VDM\Joomla\Componentbuilder\Power\Parser;
use VDM\Joomla\Componentbuilder\Compiler\Placeholder;
use VDM\Joomla\Utilities\ArrayHelper;
use
VDM\Joomla\Componentbuilder\Compiler\Interfaces\Power\InjectorInterface;
/**
* Compiler Power Injector
* @since 3.2.0
*/
class Injector implements InjectorInterface
{
/**
* Power Objects
*
* @var Power
* @since 3.2.0
**/
protected Power $power;
/**
* Compiler Powers Extractor
*
* @var Extractor
* @since 3.2.0
**/
protected Extractor $extractor;
/**
* Compiler Powers Parser
*
* @var Parser
* @since 3.2.0
**/
protected Parser $parser;
/**
* Compiler Placeholder
*
* @var Placeholder
* @since 3.2.0
*/
protected Placeholder $placeholder;
/**
* Super Power Update Map
*
* @var array
* @since 3.2.0
*/
protected array $map = [];
/**
* Insert Use Statements
*
* @var array
* @since 3.2.0
*/
protected array $useStatements = [];
/**
* Insert Trait Statements
*
* @var array
* @since 3.2.0
*/
protected array $traits = [];
/**
* Other Statements
*
* @var array
* @since 3.2.0
*/
protected array $other = [];
/**
* Duplicate Statements
*
* @var array
* @since 3.2.0
*/
protected array $duplicate = [];
/**
* Constructor.
*
* @param Power|null $power The power object.
* @param Extractor|null $extractor The powers extractor object.
* @param Parser|null $parser The powers parser object.
* @param Placeholder|null $placeholder The compiler placeholder
object.
*
* @since 3.2.0
*/
public function __construct(Power $power = null, Extractor $extractor =
null,
Parser $parser = null, Placeholder $placeholder = null)
{
$this->power = $power;
$this->extractor = $extractor;
$this->parser = $parser;
$this->placeholder = $placeholder;
}
/**
* Inject the powers found in the code
*
* @param string $code The class code
*
* @return string The updated code
* @since 3.2.0
*/
public function power(string $code): string
{
if (($guids = $this->extractor->get($code)) !== null)
{
return $this->update($guids, $code);
}
return $code;
}
/**
* Update the code
*
* @param array $guids The Power guids found
* @param string $code The class code
*
* @return string The updated code
* @since 3.2.0
*/
protected function update(array $guids, string $code): string
{
$use_statements = $this->parser->getUseStatements($code);
$traits = $this->parser->getTraits(
$this->parser->getClassCode($code) ?? ''
);
// reset with each file
$this->map = [];
$this->useStatements = [];
$this->traits = [];
$this->other = [];
$this->duplicate = [];
foreach ($guids as $key => $guid)
{
if (($power = $this->power->get($guid)) !== null)
{
if (($name = $this->inspect($power, $use_statements, $traits)) !==
null)
{
$this->map[$key] = $name;
}
}
}
// update
if ($this->map !== [])
{
if ($this->useStatements !== [])
{
$code = $this->addUseStatements($code, $use_statements);
}
return $this->placeholder->update($code, $this->map);
}
return $code;
}
/**
* Inspect the super power to determine the necessary class name based on
use statements and traits.
* It checks if the given power (class, trait, etc.) already has a
corresponding use statement
* and handles the naming accordingly to avoid conflicts.
*
* @param object $power The power object containing type,
namespace, and class name.
* @param array|null $useStatements Array of existing use statements in
the code.
* @param array|null $traits Array of existing traits used in
the code.
*
* @return string|null The determined class name, or null if the type is
not valid.
* @since 3.2.0
*/
protected function inspect(object $power, ?array $useStatements, ?array
$traits): ?string
{
$namespaceStatement = $this->buildNamespaceStatment($power);
$use_extracted = $this->extractUseStatements($namespaceStatement,
$power->class_name, $useStatements);
$name = $use_extracted['found'] ?? $power->class_name;
$name = $this->getUniqueName($name, $power);
$this->handleTraitLogic($name, $power, $traits);
if (!$use_extracted['hasStatement'])
{
$this->addUseStatement($name, $power->class_name,
$namespaceStatement);
}
return $name;
}
/**
* Builds the namespace statement from the power object's namespace
and class name.
*
* @param object $power The power object.
*
* @return string The constructed use statement.
* @since 3.2.0
*/
protected function buildNamespaceStatment(object $power): string
{
return $power->_namespace . '\\' . $power->class_name;
}
/**
* Extracts and processes use statements to find if the current class name
is already used.
* It identifies any potential naming conflicts.
*
* @param string $useStatement The search statement of the
current class.
* @param string $className The class name of the power
object.
* @param array|null $useStatements The existing use statements.
*
* @return array An array with keys 'found' and
'hasStatement'.
* @since 3.2.0
*/
protected function extractUseStatements(string $useStatement, string
$className, ?array $useStatements): array
{
$results = ['found' => null, 'hasStatement' =>
false];
if ($useStatements !== null)
{
foreach ($useStatements as $use_statement)
{
$class_name = $this->extractClassNameOrAlias($use_statement);
if ($this->isUseStatementEqual($use_statement, $useStatement))
{
if ($results['found'] === null)
{
$results['found'] = $class_name;
$results['hasStatement'] = true;
}
else
{
// TODO we need to backport fix these
$this->duplicate[$use_statement] = $class_name;
}
}
elseif ($className === $class_name)
{
$this->other[$className] = $class_name;
}
}
}
return $results;
}
/**
* Checks if the namespace statement is already declared in the current
use statements.
*
* This method uses a regular expression to check for an exact match of
the full statement,
* taking into account the possibility of an alias being used.
*
* @param string $useStatement The existing use statement to check
against.
* @param string $namespaceStatement The search statement to search for
(without the trailing semicolon, or use prefix).
*
* @return bool True if the full statement is found, false otherwise.
*/
protected function isUseStatementEqual(string $useStatement, string
$namespaceStatement): bool
{
// Create a regular expression pattern to match the full statement
// The pattern checks for the start of the statement, optional
whitespace,
// and an optional alias after the full statement.
$pattern = '/^use\s+' . preg_quote($namespaceStatement,
'/') . '(?:\s+as\s+\w+)?;$/';
// Perform the regex match to check if the use statement is equal to the
search statment
return (bool) preg_match($pattern, $useStatement);
}
/**
* Extracts the class name or alias from a use statement.
*
* This method parses a PHP 'use' statement and extracts either
the class name or its alias.
* If the statement doesn't match the expected format, or if no class
name or alias is found,
* the method returns null.
*
* Example:
* - 'use Namespace\ClassName;' -> returns
'ClassName'
* - 'use Namespace\ClassName as Alias;' -> returns
'Alias'
*
* @param string $useStatement The use statement from which to extract
the class name or alias.
*
* @return string|null The class name or alias if found, null otherwise.
* @since 3.2.0
*/
protected function extractClassNameOrAlias(string $useStatement): ?string
{
// If the input doesn't start with 'use ', assume
it's just the namespace without a use statement
if (strpos($useStatement, 'use ') !== 0)
{
return $this->extractLastNameFromNamespace($useStatement);
}
// Regular expression to extract the class name and alias from the use
statement
$pattern =
'/use\s+(?P<namespace>[\w\\\\]+?)(?:\s+as\s+(?P<alias>\w+))?;/';
if (preg_match($pattern, $useStatement, $matches))
{
// Return the alias if it exists; otherwise, return the last part of the
namespace (class name)
return $matches['alias'] ??
$this->extractLastNameFromNamespace($matches['namespace']);
}
// Return null if no match is found
return null;
}
/**
* Ensures the name for the use statement is unique, avoiding conflicts
with other classes.
*
* @param string $name The current name
* @param object $power The power object containing type, namespace,
and class name.
*
* @return string The unique name
* @since 3.2.0
*/
protected function getUniqueName(string $name, object $power): string
{
// set search namespace
$namespace = ($name !== $power->class_name) ?
$this->buildNamespaceStatment($power) : $power->_namespace;
// check if we need to update the name
if (isset($this->other[$name]))
{
// if the name is already used
while (isset($this->other[$name]))
{
if (($tmp = $this->extractClassNameOrAlias($namespace)) !== null)
{
$name = ucfirst($tmp) . $name;
$namespace = $this->removeLastNameFromNamespace($namespace);
}
else
{
$name = 'Unique' . $name;
}
}
}
// also loop new found use statements
if (isset($this->useStatements[$name]))
{
// if the name is already used
while (isset($this->useStatements[$name]))
{
if (($tmp = $this->extractClassNameOrAlias($namespace)) !== null)
{
$name = ucfirst($tmp) . $name;
$namespace = $this->removeLastNameFromNamespace($namespace);
}
else
{
$name = 'Unique' . $name;
}
}
}
return $name;
}
/**
* Extracts the last part of a namespace string, which is typically the
class name.
*
* @param string $namespace The namespace string to extract from.
*
* @return string|null The extracted class name.
* @since 3.2.0
*/
protected function extractLastNameFromNamespace(string $namespace):
?string
{
$parts = explode('\\', $namespace);
$result = end($parts);
// Remove '\\' from the beginning and end of the resulting
string
$result = trim($result, '\\');
// If the resulting string is empty, return null
return empty($result) ? null : $result;
}
/**
* Removes the last name from the namespace.
*
* @param string $namespace The namespace
*
* @return string The namespace shortened
* @since 3.2.0
*/
protected function removeLastNameFromNamespace(string $namespace): string
{
// Remove '\\' from the beginning and end of the resulting
string
$namespace = trim($namespace, '\\');
$parts = explode('\\', $namespace);
// Remove the last part (the class name)
array_pop($parts);
// Reassemble the namespace without the class name
return implode('\\', $parts);
}
/**
* Determines whether a trait statement should be added.
*
* @param object $power The power object.
*
* @return bool True if a trait statement should be added, false
otherwise.
* @since 3.2.0
*/
protected function shouldAddTraitStatement(object $power): bool
{
return $power->type === 'trait';
}
/**
* Handles specific logic for traits, such as checking if the trait is
already used.
*
* @param string $name The current name.
* @param object $power The power object containing type,
namespace, and class name.
* @param array|null $traits The traits used in the code.
*
* @return void
* @since 3.2.0
*/
protected function handleTraitLogic(string $name, object $power, ?array
$traits): void
{
if ($this->shouldAddTraitStatement($power) && $traits !==
null)
{
foreach ($traits as $trait)
{
if ($trait === $name)
{
return;
}
}
}
// add the trait
$this->traits[$name] = 'use ' . $name . ';';
}
/**
* Adds a use statement to the class if it's not already present.
*
* @param string $name The name to use.
* @param string $className The class name of the power
object.
* @param string $namespaceStatement The search statement to search for
(without the trailing semicolon, or use prefix).
*
* @since 3.2.0
*/
protected function addUseStatement(string &$name, string $className,
string $namespaceStatement): void
{
// we don't add use statements with just one part
if ($this->countPartsInString($namespaceStatement) <= 1)
{
return; // we just update the code
}
if ($name !== $className)
{
$statement = 'use ' . $namespaceStatement . ' as ' .
$name . ';';
}
else
{
$statement = 'use ' . $namespaceStatement . ';';
}
$this->useStatements[$name] = $statement;
}
/**
* Counts the number of parts in a string separated by backslashes.
*
* @param string $string The input string to be evaluated.
*
* @return int The number of parts separated by backslashes.
* @since 5.0.2
*/
protected function countPartsInString(string $string): int
{
// Split the string by the backslash
$parts = explode('\\', $string);
// Count the number of parts and return the result
if (($number = ArrayHelper::check($parts, true)) !== false)
{
return $number;
}
return 0;
}
/**
* Insert a line before the class declaration in the given class code.
*
* @param string $code The class code
* @param array|null $useStatements The existing use statements
*
* @return string The modified file content
* @since 3.2.0
*/
protected function addUseStatements(string $code, ?array $useStatements):
string
{
if ($useStatements !== null)
{
// we add the use statements using existing use statements
$key = end($useStatements);
array_unshift($this->useStatements, $key);
return $this->placeholder->update($code, [$key =>
implode(PHP_EOL, array_values($this->useStatements))]);
}
return $this->addLines($code, implode(PHP_EOL,
array_values($this->useStatements)));
}
/**
* Insert a line before the class declaration in the given class code.
*
* @param string $code The class code
* @param string $lines The new lines to insert
*
* @return string The modified file content
* @since 3.2.0
*/
protected function addLines(string $code, string $lines): string
{
// Pattern to match class, final class, abstract class, interface, and
trait
$pattern = '/(?:class|final class|abstract
class|interface|trait)\s+[a-zA-Z0-9_]+\s*(?:extends\s+[a-zA-Z0-9_]+\s*)?(?:implements\s+[a-zA-Z0-9_]+(?:\s*,\s*[a-zA-Z0-9_]+)*)?\s*\{/s';
// Find the position of the class declaration
preg_match($pattern, $code, $matches, PREG_OFFSET_CAPTURE);
$class_declaration_pos = $matches[0][1] ?? null;
if (null !== $class_declaration_pos)
{
// Find the position of the last newline character before the class
declaration
$last_newline_pos = strrpos($code, PHP_EOL, -(strlen($code) -
$class_declaration_pos));
// Find the position of the comment block right before the class
declaration
$comment_pattern = '/\s*\*\/\s*$/m';
$insert_pos = null;
if (preg_match($comment_pattern, $code, $comment_matches,
PREG_OFFSET_CAPTURE, $last_newline_pos))
{
$insert_pos = (int) $comment_matches[0][1] +
strlen($comment_matches[0][0]);
}
else
{
// Find the last empty line before the class declaration
$empty_line_pattern = '/(^|\r\n|\r|\n)[\s]*($|\r\n|\r|\n)/';
if (preg_match($empty_line_pattern, $code, $empty_line_matches,
PREG_OFFSET_CAPTURE, $last_newline_pos))
{
$insert_pos = (int) $empty_line_matches[0][1] +
strlen($empty_line_matches[0][0]);
}
}
// Insert the new line at the found position
if (null !== $insert_pos)
{
return substr_replace($code, $lines . PHP_EOL, $insert_pos, 0);
}
}
// last try targeting the defined line
return $this->addLinesAfterDefinedLine($code, $lines);
}
/**
* Inserts a new line after the defined('_JEXEC') line.
*
* @param string $code The class code
* @param string $lines The new lines to insert
*
* @return string The modified file content
* @since 3.2.0
*/
protected function addLinesAfterDefinedLine(string $code, string $lines):
string
{
// Patterns to match the defined('_JEXEC') and
defined('JPATH_BASE') lines
$patterns = [
"/defined\('_JEXEC'\)(.*?)\s*;/",
"/\\defined\('_JEXEC'\)(.*?)\s*;/",
"/defined\('JPATH_BASE'\)(.*?)\s*;/",
"/\\defined\('JPATH_BASE'\)(.*?)\s*;/",
];
$insert_pos = null;
// Iterate through the patterns and try to find a match
foreach ($patterns as $pattern)
{
preg_match($pattern, $code, $matches, PREG_OFFSET_CAPTURE);
$defined_line_pos = $matches[0][1] ?? null;
if ($defined_line_pos !== null)
{
// Find the position of the newline character after the defined() line
$next_lines_pos = strpos($code, PHP_EOL, (int) $defined_line_pos +
strlen($matches[0][0]));
// Insert the new line at the found position
if ($next_lines_pos !== false)
{
$insert_pos = $next_lines_pos;
break;
}
}
}
// Insert the new line at the found position
if ($insert_pos !== null)
{
$code = substr_replace($code, PHP_EOL . $lines, $insert_pos, 0);
}
return $code;
}
}
src/Componentbuilder/Compiler/Power/Structure.php000064400000032365151162054170016236
0ustar00<?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\Power;
use Joomla\CMS\Factory;
use Joomla\CMS\Application\CMSApplication;
use Joomla\CMS\Language\Text;
use VDM\Joomla\Componentbuilder\Compiler\Factory as Compiler;
use VDM\Joomla\Componentbuilder\Compiler\Power;
use VDM\Joomla\Componentbuilder\Compiler\Config;
use VDM\Joomla\Componentbuilder\Compiler\Registry;
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\EventInterface;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Counter;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Paths;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Folder;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\File;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Files;
use VDM\Joomla\Utilities\ObjectHelper;
use VDM\Joomla\Utilities\ArrayHelper;
use VDM\Joomla\Utilities\StringHelper;
use VDM\Joomla\Utilities\JsonHelper;
use VDM\Joomla\Utilities\FileHelper;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Placefix;
/**
* Power Structure Builder Class
*
* @since 3.2.0
*/
class Structure
{
/**
* we track the creation of htaccess files
*
* @var array
* @since 3.2.0
**/
protected array $htaccess = [];
/**
* Power Build Tracker
*
* @var array
* @since 3.2.0
**/
protected array $done = [];
/**
* Path Build Tracker
*
* @var array
* @since 3.2.0
**/
protected array $path_done = [];
/**
* Power Objects
*
* @var Power
* @since 3.2.0
**/
protected Power $power;
/**
* 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 Counter
*
* @var Counter
* @since 3.2.0
*/
protected Counter $counter;
/**
* Compiler Utilities Paths
*
* @var Paths
* @since 3.2.0
*/
protected Paths $paths;
/**
* Compiler Utilities Folder
*
* @var Folder
* @since 3.2.0
*/
protected Folder $folder;
/**
* Compiler Utilities File
*
* @var File
* @since 3.2.0
*/
protected File $file;
/**
* Compiler Utilities Files
*
* @var Files
* @since 3.2.0
*/
protected Files $files;
/**
* Database object to query local DB
*
* @var CMSApplication
* @since 3.2.0
**/
protected CMSApplication $app;
/**
* Constructor
*
* @param Power|null $power The power object.
* @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 Counter|null $counter The compiler counter
object.
* @param Paths|null $paths The compiler paths object.
* @param Folder|null $folder The compiler folder
object.
* @param File|null $file The compiler file object.
* @param Files|null $files The compiler files object.
* @param CMSApplication|null $app The CMS Application
object.
*
* @throws \Exception
* @since 3.2.0
*/
public function __construct(?Power $power = null, ?Config $config = null,
?Registry $registry = null, ?EventInterface $event = null,
?Counter $counter = null, ?Paths $paths = null, ?Folder $folder = null,
?File $file = null, ?Files $files = null, ?CMSApplication $app = null)
{
$this->power = $power ?: Compiler::_('Power');
$this->config = $config ?: Compiler::_('Config');
$this->registry = $registry ?: Compiler::_('Registry');
$this->event = $event ?: Compiler::_('Event');
$this->counter = $counter ?:
Compiler::_('Utilities.Counter');
$this->paths = $paths ?: Compiler::_('Utilities.Paths');
$this->folder = $folder ?: Compiler::_('Utilities.Folder');
$this->file = $file ?: Compiler::_('Utilities.File');
$this->files = $files ?: Compiler::_('Utilities.Files');
$this->app = $app ?: Factory::getApplication();
}
/**
* Build the Powers files, folders
*
* @return void
* @since 3.2.0
*/
public function build()
{
if (ArrayHelper::check($this->power->active))
{
// Trigger Event: jcb_ce_onBeforeSetModules
$this->event->trigger(
'jcb_ce_onBeforeBuildPowers'
);
// set super power details
$this->setSuperPowerDetails();
foreach ($this->power->active as $guid => $power)
{
if (isset($this->done[$guid]))
{
continue;
}
if (ObjectHelper::check($power)
&& isset($power->path)
&& StringHelper::check(
$power->path
))
{
// activate dynamic folders
$this->setDynamicFolders();
// power path
$power->full_path = $this->paths->component_path .
'/'
. $power->path;
$power->full_path_jcb = $this->paths->component_path .
'/'
. $power->path_jcb;
$power->full_path_parent = $this->paths->component_path .
'/'
. $power->path_parent;
// set the power paths
$this->registry->set('dynamic_paths.' .
$power->key, $power->full_path_parent);
// create the power folder if it does not exist
// we do it like this to add html files to each part
$this->folder->create($power->full_path_jcb);
$this->folder->create($power->full_path_parent);
$this->folder->create($power->full_path);
$bom = '<?php' . PHP_EOL . '// A POWER FILE' .
PHP_EOL . Placefix::_h('BOM') . PHP_EOL;
// add custom override if found
if ($power->add_licensing_template == 2)
{
$bom = '<?php' . PHP_EOL .
$power->licensing_template;
}
// set the main power php file
$this->createFile($bom . PHP_EOL .
Placefix::_h('POWERCODE') . PHP_EOL,
$power->full_path, $power->file_name . '.php',
$power->key);
// set super power files
$this->setSuperPowerFiles($power, $bom);
// set htaccess once per path
$this->setHtaccess($power);
// do each power just once
$this->done[$guid] = true;
}
}
}
}
/**
* Create a file with optional custom content and save it to the given
path.
*
* @param string $content The content.
* @param string $fullPath The full path to the destination folder.
* @param string $fileName The file name without the extension.
* @param string $key The key to append the file details.
*
* @return void
* @since 3.2.0
*/
private function createFile(string $content, string $fullPath, string
$fileName, string $key)
{
$file_details = [
'path' => $fullPath . '/' . $fileName,
'name' => $fileName,
'zip' => $fileName
];
// Write the content to the file
$this->file->write($file_details['path'], $content);
// Append the file details to the files array
$this->files->appendArray($key, $file_details);
// Increment the file counter
$this->counter->file++;
}
/**
* Set the .htaccess for this power path
*
* @param object $power The power object
*
* @return void
* @since 3.2.0
*/
private function setHtaccess(object &$power)
{
if (!isset($this->htaccess[$power->path_jcb]))
{
// set the htaccess data
$data = '# Apache 2.4+' . PHP_EOL .
'<IfModule mod_authz_core.c>' . PHP_EOL .
' Require all denied' . PHP_EOL .
'</IfModule>' . PHP_EOL . PHP_EOL .
'# Apache 2.0-2.2' . PHP_EOL .
'<IfModule !mod_authz_core.c>' . PHP_EOL .
' Deny from all' . PHP_EOL .
'</IfModule>' . PHP_EOL;
// now we must add the .htaccess file
$fileDetails = array('path' => $power->full_path_jcb .
'/.htaccess',
'name' => '.htaccess',
'zip' => '.htaccess');
$this->file->write(
$fileDetails['path'], $data
);
$this->files->appendArray($power->key, $fileDetails);
// count the file created
$this->counter->file++;
// now we must add the htaccess.txt file where the zip package my not
get the [.] files
$fileDetails = array('path' => $power->full_path_jcb .
'/htaccess.txt',
'name' => 'htaccess.txt',
'zip' => 'htaccess.txt');
$this->file->write(
$fileDetails['path'], $data
);
$this->files->appendArray($power->key, $fileDetails);
// count the file created
$this->counter->file++;
// now we must add the web.config file
$fileDetails = array('path' => $power->full_path_jcb .
'/web.config',
'name' => 'web.config',
'zip' => 'web.config');
$this->file->write(
$fileDetails['path'],
'<?xml version="1.0"?>' . PHP_EOL .
' <system.web>' . PHP_EOL .
' <authorization>' . PHP_EOL .
' <deny users="*" />' . PHP_EOL .
' </authorization>' . PHP_EOL .
' </system.web>' . PHP_EOL .
'</configuration>' . PHP_EOL
);
$this->files->appendArray($power->key, $fileDetails);
// count the file created
$this->counter->file++;
// we set these files only once
$this->htaccess[$power->path_jcb] = true;
}
}
/**
* Add the dynamic folders
*
* @return void
* @since 3.2.0
*/
private function setDynamicFolders()
{
// check if we should add the dynamic folder moving script to the
installer script
if
(!$this->registry->get('set_move_folders_install_script'))
{
$function = 'setDynamicF0ld3rs';
$script = 'script.php';
if ($this->config->get('joomla_version', 3) != 3)
{
$function = 'moveFolders';
$script = 'ComponentnameInstallerScript.php';
}
// add the setDynamicF0ld3rs() method to the install script.php file
$this->registry->set('set_move_folders_install_script',
true);
// 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_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'
);
}
}
/**
* Set the super powers details structure
*
* @return void
* @since 3.2.0
*/
private function setSuperPowerDetails()
{
if ($this->config->add_super_powers &&
ArrayHelper::check($this->power->superpowers))
{
foreach ($this->power->superpowers as $path => $powers)
{
if (isset($this->path_done[$path]))
{
continue;
}
// get existing files
$this->loadExistingSuperPower($path);
// create the path if it does not exist
$this->folder->create($path, false);
$key = StringHelper::safe($path);
// set the super powers readme file
$this->createFile(Placefix::_h('POWERREADME'),
$path, 'README.md', $key);
// set the super power index file
$this->createFile(Placefix::_h('POWERINDEX'), $path,
'super-powers.json', $key);
// do each path just once
$this->path_done[$path] = true;
}
}
}
/**
* Set the super power file paths
*
* @param object $power The power object
* @param string $bom The bom for the top of the PHP files
*
* @return void
* @since 3.2.0
*/
private function setSuperPowerFiles(object &$power, string $bom)
{
if ($this->config->add_super_powers &&
is_array($power->super_power_paths) &&
$power->super_power_paths !== [])
{
foreach ($power->super_power_paths as $path)
{
// create the path if it does not exist
$this->folder->create($path, false);
// set the super power php file
$this->createFile($bom . PHP_EOL .
Placefix::_h('POWERCODE') . PHP_EOL,
$path, 'code.php', $power->key);
// set the super power php RAW file
$this->createFile(Placefix::_h('CODEPOWER'),
$path, 'code.power', $power->key);
// set the super power json file
$this->createFile(Placefix::_h('POWERLINKER'), $path,
'settings.json', $power->key);
// set the super power readme file
$this->createFile(Placefix::_h('POWERREADME'), $path,
'README.md', $power->key);
}
}
}
/**
* Set the super power file paths
*
* @param string $repository The super power repository
*
* @return void
* @since 3.2.0
*/
private function loadExistingSuperPower(string $repository)
{
if (!isset($this->power->old_superpowers[$repository]) &&
($content = FileHelper::getContent($repository .
'/super-powers.json', null)) !== null &&
JsonHelper::check($content))
{
$this->power->old_superpowers[$repository] = json_decode($content,
true);
}
}
}
src/Componentbuilder/Compiler/Power/index.html000064400000000054151162054170015510
0ustar00<html><body
bgcolor="#FFFFFF"></body></html>src/Componentbuilder/Compiler/Registry.php000064400000001141151162054170014736
0ustar00<?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;
use VDM\Joomla\Componentbuilder\Abstraction\BaseRegistry;
/**
* Compiler Registry
*
* @since 3.2.0
*/
class Registry extends BaseRegistry
{
}
src/Componentbuilder/Compiler/Service/Adminview.php000064400000005362151162054170016462
0ustar00<?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\Service;
use Joomla\DI\Container;
use Joomla\DI\ServiceProviderInterface;
use VDM\Joomla\Componentbuilder\Compiler\Adminview\Data as AdminviewData;
use VDM\Joomla\Componentbuilder\Compiler\Adminview\Permission;
/**
* Compiler Adminview
*
* @since 3.2.0
*/
class Adminview implements ServiceProviderInterface
{
/**
* Registers the service provider with a DI container.
*
* @param Container $container The DI container.
*
* @return void
* @since 3.2.0
*/
public function register(Container $container)
{
$container->alias(AdminviewData::class, 'Adminview.Data')
->share('Adminview.Data', [$this,
'getAdminviewData'], true);
$container->alias(Permission::class,
'Adminview.Permission')
->share('Adminview.Permission', [$this,
'getAdminviewPermission'], true);
}
/**
* Get the Compiler Adminview Data
*
* @param Container $container The DI container.
*
* @return AdminviewData
* @since 3.2.0
*/
public function getAdminviewData(Container $container): AdminviewData
{
return new AdminviewData(
$container->get('Config'),
$container->get('Event'),
$container->get('Placeholder'),
$container->get('Customcode.Dispenser'),
$container->get('Model.Customtabs'),
$container->get('Model.Tabs'),
$container->get('Model.Fields'),
$container->get('Model.Historyadminview'),
$container->get('Model.Permissions'),
$container->get('Model.Conditions'),
$container->get('Model.Relations'),
$container->get('Model.Linkedviews'),
$container->get('Model.Javascriptadminview'),
$container->get('Model.Cssadminview'),
$container->get('Model.Phpadminview'),
$container->get('Model.Custombuttons'),
$container->get('Model.Customimportscripts'),
$container->get('Model.Ajaxadmin'),
$container->get('Model.Customalias'),
$container->get('Model.Sql'),
$container->get('Model.Mysqlsettings'),
$container->get('Compiler.Builder.Site.Edit.View')
);
}
/**
* Get the Compiler Adminview Permission
*
* @param Container $container The DI container.
*
* @return Permission
* @since 3.2.0
*/
public function getAdminviewPermission(Container $container): Permission
{
return new Permission(
$container->get('Compiler.Builder.Has.Permissions')
);
}
}
src/Componentbuilder/Compiler/Service/ArchitectureComHelperClass.php000064400000006603151162054170021745
0ustar00<?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\Service;
use Joomla\DI\Container;
use Joomla\DI\ServiceProviderInterface;
use
VDM\Joomla\Componentbuilder\Compiler\Interfaces\Architecture\ComHelperClass\CreateUserInterface;
use
VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaFive\ComHelperClass\CreateUser
as J5CreateUser;
use
VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaFour\ComHelperClass\CreateUser
as J4CreateUser;
use
VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaThree\ComHelperClass\CreateUser
as J3CreateUser;
/**
* Architecture Component Helper Class Service Provider
*
* @since 5.0.2
*/
class ArchitectureComHelperClass implements ServiceProviderInterface
{
/**
* Current Joomla Version Being Build
*
* @var int
* @since 5.0.2
**/
protected $targetVersion;
/**
* Registers the service provider with a DI container.
*
* @param Container $container The DI container.
*
* @return void
* @since 5.0.2
*/
public function register(Container $container)
{
$container->alias(CreateUserInterface::class,
'Architecture.ComHelperClass.CreateUser')
->share('Architecture.ComHelperClass.CreateUser', [$this,
'getCreateUser'], true);
$container->alias(J5CreateUser::class,
'Architecture.ComHelperClass.J5.CreateUser')
->share('Architecture.ComHelperClass.J5.CreateUser',
[$this, 'getJ5CreateUser'], true);
$container->alias(J4CreateUser::class,
'Architecture.ComHelperClass.J4.CreateUser')
->share('Architecture.ComHelperClass.J4.CreateUser',
[$this, 'getJ4CreateUser'], true);
$container->alias(J3CreateUser::class,
'Architecture.ComHelperClass.J3.CreateUser')
->share('Architecture.ComHelperClass.J3.CreateUser',
[$this, 'getJ3CreateUser'], true);
}
/**
* Get The CreateUserInterface Class.
*
* @param Container $container The DI container.
*
* @return CreateUserInterface
* @since 5.0.2
*/
public function getCreateUser(Container $container): CreateUserInterface
{
if (empty($this->targetVersion))
{
$this->targetVersion =
$container->get('Config')->joomla_version;
}
return $container->get('Architecture.ComHelperClass.J' .
$this->targetVersion . '.CreateUser');
}
/**
* Get The CreateUser Class.
*
* @param Container $container The DI container.
*
* @return J5CreateUser
* @since 5.0.2
*/
public function getJ5CreateUser(Container $container): J5CreateUser
{
return new J5CreateUser();
}
/**
* Get The CreateUser Class.
*
* @param Container $container The DI container.
*
* @return J4CreateUser
* @since 5.0.2
*/
public function getJ4CreateUser(Container $container): J4CreateUser
{
return new J4CreateUser();
}
/**
* Get The CreateUser Class.
*
* @param Container $container The DI container.
*
* @return J3CreateUser
* @since 5.0.2
*/
public function getJ3CreateUser(Container $container): J3CreateUser
{
return new J3CreateUser();
}
}
src/Componentbuilder/Compiler/Service/ArchitectureController.php000064400000024427151162054170021230
0ustar00<?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\Service;
use Joomla\DI\Container;
use Joomla\DI\ServiceProviderInterface;
use
VDM\Joomla\Componentbuilder\Compiler\Interfaces\Architecture\Controller\AllowAddInterface;
use
VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaFive\Controller\AllowAdd
as J5ControllerAllowAdd;
use
VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaFour\Controller\AllowAdd
as J4ControllerAllowAdd;
use
VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaThree\Controller\AllowAdd
as J3ControllerAllowAdd;
use
VDM\Joomla\Componentbuilder\Compiler\Interfaces\Architecture\Controller\AllowEditInterface;
use
VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaFive\Controller\AllowEdit
as J5ControllerAllowEdit;
use
VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaFour\Controller\AllowEdit
as J4ControllerAllowEdit;
use
VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaThree\Controller\AllowEdit
as J3ControllerAllowEdit;
use
VDM\Joomla\Componentbuilder\Compiler\Interfaces\Architecture\Controller\AllowEditViewsInterface;
use
VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaFive\Controller\AllowEditViews
as J5ControllerAllowEditViews;
use
VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaFour\Controller\AllowEditViews
as J4ControllerAllowEditViews;
use
VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaThree\Controller\AllowEditViews
as J3ControllerAllowEditViews;
/**
* Architecture Controller Service Provider
*
* @since 3.2.0
*/
class ArchitectureController implements ServiceProviderInterface
{
/**
* Current Joomla Version Being Build
*
* @var int
* @since 3.2.0
**/
protected $targetVersion;
/**
* Registers the service provider with a DI container.
*
* @param Container $container The DI container.
*
* @return void
* @since 3.2.0
*/
public function register(Container $container)
{
$container->alias(AllowAddInterface::class,
'Architecture.Controller.AllowAdd')
->share('Architecture.Controller.AllowAdd', [$this,
'getAllowAdd'], true);
$container->alias(J5ControllerAllowAdd::class,
'Architecture.Controller.J5.AllowAdd')
->share('Architecture.Controller.J5.AllowAdd', [$this,
'getJ5ControllerAllowAdd'], true);
$container->alias(J4ControllerAllowAdd::class,
'Architecture.Controller.J4.AllowAdd')
->share('Architecture.Controller.J4.AllowAdd', [$this,
'getJ4ControllerAllowAdd'], true);
$container->alias(J3ControllerAllowAdd::class,
'Architecture.Controller.J3.AllowAdd')
->share('Architecture.Controller.J3.AllowAdd', [$this,
'getJ3ControllerAllowAdd'], true);
$container->alias(AllowEditInterface::class,
'Architecture.Controller.AllowEdit')
->share('Architecture.Controller.AllowEdit', [$this,
'getAllowEdit'], true);
$container->alias(J5ControllerAllowEdit::class,
'Architecture.Controller.J5.AllowEdit')
->share('Architecture.Controller.J5.AllowEdit', [$this,
'getJ5ControllerAllowEdit'], true);
$container->alias(J4ControllerAllowEdit::class,
'Architecture.Controller.J4.AllowEdit')
->share('Architecture.Controller.J4.AllowEdit', [$this,
'getJ4ControllerAllowEdit'], true);
$container->alias(J3ControllerAllowEdit::class,
'Architecture.Controller.J3.AllowEdit')
->share('Architecture.Controller.J3.AllowEdit', [$this,
'getJ3ControllerAllowEdit'], true);
$container->alias(AllowEditViewsInterface::class,
'Architecture.Controller.AllowEditViews')
->share('Architecture.Controller.AllowEditViews', [$this,
'getAllowEditViews'], true);
$container->alias(J5ControllerAllowEditViews::class,
'Architecture.Controller.J5.AllowEditViews')
->share('Architecture.Controller.J5.AllowEditViews',
[$this, 'getJ5ControllerAllowEditViews'], true);
$container->alias(J4ControllerAllowEditViews::class,
'Architecture.Controller.J4.AllowEditViews')
->share('Architecture.Controller.J4.AllowEditViews',
[$this, 'getJ4ControllerAllowEditViews'], true);
$container->alias(J3ControllerAllowEditViews::class,
'Architecture.Controller.J3.AllowEditViews')
->share('Architecture.Controller.J3.AllowEditViews',
[$this, 'getJ3ControllerAllowEditViews'], true);
}
/**
* Get The AllowAddInterface Class.
*
* @param Container $container The DI container.
*
* @return AllowAddInterface
* @since 3.2.0
*/
public function getAllowAdd(Container $container): AllowAddInterface
{
if (empty($this->targetVersion))
{
$this->targetVersion =
$container->get('Config')->joomla_version;
}
return $container->get('Architecture.Controller.J' .
$this->targetVersion . '.AllowAdd');
}
/**
* Get The AllowAdd Class.
*
* @param Container $container The DI container.
*
* @return J5ControllerAllowAdd
* @since 3.2.0
*/
public function getJ5ControllerAllowAdd(Container $container):
J5ControllerAllowAdd
{
return new J5ControllerAllowAdd(
$container->get('Config'),
$container->get('Compiler.Creator.Permission'),
$container->get('Customcode.Dispenser')
);
}
/**
* Get The AllowAdd Class.
*
* @param Container $container The DI container.
*
* @return J4ControllerAllowAdd
* @since 3.2.0
*/
public function getJ4ControllerAllowAdd(Container $container):
J4ControllerAllowAdd
{
return new J4ControllerAllowAdd(
$container->get('Config'),
$container->get('Compiler.Creator.Permission'),
$container->get('Customcode.Dispenser')
);
}
/**
* Get The AllowAdd Class.
*
* @param Container $container The DI container.
*
* @return J3ControllerAllowAdd
* @since 3.2.0
*/
public function getJ3ControllerAllowAdd(Container $container):
J3ControllerAllowAdd
{
return new J3ControllerAllowAdd(
$container->get('Config'),
$container->get('Compiler.Creator.Permission'),
$container->get('Customcode.Dispenser')
);
}
/**
* Get The AllowEditInterface Class.
*
* @param Container $container The DI container.
*
* @return AllowEditInterface
* @since 3.2.0
*/
public function getAllowEdit(Container $container): AllowEditInterface
{
if (empty($this->targetVersion))
{
$this->targetVersion =
$container->get('Config')->joomla_version;
}
return $container->get('Architecture.Controller.J' .
$this->targetVersion . '.AllowEdit');
}
/**
* Get The AllowEdit Class.
*
* @param Container $container The DI container.
*
* @return J5ControllerAllowEdit
* @since 3.2.0
*/
public function getJ5ControllerAllowEdit(Container $container):
J5ControllerAllowEdit
{
return new J5ControllerAllowEdit(
$container->get('Config'),
$container->get('Compiler.Creator.Permission'),
$container->get('Customcode.Dispenser'),
$container->get('Compiler.Builder.Category'),
$container->get('Compiler.Builder.Category.Other.Name')
);
}
/**
* Get The AllowEdit Class.
*
* @param Container $container The DI container.
*
* @return J4ControllerAllowEdit
* @since 3.2.0
*/
public function getJ4ControllerAllowEdit(Container $container):
J4ControllerAllowEdit
{
return new J4ControllerAllowEdit(
$container->get('Config'),
$container->get('Compiler.Creator.Permission'),
$container->get('Customcode.Dispenser'),
$container->get('Compiler.Builder.Category'),
$container->get('Compiler.Builder.Category.Other.Name')
);
}
/**
* Get The AllowEdit Class.
*
* @param Container $container The DI container.
*
* @return J3ControllerAllowEdit
* @since 3.2.0
*/
public function getJ3ControllerAllowEdit(Container $container):
J3ControllerAllowEdit
{
return new J3ControllerAllowEdit(
$container->get('Config'),
$container->get('Compiler.Creator.Permission'),
$container->get('Customcode.Dispenser'),
$container->get('Compiler.Builder.Category'),
$container->get('Compiler.Builder.Category.Other.Name')
);
}
/**
* Get The AllowEditViewsInterface Class.
*
* @param Container $container The DI container.
*
* @return AllowEditViewsInterface
* @since 5.0.2
*/
public function getAllowEditViews(Container $container):
AllowEditViewsInterface
{
if (empty($this->targetVersion))
{
$this->targetVersion =
$container->get('Config')->joomla_version;
}
return $container->get('Architecture.Controller.J' .
$this->targetVersion . '.AllowEditViews');
}
/**
* Get The AllowEditViews Class.
*
* @param Container $container The DI container.
*
* @return J5ControllerAllowEdit
* @since 5.0.2
*/
public function getJ5ControllerAllowEditViews(Container $container):
J5ControllerAllowEditViews
{
return new J5ControllerAllowEditViews(
$container->get('Compiler.Creator.Permission'),
$container->get('Customcode.Dispenser'),
$container->get('Compiler.Builder.Category'),
$container->get('Compiler.Builder.Category.Other.Name')
);
}
/**
* Get The AllowEditViews Class.
*
* @param Container $container The DI container.
*
* @return J4ControllerAllowEditViews
* @since 5.0.2
*/
public function getJ4ControllerAllowEditViews(Container $container):
J4ControllerAllowEditViews
{
return new J4ControllerAllowEditViews(
$container->get('Compiler.Creator.Permission'),
$container->get('Customcode.Dispenser'),
$container->get('Compiler.Builder.Category'),
$container->get('Compiler.Builder.Category.Other.Name')
);
}
/**
* Get The AllowEditViews Class.
*
* @param Container $container The DI container.
*
* @return J3ControllerAllowEditViews
* @since 5.0.2
*/
public function getJ3ControllerAllowEditViews(Container $container):
J3ControllerAllowEditViews
{
return new J3ControllerAllowEditViews(
$container->get('Compiler.Creator.Permission'),
$container->get('Customcode.Dispenser'),
$container->get('Compiler.Builder.Category'),
$container->get('Compiler.Builder.Category.Other.Name')
);
}
}
src/Componentbuilder/Compiler/Service/ArchitectureModel.php000064400000014433151162054170020141
0ustar00<?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\Service;
use Joomla\DI\Container;
use Joomla\DI\ServiceProviderInterface;
use
VDM\Joomla\Componentbuilder\Compiler\Interfaces\Architecture\Model\CanDeleteInterface;
use
VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaFive\Model\CanDelete
as J5ModelCanDelete;
use
VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaFour\Model\CanDelete
as J4ModelCanDelete;
use
VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaThree\Model\CanDelete
as J3ModelCanDelete;
use
VDM\Joomla\Componentbuilder\Compiler\Interfaces\Architecture\Model\CanEditStateInterface;
use
VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaFive\Model\CanEditState
as J5ModelCanEditState;
use
VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaFour\Model\CanEditState
as J4ModelCanEditState;
use
VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaThree\Model\CanEditState
as J3ModelCanEditState;
/**
* Architecture Model Service Provider
*
* @since 3.2.0
*/
class ArchitectureModel implements ServiceProviderInterface
{
/**
* Current Joomla Version Being Build
*
* @var int
* @since 3.2.0
**/
protected $targetVersion;
/**
* Registers the service provider with a DI container.
*
* @param Container $container The DI container.
*
* @return void
* @since 3.2.0
*/
public function register(Container $container)
{
$container->alias(J3ModelCanDelete::class,
'Architecture.Model.J3.CanDelete')
->share('Architecture.Model.J3.CanDelete', [$this,
'getJ3ModelCanDelete'], true);
$container->alias(J4ModelCanDelete::class,
'Architecture.Model.J4.CanDelete')
->share('Architecture.Model.J4.CanDelete', [$this,
'getJ4ModelCanDelete'], true);
$container->alias(J5ModelCanDelete::class,
'Architecture.Model.J5.CanDelete')
->share('Architecture.Model.J5.CanDelete', [$this,
'getJ5ModelCanDelete'], true);
$container->alias(CanDeleteInterface::class,
'Architecture.Model.CanDelete')
->share('Architecture.Model.CanDelete', [$this,
'getModelCanDelete'], true);
$container->alias(J3ModelCanEditState::class,
'Architecture.Model.J3.CanEditState')
->share('Architecture.Model.J3.CanEditState', [$this,
'getJ3ModelCanEditState'], true);
$container->alias(J4ModelCanEditState::class,
'Architecture.Model.J4.CanEditState')
->share('Architecture.Model.J4.CanEditState', [$this,
'getJ4ModelCanEditState'], true);
$container->alias(J5ModelCanEditState::class,
'Architecture.Model.J5.CanEditState')
->share('Architecture.Model.J5.CanEditState', [$this,
'getJ5ModelCanEditState'], true);
$container->alias(CanEditStateInterface::class,
'Architecture.Model.CanEditState')
->share('Architecture.Model.CanEditState', [$this,
'getModelCanEditState'], true);
}
/**
* Get The Model CanDelete Class.
*
* @param Container $container The DI container.
*
* @return CanDeleteInterface
* @since 3.2.0
*/
public function getModelCanDelete(Container $container):
CanDeleteInterface
{
if (empty($this->targetVersion))
{
$this->targetVersion =
$container->get('Config')->joomla_version;
}
return $container->get('Architecture.Model.J' .
$this->targetVersion . '.CanDelete');
}
/**
* Get The Model CanDelete Class.
*
* @param Container $container The DI container.
*
* @return J5ModelCanDelete
* @since 3.2.0
*/
public function getJ5ModelCanDelete(Container $container):
J5ModelCanDelete
{
return new J5ModelCanDelete(
$container->get('Config'),
$container->get('Compiler.Creator.Permission')
);
}
/**
* Get The Model CanDelete Class.
*
* @param Container $container The DI container.
*
* @return J4ModelCanDelete
* @since 3.2.0
*/
public function getJ4ModelCanDelete(Container $container):
J4ModelCanDelete
{
return new J4ModelCanDelete(
$container->get('Config'),
$container->get('Compiler.Creator.Permission')
);
}
/**
* Get The Model CanDelete Class.
*
* @param Container $container The DI container.
*
* @return J3ModelCanDelete
* @since 3.2.0
*/
public function getJ3ModelCanDelete(Container $container):
J3ModelCanDelete
{
return new J3ModelCanDelete(
$container->get('Config'),
$container->get('Compiler.Creator.Permission')
);
}
/**
* Get The Model Can Edit State Class.
*
* @param Container $container The DI container.
*
* @return CanEditStateInterface
* @since 3.2.0
*/
public function getModelCanEditState(Container $container):
CanEditStateInterface
{
if (empty($this->targetVersion))
{
$this->targetVersion =
$container->get('Config')->joomla_version;
}
return $container->get('Architecture.Model.J' .
$this->targetVersion . '.CanEditState');
}
/**
* Get The Model Can Edit State Class.
*
* @param Container $container The DI container.
*
* @return J5ModelCanEditState
* @since 3.2.0
*/
public function getJ5ModelCanEditState(Container $container):
J5ModelCanEditState
{
return new J5ModelCanEditState(
$container->get('Config'),
$container->get('Compiler.Creator.Permission')
);
}
/**
* Get The Model Can Edit State Class.
*
* @param Container $container The DI container.
*
* @return J4ModelCanEditState
* @since 3.2.0
*/
public function getJ4ModelCanEditState(Container $container):
J4ModelCanEditState
{
return new J4ModelCanEditState(
$container->get('Config'),
$container->get('Compiler.Creator.Permission')
);
}
/**
* Get The Model Can Edit State Class.
*
* @param Container $container The DI container.
*
* @return J3ModelCanEditState
* @since 3.2.0
*/
public function getJ3ModelCanEditState(Container $container):
J3ModelCanEditState
{
return new J3ModelCanEditState(
$container->get('Config'),
$container->get('Compiler.Creator.Permission')
);
}
}
src/Componentbuilder/Compiler/Service/ArchitecturePlugin.php000064400000023325151162054170020337
0ustar00<?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\Service;
use Joomla\DI\Container;
use Joomla\DI\ServiceProviderInterface;
use
VDM\Joomla\Componentbuilder\Compiler\Interfaces\Architecture\Plugin\ExtensionInterface
as Extension;
use
VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaFive\Plugin\Extension
as J5Extension;
use
VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaFour\Plugin\Extension
as J4Extension;
use
VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaThree\Plugin\Extension
as J3Extension;
use
VDM\Joomla\Componentbuilder\Compiler\Interfaces\Architecture\Plugin\ProviderInterface
as Provider;
use
VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaFive\Plugin\Provider
as J5Provider;
use
VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaFour\Plugin\Provider
as J4Provider;
use
VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaThree\Plugin\Provider
as J3Provider;
use
VDM\Joomla\Componentbuilder\Interfaces\Architecture\Plugin\MainXMLInterface
as MainXML;
use
VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaFive\Plugin\MainXML
as J5MainXML;
use
VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaFour\Plugin\MainXML
as J4MainXML;
use
VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaThree\Plugin\MainXML
as J3MainXML;
/**
* Architecture Plugin Service Provider
*
* @since 5.0.2
*/
class ArchitecturePlugin implements ServiceProviderInterface
{
/**
* Current Joomla Version Being Build
*
* @var int
* @since 5.0.2
**/
protected int $targetVersion;
/**
* Registers the service provider with a DI container.
*
* @param Container $container The DI container.
*
* @return void
* @since 5.0.2
*/
public function register(Container $container)
{
$container->alias(Extension::class,
'Architecture.Plugin.Extension')
->share('Architecture.Plugin.Extension', [$this,
'getExtension'], true);
$container->alias(J5Extension::class,
'Architecture.Plugin.J5.Extension')
->share('Architecture.Plugin.J5.Extension', [$this,
'getJ5Extension'], true);
$container->alias(J4Extension::class,
'Architecture.Plugin.J4.Extension')
->share('Architecture.Plugin.J4.Extension', [$this,
'getJ4Extension'], true);
$container->alias(J3Extension::class,
'Architecture.Plugin.J3.Extension')
->share('Architecture.Plugin.J3.Extension', [$this,
'getJ3Extension'], true);
$container->alias(Provider::class,
'Architecture.Plugin.Provider')
->share('Architecture.Plugin.Provider', [$this,
'getProvider'], true);
$container->alias(J5Provider::class,
'Architecture.Plugin.J5.Provider')
->share('Architecture.Plugin.J5.Provider', [$this,
'getJ5Provider'], true);
$container->alias(J4Provider::class,
'Architecture.Plugin.J4.Provider')
->share('Architecture.Plugin.J4.Provider', [$this,
'getJ4Provider'], true);
$container->alias(J3Provider::class,
'Architecture.Plugin.J3.Provider')
->share('Architecture.Plugin.J3.Provider', [$this,
'getJ3Provider'], true);
$container->alias(MainXML::class,
'Architecture.Plugin.MainXML')
->share('Architecture.Plugin.MainXML', [$this,
'getMainXML'], true);
$container->alias(J5MainXML::class,
'Architecture.Plugin.J5.MainXML')
->share('Architecture.Plugin.J5.MainXML', [$this,
'getJ5MainXML'], true);
$container->alias(J4MainXML::class,
'Architecture.Plugin.J4.MainXML')
->share('Architecture.Plugin.J4.MainXML', [$this,
'getJ4MainXML'], true);
$container->alias(J3MainXML::class,
'Architecture.Plugin.J3.MainXML')
->share('Architecture.Plugin.J3.MainXML', [$this,
'getJ3MainXML'], true);
}
/**
* Get The Extension Class.
*
* @param Container $container The DI container.
*
* @return Extension
* @since 5.0.2
*/
public function getExtension(Container $container): Extension
{
if (empty($this->targetVersion))
{
$this->targetVersion =
$container->get('Config')->joomla_version;
}
return $container->get('Architecture.Plugin.J' .
$this->targetVersion . '.Extension');
}
/**
* Get The Extension Class.
*
* @param Container $container The DI container.
*
* @return J5Extension
* @since 5.0.2
*/
public function getJ5Extension(Container $container): J5Extension
{
return new J5Extension(
$container->get('Placeholder'),
$container->get('Compiler.Builder.Content.One'),
$container->get('Power.Parser')
);
}
/**
* Get The Extension Class.
*
* @param Container $container The DI container.
*
* @return J4Extension
* @since 5.0.2
*/
public function getJ4Extension(Container $container): J4Extension
{
return new J4Extension(
$container->get('Placeholder'),
$container->get('Compiler.Builder.Content.One'),
$container->get('Power.Parser')
);
}
/**
* Get The Extension Class.
*
* @param Container $container The DI container.
*
* @return J3Extension
* @since 5.0.2
*/
public function getJ3Extension(Container $container): J3Extension
{
return new J3Extension(
$container->get('Placeholder'),
$container->get('Compiler.Builder.Content.One')
);
}
/**
* Get The ProviderInterface Class.
*
* @param Container $container The DI container.
*
* @return Provider
* @since 5.0.2
*/
public function getProvider(Container $container): Provider
{
if (empty($this->targetVersion))
{
$this->targetVersion =
$container->get('Config')->joomla_version;
}
return $container->get('Architecture.Plugin.J' .
$this->targetVersion . '.Provider');
}
/**
* Get The Provider Class.
*
* @param Container $container The DI container.
*
* @return J5Provider
* @since 5.0.2
*/
public function getJ5Provider(Container $container): J5Provider
{
return new J5Provider(
$container->get('Placeholder'),
$container->get('Compiler.Builder.Content.One')
);
}
/**
* Get The Provider Class.
*
* @param Container $container The DI container.
*
* @return J4Provider
* @since 5.0.2
*/
public function getJ4Provider(Container $container): J4Provider
{
return new J4Provider(
$container->get('Placeholder'),
$container->get('Compiler.Builder.Content.One')
);
}
/**
* Get The Provider Class.
*
* @param Container $container The DI container.
*
* @return J3Provider
* @since 5.0.2
*/
public function getJ3Provider(Container $container): J3Provider
{
return new J3Provider(
$container->get('Placeholder'),
$container->get('Compiler.Builder.Content.One')
);
}
/**
* Get The MainXML Class.
*
* @param Container $container The DI container.
*
* @return MainXML
* @since 5.0.2
*/
public function getMainXML(Container $container): MainXML
{
if (empty($this->targetVersion))
{
$this->targetVersion =
$container->get('Config')->joomla_version;
}
return $container->get('Architecture.Plugin.J' .
$this->targetVersion . '.MainXML');
}
/**
* Get The MainXML Class.
*
* @param Container $container The DI container.
*
* @return J5MainXML
* @since 5.0.2
*/
public function getJ5MainXML(Container $container): J5MainXML
{
return new J5MainXML(
$container->get('Config'),
$container->get('Language'),
$container->get('Language.Set'),
$container->get('Language.Purge'),
$container->get('Language.Translation'),
$container->get('Language.Multilingual'),
$container->get('Event'),
$container->get('Compiler.Creator.Fieldset.Extension'),
$container->get('Compiler.Builder.Content.One'),
$container->get('Compiler.Builder.Languages'),
$container->get('Compiler.Builder.Multilingual'),
$container->get('Utilities.Counter'),
$container->get('Utilities.File')
);
}
/**
* Get The MainXML Class.
*
* @param Container $container The DI container.
*
* @return J4MainXML
* @since 5.0.2
*/
public function getJ4MainXML(Container $container): J4MainXML
{
return new J4MainXML(
$container->get('Config'),
$container->get('Language'),
$container->get('Language.Set'),
$container->get('Language.Purge'),
$container->get('Language.Translation'),
$container->get('Language.Multilingual'),
$container->get('Event'),
$container->get('Compiler.Creator.Fieldset.Extension'),
$container->get('Compiler.Builder.Content.One'),
$container->get('Compiler.Builder.Languages'),
$container->get('Compiler.Builder.Multilingual'),
$container->get('Utilities.Counter'),
$container->get('Utilities.File')
);
}
/**
* Get The MainXML Class.
*
* @param Container $container The DI container.
*
* @return J3MainXML
* @since 5.0.2
*/
public function getJ3MainXML(Container $container): J3MainXML
{
return new J3MainXML(
$container->get('Config'),
$container->get('Language'),
$container->get('Language.Set'),
$container->get('Language.Purge'),
$container->get('Language.Translation'),
$container->get('Language.Multilingual'),
$container->get('Event'),
$container->get('Compiler.Creator.Fieldset.Extension'),
$container->get('Compiler.Builder.Content.One'),
$container->get('Compiler.Builder.Languages'),
$container->get('Compiler.Builder.Multilingual'),
$container->get('Utilities.Counter'),
$container->get('Utilities.File')
);
}
}
src/Componentbuilder/Compiler/Service/BuilderAJ.php000064400000061402151162054170016335
0ustar00<?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\Service;
use Joomla\DI\Container;
use Joomla\DI\ServiceProviderInterface;
use VDM\Joomla\Componentbuilder\Compiler\Builder\AccessSwitch;
use VDM\Joomla\Componentbuilder\Compiler\Builder\AccessSwitchList;
use VDM\Joomla\Componentbuilder\Compiler\Builder\AssetsRules;
use VDM\Joomla\Componentbuilder\Compiler\Builder\AdminFilterType;
use VDM\Joomla\Componentbuilder\Compiler\Builder\Alias;
use VDM\Joomla\Componentbuilder\Compiler\Builder\BaseSixFour;
use VDM\Joomla\Componentbuilder\Compiler\Builder\Category;
use VDM\Joomla\Componentbuilder\Compiler\Builder\CategoryCode;
use VDM\Joomla\Componentbuilder\Compiler\Builder\CategoryOtherName;
use VDM\Joomla\Componentbuilder\Compiler\Builder\CheckBox;
use VDM\Joomla\Componentbuilder\Compiler\Builder\ComponentFields;
use VDM\Joomla\Componentbuilder\Compiler\Builder\ConfigFieldsets;
use
VDM\Joomla\Componentbuilder\Compiler\Builder\ConfigFieldsetsCustomfield;
use VDM\Joomla\Componentbuilder\Compiler\Builder\ContentMulti;
use VDM\Joomla\Componentbuilder\Compiler\Builder\ContentOne;
use VDM\Joomla\Componentbuilder\Compiler\Builder\Contributors;
use VDM\Joomla\Componentbuilder\Compiler\Builder\CustomAlias;
use VDM\Joomla\Componentbuilder\Compiler\Builder\CustomField;
use VDM\Joomla\Componentbuilder\Compiler\Builder\CustomFieldLinks;
use VDM\Joomla\Componentbuilder\Compiler\Builder\CustomList;
use VDM\Joomla\Componentbuilder\Compiler\Builder\CustomTabs;
use VDM\Joomla\Componentbuilder\Compiler\Builder\DatabaseKeys;
use VDM\Joomla\Componentbuilder\Compiler\Builder\DatabaseTables;
use VDM\Joomla\Componentbuilder\Compiler\Builder\DatabaseUniqueGuid;
use VDM\Joomla\Componentbuilder\Compiler\Builder\DatabaseUniqueKeys;
use VDM\Joomla\Componentbuilder\Compiler\Builder\DatabaseUninstall;
use VDM\Joomla\Componentbuilder\Compiler\Builder\DoNotEscape;
use VDM\Joomla\Componentbuilder\Compiler\Builder\DynamicFields;
use VDM\Joomla\Componentbuilder\Compiler\Builder\ExtensionCustomFields;
use VDM\Joomla\Componentbuilder\Compiler\Builder\ExtensionsParams;
use VDM\Joomla\Componentbuilder\Compiler\Builder\FieldGroupControl;
use VDM\Joomla\Componentbuilder\Compiler\Builder\FieldNames;
use VDM\Joomla\Componentbuilder\Compiler\Builder\FieldRelations;
use VDM\Joomla\Componentbuilder\Compiler\Builder\Filter;
use VDM\Joomla\Componentbuilder\Compiler\Builder\FootableScripts;
use VDM\Joomla\Componentbuilder\Compiler\Builder\FrontendParams;
use VDM\Joomla\Componentbuilder\Compiler\Builder\GetAsLookup;
use VDM\Joomla\Componentbuilder\Compiler\Builder\GetModule;
use VDM\Joomla\Componentbuilder\Compiler\Builder\GoogleChart;
use VDM\Joomla\Componentbuilder\Compiler\Builder\HasMenuGlobal;
use VDM\Joomla\Componentbuilder\Compiler\Builder\HasPermissions;
use VDM\Joomla\Componentbuilder\Compiler\Builder\HiddenFields;
use VDM\Joomla\Componentbuilder\Compiler\Builder\History;
use VDM\Joomla\Componentbuilder\Compiler\Builder\IntegerFields;
use VDM\Joomla\Componentbuilder\Compiler\Builder\ItemsMethodEximportString;
use VDM\Joomla\Componentbuilder\Compiler\Builder\ItemsMethodListString;
use VDM\Joomla\Componentbuilder\Compiler\Builder\JsonItem;
use VDM\Joomla\Componentbuilder\Compiler\Builder\JsonItemArray;
use VDM\Joomla\Componentbuilder\Compiler\Builder\JsonString;
/**
* Builder A-J Service Provider
*
* @since 3.2.0
*/
class BuilderAJ implements ServiceProviderInterface
{
/**
* Registers the service provider with a DI container.
*
* @param Container $container The DI container.
*
* @return void
* @since 3.2.0
*/
public function register(Container $container)
{
$container->alias(AccessSwitch::class,
'Compiler.Builder.Access.Switch')
->share('Compiler.Builder.Access.Switch', [$this,
'getAccessSwitch'], true);
$container->alias(AccessSwitchList::class,
'Compiler.Builder.Access.Switch.List')
->share('Compiler.Builder.Access.Switch.List', [$this,
'getAccessSwitchList'], true);
$container->alias(AssetsRules::class,
'Compiler.Builder.Assets.Rules')
->share('Compiler.Builder.Assets.Rules', [$this,
'getAssetsRules'], true);
$container->alias(AdminFilterType::class,
'Compiler.Builder.Admin.Filter.Type')
->share('Compiler.Builder.Admin.Filter.Type', [$this,
'getAdminFilterType'], true);
$container->alias(Alias::class, 'Compiler.Builder.Alias')
->share('Compiler.Builder.Alias', [$this,
'getAlias'], true);
$container->alias(BaseSixFour::class,
'Compiler.Builder.Base.Six.Four')
->share('Compiler.Builder.Base.Six.Four', [$this,
'getBaseSixFour'], true);
$container->alias(Category::class,
'Compiler.Builder.Category')
->share('Compiler.Builder.Category', [$this,
'getCategory'], true);
$container->alias(CategoryCode::class,
'Compiler.Builder.Category.Code')
->share('Compiler.Builder.Category.Code', [$this,
'getCategoryCode'], true);
$container->alias(CategoryOtherName::class,
'Compiler.Builder.Category.Other.Name')
->share('Compiler.Builder.Category.Other.Name', [$this,
'getCategoryOtherName'], true);
$container->alias(CheckBox::class,
'Compiler.Builder.Check.Box')
->share('Compiler.Builder.Check.Box', [$this,
'getCheckBox'], true);
$container->alias(ComponentFields::class,
'Compiler.Builder.Component.Fields')
->share('Compiler.Builder.Component.Fields', [$this,
'getComponentFields'], true);
$container->alias(ConfigFieldsets::class,
'Compiler.Builder.Config.Fieldsets')
->share('Compiler.Builder.Config.Fieldsets', [$this,
'getConfigFieldsets'], true);
$container->alias(ConfigFieldsetsCustomfield::class,
'Compiler.Builder.Config.Fieldsets.Customfield')
->share('Compiler.Builder.Config.Fieldsets.Customfield',
[$this, 'getConfigFieldsetsCustomfield'], true);
$container->alias(ContentMulti::class,
'Compiler.Builder.Content.Multi')
->share('Compiler.Builder.Content.Multi', [$this,
'getContentMulti'], true);
$container->alias(ContentOne::class,
'Compiler.Builder.Content.One')
->share('Compiler.Builder.Content.One', [$this,
'getContentOne'], true);
$container->alias(Contributors::class,
'Compiler.Builder.Contributors')
->share('Compiler.Builder.Contributors', [$this,
'getContributors'], true);
$container->alias(CustomAlias::class,
'Compiler.Builder.Custom.Alias')
->share('Compiler.Builder.Custom.Alias', [$this,
'getCustomAlias'], true);
$container->alias(CustomField::class,
'Compiler.Builder.Custom.Field')
->share('Compiler.Builder.Custom.Field', [$this,
'getCustomField'], true);
$container->alias(CustomFieldLinks::class,
'Compiler.Builder.Custom.Field.Links')
->share('Compiler.Builder.Custom.Field.Links', [$this,
'getCustomFieldLinks'], true);
$container->alias(CustomList::class,
'Compiler.Builder.Custom.List')
->share('Compiler.Builder.Custom.List', [$this,
'getCustomList'], true);
$container->alias(CustomTabs::class,
'Compiler.Builder.Custom.Tabs')
->share('Compiler.Builder.Custom.Tabs', [$this,
'getCustomTabs'], true);
$container->alias(DatabaseKeys::class,
'Compiler.Builder.Database.Keys')
->share('Compiler.Builder.Database.Keys', [$this,
'getDatabaseKeys'], true);
$container->alias(DatabaseTables::class,
'Compiler.Builder.Database.Tables')
->share('Compiler.Builder.Database.Tables', [$this,
'getDatabaseTables'], true);
$container->alias(DatabaseUniqueGuid::class,
'Compiler.Builder.Database.Unique.Guid')
->share('Compiler.Builder.Database.Unique.Guid', [$this,
'getDatabaseUniqueGuid'], true);
$container->alias(DatabaseUniqueKeys::class,
'Compiler.Builder.Database.Unique.Keys')
->share('Compiler.Builder.Database.Unique.Keys', [$this,
'getDatabaseUniqueKeys'], true);
$container->alias(DatabaseUninstall::class,
'Compiler.Builder.Database.Uninstall')
->share('Compiler.Builder.Database.Uninstall', [$this,
'getDatabaseUninstall'], true);
$container->alias(DoNotEscape::class,
'Compiler.Builder.Do.Not.Escape')
->share('Compiler.Builder.Do.Not.Escape', [$this,
'getDoNotEscape'], true);
$container->alias(DynamicFields::class,
'Compiler.Builder.Dynamic.Fields')
->share('Compiler.Builder.Dynamic.Fields', [$this,
'getDynamicFields'], true);
$container->alias(ExtensionCustomFields::class,
'Compiler.Builder.Extension.Custom.Fields')
->share('Compiler.Builder.Extension.Custom.Fields', [$this,
'getExtensionCustomFields'], true);
$container->alias(ExtensionsParams::class,
'Compiler.Builder.Extensions.Params')
->share('Compiler.Builder.Extensions.Params', [$this,
'getExtensionsParams'], true);
$container->alias(FieldGroupControl::class,
'Compiler.Builder.Field.Group.Control')
->share('Compiler.Builder.Field.Group.Control', [$this,
'getFieldGroupControl'], true);
$container->alias(FieldNames::class,
'Compiler.Builder.Field.Names')
->share('Compiler.Builder.Field.Names', [$this,
'getFieldNames'], true);
$container->alias(FieldRelations::class,
'Compiler.Builder.Field.Relations')
->share('Compiler.Builder.Field.Relations', [$this,
'getFieldRelations'], true);
$container->alias(Filter::class, 'Compiler.Builder.Filter')
->share('Compiler.Builder.Filter', [$this,
'getFilter'], true);
$container->alias(FootableScripts::class,
'Compiler.Builder.Footable.Scripts')
->share('Compiler.Builder.Footable.Scripts', [$this,
'getFootableScripts'], true);
$container->alias(FrontendParams::class,
'Compiler.Builder.Frontend.Params')
->share('Compiler.Builder.Frontend.Params', [$this,
'getFrontendParams'], true);
$container->alias(GetAsLookup::class,
'Compiler.Builder.Get.As.Lookup')
->share('Compiler.Builder.Get.As.Lookup', [$this,
'getGetAsLookup'], true);
$container->alias(GetModule::class,
'Compiler.Builder.Get.Module')
->share('Compiler.Builder.Get.Module', [$this,
'getGetModule'], true);
$container->alias(GoogleChart::class,
'Compiler.Builder.Google.Chart')
->share('Compiler.Builder.Google.Chart', [$this,
'getGoogleChart'], true);
$container->alias(HasMenuGlobal::class,
'Compiler.Builder.Has.Menu.Global')
->share('Compiler.Builder.Has.Menu.Global', [$this,
'getHasMenuGlobal'], true);
$container->alias(HasPermissions::class,
'Compiler.Builder.Has.Permissions')
->share('Compiler.Builder.Has.Permissions', [$this,
'getHasPermissions'], true);
$container->alias(HiddenFields::class,
'Compiler.Builder.Hidden.Fields')
->share('Compiler.Builder.Hidden.Fields', [$this,
'getHiddenFields'], true);
$container->alias(History::class,
'Compiler.Builder.History')
->share('Compiler.Builder.History', [$this,
'getHistory'], true);
$container->alias(IntegerFields::class,
'Compiler.Builder.Integer.Fields')
->share('Compiler.Builder.Integer.Fields', [$this,
'getIntegerFields'], true);
$container->alias(ItemsMethodEximportString::class,
'Compiler.Builder.Items.Method.Eximport.String')
->share('Compiler.Builder.Items.Method.Eximport.String',
[$this, 'getItemsMethodEximportString'], true);
$container->alias(ItemsMethodListString::class,
'Compiler.Builder.Items.Method.List.String')
->share('Compiler.Builder.Items.Method.List.String',
[$this, 'getItemsMethodListString'], true);
$container->alias(JsonItem::class,
'Compiler.Builder.Json.Item')
->share('Compiler.Builder.Json.Item', [$this,
'getJsonItem'], true);
$container->alias(JsonItemArray::class,
'Compiler.Builder.Json.Item.Array')
->share('Compiler.Builder.Json.Item.Array', [$this,
'getJsonItemArray'], true);
$container->alias(JsonString::class,
'Compiler.Builder.Json.String')
->share('Compiler.Builder.Json.String', [$this,
'getJsonString'], true);
}
/**
* Get The AccessSwitch Class.
*
* @param Container $container The DI container.
*
* @return AccessSwitch
* @since 3.2.0
*/
public function getAccessSwitch(Container $container): AccessSwitch
{
return new AccessSwitch();
}
/**
* Get The AccessSwitchList Class.
*
* @param Container $container The DI container.
*
* @return AccessSwitchList
* @since 3.2.0
*/
public function getAccessSwitchList(Container $container):
AccessSwitchList
{
return new AccessSwitchList();
}
/**
* Get The AssetsRules Class.
*
* @param Container $container The DI container.
*
* @return AssetsRules
* @since 3.2.0
*/
public function getAssetsRules(Container $container): AssetsRules
{
return new AssetsRules();
}
/**
* Get The AdminFilterType Class.
*
* @param Container $container The DI container.
*
* @return AdminFilterType
* @since 3.2.0
*/
public function getAdminFilterType(Container $container): AdminFilterType
{
return new AdminFilterType();
}
/**
* Get The Alias Class.
*
* @param Container $container The DI container.
*
* @return Alias
* @since 3.2.0
*/
public function getAlias(Container $container): Alias
{
return new Alias();
}
/**
* Get The BaseSixFour Class.
*
* @param Container $container The DI container.
*
* @return BaseSixFour
* @since 3.2.0
*/
public function getBaseSixFour(Container $container): BaseSixFour
{
return new BaseSixFour();
}
/**
* Get The Category Class.
*
* @param Container $container The DI container.
*
* @return Category
* @since 3.2.0
*/
public function getCategory(Container $container): Category
{
return new Category();
}
/**
* Get The CategoryCode Class.
*
* @param Container $container The DI container.
*
* @return CategoryCode
* @since 3.2.0
*/
public function getCategoryCode(Container $container): CategoryCode
{
return new CategoryCode();
}
/**
* Get The CategoryOtherName Class.
*
* @param Container $container The DI container.
*
* @return CategoryOtherName
* @since 3.2.0
*/
public function getCategoryOtherName(Container $container):
CategoryOtherName
{
return new CategoryOtherName();
}
/**
* Get The CheckBox Class.
*
* @param Container $container The DI container.
*
* @return CheckBox
* @since 3.2.0
*/
public function getCheckBox(Container $container): CheckBox
{
return new CheckBox();
}
/**
* Get The ComponentFields Class.
*
* @param Container $container The DI container.
*
* @return ComponentFields
* @since 3.2.0
*/
public function getComponentFields(Container $container): ComponentFields
{
return new ComponentFields();
}
/**
* Get The ConfigFieldsets Class.
*
* @param Container $container The DI container.
*
* @return ConfigFieldsets
* @since 3.2.0
*/
public function getConfigFieldsets(Container $container): ConfigFieldsets
{
return new ConfigFieldsets();
}
/**
* Get The ConfigFieldsetsCustomfield Class.
*
* @param Container $container The DI container.
*
* @return ConfigFieldsetsCustomfield
* @since 3.2.0
*/
public function getConfigFieldsetsCustomfield(Container $container):
ConfigFieldsetsCustomfield
{
return new ConfigFieldsetsCustomfield();
}
/**
* Get The ContentMulti Class.
*
* @param Container $container The DI container.
*
* @return ContentMulti
* @since 3.2.0
*/
public function getContentMulti(Container $container): ContentMulti
{
return new ContentMulti();
}
/**
* Get The ContentOne Class.
*
* @param Container $container The DI container.
*
* @return ContentOne
* @since 3.2.0
*/
public function getContentOne(Container $container): ContentOne
{
return new ContentOne();
}
/**
* Get The Contributors Class.
*
* @param Container $container The DI container.
*
* @return Contributors
* @since 3.2.0
*/
public function getContributors(Container $container): Contributors
{
return new Contributors();
}
/**
* Get The CustomAlias Class.
*
* @param Container $container The DI container.
*
* @return CustomAlias
* @since 3.2.0
*/
public function getCustomAlias(Container $container): CustomAlias
{
return new CustomAlias();
}
/**
* Get The CustomField Class.
*
* @param Container $container The DI container.
*
* @return CustomField
* @since 3.2.0
*/
public function getCustomField(Container $container): CustomField
{
return new CustomField();
}
/**
* Get The CustomFieldLinks Class.
*
* @param Container $container The DI container.
*
* @return CustomFieldLinks
* @since 3.2.0
*/
public function getCustomFieldLinks(Container $container):
CustomFieldLinks
{
return new CustomFieldLinks();
}
/**
* Get The CustomList Class.
*
* @param Container $container The DI container.
*
* @return CustomList
* @since 3.2.0
*/
public function getCustomList(Container $container): CustomList
{
return new CustomList();
}
/**
* Get The CustomTabs Class.
*
* @param Container $container The DI container.
*
* @return CustomTabs
* @since 3.2.0
*/
public function getCustomTabs(Container $container): CustomTabs
{
return new CustomTabs();
}
/**
* Get The DatabaseKeys Class.
*
* @param Container $container The DI container.
*
* @return DatabaseKeys
* @since 3.2.0
*/
public function getDatabaseKeys(Container $container): DatabaseKeys
{
return new DatabaseKeys();
}
/**
* Get The DatabaseTables Class.
*
* @param Container $container The DI container.
*
* @return DatabaseTables
* @since 3.2.0
*/
public function getDatabaseTables(Container $container): DatabaseTables
{
return new DatabaseTables();
}
/**
* Get The DatabaseUniqueGuid Class.
*
* @param Container $container The DI container.
*
* @return DatabaseUniqueGuid
* @since 3.2.0
*/
public function getDatabaseUniqueGuid(Container $container):
DatabaseUniqueGuid
{
return new DatabaseUniqueGuid();
}
/**
* Get The DatabaseUniqueKeys Class.
*
* @param Container $container The DI container.
*
* @return DatabaseUniqueKeys
* @since 3.2.0
*/
public function getDatabaseUniqueKeys(Container $container):
DatabaseUniqueKeys
{
return new DatabaseUniqueKeys();
}
/**
* Get The DatabaseUninstall Class.
*
* @param Container $container The DI container.
*
* @return DatabaseUninstall
* @since 3.2.0
*/
public function getDatabaseUninstall(Container $container):
DatabaseUninstall
{
return new DatabaseUninstall();
}
/**
* Get The DoNotEscape Class.
*
* @param Container $container The DI container.
*
* @return DoNotEscape
* @since 3.2.0
*/
public function getDoNotEscape(Container $container): DoNotEscape
{
return new DoNotEscape();
}
/**
* Get The DynamicFields Class.
*
* @param Container $container The DI container.
*
* @return DynamicFields
* @since 3.2.0
*/
public function getDynamicFields(Container $container): DynamicFields
{
return new DynamicFields();
}
/**
* Get The ExtensionCustomFields Class.
*
* @param Container $container The DI container.
*
* @return ExtensionCustomFields
* @since 3.2.0
*/
public function getExtensionCustomFields(Container $container):
ExtensionCustomFields
{
return new ExtensionCustomFields();
}
/**
* Get The ExtensionsParams Class.
*
* @param Container $container The DI container.
*
* @return ExtensionsParams
* @since 3.2.0
*/
public function getExtensionsParams(Container $container):
ExtensionsParams
{
return new ExtensionsParams();
}
/**
* Get The FieldGroupControl Class.
*
* @param Container $container The DI container.
*
* @return FieldGroupControl
* @since 3.2.0
*/
public function getFieldGroupControl(Container $container):
FieldGroupControl
{
return new FieldGroupControl();
}
/**
* Get The FieldNames Class.
*
* @param Container $container The DI container.
*
* @return FieldNames
* @since 3.2.0
*/
public function getFieldNames(Container $container): FieldNames
{
return new FieldNames();
}
/**
* Get The FieldRelations Class.
*
* @param Container $container The DI container.
*
* @return FieldRelations
* @since 3.2.0
*/
public function getFieldRelations(Container $container): FieldRelations
{
return new FieldRelations();
}
/**
* Get The Filter Class.
*
* @param Container $container The DI container.
*
* @return Filter
* @since 3.2.0
*/
public function getFilter(Container $container): Filter
{
return new Filter();
}
/**
* Get The FootableScripts Class.
*
* @param Container $container The DI container.
*
* @return FootableScripts
* @since 3.2.0
*/
public function getFootableScripts(Container $container): FootableScripts
{
return new FootableScripts();
}
/**
* Get The FrontendParams Class.
*
* @param Container $container The DI container.
*
* @return FrontendParams
* @since 3.2.0
*/
public function getFrontendParams(Container $container): FrontendParams
{
return new FrontendParams();
}
/**
* Get The GetAsLookup Class.
*
* @param Container $container The DI container.
*
* @return GetAsLookup
* @since 3.2.0
*/
public function getGetAsLookup(Container $container): GetAsLookup
{
return new GetAsLookup();
}
/**
* Get The GetModule Class.
*
* @param Container $container The DI container.
*
* @return GetModule
* @since 3.2.0
*/
public function getGetModule(Container $container): GetModule
{
return new GetModule();
}
/**
* Get The GoogleChart Class.
*
* @param Container $container The DI container.
*
* @return GoogleChart
* @since 3.2.0
*/
public function getGoogleChart(Container $container): GoogleChart
{
return new GoogleChart();
}
/**
* Get The HasMenuGlobal Class.
*
* @param Container $container The DI container.
*
* @return HasMenuGlobal
* @since 3.2.0
*/
public function getHasMenuGlobal(Container $container): HasMenuGlobal
{
return new HasMenuGlobal();
}
/**
* Get The HasPermissions Class.
*
* @param Container $container The DI container.
*
* @return HasPermissions
* @since 3.2.0
*/
public function getHasPermissions(Container $container): HasPermissions
{
return new HasPermissions();
}
/**
* Get The HiddenFields Class.
*
* @param Container $container The DI container.
*
* @return HiddenFields
* @since 3.2.0
*/
public function getHiddenFields(Container $container): HiddenFields
{
return new HiddenFields();
}
/**
* Get The History Class.
*
* @param Container $container The DI container.
*
* @return History
* @since 3.2.0
*/
public function getHistory(Container $container): History
{
return new History();
}
/**
* Get The IntegerFields Class.
*
* @param Container $container The DI container.
*
* @return IntegerFields
* @since 3.2.0
*/
public function getIntegerFields(Container $container): IntegerFields
{
return new IntegerFields();
}
/**
* Get The ItemsMethodEximportString Class.
*
* @param Container $container The DI container.
*
* @return ItemsMethodEximportString
* @since 3.2.0
*/
public function getItemsMethodEximportString(Container $container):
ItemsMethodEximportString
{
return new ItemsMethodEximportString();
}
/**
* Get The ItemsMethodListString Class.
*
* @param Container $container The DI container.
*
* @return ItemsMethodListString
* @since 3.2.0
*/
public function getItemsMethodListString(Container $container):
ItemsMethodListString
{
return new ItemsMethodListString();
}
/**
* Get The JsonItem Class.
*
* @param Container $container The DI container.
*
* @return JsonItem
* @since 3.2.0
*/
public function getJsonItem(Container $container): JsonItem
{
return new JsonItem();
}
/**
* Get The JsonItemArray Class.
*
* @param Container $container The DI container.
*
* @return JsonItemArray
* @since 3.2.0
*/
public function getJsonItemArray(Container $container): JsonItemArray
{
return new JsonItemArray();
}
/**
* Get The JsonString Class.
*
* @param Container $container The DI container.
*
* @return JsonString
* @since 3.2.0
*/
public function getJsonString(Container $container): JsonString
{
return new JsonString();
}
}
src/Componentbuilder/Compiler/Service/BuilderLZ.php000064400000065145151162054170016400
0ustar00<?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\Service;
use Joomla\DI\Container;
use Joomla\DI\ServiceProviderInterface;
use VDM\Joomla\Componentbuilder\Compiler\Builder\Languages;
use VDM\Joomla\Componentbuilder\Compiler\Builder\LanguageMessages;
use VDM\Joomla\Componentbuilder\Compiler\Builder\Layout;
use VDM\Joomla\Componentbuilder\Compiler\Builder\LayoutData;
use VDM\Joomla\Componentbuilder\Compiler\Builder\LibraryManager;
use VDM\Joomla\Componentbuilder\Compiler\Builder\ListFieldClass;
use VDM\Joomla\Componentbuilder\Compiler\Builder\ListHeadOverride;
use VDM\Joomla\Componentbuilder\Compiler\Builder\ListJoin;
use VDM\Joomla\Componentbuilder\Compiler\Builder\Lists;
use VDM\Joomla\Componentbuilder\Compiler\Builder\MainTextField;
use VDM\Joomla\Componentbuilder\Compiler\Builder\MetaData;
use VDM\Joomla\Componentbuilder\Compiler\Builder\ModelBasicField;
use VDM\Joomla\Componentbuilder\Compiler\Builder\ModelExpertField;
use VDM\Joomla\Componentbuilder\Compiler\Builder\ModelExpertFieldInitiator;
use VDM\Joomla\Componentbuilder\Compiler\Builder\ModelMediumField;
use VDM\Joomla\Componentbuilder\Compiler\Builder\ModelWhmcsField;
use VDM\Joomla\Componentbuilder\Compiler\Builder\MovedPublishingFields;
use VDM\Joomla\Componentbuilder\Compiler\Builder\Multilingual;
use VDM\Joomla\Componentbuilder\Compiler\Builder\MysqlTableSetting;
use VDM\Joomla\Componentbuilder\Compiler\Builder\NewPublishingFields;
use VDM\Joomla\Componentbuilder\Compiler\Builder\OrderZero;
use VDM\Joomla\Componentbuilder\Compiler\Builder\OtherFilter;
use VDM\Joomla\Componentbuilder\Compiler\Builder\OtherGroup;
use VDM\Joomla\Componentbuilder\Compiler\Builder\OtherJoin;
use VDM\Joomla\Componentbuilder\Compiler\Builder\OtherOrder;
use VDM\Joomla\Componentbuilder\Compiler\Builder\OtherQuery;
use VDM\Joomla\Componentbuilder\Compiler\Builder\OtherWhere;
use VDM\Joomla\Componentbuilder\Compiler\Builder\PermissionAction;
use VDM\Joomla\Componentbuilder\Compiler\Builder\PermissionComponent;
use VDM\Joomla\Componentbuilder\Compiler\Builder\PermissionCore;
use VDM\Joomla\Componentbuilder\Compiler\Builder\PermissionDashboard;
use VDM\Joomla\Componentbuilder\Compiler\Builder\PermissionFields;
use VDM\Joomla\Componentbuilder\Compiler\Builder\PermissionGlobalAction;
use VDM\Joomla\Componentbuilder\Compiler\Builder\PermissionViews;
use VDM\Joomla\Componentbuilder\Compiler\Builder\Request;
use VDM\Joomla\Componentbuilder\Compiler\Builder\Router;
use VDM\Joomla\Componentbuilder\Compiler\Builder\ScriptMediaSwitch;
use VDM\Joomla\Componentbuilder\Compiler\Builder\ScriptUserSwitch;
use VDM\Joomla\Componentbuilder\Compiler\Builder\Search;
use VDM\Joomla\Componentbuilder\Compiler\Builder\SelectionTranslation;
use VDM\Joomla\Componentbuilder\Compiler\Builder\SiteDecrypt;
use VDM\Joomla\Componentbuilder\Compiler\Builder\SiteDynamicGet;
use VDM\Joomla\Componentbuilder\Compiler\Builder\SiteEditView;
use VDM\Joomla\Componentbuilder\Compiler\Builder\SiteFieldData;
use VDM\Joomla\Componentbuilder\Compiler\Builder\SiteFieldDecodeFilter;
use VDM\Joomla\Componentbuilder\Compiler\Builder\SiteFields;
use VDM\Joomla\Componentbuilder\Compiler\Builder\SiteMainGet;
use VDM\Joomla\Componentbuilder\Compiler\Builder\Sort;
use VDM\Joomla\Componentbuilder\Compiler\Builder\TabCounter;
use VDM\Joomla\Componentbuilder\Compiler\Builder\Tags;
use VDM\Joomla\Componentbuilder\Compiler\Builder\TemplateData;
use VDM\Joomla\Componentbuilder\Compiler\Builder\Title;
use VDM\Joomla\Componentbuilder\Compiler\Builder\UikitComp;
use VDM\Joomla\Componentbuilder\Compiler\Builder\UpdateMysql;
use VDM\Joomla\Componentbuilder\Compiler\Builder\ViewsDefaultOrdering;
/**
* Builder L-Z Service Provider
*
* @since 3.2.0
*/
class BuilderLZ implements ServiceProviderInterface
{
/**
* Registers the service provider with a DI container.
*
* @param Container $container The DI container.
*
* @return void
* @since 3.2.0
*/
public function register(Container $container)
{
$container->alias(Languages::class,
'Compiler.Builder.Languages')
->share('Compiler.Builder.Languages', [$this,
'getLanguages'], true);
$container->alias(LanguageMessages::class,
'Compiler.Builder.Language.Messages')
->share('Compiler.Builder.Language.Messages', [$this,
'getLanguageMessages'], true);
$container->alias(Layout::class, 'Compiler.Builder.Layout')
->share('Compiler.Builder.Layout', [$this,
'getLayout'], true);
$container->alias(LayoutData::class,
'Compiler.Builder.Layout.Data')
->share('Compiler.Builder.Layout.Data', [$this,
'getLayoutData'], true);
$container->alias(LibraryManager::class,
'Compiler.Builder.Library.Manager')
->share('Compiler.Builder.Library.Manager', [$this,
'getLibraryManager'], true);
$container->alias(ListFieldClass::class,
'Compiler.Builder.List.Field.Class')
->share('Compiler.Builder.List.Field.Class', [$this,
'getListFieldClass'], true);
$container->alias(ListHeadOverride::class,
'Compiler.Builder.List.Head.Override')
->share('Compiler.Builder.List.Head.Override', [$this,
'getListHeadOverride'], true);
$container->alias(ListJoin::class,
'Compiler.Builder.List.Join')
->share('Compiler.Builder.List.Join', [$this,
'getListJoin'], true);
$container->alias(Lists::class, 'Compiler.Builder.Lists')
->share('Compiler.Builder.Lists', [$this,
'getLists'], true);
$container->alias(MainTextField::class,
'Compiler.Builder.Main.Text.Field')
->share('Compiler.Builder.Main.Text.Field', [$this,
'getMainTextField'], true);
$container->alias(MetaData::class,
'Compiler.Builder.Meta.Data')
->share('Compiler.Builder.Meta.Data', [$this,
'getMetaData'], true);
$container->alias(ModelBasicField::class,
'Compiler.Builder.Model.Basic.Field')
->share('Compiler.Builder.Model.Basic.Field', [$this,
'getModelBasicField'], true);
$container->alias(ModelExpertField::class,
'Compiler.Builder.Model.Expert.Field')
->share('Compiler.Builder.Model.Expert.Field', [$this,
'getModelExpertField'], true);
$container->alias(ModelExpertFieldInitiator::class,
'Compiler.Builder.Model.Expert.Field.Initiator')
->share('Compiler.Builder.Model.Expert.Field.Initiator',
[$this, 'getModelExpertFieldInitiator'], true);
$container->alias(ModelMediumField::class,
'Compiler.Builder.Model.Medium.Field')
->share('Compiler.Builder.Model.Medium.Field', [$this,
'getModelMediumField'], true);
$container->alias(ModelWhmcsField::class,
'Compiler.Builder.Model.Whmcs.Field')
->share('Compiler.Builder.Model.Whmcs.Field', [$this,
'getModelWhmcsField'], true);
$container->alias(MovedPublishingFields::class,
'Compiler.Builder.Moved.Publishing.Fields')
->share('Compiler.Builder.Moved.Publishing.Fields', [$this,
'getMovedPublishingFields'], true);
$container->alias(Multilingual::class,
'Compiler.Builder.Multilingual')
->share('Compiler.Builder.Multilingual', [$this,
'getMultilingual'], true);
$container->alias(MysqlTableSetting::class,
'Compiler.Builder.Mysql.Table.Setting')
->share('Compiler.Builder.Mysql.Table.Setting', [$this,
'getMysqlTableSetting'], true);
$container->alias(NewPublishingFields::class,
'Compiler.Builder.New.Publishing.Fields')
->share('Compiler.Builder.New.Publishing.Fields', [$this,
'getNewPublishingFields'], true);
$container->alias(OrderZero::class,
'Compiler.Builder.Order.Zero')
->share('Compiler.Builder.Order.Zero', [$this,
'getOrderZero'], true);
$container->alias(OtherFilter::class,
'Compiler.Builder.Other.Filter')
->share('Compiler.Builder.Other.Filter', [$this,
'getOtherFilter'], true);
$container->alias(OtherGroup::class,
'Compiler.Builder.Other.Group')
->share('Compiler.Builder.Other.Group', [$this,
'getOtherGroup'], true);
$container->alias(OtherJoin::class,
'Compiler.Builder.Other.Join')
->share('Compiler.Builder.Other.Join', [$this,
'getOtherJoin'], true);
$container->alias(OtherOrder::class,
'Compiler.Builder.Other.Order')
->share('Compiler.Builder.Other.Order', [$this,
'getOtherOrder'], true);
$container->alias(OtherQuery::class,
'Compiler.Builder.Other.Query')
->share('Compiler.Builder.Other.Query', [$this,
'getOtherQuery'], true);
$container->alias(OtherWhere::class,
'Compiler.Builder.Other.Where')
->share('Compiler.Builder.Other.Where', [$this,
'getOtherWhere'], true);
$container->alias(PermissionAction::class,
'Compiler.Builder.Permission.Action')
->share('Compiler.Builder.Permission.Action', [$this,
'getPermissionAction'], true);
$container->alias(PermissionComponent::class,
'Compiler.Builder.Permission.Component')
->share('Compiler.Builder.Permission.Component', [$this,
'getPermissionComponent'], true);
$container->alias(PermissionCore::class,
'Compiler.Builder.Permission.Core')
->share('Compiler.Builder.Permission.Core', [$this,
'getPermissionCore'], true);
$container->alias(PermissionDashboard::class,
'Compiler.Builder.Permission.Dashboard')
->share('Compiler.Builder.Permission.Dashboard', [$this,
'getPermissionDashboard'], true);
$container->alias(PermissionFields::class,
'Compiler.Builder.Permission.Fields')
->share('Compiler.Builder.Permission.Fields', [$this,
'getPermissionFields'], true);
$container->alias(PermissionGlobalAction::class,
'Compiler.Builder.Permission.Global.Action')
->share('Compiler.Builder.Permission.Global.Action',
[$this, 'getPermissionGlobalAction'], true);
$container->alias(PermissionViews::class,
'Compiler.Builder.Permission.Views')
->share('Compiler.Builder.Permission.Views', [$this,
'getPermissionViews'], true);
$container->alias(Request::class,
'Compiler.Builder.Request')
->share('Compiler.Builder.Request', [$this,
'getRequest'], true);
$container->alias(Router::class, 'Compiler.Builder.Router')
->share('Compiler.Builder.Router', [$this,
'getRouter'], true);
$container->alias(ScriptMediaSwitch::class,
'Compiler.Builder.Script.Media.Switch')
->share('Compiler.Builder.Script.Media.Switch', [$this,
'getScriptMediaSwitch'], true);
$container->alias(ScriptUserSwitch::class,
'Compiler.Builder.Script.User.Switch')
->share('Compiler.Builder.Script.User.Switch', [$this,
'getScriptUserSwitch'], true);
$container->alias(Search::class, 'Compiler.Builder.Search')
->share('Compiler.Builder.Search', [$this,
'getSearch'], true);
$container->alias(SelectionTranslation::class,
'Compiler.Builder.Selection.Translation')
->share('Compiler.Builder.Selection.Translation', [$this,
'getSelectionTranslation'], true);
$container->alias(SiteDecrypt::class,
'Compiler.Builder.Site.Decrypt')
->share('Compiler.Builder.Site.Decrypt', [$this,
'getSiteDecrypt'], true);
$container->alias(SiteDynamicGet::class,
'Compiler.Builder.Site.Dynamic.Get')
->share('Compiler.Builder.Site.Dynamic.Get', [$this,
'getSiteDynamicGet'], true);
$container->alias(SiteEditView::class,
'Compiler.Builder.Site.Edit.View')
->share('Compiler.Builder.Site.Edit.View', [$this,
'getSiteEditView'], true);
$container->alias(SiteFieldData::class,
'Compiler.Builder.Site.Field.Data')
->share('Compiler.Builder.Site.Field.Data', [$this,
'getSiteFieldData'], true);
$container->alias(SiteFieldDecodeFilter::class,
'Compiler.Builder.Site.Field.Decode.Filter')
->share('Compiler.Builder.Site.Field.Decode.Filter',
[$this, 'getSiteFieldDecodeFilter'], true);
$container->alias(SiteFields::class,
'Compiler.Builder.Site.Fields')
->share('Compiler.Builder.Site.Fields', [$this,
'getSiteFields'], true);
$container->alias(SiteMainGet::class,
'Compiler.Builder.Site.Main.Get')
->share('Compiler.Builder.Site.Main.Get', [$this,
'getSiteMainGet'], true);
$container->alias(Sort::class, 'Compiler.Builder.Sort')
->share('Compiler.Builder.Sort', [$this,
'getSort'], true);
$container->alias(TabCounter::class,
'Compiler.Builder.Tab.Counter')
->share('Compiler.Builder.Tab.Counter', [$this,
'getTabCounter'], true);
$container->alias(Tags::class, 'Compiler.Builder.Tags')
->share('Compiler.Builder.Tags', [$this,
'getTags'], true);
$container->alias(TemplateData::class,
'Compiler.Builder.Template.Data')
->share('Compiler.Builder.Template.Data', [$this,
'getTemplateData'], true);
$container->alias(Title::class, 'Compiler.Builder.Title')
->share('Compiler.Builder.Title', [$this,
'getTitle'], true);
$container->alias(UikitComp::class,
'Compiler.Builder.Uikit.Comp')
->share('Compiler.Builder.Uikit.Comp', [$this,
'getUikitComp'], true);
$container->alias(UpdateMysql::class,
'Compiler.Builder.Update.Mysql')
->share('Compiler.Builder.Update.Mysql', [$this,
'getUpdateMysql'], true);
$container->alias(ViewsDefaultOrdering::class,
'Compiler.Builder.Views.Default.Ordering')
->share('Compiler.Builder.Views.Default.Ordering', [$this,
'getViewsDefaultOrdering'], true);
}
/**
* Get The Languages Class.
*
* @param Container $container The DI container.
*
* @return Languages
* @since 3.2.0
*/
public function getLanguages(Container $container): Languages
{
return new Languages();
}
/**
* Get The LanguageMessages Class.
*
* @param Container $container The DI container.
*
* @return LanguageMessages
* @since 3.2.0
*/
public function getLanguageMessages(Container $container):
LanguageMessages
{
return new LanguageMessages();
}
/**
* Get The Layout Class.
*
* @param Container $container The DI container.
*
* @return Layout
* @since 3.2.0
*/
public function getLayout(Container $container): Layout
{
return new Layout();
}
/**
* Get The LayoutData Class.
*
* @param Container $container The DI container.
*
* @return LayoutData
* @since 3.2.0
*/
public function getLayoutData(Container $container): LayoutData
{
return new LayoutData();
}
/**
* Get The LibraryManager Class.
*
* @param Container $container The DI container.
*
* @return LibraryManager
* @since 3.2.0
*/
public function getLibraryManager(Container $container): LibraryManager
{
return new LibraryManager();
}
/**
* Get The ListFieldClass Class.
*
* @param Container $container The DI container.
*
* @return ListFieldClass
* @since 3.2.0
*/
public function getListFieldClass(Container $container): ListFieldClass
{
return new ListFieldClass();
}
/**
* Get The ListHeadOverride Class.
*
* @param Container $container The DI container.
*
* @return ListHeadOverride
* @since 3.2.0
*/
public function getListHeadOverride(Container $container):
ListHeadOverride
{
return new ListHeadOverride();
}
/**
* Get The ListJoin Class.
*
* @param Container $container The DI container.
*
* @return ListJoin
* @since 3.2.0
*/
public function getListJoin(Container $container): ListJoin
{
return new ListJoin();
}
/**
* Get The Lists Class.
*
* @param Container $container The DI container.
*
* @return Lists
* @since 3.2.0
*/
public function getLists(Container $container): Lists
{
return new Lists();
}
/**
* Get The MainTextField Class.
*
* @param Container $container The DI container.
*
* @return MainTextField
* @since 3.2.0
*/
public function getMainTextField(Container $container): MainTextField
{
return new MainTextField();
}
/**
* Get The MetaData Class.
*
* @param Container $container The DI container.
*
* @return MetaData
* @since 3.2.0
*/
public function getMetaData(Container $container): MetaData
{
return new MetaData();
}
/**
* Get The ModelBasicField Class.
*
* @param Container $container The DI container.
*
* @return ModelBasicField
* @since 3.2.0
*/
public function getModelBasicField(Container $container): ModelBasicField
{
return new ModelBasicField();
}
/**
* Get The ModelExpertField Class.
*
* @param Container $container The DI container.
*
* @return ModelExpertField
* @since 3.2.0
*/
public function getModelExpertField(Container $container):
ModelExpertField
{
return new ModelExpertField();
}
/**
* Get The ModelExpertFieldInitiator Class.
*
* @param Container $container The DI container.
*
* @return ModelExpertFieldInitiator
* @since 3.2.0
*/
public function getModelExpertFieldInitiator(Container $container):
ModelExpertFieldInitiator
{
return new ModelExpertFieldInitiator();
}
/**
* Get The ModelMediumField Class.
*
* @param Container $container The DI container.
*
* @return ModelMediumField
* @since 3.2.0
*/
public function getModelMediumField(Container $container):
ModelMediumField
{
return new ModelMediumField();
}
/**
* Get The ModelWhmcsField Class.
*
* @param Container $container The DI container.
*
* @return ModelWhmcsField
* @since 3.2.0
*/
public function getModelWhmcsField(Container $container): ModelWhmcsField
{
return new ModelWhmcsField();
}
/**
* Get The MovedPublishingFields Class.
*
* @param Container $container The DI container.
*
* @return MovedPublishingFields
* @since 3.2.0
*/
public function getMovedPublishingFields(Container $container):
MovedPublishingFields
{
return new MovedPublishingFields();
}
/**
* Get The Multilingual Class.
*
* @param Container $container The DI container.
*
* @return Multilingual
* @since 3.2.0
*/
public function getMultilingual(Container $container): Multilingual
{
return new Multilingual();
}
/**
* Get The MysqlTableSetting Class.
*
* @param Container $container The DI container.
*
* @return MysqlTableSetting
* @since 3.2.0
*/
public function getMysqlTableSetting(Container $container):
MysqlTableSetting
{
return new MysqlTableSetting();
}
/**
* Get The NewPublishingFields Class.
*
* @param Container $container The DI container.
*
* @return NewPublishingFields
* @since 3.2.0
*/
public function getNewPublishingFields(Container $container):
NewPublishingFields
{
return new NewPublishingFields();
}
/**
* Get The OrderZero Class.
*
* @param Container $container The DI container.
*
* @return OrderZero
* @since 3.2.0
*/
public function getOrderZero(Container $container): OrderZero
{
return new OrderZero();
}
/**
* Get The OtherFilter Class.
*
* @param Container $container The DI container.
*
* @return OtherFilter
* @since 3.2.0
*/
public function getOtherFilter(Container $container): OtherFilter
{
return new OtherFilter();
}
/**
* Get The OtherGroup Class.
*
* @param Container $container The DI container.
*
* @return OtherGroup
* @since 3.2.0
*/
public function getOtherGroup(Container $container): OtherGroup
{
return new OtherGroup();
}
/**
* Get The OtherJoin Class.
*
* @param Container $container The DI container.
*
* @return OtherJoin
* @since 3.2.0
*/
public function getOtherJoin(Container $container): OtherJoin
{
return new OtherJoin();
}
/**
* Get The OtherOrder Class.
*
* @param Container $container The DI container.
*
* @return OtherOrder
* @since 3.2.0
*/
public function getOtherOrder(Container $container): OtherOrder
{
return new OtherOrder();
}
/**
* Get The OtherQuery Class.
*
* @param Container $container The DI container.
*
* @return OtherQuery
* @since 3.2.0
*/
public function getOtherQuery(Container $container): OtherQuery
{
return new OtherQuery();
}
/**
* Get The OtherWhere Class.
*
* @param Container $container The DI container.
*
* @return OtherWhere
* @since 3.2.0
*/
public function getOtherWhere(Container $container): OtherWhere
{
return new OtherWhere();
}
/**
* Get The PermissionAction Class.
*
* @param Container $container The DI container.
*
* @return PermissionAction
* @since 3.2.0
*/
public function getPermissionAction(Container $container):
PermissionAction
{
return new PermissionAction();
}
/**
* Get The PermissionComponent Class.
*
* @param Container $container The DI container.
*
* @return PermissionComponent
* @since 3.2.0
*/
public function getPermissionComponent(Container $container):
PermissionComponent
{
return new PermissionComponent();
}
/**
* Get The PermissionCore Class.
*
* @param Container $container The DI container.
*
* @return PermissionCore
* @since 3.2.0
*/
public function getPermissionCore(Container $container): PermissionCore
{
return new PermissionCore();
}
/**
* Get The PermissionDashboard Class.
*
* @param Container $container The DI container.
*
* @return PermissionDashboard
* @since 3.2.0
*/
public function getPermissionDashboard(Container $container):
PermissionDashboard
{
return new PermissionDashboard();
}
/**
* Get The PermissionFields Class.
*
* @param Container $container The DI container.
*
* @return PermissionFields
* @since 3.2.0
*/
public function getPermissionFields(Container $container):
PermissionFields
{
return new PermissionFields();
}
/**
* Get The PermissionGlobalAction Class.
*
* @param Container $container The DI container.
*
* @return PermissionGlobalAction
* @since 3.2.0
*/
public function getPermissionGlobalAction(Container $container):
PermissionGlobalAction
{
return new PermissionGlobalAction();
}
/**
* Get The PermissionViews Class.
*
* @param Container $container The DI container.
*
* @return PermissionViews
* @since 3.2.0
*/
public function getPermissionViews(Container $container): PermissionViews
{
return new PermissionViews();
}
/**
* Get The Request Class.
*
* @param Container $container The DI container.
*
* @return Request
* @since 3.2.0
*/
public function getRequest(Container $container): Request
{
return new Request();
}
/**
* Get The Router Class.
*
* @param Container $container The DI container.
*
* @return Router
* @since 3.2.0
*/
public function getRouter(Container $container): Router
{
return new Router();
}
/**
* Get The ScriptMediaSwitch Class.
*
* @param Container $container The DI container.
*
* @return ScriptMediaSwitch
* @since 3.2.0
*/
public function getScriptMediaSwitch(Container $container):
ScriptMediaSwitch
{
return new ScriptMediaSwitch();
}
/**
* Get The ScriptUserSwitch Class.
*
* @param Container $container The DI container.
*
* @return ScriptUserSwitch
* @since 3.2.0
*/
public function getScriptUserSwitch(Container $container):
ScriptUserSwitch
{
return new ScriptUserSwitch();
}
/**
* Get The Search Class.
*
* @param Container $container The DI container.
*
* @return Search
* @since 3.2.0
*/
public function getSearch(Container $container): Search
{
return new Search();
}
/**
* Get The SelectionTranslation Class.
*
* @param Container $container The DI container.
*
* @return SelectionTranslation
* @since 3.2.0
*/
public function getSelectionTranslation(Container $container):
SelectionTranslation
{
return new SelectionTranslation();
}
/**
* Get The SiteDecrypt Class.
*
* @param Container $container The DI container.
*
* @return SiteDecrypt
* @since 3.2.0
*/
public function getSiteDecrypt(Container $container): SiteDecrypt
{
return new SiteDecrypt();
}
/**
* Get The SiteDynamicGet Class.
*
* @param Container $container The DI container.
*
* @return SiteDynamicGet
* @since 3.2.0
*/
public function getSiteDynamicGet(Container $container): SiteDynamicGet
{
return new SiteDynamicGet();
}
/**
* Get The SiteEditView Class.
*
* @param Container $container The DI container.
*
* @return SiteEditView
* @since 3.2.0
*/
public function getSiteEditView(Container $container): SiteEditView
{
return new SiteEditView();
}
/**
* Get The SiteFieldData Class.
*
* @param Container $container The DI container.
*
* @return SiteFieldData
* @since 3.2.0
*/
public function getSiteFieldData(Container $container): SiteFieldData
{
return new SiteFieldData();
}
/**
* Get The SiteFieldDecodeFilter Class.
*
* @param Container $container The DI container.
*
* @return SiteFieldDecodeFilter
* @since 3.2.0
*/
public function getSiteFieldDecodeFilter(Container $container):
SiteFieldDecodeFilter
{
return new SiteFieldDecodeFilter();
}
/**
* Get The SiteFields Class.
*
* @param Container $container The DI container.
*
* @return SiteFields
* @since 3.2.0
*/
public function getSiteFields(Container $container): SiteFields
{
return new SiteFields();
}
/**
* Get The SiteMainGet Class.
*
* @param Container $container The DI container.
*
* @return SiteMainGet
* @since 3.2.0
*/
public function getSiteMainGet(Container $container): SiteMainGet
{
return new SiteMainGet();
}
/**
* Get The Sort Class.
*
* @param Container $container The DI container.
*
* @return Sort
* @since 3.2.0
*/
public function getSort(Container $container): Sort
{
return new Sort();
}
/**
* Get The TabCounter Class.
*
* @param Container $container The DI container.
*
* @return TabCounter
* @since 3.2.0
*/
public function getTabCounter(Container $container): TabCounter
{
return new TabCounter();
}
/**
* Get The Tags Class.
*
* @param Container $container The DI container.
*
* @return Tags
* @since 3.2.0
*/
public function getTags(Container $container): Tags
{
return new Tags();
}
/**
* Get The TemplateData Class.
*
* @param Container $container The DI container.
*
* @return TemplateData
* @since 3.2.0
*/
public function getTemplateData(Container $container): TemplateData
{
return new TemplateData();
}
/**
* Get The Title Class.
*
* @param Container $container The DI container.
*
* @return Title
* @since 3.2.0
*/
public function getTitle(Container $container): Title
{
return new Title();
}
/**
* Get The UikitComp Class.
*
* @param Container $container The DI container.
*
* @return UikitComp
* @since 3.2.0
*/
public function getUikitComp(Container $container): UikitComp
{
return new UikitComp();
}
/**
* Get The UpdateMysql Class.
*
* @param Container $container The DI container.
*
* @return UpdateMysql
* @since 3.2.0
*/
public function getUpdateMysql(Container $container): UpdateMysql
{
return new UpdateMysql();
}
/**
* Get The ViewsDefaultOrdering Class.
*
* @param Container $container The DI container.
*
* @return ViewsDefaultOrdering
* @since 3.2.0
*/
public function getViewsDefaultOrdering(Container $container):
ViewsDefaultOrdering
{
return new ViewsDefaultOrdering();
}
}
src/Componentbuilder/Compiler/Service/Compiler.php000064400000003760151162054170016311
0ustar00<?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\Service;
use Joomla\DI\Container;
use Joomla\DI\ServiceProviderInterface;
use VDM\Joomla\Componentbuilder\Compiler\Config;
use VDM\Joomla\Componentbuilder\Compiler\Registry;
use VDM\Joomla\Componentbuilder\Table;
/**
* Compiler Service Provider
*
* @since 3.2.0
*/
class Compiler implements ServiceProviderInterface
{
/**
* Registers the service provider with a DI container.
*
* @param Container $container The DI container.
*
* @return void
* @since 3.2.0
*/
public function register(Container $container)
{
$container->alias(Config::class, 'Config')
->share('Config', [$this, 'getConfig'], true);
$container->alias(Registry::class, 'Registry')
->share('Registry', [$this, 'getRegistry'],
true);
$container->alias(Table::class, 'Table')
->share('Table', [$this, 'getTable'], true);
}
/**
* Get the Compiler Configurations
*
* @param Container $container The DI container.
*
* @return Config
* @since 3.2.0
*/
public function getConfig(Container $container): Config
{
return new Config();
}
/**
* Get the Compiler Registry
*
* @param Container $container The DI container.
*
* @return Registry
* @since 3.2.0
*/
public function getRegistry(Container $container): Registry
{
return new Registry();
}
/**
* Get the Table
*
* @param Container $container The DI container.
*
* @return Table
* @since 3.2.0
*/
public function getTable(Container $container): Table
{
return new Table();
}
}
src/Componentbuilder/Compiler/Service/Component.php000064400000021353151162054170016477
0ustar00<?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\Service;
use Joomla\DI\Container;
use Joomla\DI\ServiceProviderInterface;
use VDM\Joomla\Componentbuilder\Compiler\Component as CompilerComponent;
use VDM\Joomla\Componentbuilder\Compiler\Component\JoomlaThree\Settings as
J3Settings;
use VDM\Joomla\Componentbuilder\Compiler\Component\JoomlaFour\Settings as
J4Settings;
use VDM\Joomla\Componentbuilder\Compiler\Component\JoomlaFive\Settings as
J5Settings;
use VDM\Joomla\Componentbuilder\Compiler\Component\Dashboard;
use VDM\Joomla\Componentbuilder\Compiler\Component\Placeholder;
use VDM\Joomla\Componentbuilder\Compiler\Component\Data;
use VDM\Joomla\Componentbuilder\Compiler\Component\Structure;
use VDM\Joomla\Componentbuilder\Compiler\Component\Structuresingle;
use VDM\Joomla\Componentbuilder\Compiler\Component\Structuremultiple;
use
VDM\Joomla\Componentbuilder\Compiler\Interfaces\Component\SettingsInterface
as Settings;
/**
* Component Service Provider
*
* @since 3.2.0
*/
class Component implements ServiceProviderInterface
{
/**
* Current Joomla Version Being Build
*
* @var int
* @since 3.2.0
**/
protected $targetVersion;
/**
* Registers the service provider with a DI container.
*
* @param Container $container The DI container.
*
* @return void
* @since 3.2.0
*/
public function register(Container $container)
{
$container->alias(CompilerComponent::class, 'Component')
->share('Component', [$this,
'getCompilerComponent'], true);
$container->alias(J3Settings::class,
'Component.J3.Settings')
->share('Component.J3.Settings', [$this,
'getJ3Settings'], true);
$container->alias(J4Settings::class,
'Component.J4.Settings')
->share('Component.J4.Settings', [$this,
'getJ4Settings'], true);
$container->alias(J5Settings::class,
'Component.J5.Settings')
->share('Component.J5.Settings', [$this,
'getJ5Settings'], true);
$container->alias(Dashboard::class, 'Component.Dashboard')
->share('Component.Dashboard', [$this,
'getDashboard'], true);
$container->alias(Placeholder::class,
'Component.Placeholder')
->share('Component.Placeholder', [$this,
'getPlaceholder'], true);
$container->alias(Data::class, 'Component.Data')
->share('Component.Data', [$this, 'getData'],
true);
$container->alias(Structure::class, 'Component.Structure')
->share('Component.Structure', [$this,
'getStructure'], true);
$container->alias(Structuresingle::class,
'Component.Structure.Single')
->share('Component.Structure.Single', [$this,
'getStructuresingle'], true);
$container->alias(Structuremultiple::class,
'Component.Structure.Multiple')
->share('Component.Structure.Multiple', [$this,
'getStructuremultiple'], true);
$container->alias(Settings::class, 'Component.Settings')
->share('Component.Settings', [$this,
'getSettings'], true);
}
/**
* Get The Component Class.
*
* @param Container $container The DI container.
*
* @return CompilerComponent
* @since 3.2.0
*/
public function getCompilerComponent(Container $container):
CompilerComponent
{
return new CompilerComponent(
$container->get('Component.Data')
);
}
/**
* Get The Settings Class.
*
* @param Container $container The DI container.
*
* @return J3Settings
* @since 3.2.0
*/
public function getJ3Settings(Container $container): J3Settings
{
return new J3Settings(
$container->get('Config'),
$container->get('Registry'),
$container->get('Event'),
$container->get('Placeholder'),
$container->get('Component'),
$container->get('Utilities.Paths'),
$container->get('Utilities.Dynamicpath'),
$container->get('Utilities.Pathfix')
);
}
/**
* Get The Settings Class.
*
* @param Container $container The DI container.
*
* @return J4Settings
* @since 3.2.0
*/
public function getJ4Settings(Container $container): J4Settings
{
return new J4Settings(
$container->get('Config'),
$container->get('Registry'),
$container->get('Event'),
$container->get('Placeholder'),
$container->get('Component'),
$container->get('Utilities.Paths'),
$container->get('Utilities.Dynamicpath'),
$container->get('Utilities.Pathfix')
);
}
/**
* Get The Settings Class.
*
* @param Container $container The DI container.
*
* @return J5Settings
* @since 3.2.0
*/
public function getJ5Settings(Container $container): J5Settings
{
return new J5Settings(
$container->get('Config'),
$container->get('Registry'),
$container->get('Event'),
$container->get('Placeholder'),
$container->get('Component'),
$container->get('Utilities.Paths'),
$container->get('Utilities.Dynamicpath'),
$container->get('Utilities.Pathfix')
);
}
/**
* Get The Dashboard Class.
*
* @param Container $container The DI container.
*
* @return Dashboard
* @since 3.2.0
*/
public function getDashboard(Container $container): Dashboard
{
return new Dashboard(
$container->get('Registry'),
$container->get('Component')
);
}
/**
* Get The Placeholder Class.
*
* @param Container $container The DI container.
*
* @return Placeholder
* @since 3.2.0
*/
public function getPlaceholder(Container $container): Placeholder
{
return new Placeholder(
$container->get('Config')
);
}
/**
* Get The Data Class.
*
* @param Container $container The DI container.
*
* @return Data
* @since 3.2.0
*/
public function getData(Container $container): Data
{
return new Data(
$container->get('Config'),
$container->get('Event'),
$container->get('Placeholder'),
$container->get('Component.Placeholder'),
$container->get('Customcode.Dispenser'),
$container->get('Customcode'),
$container->get('Customcode.Gui'),
$container->get('Field'),
$container->get('Field.Name'),
$container->get('Field.Unique.Name'),
$container->get('Model.Filesfolders'),
$container->get('Model.Historycomponent'),
$container->get('Model.Whmcs'),
$container->get('Model.Sqltweaking'),
$container->get('Model.Adminviews'),
$container->get('Model.Siteviews'),
$container->get('Model.Customadminviews'),
$container->get('Model.Updateserver'),
$container->get('Model.Joomlamodules'),
$container->get('Model.Joomlaplugins'),
$container->get('Model.Router')
);
}
/**
* Get The Structure Class.
*
* @param Container $container The DI container.
*
* @return Structure
* @since 3.2.0
*/
public function getStructure(Container $container): Structure
{
return new Structure(
$container->get('Component.Settings'),
$container->get('Utilities.Paths'),
$container->get('Utilities.Folder')
);
}
/**
* Get The Structuresingle Class.
*
* @param Container $container The DI container.
*
* @return Structuresingle
* @since 3.2.0
*/
public function getStructuresingle(Container $container): Structuresingle
{
return new Structuresingle(
$container->get('Config'),
$container->get('Registry'),
$container->get('Placeholder'),
$container->get('Component.Settings'),
$container->get('Component'),
$container->get('Compiler.Builder.Content.One'),
$container->get('Utilities.Counter'),
$container->get('Utilities.Paths'),
$container->get('Utilities.Files')
);
}
/**
* Get The Structuremultiple Class.
*
* @param Container $container The DI container.
*
* @return Structuremultiple
* @since 3.2.0
*/
public function getStructuremultiple(Container $container):
Structuremultiple
{
return new Structuremultiple(
$container->get('Config'),
$container->get('Registry'),
$container->get('Component.Settings'),
$container->get('Component'),
$container->get('Model.Createdate'),
$container->get('Model.Modifieddate'),
$container->get('Utilities.Structure')
);
}
/**
* Get The Settings Class.
*
* @param Container $container The DI container.
*
* @return Settings
* @since 3.2.0
*/
public function getSettings(Container $container): Settings
{
if (empty($this->targetVersion))
{
$this->targetVersion =
$container->get('Config')->joomla_version;
}
return $container->get('Component.J' .
$this->targetVersion . '.Settings');
}
}
src/Componentbuilder/Compiler/Service/Creator.php000064400000074272151162054170016144
0ustar00<?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\Service;
use Joomla\DI\Container;
use Joomla\DI\ServiceProviderInterface;
use VDM\Joomla\Componentbuilder\Compiler\Creator\AccessSections;
use VDM\Joomla\Componentbuilder\Compiler\Creator\AccessSectionsCategory;
use
VDM\Joomla\Componentbuilder\Compiler\Creator\AccessSectionsJoomlaFields;
use VDM\Joomla\Componentbuilder\Compiler\Creator\Builders;
use VDM\Joomla\Componentbuilder\Compiler\Creator\CustomFieldTypeFile;
use VDM\Joomla\Componentbuilder\Compiler\Creator\CustomButtonPermissions;
use VDM\Joomla\Componentbuilder\Compiler\Creator\ConfigFieldsets;
use
VDM\Joomla\Componentbuilder\Compiler\Creator\ConfigFieldsetsCustomfield;
use
VDM\Joomla\Componentbuilder\Compiler\Creator\ConfigFieldsetsEmailHelper;
use VDM\Joomla\Componentbuilder\Compiler\Creator\ConfigFieldsetsEncryption;
use VDM\Joomla\Componentbuilder\Compiler\Creator\ConfigFieldsetsGlobal;
use
VDM\Joomla\Componentbuilder\Compiler\Creator\ConfigFieldsetsGooglechart;
use
VDM\Joomla\Componentbuilder\Compiler\Creator\ConfigFieldsetsGroupControl;
use
VDM\Joomla\Componentbuilder\Compiler\Creator\ConfigFieldsetsSiteControl;
use VDM\Joomla\Componentbuilder\Compiler\Creator\ConfigFieldsetsUikit;
use VDM\Joomla\Componentbuilder\Compiler\Creator\Layout;
use VDM\Joomla\Componentbuilder\Compiler\Creator\Permission;
use VDM\Joomla\Componentbuilder\Compiler\Creator\SiteFieldData;
use VDM\Joomla\Componentbuilder\Compiler\Creator\Request;
use VDM\Joomla\Componentbuilder\Compiler\Creator\Router;
use VDM\Joomla\Componentbuilder\Compiler\Creator\RouterConstructorDefault;
use VDM\Joomla\Componentbuilder\Compiler\Creator\RouterConstructorManual;
use VDM\Joomla\Componentbuilder\Compiler\Creator\RouterMethodsDefault;
use VDM\Joomla\Componentbuilder\Compiler\Creator\RouterMethodsManual;
use VDM\Joomla\Componentbuilder\Compiler\Creator\FieldsetExtension;
use VDM\Joomla\Componentbuilder\Compiler\Creator\FieldsetString;
use VDM\Joomla\Componentbuilder\Compiler\Creator\FieldsetXML;
use VDM\Joomla\Componentbuilder\Compiler\Creator\FieldsetDynamic;
use VDM\Joomla\Componentbuilder\Compiler\Creator\FieldXML;
use VDM\Joomla\Componentbuilder\Compiler\Creator\FieldString;
use VDM\Joomla\Componentbuilder\Compiler\Creator\FieldDynamic;
use VDM\Joomla\Componentbuilder\Compiler\Creator\FieldAsString;
use
VDM\Joomla\Componentbuilder\Compiler\Interfaces\Creator\Fieldtypeinterface
as FieldType;
use
VDM\Joomla\Componentbuilder\Compiler\Interfaces\Creator\Fieldsetinterface
as Fieldset;
/**
* Creator Service Provider
*
* @since 3.2.0
*/
class Creator implements ServiceProviderInterface
{
/**
* Registers the service provider with a DI container.
*
* @param Container $container The DI container.
*
* @return void
* @since 3.2.0
*/
public function register(Container $container)
{
$container->alias(AccessSections::class,
'Compiler.Creator.Access.Sections')
->share('Compiler.Creator.Access.Sections', [$this,
'getAccessSections'], true);
$container->alias(AccessSectionsCategory::class,
'Compiler.Creator.Access.Sections.Category')
->share('Compiler.Creator.Access.Sections.Category',
[$this, 'getAccessSectionsCategory'], true);
$container->alias(AccessSectionsJoomlaFields::class,
'Compiler.Creator.Access.Sections.Joomla.Fields')
->share('Compiler.Creator.Access.Sections.Joomla.Fields',
[$this, 'getAccessSectionsJoomlaFields'], true);
$container->alias(Builders::class,
'Compiler.Creator.Builders')
->share('Compiler.Creator.Builders', [$this,
'getBuilders'], true);
$container->alias(CustomFieldTypeFile::class,
'Compiler.Creator.Custom.Field.Type.File')
->share('Compiler.Creator.Custom.Field.Type.File', [$this,
'getCustomFieldTypeFile'], true);
$container->alias(CustomButtonPermissions::class,
'Compiler.Creator.Custom.Button.Permissions')
->share('Compiler.Creator.Custom.Button.Permissions',
[$this, 'getCustomButtonPermissions'], true);
$container->alias(FieldsetExtension::class,
'Compiler.Creator.Fieldset.Extension')
->share('Compiler.Creator.Fieldset.Extension', [$this,
'getFieldsetExtension'], true);
$container->alias(ConfigFieldsets::class,
'Compiler.Creator.Config.Fieldsets')
->share('Compiler.Creator.Config.Fieldsets', [$this,
'getConfigFieldsets'], true);
$container->alias(ConfigFieldsetsCustomfield::class,
'Compiler.Creator.Config.Fieldsets.Customfield')
->share('Compiler.Creator.Config.Fieldsets.Customfield',
[$this, 'getConfigFieldsetsCustomfield'], true);
$container->alias(ConfigFieldsetsEmailHelper::class,
'Compiler.Creator.Config.Fieldsets.Email.Helper')
->share('Compiler.Creator.Config.Fieldsets.Email.Helper',
[$this, 'getConfigFieldsetsEmailHelper'], true);
$container->alias(ConfigFieldsetsEncryption::class,
'Compiler.Creator.Config.Fieldsets.Encryption')
->share('Compiler.Creator.Config.Fieldsets.Encryption',
[$this, 'getConfigFieldsetsEncryption'], true);
$container->alias(ConfigFieldsetsGlobal::class,
'Compiler.Creator.Config.Fieldsets.Global')
->share('Compiler.Creator.Config.Fieldsets.Global', [$this,
'getConfigFieldsetsGlobal'], true);
$container->alias(ConfigFieldsetsGooglechart::class,
'Compiler.Creator.Config.Fieldsets.Googlechart')
->share('Compiler.Creator.Config.Fieldsets.Googlechart',
[$this, 'getConfigFieldsetsGooglechart'], true);
$container->alias(ConfigFieldsetsGroupControl::class,
'Compiler.Creator.Config.Fieldsets.Group.Control')
->share('Compiler.Creator.Config.Fieldsets.Group.Control',
[$this, 'getConfigFieldsetsGroupControl'], true);
$container->alias(ConfigFieldsetsSiteControl::class,
'Compiler.Creator.Config.Fieldsets.Site.Control')
->share('Compiler.Creator.Config.Fieldsets.Site.Control',
[$this, 'getConfigFieldsetsSiteControl'], true);
$container->alias(ConfigFieldsetsUikit::class,
'Compiler.Creator.Config.Fieldsets.Uikit')
->share('Compiler.Creator.Config.Fieldsets.Uikit', [$this,
'getConfigFieldsetsUikit'], true);
$container->alias(Layout::class, 'Compiler.Creator.Layout')
->share('Compiler.Creator.Layout', [$this,
'getLayout'], true);
$container->alias(Permission::class,
'Compiler.Creator.Permission')
->share('Compiler.Creator.Permission', [$this,
'getPermission'], true);
$container->alias(SiteFieldData::class,
'Compiler.Creator.Site.Field.Data')
->share('Compiler.Creator.Site.Field.Data', [$this,
'getSiteFieldData'], true);
$container->alias(Request::class,
'Compiler.Creator.Request')
->share('Compiler.Creator.Request', [$this,
'getRequest'], true);
$container->alias(Router::class, 'Compiler.Creator.Router')
->share('Compiler.Creator.Router', [$this,
'getRouter'], true);
$container->alias(RouterConstructorDefault::class,
'Compiler.Creator.Router.Constructor.Default')
->share('Compiler.Creator.Router.Constructor.Default',
[$this, 'getRouterConstructorDefault'], true);
$container->alias(RouterConstructorManual::class,
'Compiler.Creator.Router.Constructor.Manual')
->share('Compiler.Creator.Router.Constructor.Manual',
[$this, 'getRouterConstructorManual'], true);
$container->alias(RouterMethodsDefault::class,
'Compiler.Creator.Router.Methods.Default')
->share('Compiler.Creator.Router.Methods.Default', [$this,
'getRouterMethodsDefault'], true);
$container->alias(RouterMethodsManual::class,
'Compiler.Creator.Router.Methods.Manual')
->share('Compiler.Creator.Router.Methods.Manual', [$this,
'getRouterMethodsManual'], true);
$container->alias(FieldsetString::class,
'Compiler.Creator.Fieldset.String')
->share('Compiler.Creator.Fieldset.String', [$this,
'getFieldsetString'], true);
$container->alias(FieldsetXML::class,
'Compiler.Creator.Fieldset.XML')
->share('Compiler.Creator.Fieldset.XML', [$this,
'getFieldsetXML'], true);
$container->alias(FieldsetDynamic::class,
'Compiler.Creator.Fieldset.Dynamic')
->share('Compiler.Creator.Fieldset.Dynamic', [$this,
'getFieldsetDynamic'], true);
$container->alias(FieldXML::class,
'Compiler.Creator.Field.XML')
->share('Compiler.Creator.Field.XML', [$this,
'getFieldXML'], true);
$container->alias(FieldString::class,
'Compiler.Creator.Field.String')
->share('Compiler.Creator.Field.String', [$this,
'getFieldString'], true);
$container->alias(FieldDynamic::class,
'Compiler.Creator.Field.Dynamic')
->share('Compiler.Creator.Field.Dynamic', [$this,
'getFieldDynamic'], true);
$container->alias(FieldAsString::class,
'Compiler.Creator.Field.As.String')
->share('Compiler.Creator.Field.As.String', [$this,
'getFieldAsString'], true);
$container->alias(FieldType::class,
'Compiler.Creator.Field.Type')
->share('Compiler.Creator.Field.Type', [$this,
'getFieldType'], true);
$container->alias(Fieldset::class,
'Compiler.Creator.Fieldset')
->share('Compiler.Creator.Fieldset', [$this,
'getFieldset'], true);
}
/**
* Get The AccessSections Class.
*
* @param Container $container The DI container.
*
* @return AccessSections
* @since 3.2.0
*/
public function getAccessSections(Container $container): AccessSections
{
return new AccessSections(
$container->get('Config'),
$container->get('Event'),
$container->get('Language'),
$container->get('Component'),
$container->get('Field.Name'),
$container->get('Field.Type.Name'),
$container->get('Utilities.Counter'),
$container->get('Compiler.Creator.Permission'),
$container->get('Compiler.Builder.Assets.Rules'),
$container->get('Compiler.Builder.Custom.Tabs'),
$container->get('Compiler.Builder.Permission.Views'),
$container->get('Compiler.Builder.Permission.Fields'),
$container->get('Compiler.Builder.Permission.Component'),
$container->get('Compiler.Creator.Custom.Button.Permissions')
);
}
/**
* Get The AccessSectionsCategory Class.
*
* @param Container $container The DI container.
*
* @return AccessSectionsCategory
* @since 3.2.0
*/
public function getAccessSectionsCategory(Container $container):
AccessSectionsCategory
{
return new AccessSectionsCategory(
$container->get('Compiler.Builder.Category.Code')
);
}
/**
* Get The AccessSectionsJoomlaFields Class.
*
* @param Container $container The DI container.
*
* @return AccessSectionsJoomlaFields
* @since 3.2.0
*/
public function getAccessSectionsJoomlaFields(Container $container):
AccessSectionsJoomlaFields
{
return new AccessSectionsJoomlaFields();
}
/**
* Get The Builders Class.
*
* @param Container $container The DI container.
*
* @return Builders
* @since 3.2.0
*/
public function getBuilders(Container $container): Builders
{
return new Builders(
$container->get('Config'),
$container->get('Power'),
$container->get('Language'),
$container->get('Placeholder'),
$container->get('Compiler.Creator.Layout'),
$container->get('Compiler.Creator.Site.Field.Data'),
$container->get('Compiler.Builder.Tags'),
$container->get('Compiler.Builder.Database.Tables'),
$container->get('Compiler.Builder.Database.Unique.Keys'),
$container->get('Compiler.Builder.Database.Keys'),
$container->get('Compiler.Builder.Database.Unique.Guid'),
$container->get('Compiler.Builder.List.Join'),
$container->get('Compiler.Builder.History'),
$container->get('Compiler.Builder.Alias'),
$container->get('Compiler.Builder.Title'),
$container->get('Compiler.Builder.Category.Other.Name'),
$container->get('Compiler.Builder.Lists'),
$container->get('Compiler.Builder.Custom.List'),
$container->get('Compiler.Builder.Field.Relations'),
$container->get('Compiler.Builder.Hidden.Fields'),
$container->get('Compiler.Builder.Integer.Fields'),
$container->get('Compiler.Builder.Dynamic.Fields'),
$container->get('Compiler.Builder.Main.Text.Field'),
$container->get('Compiler.Builder.Custom.Field'),
$container->get('Compiler.Builder.Custom.Field.Links'),
$container->get('Compiler.Builder.Script.User.Switch'),
$container->get('Compiler.Builder.Script.Media.Switch'),
$container->get('Compiler.Builder.Category'),
$container->get('Compiler.Builder.Category.Code'),
$container->get('Compiler.Builder.Check.Box'),
$container->get('Compiler.Builder.Json.String'),
$container->get('Compiler.Builder.Base.Six.Four'),
$container->get('Compiler.Builder.Model.Basic.Field'),
$container->get('Compiler.Builder.Model.Whmcs.Field'),
$container->get('Compiler.Builder.Model.Medium.Field'),
$container->get('Compiler.Builder.Model.Expert.Field.Initiator'),
$container->get('Compiler.Builder.Model.Expert.Field'),
$container->get('Compiler.Builder.Json.Item'),
$container->get('Compiler.Builder.Items.Method.List.String'),
$container->get('Compiler.Builder.Json.Item.Array'),
$container->get('Compiler.Builder.Items.Method.Eximport.String'),
$container->get('Compiler.Builder.Selection.Translation'),
$container->get('Compiler.Builder.Admin.Filter.Type'),
$container->get('Compiler.Builder.Sort'),
$container->get('Compiler.Builder.Search'),
$container->get('Compiler.Builder.Filter'),
$container->get('Compiler.Builder.Component.Fields')
);
}
/**
* Get The CustomFieldTypeFile Class.
*
* @param Container $container The DI container.
*
* @return CustomFieldTypeFile
* @since 3.2.0
*/
public function getCustomFieldTypeFile(Container $container):
CustomFieldTypeFile
{
return new CustomFieldTypeFile(
$container->get('Config'),
$container->get('Compiler.Builder.Content.One'),
$container->get('Compiler.Builder.Content.Multi'),
$container->get('Compiler.Builder.Site.Field.Data'),
$container->get('Placeholder'),
$container->get('Language'),
$container->get('Component.Placeholder'),
$container->get('Utilities.Structure'),
$container->get('Field.Input.Button'),
$container->get('Compiler.Builder.Field.Group.Control'),
$container->get('Compiler.Builder.Extension.Custom.Fields'),
$container->get('Header'),
$container->get('Field.Core.Field')
);
}
/**
* Get The CustomButtonPermissions Class.
*
* @param Container $container The DI container.
*
* @return CustomButtonPermissions
* @since 3.2.0
*/
public function getCustomButtonPermissions(Container $container):
CustomButtonPermissions
{
return new CustomButtonPermissions(
$container->get('Config'),
$container->get('Language'),
$container->get('Compiler.Builder.Permission.Component'),
$container->get('Utilities.Counter')
);
}
/**
* Get The ConfigFieldsets Class.
*
* @param Container $container The DI container.
*
* @return ConfigFieldsets
* @since 3.2.0
*/
public function getConfigFieldsets(Container $container): ConfigFieldsets
{
return new ConfigFieldsets(
$container->get('Config'),
$container->get('Component'),
$container->get('Event'),
$container->get('Placeholder'),
$container->get('Component.Placeholder'),
$container->get('Compiler.Builder.Extensions.Params'),
$container->get('Compiler.Builder.Config.Fieldsets.Customfield'),
$container->get('Compiler.Creator.Field.As.String'),
$container->get('Compiler.Creator.Config.Fieldsets.Global'),
$container->get('Compiler.Creator.Config.Fieldsets.Site.Control'),
$container->get('Compiler.Creator.Config.Fieldsets.Group.Control'),
$container->get('Compiler.Creator.Config.Fieldsets.Uikit'),
$container->get('Compiler.Creator.Config.Fieldsets.Googlechart'),
$container->get('Compiler.Creator.Config.Fieldsets.Email.Helper'),
$container->get('Compiler.Creator.Config.Fieldsets.Encryption'),
$container->get('Compiler.Creator.Config.Fieldsets.Customfield')
);
}
/**
* Get The ConfigFieldsetsCustomfield Class.
*
* @param Container $container The DI container.
*
* @return ConfigFieldsetsCustomfield
* @since 3.2.0
*/
public function getConfigFieldsetsCustomfield(Container $container):
ConfigFieldsetsCustomfield
{
return new ConfigFieldsetsCustomfield(
$container->get('Config'),
$container->get('Language'),
$container->get('Compiler.Builder.Config.Fieldsets.Customfield'),
$container->get('Compiler.Builder.Config.Fieldsets')
);
}
/**
* Get The ConfigFieldsetsEmailHelper Class.
*
* @param Container $container The DI container.
*
* @return ConfigFieldsetsEmailHelper
* @since 3.2.0
*/
public function getConfigFieldsetsEmailHelper(Container $container):
ConfigFieldsetsEmailHelper
{
return new ConfigFieldsetsEmailHelper(
$container->get('Config'),
$container->get('Language'),
$container->get('Component'),
$container->get('Compiler.Builder.Config.Fieldsets'),
$container->get('Compiler.Builder.Config.Fieldsets.Customfield')
);
}
/**
* Get The ConfigFieldsetsEncryption Class.
*
* @param Container $container The DI container.
*
* @return ConfigFieldsetsEncryption
* @since 3.2.0
*/
public function getConfigFieldsetsEncryption(Container $container):
ConfigFieldsetsEncryption
{
return new ConfigFieldsetsEncryption(
$container->get('Config'),
$container->get('Language'),
$container->get('Component'),
$container->get('Compiler.Builder.Config.Fieldsets'),
$container->get('Compiler.Builder.Config.Fieldsets.Customfield')
);
}
/**
* Get The ConfigFieldsetsGlobal Class.
*
* @param Container $container The DI container.
*
* @return ConfigFieldsetsGlobal
* @since 3.2.0
*/
public function getConfigFieldsetsGlobal(Container $container):
ConfigFieldsetsGlobal
{
return new ConfigFieldsetsGlobal(
$container->get('Config'),
$container->get('Language'),
$container->get('Component'),
$container->get('Compiler.Builder.Contributors'),
$container->get('Compiler.Builder.Config.Fieldsets'),
$container->get('Compiler.Builder.Extensions.Params'),
$container->get('Compiler.Builder.Config.Fieldsets.Customfield')
);
}
/**
* Get The ConfigFieldsetsGooglechart Class.
*
* @param Container $container The DI container.
*
* @return ConfigFieldsetsGooglechart
* @since 3.2.0
*/
public function getConfigFieldsetsGooglechart(Container $container):
ConfigFieldsetsGooglechart
{
return new ConfigFieldsetsGooglechart(
$container->get('Config'),
$container->get('Language'),
$container->get('Compiler.Builder.Config.Fieldsets'),
$container->get('Compiler.Builder.Config.Fieldsets.Customfield'),
$container->get('Compiler.Builder.Extensions.Params')
);
}
/**
* Get The ConfigFieldsetsGroupControl Class.
*
* @param Container $container The DI container.
*
* @return ConfigFieldsetsGroupControl
* @since 3.2.0
*/
public function getConfigFieldsetsGroupControl(Container $container):
ConfigFieldsetsGroupControl
{
return new ConfigFieldsetsGroupControl(
$container->get('Config'),
$container->get('Language'),
$container->get('Compiler.Builder.Field.Group.Control'),
$container->get('Compiler.Builder.Config.Fieldsets'),
$container->get('Compiler.Builder.Extensions.Params'),
$container->get('Compiler.Builder.Config.Fieldsets.Customfield')
);
}
/**
* Get The ConfigFieldsetsSiteControl Class.
*
* @param Container $container The DI container.
*
* @return ConfigFieldsetsSiteControl
* @since 3.2.0
*/
public function getConfigFieldsetsSiteControl(Container $container):
ConfigFieldsetsSiteControl
{
return new ConfigFieldsetsSiteControl(
$container->get('Component'),
$container->get('Compiler.Builder.Config.Fieldsets'),
$container->get('Compiler.Builder.Config.Fieldsets.Customfield'),
$container->get('Compiler.Builder.Has.Menu.Global'),
$container->get('Compiler.Builder.Frontend.Params'),
$container->get('Compiler.Creator.Request')
);
}
/**
* Get The ConfigFieldsetsUikit Class.
*
* @param Container $container The DI container.
*
* @return ConfigFieldsetsUikit
* @since 3.2.0
*/
public function getConfigFieldsetsUikit(Container $container):
ConfigFieldsetsUikit
{
return new ConfigFieldsetsUikit(
$container->get('Config'),
$container->get('Language'),
$container->get('Compiler.Builder.Config.Fieldsets'),
$container->get('Compiler.Builder.Extensions.Params'),
$container->get('Compiler.Builder.Config.Fieldsets.Customfield')
);
}
/**
* Get The Layout Class.
*
* @param Container $container The DI container.
*
* @return Layout
* @since 3.2.0
*/
public function getLayout(Container $container): Layout
{
return new Layout(
$container->get('Config'),
$container->get('Compiler.Builder.Order.Zero'),
$container->get('Compiler.Builder.Tab.Counter'),
$container->get('Compiler.Builder.Layout'),
$container->get('Compiler.Builder.Moved.Publishing.Fields'),
$container->get('Compiler.Builder.New.Publishing.Fields')
);
}
/**
* Get The Permission Class.
*
* @param Container $container The DI container.
*
* @return Permission
* @since 3.2.0
*/
public function getPermission(Container $container): Permission
{
return new Permission(
$container->get('Config'),
$container->get('Compiler.Builder.Permission.Core'),
$container->get('Compiler.Builder.Permission.Views'),
$container->get('Compiler.Builder.Permission.Action'),
$container->get('Compiler.Builder.Permission.Component'),
$container->get('Compiler.Builder.Permission.Global.Action'),
$container->get('Compiler.Builder.Permission.Dashboard'),
$container->get('Utilities.Counter'),
$container->get('Language')
);
}
/**
* Get The SiteFieldData Class.
*
* @param Container $container The DI container.
*
* @return SiteFieldData
* @since 3.2.0
*/
public function getSiteFieldData(Container $container): SiteFieldData
{
return new SiteFieldData(
$container->get('Config'),
$container->get('Compiler.Builder.Site.Fields'),
$container->get('Compiler.Builder.Site.Field.Data')
);
}
/**
* Get The Request Class.
*
* @param Container $container The DI container.
*
* @return Request
* @since 3.2.0
*/
public function getRequest(Container $container): Request
{
return new Request(
$container->get('Compiler.Builder.Request')
);
}
/**
* Get The Router Class.
*
* @param Container $container The DI container.
*
* @return Router
* @since 3.2.0
*/
public function getRouter(Container $container): Router
{
return new Router(
$container->get('Customcode.Dispenser'),
$container->get('Compiler.Builder.Request'),
$container->get('Compiler.Builder.Router'),
$container->get('Compiler.Creator.Router.Constructor.Default'),
$container->get('Compiler.Creator.Router.Constructor.Manual'),
$container->get('Compiler.Creator.Router.Methods.Default'),
$container->get('Compiler.Creator.Router.Methods.Manual')
);
}
/**
* Get The RouterConstructorDefault Class.
*
* @param Container $container The DI container.
*
* @return RouterConstructorDefault
* @since 3.2.0
*/
public function getRouterConstructorDefault(Container $container):
RouterConstructorDefault
{
return new RouterConstructorDefault(
$container->get('Compiler.Builder.Router')
);
}
/**
* Get The RouterConstructorManual Class.
*
* @param Container $container The DI container.
*
* @return RouterConstructorManual
* @since 3.2.0
*/
public function getRouterConstructorManual(Container $container):
RouterConstructorManual
{
return new RouterConstructorManual(
$container->get('Compiler.Builder.Router')
);
}
/**
* Get The RouterMethodsDefault Class.
*
* @param Container $container The DI container.
*
* @return RouterMethodsDefault
* @since 3.2.0
*/
public function getRouterMethodsDefault(Container $container):
RouterMethodsDefault
{
return new RouterMethodsDefault(
$container->get('Compiler.Builder.Router')
);
}
/**
* Get The RouterMethodsManual Class.
*
* @param Container $container The DI container.
*
* @return RouterMethodsManual
* @since 3.2.0
*/
public function getRouterMethodsManual(Container $container):
RouterMethodsManual
{
return new RouterMethodsManual(
$container->get('Compiler.Builder.Router')
);
}
/**
* Get The FieldsetExtension Class.
*
* @param Container $container The DI container.
*
* @return FieldsetExtension
* @since 5.0.2
*/
public function getFieldsetExtension(Container $container):
FieldsetExtension
{
return new FieldsetExtension(
$container->get('Component.Placeholder'),
$container->get('Compiler.Creator.Fieldset.Dynamic')
);
}
/**
* Get The FieldsetString Class.
*
* @param Container $container The DI container.
*
* @return FieldsetString
* @since 3.2.0
*/
public function getFieldsetString(Container $container): FieldsetString
{
return new FieldsetString(
$container->get('Config'),
$container->get('Placeholder'),
$container->get('Language.Fieldset'),
$container->get('Event'),
$container->get('Adminview.Permission'),
$container->get('Compiler.Creator.Field.Dynamic'),
$container->get('Compiler.Builder.Field.Names'),
$container->get('Compiler.Builder.Access.Switch'),
$container->get('Compiler.Builder.Meta.Data'),
$container->get('Compiler.Creator.Layout'),
$container->get('Utilities.Counter')
);
}
/**
* Get The FieldsetXML Class.
*
* @param Container $container The DI container.
*
* @return FieldsetXML
* @since 3.2.0
*/
public function getFieldsetXML(Container $container): FieldsetXML
{
return new FieldsetXML(
$container->get('Config'),
$container->get('Placeholder'),
$container->get('Language.Fieldset'),
$container->get('Event'),
$container->get('Adminview.Permission'),
$container->get('Compiler.Creator.Field.Dynamic'),
$container->get('Compiler.Builder.Field.Names'),
$container->get('Compiler.Builder.Access.Switch'),
$container->get('Compiler.Builder.Meta.Data'),
$container->get('Compiler.Creator.Layout'),
$container->get('Utilities.Counter'),
$container->get('Utilities.Xml')
);
}
/**
* Get The FieldsetDynamic Class.
*
* @param Container $container The DI container.
*
* @return FieldsetDynamic
* @since 3.2.0
*/
public function getFieldsetDynamic(Container $container): FieldsetDynamic
{
return new FieldsetDynamic(
$container->get('Compiler.Creator.Field.As.String')
);
}
/**
* Get The FieldXML Class.
*
* @param Container $container The DI container.
*
* @return FieldXML
* @since 3.2.0
*/
public function getFieldXML(Container $container): FieldXML
{
return new FieldXML(
$container->get('Config'),
$container->get('Language'),
$container->get('Field'),
$container->get('Field.Groups'),
$container->get('Field.Name'),
$container->get('Field.Type.Name'),
$container->get('Field.Attributes'),
$container->get('Utilities.Xml'),
$container->get('Compiler.Creator.Custom.Field.Type.File'),
$container->get('Utilities.Counter')
);
}
/**
* Get The FieldString Class.
*
* @param Container $container The DI container.
*
* @return FieldString
* @since 3.2.0
*/
public function getFieldString(Container $container): FieldString
{
return new FieldString(
$container->get('Config'),
$container->get('Language'),
$container->get('Field'),
$container->get('Field.Groups'),
$container->get('Field.Name'),
$container->get('Field.Type.Name'),
$container->get('Field.Attributes'),
$container->get('Compiler.Creator.Custom.Field.Type.File'),
$container->get('Utilities.Counter')
);
}
/**
* Get The FieldDynamic Class.
*
* @param Container $container The DI container.
*
* @return FieldDynamic
* @since 3.2.0
*/
public function getFieldDynamic(Container $container): FieldDynamic
{
return new FieldDynamic(
$container->get('Field.Name'),
$container->get('Field.Type.Name'),
$container->get('Field.Attributes'),
$container->get('Field.Groups'),
$container->get('Compiler.Builder.Field.Names'),
$container->get('Compiler.Creator.Field.Type'),
$container->get('Compiler.Creator.Builders'),
$container->get('Compiler.Creator.Layout')
);
}
/**
* Get The FieldAsString Class.
*
* @param Container $container The DI container.
*
* @return FieldAsString
* @since 3.2.0
*/
public function getFieldAsString(Container $container): FieldAsString
{
return new FieldAsString(
$container->get('Compiler.Creator.Field.Dynamic'),
$container->get('Utilities.Xml')
);
}
/**
* Get The Fieldtypeinterface Class.
*
* @param Container $container The DI container.
*
* @return FieldType
* @since 3.2.0
*/
public function getFieldType(Container $container): FieldType
{
// check what type of field builder to use
if
($container->get('Config')->get('field_builder_type',
2) == 1)
{
// build field set using string manipulation
return $container->get('Compiler.Creator.Field.String');
}
else
{
// build field set with simpleXMLElement class
return $container->get('Compiler.Creator.Field.XML');
}
}
/**
* Get The Fieldsetinterface Class.
*
* @param Container $container The DI container.
*
* @return Fieldset
* @since 3.2.0
*/
public function getFieldset(Container $container): Fieldset
{
// check what type of field builder to use
if
($container->get('Config')->get('field_builder_type',
2) == 1)
{
// build field set using string manipulation
return
$container->get('Compiler.Creator.Fieldset.String');
}
else
{
// build field set with simpleXMLElement class
return $container->get('Compiler.Creator.Fieldset.XML');
}
}
}
src/Componentbuilder/Compiler/Service/Customcode.php000064400000012701151162054170016637
0ustar00<?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\Service;
use Joomla\DI\Container;
use Joomla\DI\ServiceProviderInterface;
use VDM\Joomla\Componentbuilder\Compiler\Customcode as CompilerCustomcode;
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\CustomcodeInterface;
use VDM\Joomla\Componentbuilder\Compiler\Customcode\External;
use VDM\Joomla\Componentbuilder\Compiler\Customcode\Gui;
use VDM\Joomla\Componentbuilder\Compiler\Customcode\Hash;
use VDM\Joomla\Componentbuilder\Compiler\Customcode\LockBase;
use VDM\Joomla\Componentbuilder\Compiler\Customcode\Dispenser;
use VDM\Joomla\Componentbuilder\Compiler\Customcode\Extractor;
use VDM\Joomla\Componentbuilder\Compiler\Customcode\Extractor\Paths;
/**
* Compiler Custom Code Service Provider
*
* @since 3.2.0
*/
class Customcode implements ServiceProviderInterface
{
/**
* Registers the service provider with a DI container.
*
* @param Container $container The DI container.
*
* @return void
* @since 3.2.0
*/
public function register(Container $container)
{
$container->alias(CompilerCustomcode::class, 'Customcode')
->share('Customcode', [$this, 'getCustomcode'],
true);
$container->alias(External::class, 'Customcode.External')
->share('Customcode.External', [$this,
'getExternal'], true);
$container->alias(Gui::class, 'Customcode.Gui')
->share('Customcode.Gui', [$this, 'getGui'],
true);
$container->alias(Hash::class, 'Customcode.Hash')
->share('Customcode.Hash', [$this, 'getHash'],
true);
$container->alias(LockBase::class, 'Customcode.LockBase')
->share('Customcode.LockBase', [$this,
'getLockBase'], true);
$container->alias(Dispenser::class, 'Customcode.Dispenser')
->share('Customcode.Dispenser', [$this,
'getDispenser'], true);
$container->alias(Paths::class,
'Customcode.Extractor.Paths')
->share('Customcode.Extractor.Paths', [$this,
'getPaths'], true);
$container->alias(Extractor::class, 'Customcode.Extractor')
->share('Customcode.Extractor', [$this,
'getExtractor'], true);
}
/**
* Get the Compiler Customcode
*
* @param Container $container The DI container.
*
* @return CustomcodeInterface
* @since 3.2.0
*/
public function getCustomcode(Container $container): CustomcodeInterface
{
return new CompilerCustomcode(
$container->get('Config'),
$container->get('Placeholder'),
$container->get('Language.Extractor'),
$container->get('Power.Extractor'),
$container->get('Joomla.Power.Extractor'),
$container->get('Customcode.External')
);
}
/**
* Get the Compiler Customcode External
*
* @param Container $container The DI container.
*
* @return External
* @since 3.2.0
*/
public function getExternal(Container $container): External
{
return new External(
$container->get('Placeholder')
);
}
/**
* Get the Compiler Customcode Gui
*
* @param Container $container The DI container.
*
* @return Gui
* @since 3.2.0
*/
public function getGui(Container $container): Gui
{
return new Gui(
$container->get('Config'),
$container->get('Placeholder.Reverse')
);
}
/**
* Get the Customcode Hash
*
* @param Container $container The DI container.
*
* @return Hash
* @since 3.2.0
*/
public function getHash(Container $container): Hash
{
return new Hash(
$container->get('Placeholder')
);
}
/**
* Get the Customcode LockBase64
*
* @param Container $container The DI container.
*
* @return LockBase
* @since 3.2.0
*/
public function getLockBase(Container $container): LockBase
{
return new LockBase(
$container->get('Placeholder')
);
}
/**
* Get the Customcode Dispenser
*
* @param Container $container The DI container.
*
* @return Dispenser
* @since 3.2.0
*/
public function getDispenser(Container $container): Dispenser
{
return new Dispenser(
$container->get('Placeholder'),
$container->get('Customcode'),
$container->get('Customcode.Gui'),
$container->get('Customcode.Hash'),
$container->get('Customcode.LockBase')
);
}
/**
* Get the Customcode Extractor Paths
*
* @param Container $container The DI container.
*
* @return Paths
* @since 3.2.0
*/
public function getPaths(Container $container): Paths
{
return new Paths(
$container->get('Config'),
$container->get('Placeholder'),
$container->get('Component.Placeholder'),
$container->get('Customcode'),
$container->get('Language.Extractor')
);
}
/**
* Get the Customcode Extractor
*
* @param Container $container The DI container.
*
* @return Extractor
* @since 3.2.0
*/
public function getExtractor(Container $container): Extractor
{
return new Extractor(
$container->get('Config'),
$container->get('Customcode.Gui'),
$container->get('Customcode.Extractor.Paths'),
$container->get('Placeholder.Reverse'),
$container->get('Component.Placeholder'),
$container->get('Utilities.Pathfix')
);
}
}
src/Componentbuilder/Compiler/Service/Customview.php000064400000006357151162054170016711
0ustar00<?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\Service;
use Joomla\DI\Container;
use Joomla\DI\ServiceProviderInterface;
use VDM\Joomla\Componentbuilder\Compiler\Customview\Data as CustomviewData;
use VDM\Joomla\Componentbuilder\Compiler\Dynamicget\Data as DynamicgetData;
use VDM\Joomla\Componentbuilder\Compiler\Dynamicget\Selection as
DynamicgetSelection;
/**
* Compiler Customview
*
* @since 3.2.0
*/
class Customview implements ServiceProviderInterface
{
/**
* Registers the service provider with a DI container.
*
* @param Container $container The DI container.
*
* @return void
* @since 3.2.0
*/
public function register(Container $container)
{
$container->alias(CustomviewData::class, 'Customview.Data')
->share('Customview.Data', [$this,
'getCustomviewData'], true);
$container->alias(DynamicgetData::class, 'Dynamicget.Data')
->share('Dynamicget.Data', [$this,
'getDynamicgetData'], true);
$container->alias(DynamicgetSelection::class,
'Dynamicget.Selection')
->share('Dynamicget.Selection', [$this,
'getDynamicgetSelection'], true);
}
/**
* Get the Compiler Customview Data
*
* @param Container $container The DI container.
*
* @return CustomviewData
* @since 3.2.0
*/
public function getCustomviewData(Container $container): CustomviewData
{
return new CustomviewData(
$container->get('Config'),
$container->get('Event'),
$container->get('Customcode'),
$container->get('Customcode.Gui'),
$container->get('Model.Libraries'),
$container->get('Templatelayout.Data'),
$container->get('Dynamicget.Data'),
$container->get('Model.Loader'),
$container->get('Model.Javascriptcustomview'),
$container->get('Model.Csscustomview'),
$container->get('Model.Phpcustomview'),
$container->get('Model.Ajaxcustomview'),
$container->get('Model.Custombuttons')
);
}
/**
* Get the Compiler Dynamicget Data
*
* @param Container $container The DI container.
*
* @return DynamicgetData
* @since 3.2.0
*/
public function getDynamicgetData(Container $container): DynamicgetData
{
return new DynamicgetData(
$container->get('Config'),
$container->get('Registry'),
$container->get('Event'),
$container->get('Customcode'),
$container->get('Customcode.Dispenser'),
$container->get('Customcode.Gui'),
$container->get('Model.Dynamicget')
);
}
/**
* Get the Compiler Dynamicget Selection
*
* @param Container $container The DI container.
*
* @return DynamicgetSelection
* @since 3.2.0
*/
public function getDynamicgetSelection(Container $container):
DynamicgetSelection
{
return new DynamicgetSelection(
$container->get('Config'),
$container->get('Compiler.Builder.Get.As.Lookup'),
$container->get('Compiler.Builder.Site.Fields')
);
}
}
src/Componentbuilder/Compiler/Service/Event.php000064400000005403151162054170015614
0ustar00<?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\Service;
use Joomla\DI\Container;
use Joomla\DI\ServiceProviderInterface;
use Joomla\CMS\Version;
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\EventInterface;
use VDM\Joomla\Componentbuilder\Compiler\JoomlaThree\Event as J3Event;
use VDM\Joomla\Componentbuilder\Compiler\JoomlaFour\Event as J4Event;
use VDM\Joomla\Componentbuilder\Compiler\JoomlaFive\Event as J5Event;
/**
* Event Service Provider
*
* @since 3.2.0
*/
class Event implements ServiceProviderInterface
{
/**
* Current Joomla Version We are IN
*
* @var int
* @since 3.2.0
**/
protected $currentVersion;
/**
* Registers the service provider with a DI container.
*
* @param Container $container The DI container.
*
* @return void
* @since 3.2.0
*/
public function register(Container $container)
{
$container->alias(J3Event::class, 'J3.Event')
->share('J3.Event', [$this, 'getJ3Event'],
true);
$container->alias(J4Event::class, 'J4.Event')
->share('J4.Event', [$this, 'getJ4Event'],
true);
$container->alias(J5Event::class, 'J5.Event')
->share('J5.Event', [$this, 'getJ5Event'],
true);
$container->alias(EventInterface::class, 'Event')
->share('Event', [$this, 'getEvent'], true);
}
/**
* Get the Event
*
* @param Container $container The DI container.
*
* @return EventInterface
* @since 3.2.0
*/
public function getEvent(Container $container): EventInterface
{
if (empty($this->currentVersion))
{
$this->currentVersion = Version::MAJOR_VERSION;
}
return $container->get('J' . $this->currentVersion .
'.Event');
}
/**
* Get the Joomla 3 Event
*
* @param Container $container The DI container.
*
* @return J3Event
* @since 3.2.0
*/
public function getJ3Event(Container $container): J3Event
{
return new J3Event();
}
/**
* Get the Joomla 4 Event
*
* @param Container $container The DI container.
*
* @return J4Event
* @since 3.2.0
*/
public function getJ4Event(Container $container): J4Event
{
return new J4Event();
}
/**
* Get the Joomla 5 Event
*
* @param Container $container The DI container.
*
* @return J5Event
* @since 3.2.0
*/
public function getJ5Event(Container $container): J5Event
{
return new J5Event();
}
}
src/Componentbuilder/Compiler/Service/Extension.php000064400000006507151162054170016515
0ustar00<?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\Service;
use Joomla\DI\Container;
use Joomla\DI\ServiceProviderInterface;
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\GetScriptInterface;
use
VDM\Joomla\Componentbuilder\Compiler\Extension\JoomlaThree\InstallScript as
J3InstallScript;
use VDM\Joomla\Componentbuilder\Compiler\Extension\JoomlaFour\InstallScript
as J4InstallScript;
use VDM\Joomla\Componentbuilder\Compiler\Extension\JoomlaFive\InstallScript
as J5InstallScript;
/**
* Extension Script Service Provider
*
* @since 3.2.0
*/
class Extension implements ServiceProviderInterface
{
/**
* Current Joomla Version Being Build
*
* @var int
* @since 3.2.0
**/
protected $targetVersion;
/**
* Registers the service provider with a DI container.
*
* @param Container $container The DI container.
*
* @return void
* @since 3.2.0
*/
public function register(Container $container)
{
$container->alias(GetScriptInterface::class,
'Extension.InstallScript')
->share('Extension.InstallScript', [$this,
'getExtensionInstallScript'], true);
$container->alias(J3InstallScript::class,
'J3.Extension.InstallScript')
->share('J3.Extension.InstallScript', [$this,
'getJ3ExtensionInstallScript'], true);
$container->alias(J4InstallScript::class,
'J4.Extension.InstallScript')
->share('J4.Extension.InstallScript', [$this,
'getJ4ExtensionInstallScript'], true);
$container->alias(J5InstallScript::class,
'J5.Extension.InstallScript')
->share('J5.Extension.InstallScript', [$this,
'getJ5ExtensionInstallScript'], true);
}
/**
* Get the Joomla 3 Extension Install Script
*
* @param Container $container The DI container.
*
* @return J3InstallScript
* @since 3.2.0
*/
public function getJ3ExtensionInstallScript(Container $container):
J3InstallScript
{
return new J3InstallScript();
}
/**
* Get the Joomla 4 Extension Install Script
*
* @param Container $container The DI container.
*
* @return J4InstallScript
* @since 3.2.0
*/
public function getJ4ExtensionInstallScript(Container $container):
J4InstallScript
{
return new J4InstallScript();
}
/**
* Get the Joomla 5 Extension Install Script
*
* @param Container $container The DI container.
*
* @return J5InstallScript
* @since 3.2.0
*/
public function getJ5ExtensionInstallScript(Container $container):
J5InstallScript
{
return new J5InstallScript();
}
/**
* Get the Joomla Extension Install Script
*
* @param Container $container The DI container.
*
* @return GetScriptInterface
* @since 3.2.0
*/
public function getExtensionInstallScript(Container $container):
GetScriptInterface
{
if (empty($this->targetVersion))
{
$this->targetVersion =
$container->get('Config')->joomla_version;
}
return $container->get('J' . $this->targetVersion .
'.Extension.InstallScript');
}
}
src/Componentbuilder/Compiler/Service/Field.php000064400000025563151162054170015567
0ustar00<?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\Service;
use Joomla\DI\Container;
use Joomla\DI\ServiceProviderInterface;
use Joomla\CMS\Version;
use VDM\Joomla\Componentbuilder\Compiler\Field as CompilerField;
use VDM\Joomla\Componentbuilder\Compiler\Field\Data;
use VDM\Joomla\Componentbuilder\Compiler\Field\Groups;
use VDM\Joomla\Componentbuilder\Compiler\Field\Attributes;
use VDM\Joomla\Componentbuilder\Compiler\Field\Name;
use VDM\Joomla\Componentbuilder\Compiler\Field\TypeName;
use VDM\Joomla\Componentbuilder\Compiler\Field\UniqueName;
use VDM\Joomla\Componentbuilder\Compiler\Field\Rule;
use VDM\Joomla\Componentbuilder\Compiler\Field\Customcode;
use VDM\Joomla\Componentbuilder\Compiler\Field\DatabaseName;
use VDM\Joomla\Componentbuilder\Compiler\Field\JoomlaThree\CoreField as
J3CoreField;
use VDM\Joomla\Componentbuilder\Compiler\Field\JoomlaFour\CoreField as
J4CoreField;
use VDM\Joomla\Componentbuilder\Compiler\Field\JoomlaFive\CoreField as
J5CoreField;
use VDM\Joomla\Componentbuilder\Compiler\Field\JoomlaThree\InputButton as
J3InputButton;
use VDM\Joomla\Componentbuilder\Compiler\Field\JoomlaFour\InputButton as
J4InputButton;
use VDM\Joomla\Componentbuilder\Compiler\Field\JoomlaFive\InputButton as
J5InputButton;
use
VDM\Joomla\Componentbuilder\Compiler\Interfaces\Field\CoreFieldInterface as
CoreField;
use
VDM\Joomla\Componentbuilder\Compiler\Interfaces\Field\InputButtonInterface
as InputButton;
/**
* Compiler Field
*
* @since 3.2.0
*/
class Field implements ServiceProviderInterface
{
/**
* Current Joomla Version Being Build
*
* @var int
* @since 3.2.0
**/
protected $targetVersion;
/**
* Current Joomla Version We are IN
*
* @var int
* @since 3.2.0
**/
protected $currentVersion;
/**
* Registers the service provider with a DI container.
*
* @param Container $container The DI container.
*
* @return void
* @since 3.2.0
*/
public function register(Container $container)
{
$container->alias(CompilerField::class, 'Field')
->share('Field', [$this, 'getCompilerField'],
true);
$container->alias(Data::class, 'Field.Data')
->share('Field.Data', [$this, 'getData'], true);
$container->alias(Groups::class, 'Field.Groups')
->share('Field.Groups', [$this, 'getGroups'],
true);
$container->alias(Attributes::class, 'Field.Attributes')
->share('Field.Attributes', [$this,
'getAttributes'], true);
$container->alias(Name::class, 'Field.Name')
->share('Field.Name', [$this, 'getName'], true);
$container->alias(TypeName::class, 'Field.Type.Name')
->share('Field.Type.Name', [$this,
'getTypeName'], true);
$container->alias(UniqueName::class, 'Field.Unique.Name')
->share('Field.Unique.Name', [$this,
'getUniqueName'], true);
$container->alias(Rule::class, 'Field.Rule')
->share('Field.Rule', [$this, 'getRule'], true);
$container->alias(Customcode::class, 'Field.Customcode')
->share('Field.Customcode', [$this,
'getCustomcode'], true);
$container->alias(DatabaseName::class,
'Field.Database.Name')
->share('Field.Database.Name', [$this,
'getDatabaseName'], true);
$container->alias(J3CoreField::class,
'J3.Field.Core.Field')
->share('J3.Field.Core.Field', [$this,
'getJ3CoreField'], true);
$container->alias(J4CoreField::class,
'J4.Field.Core.Field')
->share('J4.Field.Core.Field', [$this,
'getJ4CoreField'], true);
$container->alias(J5CoreField::class,
'J5.Field.Core.Field')
->share('J5.Field.Core.Field', [$this,
'getJ5CoreField'], true);
$container->alias(J3InputButton::class,
'J3.Field.Input.Button')
->share('J3.Field.Input.Button', [$this,
'getJ3InputButton'], true);
$container->alias(J4InputButton::class,
'J4.Field.Input.Button')
->share('J4.Field.Input.Button', [$this,
'getJ4InputButton'], true);
$container->alias(J5InputButton::class,
'J5.Field.Input.Button')
->share('J5.Field.Input.Button', [$this,
'getJ5InputButton'], true);
$container->alias(CoreField::class, 'Field.Core.Field')
->share('Field.Core.Field', [$this,
'getCoreField'], true);
$container->alias(InputButton::class, 'Field.Input.Button')
->share('Field.Input.Button', [$this,
'getInputButton'], true);
}
/**
* Get The Field Class.
*
* @param Container $container The DI container.
*
* @return CompilerField
* @since 3.2.0
*/
public function getCompilerField(Container $container): CompilerField
{
return new CompilerField(
$container->get('Field.Data'),
$container->get('Field.Name'),
$container->get('Field.Type.Name'),
$container->get('Field.Unique.Name')
);
}
/**
* Get The Data Class.
*
* @param Container $container The DI container.
*
* @return Data
* @since 3.2.0
*/
public function getData(Container $container): Data
{
return new Data(
$container->get('Config'),
$container->get('Event'),
$container->get('History'),
$container->get('Placeholder'),
$container->get('Customcode'),
$container->get('Field.Customcode'),
$container->get('Field.Rule')
);
}
/**
* Get The Groups Class.
*
* @param Container $container The DI container.
*
* @return Groups
* @since 3.2.0
*/
public function getGroups(Container $container): Groups
{
return new Groups();
}
/**
* Get The Attributes Class.
*
* @param Container $container The DI container.
*
* @return Attributes
* @since 3.2.0
*/
public function getAttributes(Container $container): Attributes
{
return new Attributes(
$container->get('Config'),
$container->get('Registry'),
$container->get('Compiler.Builder.List.Field.Class'),
$container->get('Compiler.Builder.Do.Not.Escape'),
$container->get('Placeholder'),
$container->get('Customcode'),
$container->get('Language'),
$container->get('Field.Groups')
);
}
/**
* Get The Name Class.
*
* @param Container $container The DI container.
*
* @return Name
* @since 3.2.0
*/
public function getName(Container $container): Name
{
return new Name(
$container->get('Placeholder'),
$container->get('Field.Unique.Name'),
$container->get('Compiler.Builder.Category.Other.Name')
);
}
/**
* Get The TypeName Class.
*
* @param Container $container The DI container.
*
* @return TypeName
* @since 3.2.0
*/
public function getTypeName(Container $container): TypeName
{
return new TypeName();
}
/**
* Get The UniqueName Class.
*
* @param Container $container The DI container.
*
* @return UniqueName
* @since 3.2.0
*/
public function getUniqueName(Container $container): UniqueName
{
return new UniqueName(
$container->get('Registry')
);
}
/**
* Get The Rule Class.
*
* @param Container $container The DI container.
*
* @return Rule
* @since 3.2.0
*/
public function getRule(Container $container): Rule
{
return new Rule(
$container->get('Registry'),
$container->get('Customcode'),
$container->get('Customcode.Gui'),
$container->get('Placeholder'),
$container->get('Field.Core.Rule')
);
}
/**
* Get The Customcode Class.
*
* @param Container $container The DI container.
*
* @return Customcode
* @since 3.2.0
*/
public function getCustomcode(Container $container): Customcode
{
return new Customcode(
$container->get('Customcode.Dispenser')
);
}
/**
* Get The DatabaseName Class.
*
* @param Container $container The DI container.
*
* @return DatabaseName
* @since 3.2.0
*/
public function getDatabaseName(Container $container): DatabaseName
{
return new DatabaseName(
$container->get('Compiler.Builder.Lists'),
$container->get('Registry')
);
}
/**
* Get The CoreField Class.
*
* @param Container $container The DI container.
*
* @return J3CoreField
* @since 3.2.0
*/
public function getJ3CoreField(Container $container): J3CoreField
{
return new J3CoreField();
}
/**
* Get The CoreField Class.
*
* @param Container $container The DI container.
*
* @return J4CoreField
* @since 3.2.0
*/
public function getJ4CoreField(Container $container): J4CoreField
{
return new J4CoreField();
}
/**
* Get The CoreField Class.
*
* @param Container $container The DI container.
*
* @return J5CoreField
* @since 3.2.0
*/
public function getJ5CoreField(Container $container): J5CoreField
{
return new J5CoreField();
}
/**
* Get The J3InputButton Class.
*
* @param Container $container The DI container.
*
* @return J3InputButton
* @since 3.2.0
*/
public function getJ3InputButton(Container $container): J3InputButton
{
return new J3InputButton(
$container->get('Config'),
$container->get('Placeholder'),
$container->get('Compiler.Creator.Permission')
);
}
/**
* Get The J4InputButton Class.
*
* @param Container $container The DI container.
*
* @return J4InputButton
* @since 3.2.0
*/
public function getJ4InputButton(Container $container): J4InputButton
{
return new J4InputButton(
$container->get('Config'),
$container->get('Placeholder'),
$container->get('Compiler.Creator.Permission')
);
}
/**
* Get The J5InputButton Class.
*
* @param Container $container The DI container.
*
* @return J5InputButton
* @since 3.2.0
*/
public function getJ5InputButton(Container $container): J5InputButton
{
return new J5InputButton(
$container->get('Config'),
$container->get('Placeholder'),
$container->get('Compiler.Creator.Permission')
);
}
/**
* Get The CoreFieldInterface Class.
*
* @param Container $container The DI container.
*
* @return CoreField
* @since 3.2.0
*/
public function getCoreField(Container $container): CoreField
{
if (empty($this->currentVersion))
{
$this->currentVersion = Version::MAJOR_VERSION;
}
return $container->get('J' . $this->currentVersion .
'.Field.Core.Field');
}
/**
* Get The InputButton Class.
*
* @param Container $container The DI container.
*
* @return InputButton
* @since 3.2.0
*/
public function getInputButton(Container $container): InputButton
{
if (empty($this->targetVersion))
{
$this->targetVersion =
$container->get('Config')->joomla_version;
}
return $container->get('J' . $this->targetVersion .
'.Field.Input.Button');
}
}
src/Componentbuilder/Compiler/Service/Header.php000064400000010142151162054170015717
0ustar00<?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\Service;
use Joomla\DI\Container;
use Joomla\DI\ServiceProviderInterface;
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\HeaderInterface;
use VDM\Joomla\Componentbuilder\Compiler\JoomlaThree\Header as J3Header;
use VDM\Joomla\Componentbuilder\Compiler\JoomlaFour\Header as J4Header;
use VDM\Joomla\Componentbuilder\Compiler\JoomlaFive\Header as J5Header;
/**
* Header Service Provider
*
* @since 3.2.0
*/
class Header implements ServiceProviderInterface
{
/**
* Current Joomla Version Being Build
*
* @var int
* @since 3.2.0
**/
protected $targetVersion;
/**
* Registers the service provider with a DI container.
*
* @param Container $container The DI container.
*
* @return void
* @since 3.2.0
*/
public function register(Container $container)
{
$container->alias(J3Header::class, 'J3.Header')
->share('J3.Header', [$this, 'getJ3Header'],
true);
$container->alias(J4Header::class, 'J4.Header')
->share('J4.Header', [$this, 'getJ4Header'],
true);
$container->alias(J5Header::class, 'J5.Header')
->share('J5.Header', [$this, 'getJ5Header'],
true);
$container->alias(HeaderInterface::class, 'Header')
->share('Header', [$this, 'getHeader'], true);
}
/**
* Get the Header
*
* @param Container $container The DI container.
*
* @return HeaderInterface
* @since 3.2.0
*/
public function getHeader(Container $container): HeaderInterface
{
if (empty($this->targetVersion))
{
$this->targetVersion =
$container->get('Config')->joomla_version;
}
return $container->get('J' . $this->targetVersion .
'.Header');
}
/**
* Get The Header Class.
*
* @param Container $container The DI container.
*
* @return J3Header
* @since 3.2.0
*/
public function getJ3Header(Container $container): J3Header
{
return new J3Header(
$container->get('Config'),
$container->get('Event'),
$container->get('Placeholder'),
$container->get('Language'),
$container->get('Compiler.Builder.Uikit.Comp'),
$container->get('Compiler.Builder.Admin.Filter.Type'),
$container->get('Compiler.Builder.Category'),
$container->get('Compiler.Builder.Access.Switch.List'),
$container->get('Compiler.Builder.Filter'),
$container->get('Compiler.Builder.Tags')
);
}
/**
* Get The Header Class.
*
* @param Container $container The DI container.
*
* @return J4Header
* @since 3.2.0
*/
public function getJ4Header(Container $container): J4Header
{
return new J4Header(
$container->get('Config'),
$container->get('Event'),
$container->get('Placeholder'),
$container->get('Language'),
$container->get('Compiler.Builder.Uikit.Comp'),
$container->get('Compiler.Builder.Admin.Filter.Type'),
$container->get('Compiler.Builder.Category'),
$container->get('Compiler.Builder.Access.Switch.List'),
$container->get('Compiler.Builder.Filter'),
$container->get('Compiler.Builder.Tags')
);
}
/**
* Get The Header Class.
*
* @param Container $container The DI container.
*
* @return J5Header
* @since 3.2.0
*/
public function getJ5Header(Container $container): J5Header
{
return new J5Header(
$container->get('Config'),
$container->get('Event'),
$container->get('Placeholder'),
$container->get('Language'),
$container->get('Compiler.Builder.Uikit.Comp'),
$container->get('Compiler.Builder.Admin.Filter.Type'),
$container->get('Compiler.Builder.Category'),
$container->get('Compiler.Builder.Access.Switch.List'),
$container->get('Compiler.Builder.Filter'),
$container->get('Compiler.Builder.Tags')
);
}
}
src/Componentbuilder/Compiler/Service/History.php000064400000005703151162054170016177
0ustar00<?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\Service;
use Joomla\DI\Container;
use Joomla\DI\ServiceProviderInterface;
use Joomla\CMS\Version;
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\HistoryInterface;
use VDM\Joomla\Componentbuilder\Compiler\JoomlaThree\History as J3History;
use VDM\Joomla\Componentbuilder\Compiler\JoomlaFour\History as J4History;
use VDM\Joomla\Componentbuilder\Compiler\JoomlaFive\History as J5History;
/**
* History Service Provider
*
* @since 3.2.0
*/
class History implements ServiceProviderInterface
{
/**
* Current Joomla Version We are IN
*
* @var int
* @since 3.2.0
**/
protected $currentVersion;
/**
* Registers the service provider with a DI container.
*
* @param Container $container The DI container.
*
* @return void
* @since 3.2.0
*/
public function register(Container $container)
{
$container->alias(J3History::class, 'J3.History')
->share('J3.History', [$this, 'getJ3History'],
true);
$container->alias(J4History::class, 'J4.History')
->share('J4.History', [$this, 'getJ4History'],
true);
$container->alias(J5History::class, 'J5.History')
->share('J5.History', [$this, 'getJ5History'],
true);
$container->alias(HistoryInterface::class, 'History')
->share('History', [$this, 'getHistory'], true);
}
/**
* Get the History
*
* @param Container $container The DI container.
*
* @return HistoryInterface
* @since 3.2.0
*/
public function getHistory(Container $container): HistoryInterface
{
if (empty($this->currentVersion))
{
$this->currentVersion = Version::MAJOR_VERSION;
}
return $container->get('J' . $this->currentVersion .
'.History');
}
/**
* Get the Joomla 3 History
*
* @param Container $container The DI container.
*
* @return J3History
* @since 3.2.0
*/
public function getJ3History(Container $container): J3History
{
return new J3History(
$container->get('Config')
);
}
/**
* Get the Joomla 4 History
*
* @param Container $container The DI container.
*
* @return J4History
* @since 3.2.0
*/
public function getJ4History(Container $container): J4History
{
return new J4History(
$container->get('Config')
);
}
/**
* Get the Joomla 5 History
*
* @param Container $container The DI container.
*
* @return J5History
* @since 3.2.0
*/
public function getJ5History(Container $container): J5History
{
return new J5History(
$container->get('Config')
);
}
}
src/Componentbuilder/Compiler/Service/JoomlaPower.php000064400000007004151162054170016770
0ustar00<?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\Service;
use Joomla\DI\Container;
use Joomla\DI\ServiceProviderInterface;
use VDM\Joomla\Componentbuilder\Compiler\JoomlaPower as Powers;
use VDM\Joomla\Componentbuilder\JoomlaPower\Grep;
use VDM\Joomla\Componentbuilder\JoomlaPower\Remote\Get;
use VDM\Joomla\Componentbuilder\Compiler\JoomlaPower\Extractor;
use VDM\Joomla\Componentbuilder\Compiler\JoomlaPower\Injector;
/**
* Compiler Joomla Power Service Provider
*
* @since 3.2.0
*/
class JoomlaPower implements ServiceProviderInterface
{
/**
* Registers the service provider with a DI container.
*
* @param Container $container The DI container.
*
* @return void
* @since 3.2.0
*/
public function register(Container $container)
{
$container->alias(Powers::class, 'Joomla.Power')
->share('Joomla.Power', [$this, 'getPowers'],
true);
$container->alias(Get::class, 'Joomla.Power.Remote.Get')
->share('Joomla.Power.Remote.Get', [$this,
'getRemoteGet'], true);
$container->alias(Grep::class, 'Joomla.Power.Grep')
->share('Joomla.Power.Grep', [$this, 'getGrep'],
true);
$container->alias(Extractor::class,
'Joomla.Power.Extractor')
->share('Joomla.Power.Extractor', [$this,
'getExtractor'], true);
$container->alias(Injector::class, 'Joomla.Power.Injector')
->share('Joomla.Power.Injector', [$this,
'getInjector'], true);
}
/**
* Get the Powers
*
* @param Container $container The DI container.
*
* @return Powers
* @since 3.2.0
*/
public function getPowers(Container $container): Powers
{
return new Powers(
$container->get('Config'),
$container->get('Placeholder'),
$container->get('Customcode'),
$container->get('Customcode.Gui'),
$container->get('Joomla.Power.Remote.Get')
);
}
/**
* Get the Remote Get
*
* @param Container $container The DI container.
*
* @return Get
* @since 3.2.0
*/
public function getRemoteGet(Container $container): Get
{
return new Get(
$container->get('Joomla.Power.Grep'),
$container->get('Data.Item')
);
}
/**
* Get the Grep
*
* @param Container $container The DI container.
*
* @return Grep
* @since 3.2.0
*/
public function getGrep(Container $container): Grep
{
return new Grep(
$container->get('Gitea.Repository.Contents'),
$container->get('Config')->approved_joomla_paths
);
}
/**
* Get the Compiler Power Extractor
*
* @param Container $container The DI container.
*
* @return Extractor
* @since 3.2.0
*/
public function getExtractor(Container $container): Extractor
{
return new Extractor(
$container->get('Config')->joomla_version
);
}
/**
* Get the Compiler Power Injector
*
* @param Container $container The DI container.
*
* @return Injector
* @since 3.2.0
*/
public function getInjector(Container $container): Injector
{
return new Injector(
$container->get('Joomla.Power'),
$container->get('Joomla.Power.Extractor'),
$container->get('Power.Parser'),
$container->get('Placeholder')
);
}
}
src/Componentbuilder/Compiler/Service/Joomlamodule.php000064400000005024151162054170017161
0ustar00<?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\Service;
use Joomla\DI\Container;
use Joomla\DI\ServiceProviderInterface;
use VDM\Joomla\Componentbuilder\Compiler\Joomlamodule\Data;
use VDM\Joomla\Componentbuilder\Compiler\Joomlamodule\Structure;
/**
* Joomla Module Service Provider
*
* @since 3.2.0
*/
class Joomlamodule implements ServiceProviderInterface
{
/**
* Registers the service provider with a DI container.
*
* @param Container $container The DI container.
*
* @return void
* @since 3.2.0
*/
public function register(Container $container)
{
$container->alias(Data::class, 'Joomlamodule.Data')
->share('Joomlamodule.Data', [$this, 'getData'],
true);
$container->alias(Structure::class,
'Joomlamodule.Structure')
->share('Joomlamodule.Structure', [$this,
'getStructure'], true);
}
/**
* Get The Data Class.
*
* @param Container $container The DI container.
*
* @return Data
* @since 3.2.0
*/
public function getData(Container $container): Data
{
return new Data(
$container->get('Config'),
$container->get('Customcode'),
$container->get('Customcode.Gui'),
$container->get('Placeholder'),
$container->get('Language'),
$container->get('Field'),
$container->get('Field.Name'),
$container->get('Model.Filesfolders'),
$container->get('Model.Libraries'),
$container->get('Dynamicget.Data'),
$container->get('Templatelayout.Data')
);
}
/**
* Get The Structure Class.
*
* @param Container $container The DI container.
*
* @return Structure
* @since 3.2.0
*/
public function getStructure(Container $container): Structure
{
return new Structure(
$container->get('Joomlamodule.Data'),
$container->get('Component'),
$container->get('Config'),
$container->get('Registry'),
$container->get('Customcode.Dispenser'),
$container->get('Event'),
$container->get('Utilities.Counter'),
$container->get('Utilities.Folder'),
$container->get('Utilities.File'),
$container->get('Utilities.Files'),
$container->get('Compiler.Builder.Template.Data')
);
}
}
src/Componentbuilder/Compiler/Service/Joomlaplugin.php000064400000025436151162054170017203
0ustar00<?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\Service;
use Joomla\DI\Container;
use Joomla\DI\ServiceProviderInterface;
use VDM\Joomla\Componentbuilder\Compiler\Joomlaplugin\JoomlaThree\Data as
J3PluginData;
use VDM\Joomla\Componentbuilder\Compiler\Joomlaplugin\JoomlaFour\Data as
J4PluginData;
use VDM\Joomla\Componentbuilder\Compiler\Joomlaplugin\JoomlaFive\Data as
J5PluginData;
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\PluginDataInterface as
PluginData;
use VDM\Joomla\Componentbuilder\Compiler\Joomlaplugin\JoomlaThree\Structure
as J3Structure;
use VDM\Joomla\Componentbuilder\Compiler\Joomlaplugin\JoomlaFour\Structure
as J4Structure;
use VDM\Joomla\Componentbuilder\Compiler\Joomlaplugin\JoomlaFive\Structure
as J5Structure;
use VDM\Joomla\Componentbuilder\Interfaces\Plugin\StructureInterface as
Structure;
use VDM\Joomla\Componentbuilder\Compiler\Joomlaplugin\JoomlaThree\Infusion
as J3Infusion;
use VDM\Joomla\Componentbuilder\Compiler\Joomlaplugin\JoomlaFour\Infusion
as J4Infusion;
use VDM\Joomla\Componentbuilder\Compiler\Joomlaplugin\JoomlaFive\Infusion
as J5Infusion;
use VDM\Joomla\Componentbuilder\Interfaces\Plugin\InfusionInterface as
Infusion;
/**
* Joomla Plugin Service Provider
*
* @since 3.2.0
*/
class Joomlaplugin implements ServiceProviderInterface
{
/**
* Current Joomla Version Being Build
*
* @var int
* @since 5.0.2
**/
protected $targetVersion;
/**
* Registers the service provider with a DI container.
*
* @param Container $container The DI container.
*
* @return void
* @since 3.2.0
*/
public function register(Container $container)
{
$container->alias(J3PluginData::class,
'Joomlaplugin.J3.Data')
->share('Joomlaplugin.J3.Data', [$this,
'getJ3PluginData'], true);
$container->alias(J4PluginData::class,
'Joomlaplugin.J4.Data')
->share('Joomlaplugin.J4.Data', [$this,
'getJ4PluginData'], true);
$container->alias(J5PluginData::class,
'Joomlaplugin.J5.Data')
->share('Joomlaplugin.J5.Data', [$this,
'getJ5PluginData'], true);
$container->alias(PluginData::class, 'Joomlaplugin.Data')
->share('Joomlaplugin.Data', [$this,
'getPluginData'], true);
$container->alias(J3Structure::class,
'Joomlaplugin.J3.Structure')
->share('Joomlaplugin.J3.Structure', [$this,
'getJ3Structure'], true);
$container->alias(J4Structure::class,
'Joomlaplugin.J4.Structure')
->share('Joomlaplugin.J4.Structure', [$this,
'getJ4Structure'], true);
$container->alias(J5Structure::class,
'Joomlaplugin.J5.Structure')
->share('Joomlaplugin.J5.Structure', [$this,
'getJ5Structure'], true);
$container->alias(Structure::class,
'Joomlaplugin.Structure')
->share('Joomlaplugin.Structure', [$this,
'getStructure'], true);
$container->alias(J3Infusion::class,
'Joomlaplugin.J3.Infusion')
->share('Joomlaplugin.J3.Infusion', [$this,
'getJ3Infusion'], true);
$container->alias(J4Infusion::class,
'Joomlaplugin.J4.Infusion')
->share('Joomlaplugin.J4.Infusion', [$this,
'getJ4Infusion'], true);
$container->alias(J5Infusion::class,
'Joomlaplugin.J5.Infusion')
->share('Joomlaplugin.J5.Infusion', [$this,
'getJ5Infusion'], true);
$container->alias(Infusion::class, 'Joomlaplugin.Infusion')
->share('Joomlaplugin.Infusion', [$this,
'getInfusion'], true);
}
/**
* Get The Plug-in Data Class.
*
* @param Container $container The DI container.
*
* @return PluginData
* @since 5.0.2
*/
public function getPluginData(Container $container): PluginData
{
if (empty($this->targetVersion))
{
$this->targetVersion =
$container->get('Config')->joomla_version;
}
return $container->get('Joomlaplugin.J' .
$this->targetVersion . '.Data');
}
/**
* Get The PluginData Class.
*
* @param Container $container The DI container.
*
* @return J3PluginData
* @since 5.0.2
*/
public function getJ3PluginData(Container $container): J3PluginData
{
return new J3PluginData(
$container->get('Config'),
$container->get('Customcode'),
$container->get('Customcode.Gui'),
$container->get('Placeholder'),
$container->get('Language'),
$container->get('Field'),
$container->get('Field.Name'),
$container->get('Model.Filesfolders')
);
}
/**
* Get The PluginData Class.
*
* @param Container $container The DI container.
*
* @return J4PluginData
* @since 5.0.2
*/
public function getJ4PluginData(Container $container): J4PluginData
{
return new J4PluginData(
$container->get('Config'),
$container->get('Customcode'),
$container->get('Customcode.Gui'),
$container->get('Placeholder'),
$container->get('Language'),
$container->get('Field'),
$container->get('Field.Name'),
$container->get('Model.Filesfolders')
);
}
/**
* Get The PluginData Class.
*
* @param Container $container The DI container.
*
* @return J5PluginData
* @since 5.0.2
*/
public function getJ5PluginData(Container $container): J5PluginData
{
return new J5PluginData(
$container->get('Config'),
$container->get('Customcode'),
$container->get('Customcode.Gui'),
$container->get('Placeholder'),
$container->get('Language'),
$container->get('Field'),
$container->get('Field.Name'),
$container->get('Model.Filesfolders')
);
}
/**
* Get the Joomla Plugin Structure Builder
*
* @param Container $container The DI container.
*
* @return Structure
* @since 3.2.0
*/
public function getStructure(Container $container): Structure
{
if (empty($this->targetVersion))
{
$this->targetVersion =
$container->get('Config')->joomla_version;
}
return $container->get('Joomlaplugin.J' .
$this->targetVersion . '.Structure');
}
/**
* Get the Joomla 3 Plugin Structure Builder
*
* @param Container $container The DI container.
*
* @return Structure
* @since 5.0.2
*/
public function getJ3Structure(Container $container): J3Structure
{
return new J3Structure(
$container->get('Joomlaplugin.Data'),
$container->get('Component'),
$container->get('Config'),
$container->get('Registry'),
$container->get('Customcode.Dispenser'),
$container->get('Event'),
$container->get('Utilities.Counter'),
$container->get('Utilities.Folder'),
$container->get('Utilities.File'),
$container->get('Utilities.Files')
);
}
/**
* Get the Joomla 4 Plugin Structure Builder
*
* @param Container $container The DI container.
*
* @return Structure
* @since 5.0.2
*/
public function getJ4Structure(Container $container): J4Structure
{
return new J4Structure(
$container->get('Joomlaplugin.Data'),
$container->get('Component'),
$container->get('Config'),
$container->get('Registry'),
$container->get('Customcode.Dispenser'),
$container->get('Event'),
$container->get('Utilities.Counter'),
$container->get('Utilities.Folder'),
$container->get('Utilities.File'),
$container->get('Utilities.Files'),
$container->get('Placeholder')
);
}
/**
* Get the Joomla 5 Plugin Structure Builder
*
* @param Container $container The DI container.
*
* @return Structure
* @since 5.0.2
*/
public function getJ5Structure(Container $container): J5Structure
{
return new J5Structure(
$container->get('Joomlaplugin.Data'),
$container->get('Component'),
$container->get('Config'),
$container->get('Registry'),
$container->get('Customcode.Dispenser'),
$container->get('Event'),
$container->get('Utilities.Counter'),
$container->get('Utilities.Folder'),
$container->get('Utilities.File'),
$container->get('Utilities.Files'),
$container->get('Placeholder')
);
}
/**
* Get The InfusionInterface Class.
*
* @param Container $container The DI container.
*
* @return Infusion
* @since 5.0.2
*/
public function getInfusion(Container $container): Infusion
{
if (empty($this->targetVersion))
{
$this->targetVersion =
$container->get('Config')->joomla_version;
}
return $container->get('Joomlaplugin.J' .
$this->targetVersion . '.Infusion');
}
/**
* Get The Infusion Class.
*
* @param Container $container The DI container.
*
* @return J3Infusion
* @since 5.0.2
*/
public function getJ3Infusion(Container $container): J3Infusion
{
return new J3Infusion(
$container->get('Config'),
$container->get('Placeholder'),
$container->get('Header'),
$container->get('Event'),
$container->get('Joomlaplugin.Data'),
$container->get('Extension.InstallScript'),
$container->get('Architecture.Plugin.Extension'),
$container->get('Architecture.Plugin.MainXML'),
$container->get('Compiler.Builder.Content.Multi'),
$container->get('Compiler.Creator.Fieldset.Extension')
);
}
/**
* Get The Infusion Class.
*
* @param Container $container The DI container.
*
* @return J4Infusion
* @since 5.0.2
*/
public function getJ4Infusion(Container $container): J4Infusion
{
return new J4Infusion(
$container->get('Config'),
$container->get('Placeholder'),
$container->get('Header'),
$container->get('Event'),
$container->get('Joomlaplugin.Data'),
$container->get('Extension.InstallScript'),
$container->get('Architecture.Plugin.Extension'),
$container->get('Architecture.Plugin.Provider'),
$container->get('Architecture.Plugin.MainXML'),
$container->get('Compiler.Builder.Content.Multi'),
$container->get('Compiler.Builder.Content.One'),
$container->get('Compiler.Creator.Fieldset.Extension')
);
}
/**
* Get The Infusion Class.
*
* @param Container $container The DI container.
*
* @return J5Infusion
* @since 5.0.2
*/
public function getJ5Infusion(Container $container): J5Infusion
{
return new J5Infusion(
$container->get('Config'),
$container->get('Placeholder'),
$container->get('Header'),
$container->get('Event'),
$container->get('Joomlaplugin.Data'),
$container->get('Extension.InstallScript'),
$container->get('Architecture.Plugin.Extension'),
$container->get('Architecture.Plugin.Provider'),
$container->get('Architecture.Plugin.MainXML'),
$container->get('Compiler.Builder.Content.Multi'),
$container->get('Compiler.Builder.Content.One'),
$container->get('Compiler.Creator.Fieldset.Extension')
);
}
}
src/Componentbuilder/Compiler/Service/Language.php000064400000012560151162054170016260
0ustar00<?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\Service;
use Joomla\DI\Container;
use Joomla\DI\ServiceProviderInterface;
use VDM\Joomla\Componentbuilder\Compiler\Language as CompilerLanguage;
use VDM\Joomla\Componentbuilder\Compiler\Language\Set;
use VDM\Joomla\Componentbuilder\Compiler\Language\Purge;
use VDM\Joomla\Componentbuilder\Compiler\Language\Insert;
use VDM\Joomla\Componentbuilder\Compiler\Language\Update;
use VDM\Joomla\Componentbuilder\Compiler\Language\Extractor;
use VDM\Joomla\Componentbuilder\Compiler\Language\Fieldset;
use VDM\Joomla\Componentbuilder\Compiler\Language\Multilingual;
use VDM\Joomla\Componentbuilder\Compiler\Language\Translation;
/**
* Compiler Language Service Provider
*
* @since 3.2.0
*/
class Language implements ServiceProviderInterface
{
/**
* Registers the service provider with a DI container.
*
* @param Container $container The DI container.
*
* @return void
* @since 3.2.0
*/
public function register(Container $container)
{
$container->alias(CompilerLanguage::class, 'Language')
->share('Language', [$this,
'getCompilerLanguage'], true);
$container->alias(Set::class, 'Language.Set')
->share('Language.Set', [$this, 'getSet'],
true);
$container->alias(Purge::class, 'Language.Purge')
->share('Language.Purge', [$this, 'getPurge'],
true);
$container->alias(Insert::class, 'Language.Insert')
->share('Language.Insert', [$this, 'getInsert'],
true);
$container->alias(Update::class, 'Language.Update')
->share('Language.Update', [$this, 'getUpdate'],
true);
$container->alias(Extractor::class, 'Language.Extractor')
->share('Language.Extractor', [$this,
'getExtractor'], true);
$container->alias(Fieldset::class, 'Language.Fieldset')
->share('Language.Fieldset', [$this,
'getFieldset'], true);
$container->alias(Multilingual::class,
'Language.Multilingual')
->share('Language.Multilingual', [$this,
'getMultilingual'], true);
$container->alias(Translation::class,
'Language.Translation')
->share('Language.Translation', [$this,
'getTranslation'], true);
}
/**
* Get The Language Class.
*
* @param Container $container The DI container.
*
* @return CompilerLanguage
* @since 3.2.0
*/
public function getCompilerLanguage(Container $container):
CompilerLanguage
{
return new CompilerLanguage(
$container->get('Config')
);
}
/**
* Get The Set Class.
*
* @param Container $container The DI container.
*
* @return Set
* @since 3.2.0
*/
public function getSet(Container $container): Set
{
return new Set(
$container->get('Config'),
$container->get('Language'),
$container->get('Compiler.Builder.Multilingual'),
$container->get('Compiler.Builder.Languages'),
$container->get('Language.Insert'),
$container->get('Language.Update')
);
}
/**
* Get The Purge Class.
*
* @param Container $container The DI container.
*
* @return Purge
* @since 5.0.2
*/
public function getPurge(Container $container): Purge
{
return new Purge(
$container->get('Language.Update')
);
}
/**
* Get The Insert Class.
*
* @param Container $container The DI container.
*
* @return Insert
* @since 5.0.2
*/
public function getInsert(Container $container): Insert
{
return new Insert();
}
/**
* Get The Update Class.
*
* @param Container $container The DI container.
*
* @return Update
* @since 5.0.2
*/
public function getUpdate(Container $container): Update
{
return new Update();
}
/**
* Get The Extractor Class.
*
* @param Container $container The DI container.
*
* @return Extractor
* @since 3.2.0
*/
public function getExtractor(Container $container): Extractor
{
return new Extractor(
$container->get('Config'),
$container->get('Language'),
$container->get('Placeholder')
);
}
/**
* Get The Fieldset Class.
*
* @param Container $container The DI container.
*
* @return Fieldset
* @since 3.2.0
*/
public function getFieldset(Container $container): Fieldset
{
return new Fieldset(
$container->get('Language'),
$container->get('Compiler.Builder.Meta.Data'),
$container->get('Compiler.Builder.Access.Switch'),
$container->get('Compiler.Builder.Access.Switch.List')
);
}
/**
* Get The Multilingual Class.
*
* @param Container $container The DI container.
*
* @return Multilingual
* @since 5.0.2
*/
public function getMultilingual(Container $container): Multilingual
{
return new Multilingual();
}
/**
* Get The Translation Class.
*
* @param Container $container The DI container.
*
* @return Translation
* @since 3.2.0
*/
public function getTranslation(Container $container): Translation
{
return new Translation(
$container->get('Config'),
$container->get('Compiler.Builder.Language.Messages')
);
}
}
src/Componentbuilder/Compiler/Service/Library.php000064400000004352151162054170016141
0ustar00<?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\Service;
use Joomla\DI\Container;
use Joomla\DI\ServiceProviderInterface;
use VDM\Joomla\Componentbuilder\Compiler\Library\Data;
use VDM\Joomla\Componentbuilder\Compiler\Library\Structure;
/**
* Compiler Library
*
* @since 3.2.0
*/
class Library implements ServiceProviderInterface
{
/**
* Registers the service provider with a DI container.
*
* @param Container $container The DI container.
*
* @return void
* @since 3.2.0
*/
public function register(Container $container)
{
$container->alias(Data::class, 'Library.Data')
->share('Library.Data', [$this, 'getData'],
true);
$container->alias(Structure::class, 'Library.Structure')
->share('Library.Structure', [$this,
'getStructure'], true);
}
/**
* Get the Compiler Library Data
*
* @param Container $container The DI container.
*
* @return Data
* @since 3.2.0
*/
public function getData(Container $container): Data
{
return new Data(
$container->get('Config'),
$container->get('Registry'),
$container->get('Customcode'),
$container->get('Customcode.Gui'),
$container->get('Field.Data'),
$container->get('Model.Filesfolders')
);
}
/**
* Get the Compiler Library Structure Builder
*
* @param Container $container The DI container.
*
* @return Structure
* @since 3.2.0
*/
public function getStructure(Container $container): Structure
{
return new Structure(
$container->get('Config'),
$container->get('Registry'),
$container->get('Event'),
$container->get('Component'),
$container->get('Compiler.Builder.Content.One'),
$container->get('Utilities.Counter'),
$container->get('Utilities.Paths'),
$container->get('Utilities.Folder'),
$container->get('Utilities.File')
);
}
}
src/Componentbuilder/Compiler/Service/Model.php000064400000060246151162054170015601
0ustar00<?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\Service;
use Joomla\DI\Container;
use Joomla\DI\ServiceProviderInterface;
use VDM\Joomla\Componentbuilder\Server\Model\Load as ServerLoad;
use VDM\Joomla\Componentbuilder\Compiler\Model\Joomlaplugins;
use VDM\Joomla\Componentbuilder\Compiler\Model\Joomlamodules;
use VDM\Joomla\Componentbuilder\Compiler\Model\Historycomponent;
use VDM\Joomla\Componentbuilder\Compiler\Model\Customadminviews;
use VDM\Joomla\Componentbuilder\Compiler\Model\Ajaxcustomview;
use VDM\Joomla\Componentbuilder\Compiler\Model\Javascriptcustomview;
use VDM\Joomla\Componentbuilder\Compiler\Model\Csscustomview;
use VDM\Joomla\Componentbuilder\Compiler\Model\Phpcustomview;
use VDM\Joomla\Componentbuilder\Compiler\Model\Dynamicget;
use VDM\Joomla\Componentbuilder\Compiler\Model\Libraries;
use VDM\Joomla\Componentbuilder\Compiler\Model\Siteviews;
use VDM\Joomla\Componentbuilder\Compiler\Model\Permissions;
use VDM\Joomla\Componentbuilder\Compiler\Model\Historyadminview;
use VDM\Joomla\Componentbuilder\Compiler\Model\Mysqlsettings;
use VDM\Joomla\Componentbuilder\Compiler\Model\Sql;
use VDM\Joomla\Componentbuilder\Compiler\Model\Customalias;
use VDM\Joomla\Componentbuilder\Compiler\Model\Ajaxadmin;
use VDM\Joomla\Componentbuilder\Compiler\Model\Customimportscripts;
use VDM\Joomla\Componentbuilder\Compiler\Model\Custombuttons;
use VDM\Joomla\Componentbuilder\Compiler\Model\Loader;
use VDM\Joomla\Componentbuilder\Compiler\Model\Phpadminview;
use VDM\Joomla\Componentbuilder\Compiler\Model\Cssadminview;
use VDM\Joomla\Componentbuilder\Compiler\Model\Javascriptadminview;
use VDM\Joomla\Componentbuilder\Compiler\Model\Linkedviews;
use VDM\Joomla\Componentbuilder\Compiler\Model\Relations;
use VDM\Joomla\Componentbuilder\Compiler\Model\Conditions;
use VDM\Joomla\Componentbuilder\Compiler\Model\Fields;
use VDM\Joomla\Componentbuilder\Compiler\Model\Updatesql;
use VDM\Joomla\Componentbuilder\Compiler\Model\Tabs;
use
VDM\Joomla\Componentbuilder\Compiler\Interfaces\Model\CustomtabsInterface
as Customtabs;
use VDM\Joomla\Componentbuilder\Compiler\Model\JoomlaThree\Customtabs as
CustomtabsJ3;
use VDM\Joomla\Componentbuilder\Compiler\Model\JoomlaFour\Customtabs as
CustomtabsJ4;
use VDM\Joomla\Componentbuilder\Compiler\Model\JoomlaFive\Customtabs as
CustomtabsJ5;
use VDM\Joomla\Componentbuilder\Compiler\Model\Adminviews;
use VDM\Joomla\Componentbuilder\Compiler\Model\Sqltweaking;
use VDM\Joomla\Componentbuilder\Compiler\Model\Sqldump;
use VDM\Joomla\Componentbuilder\Compiler\Model\Whmcs;
use VDM\Joomla\Componentbuilder\Compiler\Model\Filesfolders;
use VDM\Joomla\Componentbuilder\Compiler\Model\Modifieddate;
use VDM\Joomla\Componentbuilder\Compiler\Model\Createdate;
use VDM\Joomla\Componentbuilder\Compiler\Model\Router;
use VDM\Joomla\Componentbuilder\Compiler\Model\Updateserver;
/**
* Model Service Provider
*
* @since 3.2.0
*/
class Model implements ServiceProviderInterface
{
/**
* Current Joomla Version Being Build
*
* @var int
* @since 3.2.0
**/
protected $targetVersion;
/**
* Registers the service provider with a DI container.
*
* @param Container $container The DI container.
*
* @return void
* @since 3.2.0
*/
public function register(Container $container)
{
$container->alias(ServerLoad::class, 'Model.Server.Load')
->share('Model.Server.Load', [$this,
'getServerLoad'], true);
$container->alias(Joomlaplugins::class,
'Model.Joomlaplugins')
->share('Model.Joomlaplugins', [$this,
'getJoomlaplugins'], true);
$container->alias(Joomlamodules::class,
'Model.Joomlamodules')
->share('Model.Joomlamodules', [$this,
'getJoomlamodules'], true);
$container->alias(Historycomponent::class,
'Model.Historycomponent')
->share('Model.Historycomponent', [$this,
'getHistorycomponent'], true);
$container->alias(Customadminviews::class,
'Model.Customadminviews')
->share('Model.Customadminviews', [$this,
'getCustomadminviews'], true);
$container->alias(Ajaxcustomview::class,
'Model.Ajaxcustomview')
->share('Model.Ajaxcustomview', [$this,
'getAjaxcustomview'], true);
$container->alias(Javascriptcustomview::class,
'Model.Javascriptcustomview')
->share('Model.Javascriptcustomview', [$this,
'getJavascriptcustomview'], true);
$container->alias(Csscustomview::class,
'Model.Csscustomview')
->share('Model.Csscustomview', [$this,
'getCsscustomview'], true);
$container->alias(Phpcustomview::class,
'Model.Phpcustomview')
->share('Model.Phpcustomview', [$this,
'getPhpcustomview'], true);
$container->alias(Dynamicget::class, 'Model.Dynamicget')
->share('Model.Dynamicget', [$this,
'getDynamicget'], true);
$container->alias(Libraries::class, 'Model.Libraries')
->share('Model.Libraries', [$this,
'getLibraries'], true);
$container->alias(Siteviews::class, 'Model.Siteviews')
->share('Model.Siteviews', [$this,
'getSiteviews'], true);
$container->alias(Permissions::class, 'Model.Permissions')
->share('Model.Permissions', [$this,
'getPermissions'], true);
$container->alias(Historyadminview::class,
'Model.Historyadminview')
->share('Model.Historyadminview', [$this,
'getHistoryadminview'], true);
$container->alias(Mysqlsettings::class,
'Model.Mysqlsettings')
->share('Model.Mysqlsettings', [$this,
'getMysqlsettings'], true);
$container->alias(Sql::class, 'Model.Sql')
->share('Model.Sql', [$this, 'getSql'], true);
$container->alias(Customalias::class, 'Model.Customalias')
->share('Model.Customalias', [$this,
'getCustomalias'], true);
$container->alias(Ajaxadmin::class, 'Model.Ajaxadmin')
->share('Model.Ajaxadmin', [$this,
'getAjaxadmin'], true);
$container->alias(Customimportscripts::class,
'Model.Customimportscripts')
->share('Model.Customimportscripts', [$this,
'getCustomimportscripts'], true);
$container->alias(Custombuttons::class,
'Model.Custombuttons')
->share('Model.Custombuttons', [$this,
'getCustombuttons'], true);
$container->alias(Loader::class, 'Model.Loader')
->share('Model.Loader', [$this, 'getLoader'],
true);
$container->alias(Phpadminview::class,
'Model.Phpadminview')
->share('Model.Phpadminview', [$this,
'getPhpadminview'], true);
$container->alias(Cssadminview::class,
'Model.Cssadminview')
->share('Model.Cssadminview', [$this,
'getCssadminview'], true);
$container->alias(Javascriptadminview::class,
'Model.Javascriptadminview')
->share('Model.Javascriptadminview', [$this,
'getJavascriptadminview'], true);
$container->alias(Linkedviews::class, 'Model.Linkedviews')
->share('Model.Linkedviews', [$this,
'getLinkedviews'], true);
$container->alias(Relations::class, 'Model.Relations')
->share('Model.Relations', [$this,
'getRelations'], true);
$container->alias(Conditions::class, 'Model.Conditions')
->share('Model.Conditions', [$this,
'getConditions'], true);
$container->alias(Fields::class, 'Model.Fields')
->share('Model.Fields', [$this, 'getFields'],
true);
$container->alias(Updatesql::class, 'Model.Updatesql')
->share('Model.Updatesql', [$this,
'getUpdatesql'], true);
$container->alias(Tabs::class, 'Model.Tabs')
->share('Model.Tabs', [$this, 'getTabs'], true);
$container->alias(Customtabs::class, 'Model.Customtabs')
->share('Model.Customtabs', [$this,
'getCustomtabs'], true);
$container->alias(CustomtabsJ3::class,
'Model.J3.Customtabs')
->share('Model.J3.Customtabs', [$this,
'getCustomtabsJ3'], true);
$container->alias(CustomtabsJ4::class,
'Model.J4.Customtabs')
->share('Model.J4.Customtabs', [$this,
'getCustomtabsJ4'], true);
$container->alias(CustomtabsJ5::class,
'Model.J5.Customtabs')
->share('Model.J5.Customtabs', [$this,
'getCustomtabsJ5'], true);
$container->alias(Adminviews::class, 'Model.Adminviews')
->share('Model.Adminviews', [$this,
'getAdminviews'], true);
$container->alias(Sqltweaking::class, 'Model.Sqltweaking')
->share('Model.Sqltweaking', [$this,
'getSqltweaking'], true);
$container->alias(Sqldump::class, 'Model.Sqldump')
->share('Model.Sqldump', [$this, 'getSqldump'],
true);
$container->alias(Whmcs::class, 'Model.Whmcs')
->share('Model.Whmcs', [$this, 'getWhmcs'],
true);
$container->alias(Filesfolders::class,
'Model.Filesfolders')
->share('Model.Filesfolders', [$this,
'getFilesfolders'], true);
$container->alias(Modifieddate::class,
'Model.Modifieddate')
->share('Model.Modifieddate', [$this,
'getModifieddate'], true);
$container->alias(Createdate::class, 'Model.Createdate')
->share('Model.Createdate', [$this,
'getCreatedate'], true);
$container->alias(Router::class, 'Model.Router')
->share('Model.Router', [$this, 'getRouter'],
true);
$container->alias(Updateserver::class,
'Model.Updateserver')
->share('Model.Updateserver', [$this,
'getUpdateserver'], true);
}
/**
* Get The Load Class.
*
* @param Container $container The DI container.
*
* @return ServerLoad
* @since 3.2.0
*/
public function getServerLoad(Container $container): ServerLoad
{
return new ServerLoad(
$container->get('Crypt'),
$container->get('Table')
);
}
/**
* Get The Joomlaplugins Class.
*
* @param Container $container The DI container.
*
* @return Joomlaplugins
* @since 3.2.0
*/
public function getJoomlaplugins(Container $container): Joomlaplugins
{
return new Joomlaplugins(
$container->get('Joomlaplugin.Data')
);
}
/**
* Get The Joomlamodules Class.
*
* @param Container $container The DI container.
*
* @return Joomlamodules
* @since 3.2.0
*/
public function getJoomlamodules(Container $container): Joomlamodules
{
return new Joomlamodules(
$container->get('Joomlamodule.Data')
);
}
/**
* Get The Historycomponent Class.
*
* @param Container $container The DI container.
*
* @return Historycomponent
* @since 3.2.0
*/
public function getHistorycomponent(Container $container):
Historycomponent
{
return new Historycomponent(
$container->get('Config'),
$container->get('History'),
$container->get('Model.Updatesql')
);
}
/**
* Get The Customadminviews Class.
*
* @param Container $container The DI container.
*
* @return Customadminviews
* @since 3.2.0
*/
public function getCustomadminviews(Container $container):
Customadminviews
{
return new Customadminviews(
$container->get('Customview.Data'),
$container->get('Config')
);
}
/**
* Get The Ajaxcustomview Class.
*
* @param Container $container The DI container.
*
* @return Ajaxcustomview
* @since 3.2.0
*/
public function getAjaxcustomview(Container $container): Ajaxcustomview
{
return new Ajaxcustomview(
$container->get('Config'),
$container->get('Customcode.Dispenser')
);
}
/**
* Get The Javascriptcustomview Class.
*
* @param Container $container The DI container.
*
* @return Javascriptcustomview
* @since 3.2.0
*/
public function getJavascriptcustomview(Container $container):
Javascriptcustomview
{
return new Javascriptcustomview(
$container->get('Customcode'),
$container->get('Customcode.Gui')
);
}
/**
* Get The Csscustomview Class.
*
* @param Container $container The DI container.
*
* @return Csscustomview
* @since 3.2.0
*/
public function getCsscustomview(Container $container): Csscustomview
{
return new Csscustomview(
$container->get('Customcode')
);
}
/**
* Get The Phpcustomview Class.
*
* @param Container $container The DI container.
*
* @return Phpcustomview
* @since 3.2.0
*/
public function getPhpcustomview(Container $container): Phpcustomview
{
return new Phpcustomview(
$container->get('Customcode'),
$container->get('Customcode.Gui'),
$container->get('Model.Loader'),
$container->get('Templatelayout.Data')
);
}
/**
* Get The Dynamicget Class.
*
* @param Container $container The DI container.
*
* @return Dynamicget
* @since 3.2.0
*/
public function getDynamicget(Container $container): Dynamicget
{
return new Dynamicget(
$container->get('Config'),
$container->get('Compiler.Builder.Site.Dynamic.Get'),
$container->get('Compiler.Builder.Site.Main.Get'),
$container->get('Customcode'),
$container->get('Customcode.Gui'),
$container->get('Placeholder'),
$container->get('Dynamicget.Selection')
);
}
/**
* Get The Libraries Class.
*
* @param Container $container The DI container.
*
* @return Libraries
* @since 3.2.0
*/
public function getLibraries(Container $container): Libraries
{
return new Libraries(
$container->get('Config'),
$container->get('Compiler.Builder.Library.Manager'),
$container->get('Library.Data')
);
}
/**
* Get The Siteviews Class.
*
* @param Container $container The DI container.
*
* @return Siteviews
* @since 3.2.0
*/
public function getSiteviews(Container $container): Siteviews
{
return new Siteviews(
$container->get('Customview.Data'),
$container->get('Config')
);
}
/**
* Get The Permissions Class.
*
* @param Container $container The DI container.
*
* @return Permissions
* @since 3.2.0
*/
public function getPermissions(Container $container): Permissions
{
return new Permissions();
}
/**
* Get The Historyadminview Class.
*
* @param Container $container The DI container.
*
* @return Historyadminview
* @since 3.2.0
*/
public function getHistoryadminview(Container $container):
Historyadminview
{
return new Historyadminview(
$container->get('Config'),
$container->get('History'),
$container->get('Model.Updatesql')
);
}
/**
* Get The Mysqlsettings Class.
*
* @param Container $container The DI container.
*
* @return Mysqlsettings
* @since 3.2.0
*/
public function getMysqlsettings(Container $container): Mysqlsettings
{
return new Mysqlsettings(
$container->get('Config'),
$container->get('Compiler.Builder.Mysql.Table.Setting')
);
}
/**
* Get The Sql Class.
*
* @param Container $container The DI container.
*
* @return Sql
* @since 3.2.0
*/
public function getSql(Container $container): Sql
{
return new Sql(
$container->get('Customcode.Dispenser'),
$container->get('Model.Sqldump')
);
}
/**
* Get The Customalias Class.
*
* @param Container $container The DI container.
*
* @return Customalias
* @since 3.2.0
*/
public function getCustomalias(Container $container): Customalias
{
return new Customalias(
$container->get('Compiler.Builder.Custom.Alias'),
$container->get('Field.Name')
);
}
/**
* Get The Ajaxadmin Class.
*
* @param Container $container The DI container.
*
* @return Ajaxadmin
* @since 3.2.0
*/
public function getAjaxadmin(Container $container): Ajaxadmin
{
return new Ajaxadmin(
$container->get('Config'),
$container->get('Compiler.Builder.Site.Edit.View'),
$container->get('Customcode.Dispenser')
);
}
/**
* Get The Customimportscripts Class.
*
* @param Container $container The DI container.
*
* @return Customimportscripts
* @since 3.2.0
*/
public function getCustomimportscripts(Container $container):
Customimportscripts
{
return new Customimportscripts(
$container->get('Customcode.Dispenser')
);
}
/**
* Get The Custombuttons Class.
*
* @param Container $container The DI container.
*
* @return Custombuttons
* @since 3.2.0
*/
public function getCustombuttons(Container $container): Custombuttons
{
return new Custombuttons(
$container->get('Customcode'),
$container->get('Customcode.Gui'),
$container->get('Templatelayout.Data')
);
}
/**
* Get The Loader Class.
*
* @param Container $container The DI container.
*
* @return Loader
* @since 3.2.0
*/
public function getLoader(Container $container): Loader
{
return new Loader(
$container->get('Config'),
$container->get('Compiler.Builder.Footable.Scripts'),
$container->get('Compiler.Builder.Google.Chart'),
$container->get('Compiler.Builder.Get.Module'),
$container->get('Compiler.Builder.Uikit.Comp')
);
}
/**
* Get The Phpadminview Class.
*
* @param Container $container The DI container.
*
* @return Phpadminview
* @since 3.2.0
*/
public function getPhpadminview(Container $container): Phpadminview
{
return new Phpadminview(
$container->get('Customcode.Dispenser'),
$container->get('Templatelayout.Data')
);
}
/**
* Get The Cssadminview Class.
*
* @param Container $container The DI container.
*
* @return Cssadminview
* @since 3.2.0
*/
public function getCssadminview(Container $container): Cssadminview
{
return new Cssadminview(
$container->get('Customcode.Dispenser')
);
}
/**
* Get The Javascriptadminview Class.
*
* @param Container $container The DI container.
*
* @return Javascriptadminview
* @since 3.2.0
*/
public function getJavascriptadminview(Container $container):
Javascriptadminview
{
return new Javascriptadminview(
$container->get('Customcode.Dispenser')
);
}
/**
* Get The Linkedviews Class.
*
* @param Container $container The DI container.
*
* @return Linkedviews
* @since 3.2.0
*/
public function getLinkedviews(Container $container): Linkedviews
{
return new Linkedviews(
$container->get('Registry')
);
}
/**
* Get The Relations Class.
*
* @param Container $container The DI container.
*
* @return Relations
* @since 3.2.0
*/
public function getRelations(Container $container): Relations
{
return new Relations(
$container->get('Config'),
$container->get('Language'),
$container->get('Customcode'),
$container->get('Compiler.Builder.List.Join'),
$container->get('Compiler.Builder.List.Head.Override'),
$container->get('Compiler.Builder.Field.Relations')
);
}
/**
* Get The Conditions Class.
*
* @param Container $container The DI container.
*
* @return Conditions
* @since 3.2.0
*/
public function getConditions(Container $container): Conditions
{
return new Conditions(
$container->get('Field.Type.Name'),
$container->get('Field.Name'),
$container->get('Field.Groups')
);
}
/**
* Get The Fields Class.
*
* @param Container $container The DI container.
*
* @return Fields
* @since 3.2.0
*/
public function getFields(Container $container): Fields
{
return new Fields(
$container->get('Config'),
$container->get('Registry'),
$container->get('History'),
$container->get('Customcode'),
$container->get('Field'),
$container->get('Field.Name'),
$container->get('Field.Groups'),
$container->get('Model.Updatesql')
);
}
/**
* Get The Updatesql Class.
*
* @param Container $container The DI container.
*
* @return Updatesql
* @since 3.2.0
*/
public function getUpdatesql(Container $container): Updatesql
{
return new Updatesql(
$container->get('Registry')
);
}
/**
* Get The Tabs Class.
*
* @param Container $container The DI container.
*
* @return Tabs
* @since 3.2.0
*/
public function getTabs(Container $container): Tabs
{
return new Tabs();
}
/**
* Get The Customtabs Class.
*
* @param Container $container The DI container.
*
* @return Customtabs
* @since 3.2.0
*/
public function getCustomtabs(Container $container): Customtabs
{
if (empty($this->targetVersion))
{
$this->targetVersion =
$container->get('Config')->joomla_version;
}
return $container->get('Model.J' . $this->targetVersion .
'.Customtabs');
}
/**
* Get The CustomtabsJ3 Class.
*
* @param Container $container The DI container.
*
* @return CustomtabsJ3
* @since 3.2.0
*/
public function getCustomtabsJ3(Container $container): CustomtabsJ3
{
return new CustomtabsJ3(
$container->get('Config'),
$container->get('Compiler.Builder.Custom.Tabs'),
$container->get('Language'),
$container->get('Placeholder'),
$container->get('Customcode')
);
}
/**
* Get The CustomtabsJ4 Class.
*
* @param Container $container The DI container.
*
* @return CustomtabsJ4
* @since 3.2.0
*/
public function getCustomtabsJ4(Container $container): CustomtabsJ4
{
return new CustomtabsJ4(
$container->get('Config'),
$container->get('Compiler.Builder.Custom.Tabs'),
$container->get('Language'),
$container->get('Placeholder'),
$container->get('Customcode')
);
}
/**
* Get The CustomtabsJ5 Class.
*
* @param Container $container The DI container.
*
* @return CustomtabsJ5
* @since 3.2.0
*/
public function getCustomtabsJ5(Container $container): CustomtabsJ5
{
return new CustomtabsJ5(
$container->get('Config'),
$container->get('Compiler.Builder.Custom.Tabs'),
$container->get('Language'),
$container->get('Placeholder'),
$container->get('Customcode')
);
}
/**
* Get The Adminviews Class.
*
* @param Container $container The DI container.
*
* @return Adminviews
* @since 3.2.0
*/
public function getAdminviews(Container $container): Adminviews
{
return new Adminviews(
$container->get('Config'),
$container->get('Adminview.Data'),
$container->get('Compiler.Builder.Site.Edit.View'),
$container->get('Compiler.Builder.Admin.Filter.Type')
);
}
/**
* Get The Sqltweaking Class.
*
* @param Container $container The DI container.
*
* @return Sqltweaking
* @since 3.2.0
*/
public function getSqltweaking(Container $container): Sqltweaking
{
return new Sqltweaking(
$container->get('Registry')
);
}
/**
* Get The Sqldump Class.
*
* @param Container $container The DI container.
*
* @return Sqldump
* @since 3.2.0
*/
public function getSqldump(Container $container): Sqldump
{
return new Sqldump(
$container->get('Registry')
);
}
/**
* Get The Whmcs Class.
*
* @param Container $container The DI container.
*
* @return Whmcs
* @since 3.2.0
*/
public function getWhmcs(Container $container): Whmcs
{
return new Whmcs();
}
/**
* Get The Filesfolders Class.
*
* @param Container $container The DI container.
*
* @return Filesfolders
* @since 3.2.0
*/
public function getFilesfolders(Container $container): Filesfolders
{
return new Filesfolders();
}
/**
* Get The Modifieddate Class.
*
* @param Container $container The DI container.
*
* @return Modifieddate
* @since 3.2.0
*/
public function getModifieddate(Container $container): Modifieddate
{
return new Modifieddate();
}
/**
* Get The Createdate Class.
*
* @param Container $container The DI container.
*
* @return Createdate
* @since 3.2.0
*/
public function getCreatedate(Container $container): Createdate
{
return new Createdate();
}
/**
* Get The Router Class.
*
* @param Container $container The DI container.
*
* @return Router
* @since 3.2.0
*/
public function getRouter(Container $container): Router
{
return new Router(
$container->get('Config'),
$container->get('Customcode.Dispenser'),
$container->get('Compiler.Builder.Router')
);
}
/**
* Get The Updateserver Class.
*
* @param Container $container The DI container.
*
* @return Updateserver
* @since 3.2.0
*/
public function getUpdateserver(Container $container): Updateserver
{
return new Updateserver();
}
}
src/Componentbuilder/Compiler/Service/Placeholder.php000064400000004076151162054170016762
0ustar00<?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\Service;
use Joomla\DI\Container;
use Joomla\DI\ServiceProviderInterface;
use VDM\Joomla\Componentbuilder\Compiler\Placeholder as
CompilerPlaceholder;
use VDM\Joomla\Componentbuilder\Compiler\Placeholder\Reverse;
/**
* Compiler Placeholder Service Provider
*
* @since 3.2.0
*/
class Placeholder implements ServiceProviderInterface
{
/**
* Registers the service provider with a DI container.
*
* @param Container $container The DI container.
*
* @return void
* @since 3.2.0
*/
public function register(Container $container)
{
$container->alias(CompilerPlaceholder::class,
'Placeholder')
->share('Placeholder', [$this, 'getPlaceholder'],
true);
$container->alias(Reverse::class, 'Placeholder.Reverse')
->share('Placeholder.Reverse', [$this,
'getPlaceholderReverse'], true);
}
/**
* Get the Compiler Placeholder
*
* @param Container $container The DI container.
*
* @return CompilerPlaceholder
* @since 3.2.0
*/
public function getPlaceholder(Container $container): CompilerPlaceholder
{
return new CompilerPlaceholder(
$container->get('Config')
);
}
/**
* Get the Compiler Placeholder Reverse
*
* @param Container $container The DI container.
*
* @return Reverse
* @since 3.2.0
*/
public function getPlaceholderReverse(Container $container): Reverse
{
return new Reverse(
$container->get('Config'),
$container->get('Placeholder'),
$container->get('Language'),
$container->get('Language.Extractor'),
$container->get('Power.Extractor'),
$container->get('Joomla.Power.Extractor')
);
}
}
src/Componentbuilder/Compiler/Service/Power.php000064400000016171151162054170015633
0ustar00<?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\Service;
use Joomla\DI\Container;
use Joomla\DI\ServiceProviderInterface;
use VDM\Joomla\Componentbuilder\Compiler\Power as Powers;
use VDM\Joomla\Componentbuilder\Power\Remote\Get;
use VDM\Joomla\Componentbuilder\Power\Grep;
use VDM\Joomla\Componentbuilder\Compiler\Power\Autoloader;
use VDM\Joomla\Componentbuilder\Compiler\Power\Infusion;
use VDM\Joomla\Componentbuilder\Compiler\Power\Structure;
use VDM\Joomla\Componentbuilder\Power\Parser;
use VDM\Joomla\Componentbuilder\Power\Plantuml;
use VDM\Joomla\Componentbuilder\Power\Readme\Item as ItemReadme;
use VDM\Joomla\Componentbuilder\Power\Readme\Main as MainReadme;
use VDM\Joomla\Componentbuilder\Compiler\Power\Extractor;
use VDM\Joomla\Componentbuilder\Compiler\Power\Injector;
/**
* Compiler Power Service Provider
*
* @since 3.2.0
*/
class Power implements ServiceProviderInterface
{
/**
* Registers the service provider with a DI container.
*
* @param Container $container The DI container.
*
* @return void
* @since 3.2.0
*/
public function register(Container $container)
{
$container->alias(Powers::class, 'Power')
->share('Power', [$this, 'getPowers'], true);
$container->alias(Get::class, 'Power.Remote.Get')
->share('Power.Remote.Get', [$this,
'getRemoteGet'], true);
$container->alias(Grep::class, 'Power.Grep')
->share('Power.Grep', [$this, 'getGrep'], true);
$container->alias(Autoloader::class, 'Power.Autoloader')
->share('Power.Autoloader', [$this,
'getAutoloader'], true);
$container->alias(Infusion::class, 'Power.Infusion')
->share('Power.Infusion', [$this, 'getInfusion'],
true);
$container->alias(Structure::class, 'Power.Structure')
->share('Power.Structure', [$this,
'getStructure'], true);
$container->alias(Parser::class, 'Power.Parser')
->share('Power.Parser', [$this, 'getParser'],
true);
$container->alias(Plantuml::class, 'Power.Plantuml')
->share('Power.Plantuml', [$this, 'getPlantuml'],
true);
$container->alias(ItemReadme::class, 'Power.Readme.Item')
->share('Power.Readme.Item', [$this,
'getItemReadme'], true);
$container->alias(MainReadme::class, 'Power.Readme.Main')
->share('Power.Readme.Main', [$this,
'getMainReadme'], true);
$container->alias(Extractor::class, 'Power.Extractor')
->share('Power.Extractor', [$this,
'getExtractor'], true);
$container->alias(Injector::class, 'Power.Injector')
->share('Power.Injector', [$this, 'getInjector'],
true);
}
/**
* Get The Power Class.
*
* @param Container $container The DI container.
*
* @return Powers
* @since 3.2.0
*/
public function getPowers(Container $container): Powers
{
return new Powers(
$container->get('Config'),
$container->get('Placeholder'),
$container->get('Customcode'),
$container->get('Customcode.Gui'),
$container->get('Power.Remote.Get')
);
}
/**
* Get The Remote Get Class.
*
* @param Container $container The DI container.
*
* @return Get
* @since 3.2.0
*/
public function getRemoteGet(Container $container): Get
{
return new Get(
$container->get('Power.Grep'),
$container->get('Data.Item')
);
}
/**
* Get The Grep Class.
*
* @param Container $container The DI container.
*
* @return Grep
* @since 3.2.0
*/
public function getGrep(Container $container): Grep
{
return new Grep(
$container->get('Gitea.Repository.Contents'),
$container->get('Config')->approved_paths,
$container->get('Config')->local_powers_repository_path
);
}
/**
* Get The Autoloader Class.
*
* @param Container $container The DI container.
*
* @return Autoloader
* @since 3.2.0
*/
public function getAutoloader(Container $container): Autoloader
{
return new Autoloader(
$container->get('Power'),
$container->get('Config'),
$container->get('Compiler.Builder.Content.One')
);
}
/**
* Get The Infusion Class.
*
* @param Container $container The DI container.
*
* @return Infusion
* @since 3.2.0
*/
public function getInfusion(Container $container): Infusion
{
return new Infusion(
$container->get('Config'),
$container->get('Power'),
$container->get('Compiler.Builder.Content.One'),
$container->get('Compiler.Builder.Content.Multi'),
$container->get('Power.Parser'),
$container->get('Power.Readme.Item'),
$container->get('Power.Readme.Main'),
$container->get('Placeholder'),
$container->get('Event')
);
}
/**
* Get The Structure Class.
*
* @param Container $container The DI container.
*
* @return Structure
* @since 3.2.0
*/
public function getStructure(Container $container): Structure
{
return new Structure(
$container->get('Power'),
$container->get('Config'),
$container->get('Registry'),
$container->get('Event'),
$container->get('Utilities.Counter'),
$container->get('Utilities.Paths'),
$container->get('Utilities.Folder'),
$container->get('Utilities.File'),
$container->get('Utilities.Files')
);
}
/**
* Get The Parser Class.
*
* @param Container $container The DI container.
*
* @return Parser
* @since 3.2.0
*/
public function getParser(Container $container): Parser
{
return new Parser();
}
/**
* Get The Plantuml Class.
*
* @param Container $container The DI container.
*
* @return Plantuml
* @since 3.2.0
*/
public function getPlantuml(Container $container): Plantuml
{
return new Plantuml();
}
/**
* Get The Readme Class.
*
* @param Container $container The DI container.
*
* @return ItemReadme
* @since 3.2.0
*/
public function getItemReadme(Container $container): ItemReadme
{
return new ItemReadme(
$container->get('Power.Plantuml')
);
}
/**
* Get The Readme Class.
*
* @param Container $container The DI container.
*
* @return MainReadme
* @since 3.2.0
*/
public function getMainReadme(Container $container): MainReadme
{
return new MainReadme();
}
/**
* Get The Extractor Class.
*
* @param Container $container The DI container.
*
* @return Extractor
* @since 3.2.0
*/
public function getExtractor(Container $container): Extractor
{
return new Extractor();
}
/**
* Get The Injector Class.
*
* @param Container $container The DI container.
*
* @return Injector
* @since 3.2.0
*/
public function getInjector(Container $container): Injector
{
return new Injector(
$container->get('Power'),
$container->get('Power.Extractor'),
$container->get('Power.Parser'),
$container->get('Placeholder')
);
}
}
src/Componentbuilder/Compiler/Service/Templatelayout.php000064400000004242151162054170017544
0ustar00<?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\Service;
use Joomla\DI\Container;
use Joomla\DI\ServiceProviderInterface;
use VDM\Joomla\Componentbuilder\Compiler\Templatelayout\Data as
TemplatelayoutData;
use VDM\Joomla\Componentbuilder\Compiler\Alias\Data as AliasData;
/**
* Compiler Templatelayout
*
* @since 3.2.0
*/
class Templatelayout implements ServiceProviderInterface
{
/**
* Registers the service provider with a DI container.
*
* @param Container $container The DI container.
*
* @return void
* @since 3.2.0
*/
public function register(Container $container)
{
$container->alias(TemplatelayoutData::class,
'Templatelayout.Data')
->share('Templatelayout.Data', [$this,
'getTemplatelayoutData'], true);
$container->alias(AliasData::class, 'Alias.Data')
->share('Alias.Data', [$this, 'getAliasData'],
true);
}
/**
* Get The Data Class.
*
* @param Container $container The DI container.
*
* @return TemplatelayoutData
* @since 3.2.0
*/
public function getTemplatelayoutData(Container $container):
TemplatelayoutData
{
return new TemplatelayoutData(
$container->get('Config'),
$container->get('Compiler.Builder.Layout.Data'),
$container->get('Compiler.Builder.Template.Data'),
$container->get('Alias.Data')
);
}
/**
* Get The Data Class.
*
* @param Container $container The DI container.
*
* @return AliasData
* @since 3.2.0
*/
public function getAliasData(Container $container): AliasData
{
return new AliasData(
$container->get('Config'),
$container->get('Registry'),
$container->get('Customcode'),
$container->get('Customcode.Gui'),
$container->get('Model.Loader'),
$container->get('Model.Libraries')
);
}
}
src/Componentbuilder/Compiler/Service/Utilities.php000064400000014341151162054170016507
0ustar00<?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\Service;
use Joomla\DI\Container;
use Joomla\DI\ServiceProviderInterface;
use VDM\Joomla\Componentbuilder\Compiler\Config;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Folder;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\File;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\FileInjector;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Paths;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Counter;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Files;
use VDM\Joomla\Componentbuilder\Utilities\Constantpaths;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Dynamicpath;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Pathfix;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Structure;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Xml;
/**
* Utilities Service Provider
*
* @since 3.2.0
*/
class Utilities implements ServiceProviderInterface
{
/**
* Registers the service provider with a DI container.
*
* @param Container $container The DI container.
*
* @return void
* @since 3.2.0
*/
public function register(Container $container)
{
$container->alias(Folder::class, 'Utilities.Folder')
->share('Utilities.Folder', [$this, 'getFolder'],
true);
$container->alias(File::class, 'Utilities.File')
->share('Utilities.File', [$this, 'getFile'],
true);
$container->alias(FileInjector::class,
'Utilities.FileInjector')
->share('Utilities.FileInjector', [$this,
'getFileInjector'], true);
$container->alias(Counter::class, 'Utilities.Counter')
->share('Utilities.Counter', [$this,
'getCounter'], true);
$container->alias(Paths::class, 'Utilities.Paths')
->share('Utilities.Paths', [$this, 'getPaths'],
true);
$container->alias(Files::class, 'Utilities.Files')
->share('Utilities.Files', [$this, 'getFiles'],
true);
$container->alias(Constantpaths::class,
'Utilities.Constantpaths')
->share('Utilities.Constantpaths', [$this,
'getConstantpaths'], true);
$container->alias(Dynamicpath::class,
'Utilities.Dynamicpath')
->share('Utilities.Dynamicpath', [$this,
'getDynamicpath'], true);
$container->alias(Pathfix::class, 'Utilities.Pathfix')
->share('Utilities.Pathfix', [$this,
'getPathfix'], true);
$container->alias(Structure::class, 'Utilities.Structure')
->share('Utilities.Structure', [$this,
'getStructure'], true);
$container->alias(Xml::class, 'Utilities.Xml')
->share('Utilities.Xml', [$this, 'getXml'],
true);
}
/**
* Get the Compiler Folder
*
* @param Container $container The DI container.
*
* @return Folder
* @since 3.2.0
*/
public function getFolder(Container $container): Folder
{
return new Folder(
$container->get('Utilities.Counter'),
$container->get('Utilities.File')
);
}
/**
* Get the Compiler File
*
* @param Container $container The DI container.
*
* @return File
* @since 3.2.0
*/
public function getFile(Container $container): File
{
return new File(
$container->get('Utilities.Counter')
);
}
/**
* Get The FileInjector Class.
*
* @param Container $container The DI container.
*
* @return FileInjector
* @since 3.2.0
*/
public function getFileInjector(Container $container): FileInjector
{
return new FileInjector(
$container->get('Power.Injector'),
$container->get('Joomla.Power.Injector')
);
}
/**
* Get the Compiler Counter
*
* @param Container $container The DI container.
*
* @return Counter
* @since 3.2.0
*/
public function getCounter(Container $container): Counter
{
return new Counter(
$container->get('Compiler.Builder.Content.One')
);
}
/**
* Get the Compiler Paths
*
* @param Container $container The DI container.
*
* @return Paths
* @since 3.2.0
*/
public function getPaths(Container $container): Paths
{
return new Paths(
$container->get('Config'),
$container->get('Component')
);
}
/**
* Get the Compiler Files Bucket
*
* @param Container $container The DI container.
*
* @return Files
* @since 3.2.0
*/
public function getFiles(Container $container): Files
{
return new Files();
}
/**
* Get the Constant Paths
*
* @param Container $container The DI container.
*
* @return Constantpaths
* @since 3.2.0
*/
public function getConstantpaths(Container $container): Constantpaths
{
return new Constantpaths();
}
/**
* Get the Compiler Dynamic Path
*
* @param Container $container The DI container.
*
* @return Dynamicpath
* @since 3.2.0
*/
public function getDynamicpath(Container $container): Dynamicpath
{
return new Dynamicpath(
$container->get('Placeholder'),
$container->get('Utilities.Constantpaths')
);
}
/**
* Get the Compiler Path Fixer
*
* @param Container $container The DI container.
*
* @return Pathfix
* @since 3.2.0
*/
public function getPathfix(Container $container): Pathfix
{
return new Pathfix();
}
/**
* Get the Compiler Structure Dynamic Builder
*
* @param Container $container The DI container.
*
* @return Structure
* @since 3.2.0
*/
public function getStructure(Container $container): Structure
{
return new Structure(
$container->get('Placeholder'),
$container->get('Component.Settings'),
$container->get('Utilities.Paths'),
$container->get('Utilities.Counter'),
$container->get('Utilities.File'),
$container->get('Utilities.Files')
);
}
/**
* Get the Compiler Xml Helper
*
* @param Container $container The DI container.
*
* @return Xml
* @since 3.2.0
*/
public function getXml(Container $container): Xml
{
return new Xml(
$container->get('Config')
);
}
}
src/Componentbuilder/Compiler/Service/index.html000064400000000054151162054170016014
0ustar00<html><body
bgcolor="#FFFFFF"></body></html>src/Componentbuilder/Compiler/Templatelayout/Data.php000064400000015130151162054170017013
0ustar00<?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\Templatelayout;
use VDM\Joomla\Componentbuilder\Compiler\Config;
use VDM\Joomla\Componentbuilder\Compiler\Builder\LayoutData;
use VDM\Joomla\Componentbuilder\Compiler\Builder\TemplateData;
use VDM\Joomla\Componentbuilder\Compiler\Alias\Data as Aliasdata;
use VDM\Joomla\Utilities\ArrayHelper;
use VDM\Joomla\Utilities\GetHelper;
/**
* Template Layout Data Class
*
* @since 3.2.0
*/
class Data
{
/**
* The Config Class.
*
* @var Config
* @since 3.2.0
*/
protected Config $config;
/**
* The LayoutData Class.
*
* @var LayoutData
* @since 3.2.0
*/
protected LayoutData $layoutdata;
/**
* The TemplateData Class.
*
* @var TemplateData
* @since 3.2.0
*/
protected TemplateData $templatedata;
/**
* The Data Class.
*
* @var Aliasdata
* @since 3.2.0
*/
protected Aliasdata $aliasdata;
/**
* Constructor.
*
* @param Config $config The Config Class.
* @param LayoutData $layoutdata The LayoutData Class.
* @param TemplateData $templatedata The TemplateData Class.
* @param Aliasdata $aliasdata The AliasData Class.
*
* @since 3.2.0
*/
public function __construct(Config $config, LayoutData $layoutdata,
TemplateData $templatedata, Aliasdata $aliasdata)
{
$this->config = $config;
$this->layoutdata = $layoutdata;
$this->templatedata = $templatedata;
$this->aliasdata = $aliasdata;
}
/**
* Set Template and Layout Data
*
* @param string $content The content to check
* @param string $view The view code name
* @param bool $found The proof that something was found
* @param array $templates The option to pass templates keys (to
avoid search)
* @param array $layouts The option to pass layout keys (to avoid
search)
*
* @return bool if something was found true
* @since 3.2.0
*/
public function set(string $content, string $view, bool $found = false,
array $templates = [], array $layouts = []): bool
{
// to check inside the templates
$again = [];
// check if template keys were passed
if (!ArrayHelper::check($templates))
{
// set the Template data
$temp1 = GetHelper::allBetween(
$content, "\$this->loadTemplate('",
"')"
);
$temp2 = GetHelper::allBetween(
$content, '$this->loadTemplate("',
'")'
);
if (ArrayHelper::check($temp1)
&& ArrayHelper::check($temp2))
{
$templates = array_merge($temp1, $temp2);
}
else
{
if (ArrayHelper::check($temp1))
{
$templates = $temp1;
}
elseif (ArrayHelper::check($temp2))
{
$templates = $temp2;
}
}
}
// check if we found templates
if (ArrayHelper::check($templates, true))
{
foreach ($templates as $template)
{
if (!$this->templatedata->
exists($this->config->build_target . '.' . $view .
'.' . $template))
{
$data = $this->aliasdata->get(
$template, 'template', $view
);
if (ArrayHelper::check($data))
{
// load it to the template data array
$this->templatedata->
set($this->config->build_target . '.' . $view .
'.' . $template, $data);
// call self to get child data
$again[] = ['content' => $data['html'],
'view' => $view];
$again[] = ['content' => $data['php_view'],
'view' => $view];
}
}
// check if we have the template set (and nothing yet found)
if (!$found && $this->templatedata->
exists($this->config->build_target . '.' . $view .
'.' . $template, null))
{
// something was found
$found = true;
}
}
}
// check if layout keys were passed
if (!ArrayHelper::check($layouts))
{
$layout_bucket = [];
// set the Layout data
if (($layouts_found = GetHelper::allBetween(
$content, "LayoutHelper::render('", "',"
)) !== null)
{
$layout_bucket[] = $layouts_found;
}
if (($layouts_found = GetHelper::allBetween(
$content, 'LayoutHelper::render("', '",'
)) !== null)
{
$layout_bucket[] = $layouts_found;
}
// set the Layout data
if (($layouts_found = GetHelper::allBetween(
$content, "Joomla__" .
"_7ab82272_0b3d_4bb1_af35_e63a096cfe0b___Power::render('",
"',"
)) !== null)
{
$layout_bucket[] = $layouts_found;
}
if (($layouts_found = GetHelper::allBetween(
$content, 'Joomla__' .
'_7ab82272_0b3d_4bb1_af35_e63a096cfe0b___Power::render("',
'",'
)) !== null)
{
$layout_bucket[] = $layouts_found;
}
// Flatten and merge all collected layouts if any
if ($layout_bucket !== [])
{
$layouts = array_merge($layouts, ...$layout_bucket);
}
}
// check if we found layouts
if (ArrayHelper::check($layouts, true))
{
// get the other target if both
$_target = null;
if ($this->config->lang_target === 'both')
{
$_target = ($this->config->build_target === 'admin') ?
'site' : 'admin';
}
foreach ($layouts as $layout)
{
if (!$this->layoutdata->exists($this->config->build_target
. '.' . $layout))
{
$data = $this->aliasdata->get($layout, 'layout',
$view);
if (ArrayHelper::check($data))
{
// load it to the layout data array
$this->layoutdata->
set($this->config->build_target . '.' . $layout,
$data);
// check if other target is set
if ($this->config->lang_target === 'both' &&
$_target)
{
$this->layoutdata->set($_target . '.' . $layout,
$data);
}
// call self to get child data
$again[] = ['content' => $data['html'],
'view' => $view];
$again[] = ['content' => $data['php_view'],
'view' => $view];
}
}
// check if we have the layout set (and nothing yet found)
if (!$found &&
$this->layoutdata->exists($this->config->build_target .
'.' . $layout))
{
// something was found
$found = true;
}
}
}
// check again
if (ArrayHelper::check($again))
{
foreach ($again as $go)
{
$found = $this->set(
$go['content'], $go['view'], $found
);
}
}
// return the proof that something was found
return $found;
}
}
src/Componentbuilder/Compiler/Templatelayout/index.html000064400000000054151162054170017425
0ustar00<html><body
bgcolor="#FFFFFF"></body></html>src/Componentbuilder/Compiler/Utilities/Counter.php000064400000021602151162054170016524
0ustar00<?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\Utilities;
use VDM\Joomla\Componentbuilder\Compiler\Builder\ContentOne as Content;
/**
* Compiler Utilities Counter
*
* @since 3.2.0
*/
class Counter
{
/**
* The folder counter
*
* @var int
* @since 3.2.0
*/
public int $folder = 0;
/**
* The file counter
*
* @var int
* @since 3.2.0
*/
public int $file = 0;
/**
* The page counter
*
* @var int
* @since 3.2.0
*/
public int $page = 0;
/**
* The line counter
*
* @var int
* @since 3.2.0
*/
public int $line = 0;
/**
* The field counter
*
* @var int
* @since 3.2.0
*/
public int $field = 0;
/**
* The access size
*
* @var int
* @since 3.2.0
*/
public int $accessSize = 0;
/**
* The seconds counter
*
* @var int
* @since 3.2.0
*/
protected int $seconds = 0;
/**
* The actual seconds counter
*
* @var float
* @since 3.2.0
*/
protected float $actualSeconds = 0;
/**
* The folder seconds counter
*
* @var int
* @since 3.2.0
*/
protected int $folderSeconds = 0;
/**
* The file seconds counter
*
* @var int
* @since 3.2.0
*/
protected int $fileSeconds = 0;
/**
* The line seconds counter
*
* @var int
* @since 3.2.0
*/
protected int $lineSeconds = 0;
/**
* The seconds debugging counter
*
* @var float
* @since 3.2.0
*/
protected float $secondsDebugging = 0;
/**
* The seconds planning counter
*
* @var float
* @since 3.2.0
*/
protected float $secondsPlanning = 0;
/**
* The seconds mapping counter
*
* @var float
* @since 3.2.0
*/
protected float $secondsMapping = 0;
/**
* The seconds office counter
*
* @var float
* @since 3.2.0
*/
protected float $secondsOffice = 0;
/**
* The total hours counter
*
* @var int
* @since 3.2.0
*/
protected int $totalHours = 0;
/**
* The debugging hours counter
*
* @var int
* @since 3.2.0
*/
protected int $debuggingHours = 0;
/**
* The planning hours counter
*
* @var int
* @since 3.2.0
*/
protected int $planningHours = 0;
/**
* The mapping hours counter
*
* @var int
* @since 3.2.0
*/
protected int $mappingHours = 0;
/**
* The office hours counter
*
* @var int
* @since 3.2.0
*/
protected int $officeHours = 0;
/**
* The actual Total Hours counter
*
* @var int
* @since 3.2.0
*/
protected int $actualTotalHours = 0;
/**
* The actual hours spent counter
*
* @var int
* @since 3.2.0
*/
protected int $actualHoursSpent = 0;
/**
* The actual days spent counter
*
* @var int
* @since 3.2.0
*/
protected int $actualDaysSpent = 0;
/**
* The total days counter
*
* @var int
* @since 3.2.0
*/
protected int $totalDays = 0;
/**
* The actual Total Days counter
*
* @var int
* @since 3.2.0
*/
protected int $actualTotalDays = 0;
/**
* The project week time counter
*
* @var float
* @since 3.2.0
*/
protected float $projectWeekTime = 0;
/**
* The project month time counter
*
* @var float
* @since 3.2.0
*/
protected float $projectMonthTime = 0;
/**
* The compiler start timer
*
* @var float
* @since 3.2.0
*/
protected float $start = 0;
/**
* The compiler end timer
*
* @var float
* @since 3.2.0
*/
protected float $end = 0;
/**
* The compiler timer
*
* @var float
* @since 3.2.0
*/
protected float $timer = 0;
/**
* The ContentOne Class.
*
* @var Content
* @since 3.2.0
*/
protected Content $content;
/**
* Constructor.
*
* @param Content $content The ContentOne Class.
*
* @since 3.2.0
*/
public function __construct(Content $content)
{
$this->content = $content;
}
/**
* Start the timer
*
* @return void
* @since 3.2.0
*/
public function start()
{
$this->start = microtime(true);
}
/**
* End the timer
*
* @return void
* @since 3.2.0
*/
public function end()
{
$this->end = microtime(true);
// calculate the lenght
$this->timer = $this->end - $this->start;
// compiler time
$this->content->set('COMPILER_TIMER_END',
$this->end);
$this->content->set('COMPILER_TIMER', $this->timer);
}
/**
* Set all the time values
*
* @return void
* @since 3.2.0
*/
public function set()
{
// calculate all the values
$this->calculate();
// set some defaults
$this->content->set('LINE_COUNT', $this->line);
$this->content->set('FIELD_COUNT', $this->field);
$this->content->set('FILE_COUNT', $this->file);
$this->content->set('FOLDER_COUNT', $this->folder);
$this->content->set('PAGE_COUNT', $this->page);
$this->content->set('folders', $this->folderSeconds);
$this->content->set('foldersSeconds',
$this->folderSeconds);
$this->content->set('files', $this->fileSeconds);
$this->content->set('filesSeconds',
$this->fileSeconds);
$this->content->set('lines', $this->lineSeconds);
$this->content->set('linesSeconds',
$this->lineSeconds);
$this->content->set('seconds', $this->actualSeconds);
$this->content->set('actualSeconds',
$this->actualSeconds);
$this->content->set('totalHours', $this->totalHours);
$this->content->set('totalDays', $this->totalDays);
$this->content->set('debugging',
$this->secondsDebugging);
$this->content->set('secondsDebugging',
$this->secondsDebugging);
$this->content->set('planning',
$this->secondsPlanning);
$this->content->set('secondsPlanning',
$this->secondsPlanning);
$this->content->set('mapping',
$this->secondsMapping);
$this->content->set('secondsMapping',
$this->secondsMapping);
$this->content->set('office', $this->secondsOffice);
$this->content->set('secondsOffice',
$this->secondsOffice);
$this->content->set('actualTotalHours',
$this->actualTotalHours);
$this->content->set('actualTotalDays',
$this->actualTotalDays);
$this->content->set('debuggingHours',
$this->debuggingHours);
$this->content->set('planningHours',
$this->planningHours);
$this->content->set('mappingHours',
$this->mappingHours);
$this->content->set('officeHours',
$this->officeHours);
$this->content->set('actualHoursSpent',
$this->actualHoursSpent);
$this->content->set('actualDaysSpent',
$this->actualDaysSpent);
$this->content->set('projectWeekTime',
$this->projectWeekTime);
$this->content->set('projectMonthTime',
$this->projectMonthTime);
// compiler time
$this->content->set('COMPILER_TIMER_START',
$this->start);
}
/**
* Calculate all the time values
*
* @return void
* @since 3.2.0
*/
protected function calculate()
{
// what is the size in terms of an A4 book
$this->page = round($this->line / 56);
// setup the unrealistic numbers
$this->folderSeconds = $this->folder * 5;
$this->fileSeconds = $this->file * 5;
$this->lineSeconds = $this->line * 10;
$this->seconds = $this->folderSeconds +
$this->fileSeconds
+ $this->lineSeconds;
$this->totalHours = round($this->seconds / 3600);
$this->totalDays = round($this->totalHours / 8);
// setup the more realistic numbers
$this->secondsDebugging = $this->seconds / 4;
$this->secondsPlanning = $this->seconds / 7;
$this->secondsMapping = $this->seconds / 10;
$this->secondsOffice = $this->seconds / 6;
$this->actualSeconds = $this->folderSeconds +
$this->fileSeconds
+ $this->lineSeconds + $this->secondsDebugging
+ $this->secondsPlanning + $this->secondsMapping
+ $this->secondsOffice;
$this->actualTotalHours = round($this->actualSeconds / 3600);
$this->actualTotalDays = round($this->actualTotalHours / 8);
$this->debuggingHours = round($this->secondsDebugging / 3600);
$this->planningHours = round($this->secondsPlanning / 3600);
$this->mappingHours = round($this->secondsMapping / 3600);
$this->officeHours = round($this->secondsOffice / 3600);
// the actual time spent
$this->actualHoursSpent = $this->actualTotalHours -
$this->totalHours;
$this->actualDaysSpent = $this->actualTotalDays -
$this->totalDays;
// calculate the projects actual time frame of completion
$this->projectWeekTime = round($this->actualTotalDays / 5, 1);
$this->projectMonthTime = round($this->actualTotalDays / 24, 1);
}
}
src/Componentbuilder/Compiler/Utilities/Dynamicpath.php000064400000003421151162054170017345
0ustar00<?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\Utilities;
use VDM\Joomla\Componentbuilder\Compiler\Factory as Compiler;
use VDM\Joomla\Componentbuilder\Compiler\Placeholder;
use VDM\Joomla\Componentbuilder\Utilities\Constantpaths;
/**
* Compiler Utilities Dynamic Path
*
* @since 3.2.0
*/
class Dynamicpath
{
/**
* Compiler Placeholder
*
* @var Placeholder
* @since 3.2.0
**/
protected Placeholder $placeholder;
/**
* Constant Paths
*
* @var array
* @since 3.2.0
**/
protected array $paths;
/**
* Constructor.
*
* @param Placeholder|null $placeholder The Compiler Placeholder
object.
* @param Constantpaths|null $paths The Constant Paths
object.
*
* @since 3.2.0
*/
public function __construct(?Placeholder $placeholder = null,
?Constantpaths $paths = null)
{
$this->placeholder = $placeholder ?:
Compiler::_('Placeholder');
$paths = $paths ?: Compiler::_('Utilities.Constantpaths');
// load the constant paths
$this->paths = $paths->get();
}
/**
* Update path with dynamic value
*
* @param string $path The path to update
*
* @return string The updated path
* @since 3.2.0
*/
public function update(string $path): string
{
return $this->placeholder->update_(
$this->placeholder->update(
$path, $this->paths
)
);
}
}
src/Componentbuilder/Compiler/Utilities/FieldHelper.php000064400000002672151162054170017276
0ustar00<?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\Utilities;
use VDM\Joomla\Utilities\StringHelper;
use VDM\Joomla\Utilities\GetHelper;
use VDM\Joomla\Utilities\Base64Helper;
/**
* The Field Helper
*
* @since 3.2.0
*/
abstract class FieldHelper
{
/**
* Get a field value from the XML stored string
*
* @param string $xml The xml string of the field
* @param string $get The value key to get from the
string
* @param string $confirmation The value to confirm found value
*
* @return string The field value from xml
* @since 3.2.0
*/
public static function getValue(&$xml, string &$get, string
$confirmation = ''): string
{
if (StringHelper::check($xml))
{
// if we have a PHP value, we must base64 decode it
if (strpos($get, 'type_php') !== false)
{
return Base64Helper::open(GetHelper::between($xml, $get .
'="', '"', $confirmation));
}
return GetHelper::between($xml, $get . '="',
'"', $confirmation);
}
return $confirmation;
}
}
src/Componentbuilder/Compiler/Utilities/File.php000064400000004770151162054170015773
0ustar00<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September, 2020
* @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\Utilities;
use Joomla\CMS\Filesystem\File as JoomlaFile;
use VDM\Joomla\Componentbuilder\Compiler\Factory as Compiler;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Counter;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Paths;
use VDM\Joomla\Utilities\FileHelper;
/**
* File helper
*
* @since 3.2.0
*/
class File
{
/**
* Compiler Utilities Counter
*
* @var Counter
* @since 3.2.0
*/
protected Counter $counter;
/**
* Compiler Utilities Paths
*
* @var Paths
* @since 3.2.0
*/
protected Paths $paths;
/**
* Constructor
*
* @param Counter|null $counter The compiler counter object.
* @param Paths|null $paths The compiler paths object.
*
* @since 3.2.0
*/
public function __construct(?Counter $counter = null, ?Paths $paths =
null)
{
$this->counter = $counter ?:
Compiler::_('Utilities.Counter');
$this->paths = $paths ?: Compiler::_('Utilities.Paths');
}
/**
* set HTML blank file to a path
*
* @param string $path The path to where to set the blank html file
* @param string $root The root path
*
* @return void
*/
public function html(string $path = '', string $root =
'component')
{
if ('component' === $root)
{
$root = $this->paths->component_path . '/';
}
// use path if exist
if (strlen($path) > 0)
{
JoomlaFile::copy(
$this->paths->template_path . '/index.html',
$root . $path . '/index.html'
);
}
else
{
JoomlaFile::copy(
$this->paths->template_path . '/index.html',
$root . '/index.html'
);
}
// count the file created
$this->counter->file++;
}
/**
* Create a file on the server if it does not exist, or Overwrite existing
files
*
* @param string $path The path and file name where to safe the
data
* @param string $data The data to safe
*
* @return bool true On success
* @since 3.2.0
*/
public function write(string $path, string $data): bool
{
return FileHelper::write($path, $data);
}
}
src/Componentbuilder/Compiler/Utilities/FileInjector.php000064400000016242151162054170017466
0ustar00<?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\Utilities;
use VDM\Joomla\Componentbuilder\Compiler\Power\Injector as Power;
use VDM\Joomla\Componentbuilder\Compiler\JoomlaPower\Injector as
JoomlaPower;
use VDM\Joomla\Utilities\MathHelper;
/**
* File Injector
* Thanks to http://stackoverflow.com/a/16813550/1429677
*
* @since 3.2.0
*/
final class FileInjector
{
/**
* The Injector Class.
*
* @var Power
* @since 3.2.0
*/
protected Power $power;
/**
* The Joomla Injector Class.
*
* @var JoomlaPower
* @since 3.2.1
*/
protected JoomlaPower $joomla;
/**
* The power pattern to get the powers
*
* @var string
* @since 3.2.0
**/
protected string $powerPattern =
'/Super_'.'_'.'_[a-zA-Z0-9_]+_'.'_'.'_Power/';
/**
* The Joomla power pattern to get the powers
*
* @var string
* @since 3.2.1
**/
protected string $joomlaPattern =
'/Joomla_'.'_'.'_[a-zA-Z0-9_]+_'.'_'.'_Power/';
/**
* Constructor.
*
* @param Power $power The Injector Class.
* @param JoomlaPower $joomla The Joomla Injector Class.
*
* @since 3.2.1
*/
public function __construct(Power $power, JoomlaPower $joomla)
{
$this->power = $power;
$this->joomla = $joomla;
}
/**
* Inserts or replaces data in a file at a specific position.
*
* @param string $file The path of the file to modify.
* @param string $data The data to insert or replace.
* @param int $position The position in the file where the data
should be inserted or replaced.
* @param int|null $replace The number of bytes to replace; if null,
data will be inserted.
*
* @return void
* @throws \RuntimeException If unable to open or modify the file.
* @throws \InvalidArgumentException If the position is negative.
* @since 3.2.0
*/
public function add(string $file, string $data, int $position, ?int
$replace = null): void
{
if ($position < 0)
{
throw new \InvalidArgumentException('Position cannot be
negative.');
}
$found_joomla_powers = preg_match($this->joomlaPattern, $data);
$found_super_powers = preg_match($this->powerPattern, $data);
$actual_file = $this->openFileWithLock($file);
try
{
$temp_file = fopen('php://temp', "rw+");
if ($temp_file === false)
{
throw new \RuntimeException("Unable to open temporary
file.");
}
$this->processFile($actual_file, $temp_file, $data, $position,
$replace);
if ($found_joomla_powers)
{
$this->injectJoomlaPowers($actual_file);
}
if ($found_super_powers)
{
$this->injectSuperPowers($actual_file);
}
}
finally
{
flock($actual_file, LOCK_UN);
fclose($actual_file);
if (isset($temp_file))
{
fclose($temp_file);
}
}
}
/**
* Opens a file and acquires an exclusive lock on it.
*
* @param string $file The file path to open.
*
* @return resource The file handle.
* @throws \RuntimeException If the file cannot be opened or locked.
* @since 3.2.0
*/
private function openFileWithLock(string $file)
{
$actual_file = fopen($file, "rw+");
if ($actual_file === false || !flock($actual_file, LOCK_EX))
{
throw new \RuntimeException("Unable to open and lock the file:
{$file}");
}
return $actual_file;
}
/**
* Processes the file for data insertion and copying the remaining data.
*
* @param resource $actual_file The file handle of the actual file.
* @param resource $temp_file The file handle of the temporary file.
* @param string $data The data to be inserted.
* @param int $position The position in the file for the data
insertion.
* @param int|null $replace The number of bytes to replace; if null,
data will be inserted.
*
* @return void
* @since 3.2.0
*/
private function processFile($actual_file, $temp_file, string $data, int
$position, ?int $replace): void
{
// Make a copy of the file in the temporary stream
stream_copy_to_stream($actual_file, $temp_file);
// Move to the position where the data should be added
fseek($actual_file, $position);
// Add the data
fwrite($actual_file, $data);
$this->truncateIfNeeded($actual_file, $data, $position);
$this->copyRemainingData($actual_file, $temp_file, $position,
$replace);
}
/**
* Truncates the file after data insertion if necessary.
*
* @param resource $actual_file The file handle.
* @param string $data The data that was inserted.
* @param int $position The position where data was inserted.
*
* @return void
* @since 3.2.0
*/
private function truncateIfNeeded($actual_file, string $data, int
$position): void
{
// Truncate the file at the end of the added data if replacing
$data_length = mb_strlen($data, '8bit');
$remove = MathHelper::bc('add', $position, $data_length);
ftruncate($actual_file, $remove);
}
/**
* Copies the remaining data from the temporary stream to the actual
file.
*
* @param resource $actual_file The file handle of the actual file.
* @param resource $temp_file The file handle of the temporary file.
* @param int $position The position in the file where data
insertion finished.
* @param int|null $replace The number of bytes that were replaced;
if null, data was inserted.
*
* @return void
* @since 3.2.0
*/
private function copyRemainingData($actual_file, $temp_file, int
$position, ?int $replace): void
{
// check if this was a replacement of data
$position = MathHelper::bc('add', $position, $replace ?: 0);
// Move to the position of the remaining data in the temporary stream
fseek($temp_file, $position);
// Copy the remaining data from the temporary stream to the file
stream_copy_to_stream($temp_file, $actual_file);
}
/**
* Injects super powers into the file content, if found, and updates the
file.
*
* @param resource $actual_file The file handle of the actual file.
*
* @return void
* @since 3.2.0
*/
private function injectSuperPowers($actual_file): void
{
rewind($actual_file);
$power_data = $this->power->power(
stream_get_contents($actual_file)
);
ftruncate($actual_file, 0);
rewind($actual_file);
fwrite($actual_file, $power_data);
}
/**
* Injects Joomla powers into the file content, if found, and updates the
file.
*
* @param resource $actual_file The file handle of the actual file.
*
* @return void
* @since 3.2.1
*/
private function injectJoomlaPowers($actual_file): void
{
rewind($actual_file);
$power_data = $this->joomla->power(
stream_get_contents($actual_file)
);
ftruncate($actual_file, 0);
rewind($actual_file);
fwrite($actual_file, $power_data);
}
}
src/Componentbuilder/Compiler/Utilities/Files.php000064400000001166151162054170016152
0ustar00<?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\Utilities;
use VDM\Joomla\Componentbuilder\Abstraction\BaseRegistry;
/**
* Compiler Utilities Files Bucket
*
* @since 3.2.0
*/
class Files extends BaseRegistry
{
}
src/Componentbuilder/Compiler/Utilities/Folder.php000064400000007517151162054170016331
0ustar00<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September, 2020
* @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\Utilities;
use Joomla\CMS\Filesystem\Folder as JoomlaFolder;
use Joomla\CMS\Filesystem\File as JoomlaFile;
use VDM\Joomla\Componentbuilder\Compiler\Factory as Compiler;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Counter;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\File;
use VDM\Joomla\Utilities\ArrayHelper;
/**
* Folder helper
*
* @since 3.2.0
*/
class Folder
{
/**
* Compiler Counter
*
* @var Counter
* @since 3.2.0
*/
protected Counter $counter;
/**
* Compiler Utilities File
*
* @var File
* @since 3.2.0
*/
protected File $file;
/**
* Constructor
*
* @param Counter|null $counter The compiler counter object.
* @param File|null $file The compiler file object.
*
* @since 3.2.0
*/
public function __construct(?Counter $counter = null, ?File $file = null)
{
$this->counter = $counter ?:
Compiler::_('Utilities.Counter');
$this->file = $file ?: Compiler::_('Utilities.File');
}
/**
* Create Path if not exist
*
* @param string $path The path to folder to create
* @param bool $addHtml The the switch to add the HTML
*
* @return void
* @since 3.2.0
*/
public function create(string $path, bool $addHtml = true)
{
// check if the path exist
if (!JoomlaFolder::exists($path))
{
// create the path
JoomlaFolder::create(
$path
);
// count the folder created
$this->counter->folder++;
if ($addHtml)
{
// add index.html (boring I know)
$this->file->html(
$path, ''
);
}
}
}
/**
* Remove folders with files
*
* @param string $path The path to folder to remove
* @param array|null $ignore The folders and files to ignore and not
remove
*
* @return boolean True if all are removed
* @since 3.2.0
*/
public function remove(string $path, ?array $ignore = null): bool
{
if (!JoomlaFolder::exists($path))
{
return false;
}
$it = new \RecursiveDirectoryIterator($path,
\RecursiveDirectoryIterator::SKIP_DOTS);
$files = new \RecursiveIteratorIterator($it,
\RecursiveIteratorIterator::CHILD_FIRST);
// Prepare a base path without trailing slash for comparison
$basePath = rtrim($path, '/');
foreach ($files as $fileinfo)
{
$filePath = $fileinfo->getRealPath();
if ($this->shouldIgnore($basePath, $filePath, $ignore))
{
continue;
}
if ($fileinfo->isDir())
{
JoomlaFolder::delete($filePath);
}
else
{
JoomlaFile::delete($filePath);
}
}
// Delete the root folder if ignore not set
if (!ArrayHelper::check($ignore))
{
return JoomlaFolder::delete($path);
}
return true;
}
/**
* Check if the current path should be ignored.
*
* @param string $basePath The base directory path
* @param string $filePath The current file or directory path
* @param array|null $ignore List of items to ignore
*
* @return boolean True if the path should be ignored
* @since 3.2.0
*/
protected function shouldIgnore(string $basePath, string $filePath, ?array
$ignore = null): bool
{
if (!$ignore || !ArrayHelper::check($ignore))
{
return false;
}
foreach ($ignore as $item)
{
if (strpos($filePath, $basePath . '/' . $item) !== false)
{
return true;
}
}
return false;
}
}
src/Componentbuilder/Compiler/Utilities/Indent.php000064400000003275151162054170016334
0ustar00<?php
/**
* @package Joomla.Component.Builder
*
* @created 3rd 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\Utilities;
use VDM\Joomla\Componentbuilder\Compiler\Factory as Compiler;
/**
* The Indentation Factory
*
* @since 3.2.0
*/
abstract class Indent
{
/**
* Spacer bucket (to speed-up the build)
*
* @var array
* @since 3.2.0
*/
private static array $bucket = [];
/**
* The indentation string
*
* @var string
* @since 3.2.0
*/
private static string $indent;
/**
* Set the space
*
* @param int $nr The number of spaces
*
* @return string
* @since 3.2.0
*/
public static function _(int $nr): string
{
// check if we already have the string
if (!isset(self::$bucket[$nr]))
{
// get the string
self::$bucket[$nr] = str_repeat(self::indent(), (int) $nr);
}
// return stored indentation
return self::$bucket[$nr];
}
/**
* Get the indentation string
*
* @return string
* @since 3.2.0
*/
private static function indent(): string
{
if (empty(self::$indent))
{
self::init();
}
return self::$indent;
}
/**
* The constructor for indent
*
* @return void
* @since 3.2.0
*/
private static function init()
{
// the default is TAB
self::$indent = Compiler::_('Config')->indentation_value;
}
}
src/Componentbuilder/Compiler/Utilities/Line.php000064400000002703151162054170015775
0ustar00<?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\Utilities;
use VDM\Joomla\Componentbuilder\Compiler\Factory as Compiler;
/**
* The Debug Line Number Factory
*
* @since 3.2.0
*/
abstract class Line
{
/**
* Should we add debug lines
*
* @since 3.2.0
**/
private static $add = 'check';
/**
* Set the line number in comments
*
* @param int $nr The line number
* @param string $class The class name
*
* @return string
* @since 3.2.0
*/
public static function _(int $nr, string $class): string
{
if (self::add())
{
return ' [' . $class . ' ' . $nr . ']';
}
return '';
}
/**
* Check if we should add the line number
*
* @return bool
* @since 3.2.0
*/
private static function add(): bool
{
if (!is_bool(self::$add))
{
self::init();
}
return self::$add;
}
/**
* The constructor for add
*
* @return void
* @since 3.2.0
*/
private static function init()
{
self::$add = Compiler::_('Config')->debug_line_nr;
}
}
src/Componentbuilder/Compiler/Utilities/Minify.php000064400000003127151162054170016342
0ustar00<?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\Utilities;
use VDM\Minify\Css;
use VDM\Minify\JavaScript;
/**
* Compiler Minifier
*
* @since 3.2.0
*/
abstract class Minify
{
/**
* Minify JavaScript Class
*
* @var JavaScript
* @since 3.2.0
*/
public static JavaScript $js;
/**
* Minify Css Class
*
* @var Css
* @since 3.2.0
*/
public static Css $css;
/**
* Minify JavaScript
*
* @param string $data
*
* @return string
* @since 3.2.0
*/
public static function js(string $data): string
{
// check if instance already set
if (empty(self::$js))
{
// set instanceof on JavaScript
self::$js = new JavaScript;
}
// add the data
self::$js->add($data);
// return minified
return self::$js->minify();
}
/**
* Minify Css
*
* @param string $data
*
* @return string
* @since 3.2.0
*/
public static function css(string $data): string
{
// check if instance already set
if (empty(self::$css))
{
// set instanceof on Css
self::$css = new Css;
}
// add the data
self::$css->add($data);
// return minified
return self::$css->minify();
}
}
src/Componentbuilder/Compiler/Utilities/Pathfix.php000064400000003135151162054170016511
0ustar00<?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\Utilities;
use VDM\Joomla\Utilities\ArrayHelper;
use VDM\Joomla\Utilities\StringHelper;
/**
* Compiler Path Fix
*
* @since 3.2.0
*/
class Pathfix
{
/**
* Fix the path to work in the JCB script <-- (main issue here)
* Since we need / slash in all paths, for the JCB script even if it is
Windows
* and since MS works with both forward and back slashes
* we just convert all slashes to forward slashes
*
* THIS is just my hack (fix) if you know a better way! speak-up!
*
* @param mixed $values the array of paths or the path as a string
* @param array $targets paths to target
*
* @return void
* @since 3.2.0
*/
public function set(&$values, array $targets = [])
{
// if multiple to gets searched and fixed
if (ArrayHelper::check($values) && ArrayHelper::check($targets))
{
foreach ($targets as $target)
{
if (isset($values[$target]))
{
$this->set($values[$target], $targets);
}
}
}
// if just a string
elseif (StringHelper::check($values) && strpos((string) $values,
'\\') !== false)
{
$values = str_replace('\\', '/', (string) $values);
}
}
}
src/Componentbuilder/Compiler/Utilities/Paths.php000064400000010201151162054170016155
0ustar00<?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\Utilities;
use VDM\Joomla\Componentbuilder\Compiler\Config;
use VDM\Joomla\Componentbuilder\Compiler\Component;
use VDM\Joomla\Abstraction\Registry;
/**
* Compiler Utilities Paths
*
* @since 3.2.0
*/
class Paths extends Registry
{
/**
* Compiler Config
*
* @var Config
* @since 3.2.0
**/
protected Config $config;
/**
* Compiler Component
*
* @var Component
* @since 3.2.0
**/
protected Component $component;
/**
* Constructor
*
* @param Config $config The compiler config object.
* @param Component $component The component class.
*
* @since 3.2.0
*/
public function __construct(Config $config = null, Component $component =
null)
{
$this->config = $config;
$this->component = $component;
// set the template path
$this->setTemplatePath();
// set component sales name
$this->setComponentSalesName();
// set component backup name
$this->setComponentBackupName();
// set component folder name
$this->setComponentFolderName();
// set component path
$this->setComponentPath();
// set the template path for custom
$this->setTemplatePathCustom();
}
/**
* getting any valid paths
*
* @param string $key The value's key/path name
*
* @return string The path found as a string
* @since 3.2.0
* @throws \InvalidArgumentException If $key is not a valid function
name.
*/
public function __get(string $key): string
{
// check if it has been set
if ($this->exists($key))
{
return $this->get($key);
}
throw new \InvalidArgumentException(sprintf('Path %s could not be
found in the Paths Class.', $key));
}
/**
* Set the template path
*
* @return void
*
* @since 3.2.0
*/
private function setTemplatePath(): void
{
$this->set('template_path',
$this->config->get('compiler_path',
JPATH_COMPONENT_ADMINISTRATOR . '/compiler') .
'/joomla_'
.
$this->config->joomla_versions[$this->config->joomla_version]['folder_key']
);
}
/**
* Set component sales name
*
* @return void
*
* @since 3.2.0
*/
private function setComponentSalesName(): void
{
$this->set('component_sales_name',
'com_' . $this->component->get('sales_name') .
'__J'
. $this->config->joomla_version
);
}
/**
* Set component backup name
*
* @return void
*
* @since 3.2.0
*/
private function setComponentBackupName(): void
{
$this->set('component_backup_name',
'com_' . $this->component->get('sales_name') .
'_v' . str_replace(
'.', '_', (string)
$this->component->get('component_version')
) . '__J' . $this->config->joomla_version
);
}
/**
* Set component folder name
*
* @return void
*
* @since 3.2.0
*/
private function setComponentFolderName(): void
{
$this->set('component_folder_name',
'com_' . $this->component->get('name_code') .
'_v' . str_replace(
'.', '_', (string)
$this->component->get('component_version')
) . '__J' . $this->config->joomla_version
);
}
/**
* Set component path
*
* @return void
*
* @since 3.2.0
*/
private function setComponentPath(): void
{
$this->set('component_path',
$this->config->get('compiler_path',
JPATH_COMPONENT_ADMINISTRATOR . '/compiler') . '/'
. $this->get('component_folder_name')
);
}
/**
* set the template path for custom TODO: just use custom_folder_path in
config
*
* @return void
*
* @since 3.2.0
*/
private function setTemplatePathCustom(): void
{
$this->set('template_path_custom',
$this->config->get(
'custom_folder_path', JPATH_COMPONENT_ADMINISTRATOR .
'/custom'
)
);
}
}
src/Componentbuilder/Compiler/Utilities/Placefix.php000064400000003620151162054170016640
0ustar00<?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\Utilities;
/**
* The Placeholder Prefix and Suffix Factory
*
* @since 3.2.0
*/
abstract class Placefix
{
/**
* The hash prefix and suffix
*
* @var string
* @since 3.2.0
**/
private static string $hhh = '#' . '#' .
'#';
/**
* The open prefix
*
* @var string
* @since 3.2.0
**/
private static string $bbb = '[' . '[' .
'[';
/**
* The close suffix
*
* @var string
* @since 3.2.0
**/
private static string $ddd = ']' . ']' .
']';
/**
* Get a prefix and suffix added to given string
*
* @param string $class The class name
*
* @return string
* @since 3.2.0
*/
public static function _(string $string): string
{
return self::b() . $string . self::d();
}
/**
* Get a open prefix
*
* @return string
* @since 3.2.0
*/
public static function b(): string
{
return self::$bbb;
}
/**
* Get a close suffix
*
* @return string
* @since 3.2.0
*/
public static function d(): string
{
return self::$ddd;
}
/**
* Get a hash prefix and suffix added to given string
*
* @param string $class The class name
*
* @return string
* @since 3.2.0
*/
public static function _h(string $string): string
{
return self::h() . $string . self::h();
}
/**
* Get a hash-fix
*
* @return string
* @since 3.2.0
*/
public static function h(): string
{
return self::$hhh;
}
}
src/Componentbuilder/Compiler/Utilities/Structure.php000064400000020557151162054170017115
0ustar00<?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\Utilities;
use Joomla\CMS\Factory;
use Joomla\CMS\Application\CMSApplication;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Filesystem\File as JoomlaFile;
use Joomla\CMS\Filesystem\Folder;
use VDM\Joomla\Componentbuilder\Compiler\Placeholder;
use
VDM\Joomla\Componentbuilder\Compiler\Interfaces\Component\SettingsInterface
as Settings;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Paths;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Counter;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\File;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Files;
use VDM\Joomla\Utilities\ArrayHelper;
use VDM\Joomla\Utilities\StringHelper;
/**
* Compiler Utilities To Build Structure
*
* @since 3.2.0
*/
class Structure
{
/**
* The Placeholder Class.
*
* @var Placeholder
* @since 3.2.0
*/
protected Placeholder $placeholder;
/**
* The SettingsInterface Class.
*
* @var Settings
* @since 3.2.0
*/
protected Settings $settings;
/**
* The Paths Class.
*
* @var Paths
* @since 3.2.0
*/
protected Paths $paths;
/**
* The Counter Class.
*
* @var Counter
* @since 3.2.0
*/
protected Counter $counter;
/**
* The File Class.
*
* @var File
* @since 3.2.0
*/
protected File $file;
/**
* The Files Class.
*
* @var Files
* @since 3.2.0
*/
protected Files $files;
/**
* Database object to query local DB
*
* @var CMSApplication
* @since 3.2.0
**/
protected CMSApplication $app;
/**
* Constructor.
*
* @param Placeholder $placeholder The Placeholder Class.
* @param Settings $settings The SettingsInterface
Class.
* @param Paths $paths The Paths Class.
* @param Counter $counter The Counter Class.
* @param File $file The File Class.
* @param Files $files The Files Class.
* @param CMSApplication|null $app The CMS Application
object.
*
* @since 3.2.0
*/
public function __construct(Placeholder $placeholder, Settings $settings,
Paths $paths,
Counter $counter, File $file, Files $files, ?CMSApplication $app = null)
{
$this->placeholder = $placeholder;
$this->settings = $settings;
$this->paths = $paths;
$this->counter = $counter;
$this->file = $file;
$this->files = $files;
$this->app = $app ?: Factory::getApplication();
}
/**
* Build Structural Needed Files & Folders
*
* @param array $target The main target and name
* @param string $type The type in the target
* @param string|null $fileName The custom file name
* @param array|null $config To add more data to the files info
*
* @return bool true on success
* @since 3.2.0
*/
public function build(array $target, string $type,
?string $fileName = null, ?array $config = null): bool
{
// did we build the files (any number)
$build_status = false;
// check that we have the target values
if (ArrayHelper::check($target))
{
// search the target
foreach ($target as $main => $name)
{
// get the key name (either file name or name)
$key = $fileName ?? $name;
// add to placeholders as Name and name
$this->placeholder->set('Name',
StringHelper::safe($name, 'F'));
$this->placeholder->set('name',
StringHelper::safe($name));
$this->placeholder->set('Key', StringHelper::safe($key,
'F'));
$this->placeholder->set('key',
StringHelper::safe($key));
// make sure it is lower case
$name = StringHelper::safe($name);
// setup the files
foreach ($this->settings->multiple()->{$main} as $item =>
$details)
{
if ($details->type === $type)
{
$file_details = $this->getFileDetails(
$details,
(string) $item,
$name,
$fileName,
$config
);
if (is_array($file_details))
{
// store the new files
$this->files->appendArray('dynamic.' .
$file_details['view'],
$file_details);
// we have build at least one
$build_status = true;
}
}
}
// remove the name from placeholders
$this->placeholder->remove('Name');
$this->placeholder->remove('name');
$this->placeholder->remove('Key');
$this->placeholder->remove('key');
}
}
return $build_status;
}
/**
* Get the details
*
* @param object $details The item details
* @param string $item The item name
* @param string $name The given name
* @param string|null $fileName The custom file name
* @param array|null $config To add more data to the files info
*
* @return array|null The details
* @since 3.2.0
*/
private function getFileDetails(object $details, string $item,
string $name, ?string $fileName = null, ?array $config = null): ?array
{
$zip_path = '';
if (($path = $this->getPath($details, $zip_path, $name)) === null)
{
return null;
}
// setup the folder
if (!Folder::exists($path))
{
Folder::create($path);
$this->file->html($zip_path);
// count the folder created
$this->counter->folder++;
}
$new_name = $this->getNewName($details, $item, $name, $fileName);
if (!JoomlaFile::exists($path . '/' . $new_name))
{
// move the file to its place
JoomlaFile::copy(
$this->paths->template_path . '/' . $item,
$path . '/' . $new_name
);
// count the file created
$this->counter->file++;
}
// we can't have dots in a view name
if (strpos($name, '.') !== false)
{
$name = preg_replace('/[\.]+/', '_', (string)
$name);
}
// setup array for new file
$file = [
'path' => $path . '/' . $new_name,
'name' => $new_name,
'view' => $name,
'zip' => $zip_path . '/' . $new_name
];
if (ArrayHelper::check($config))
{
$file['config'] = $config;
}
return $file;
}
/**
* Get the path
*
* @param object $details The item details
* @param string $zipPath The zip path
* @param string $name The name
*
* @return string|null The path
* @since 3.2.0
*/
private function getPath(object $details, string &$zipPath, string
$name): ?string
{
// set destination path
if (strpos((string) $details->path, 'VIEW') !== false)
{
$path = str_replace('VIEW', $name, (string)
$details->path);
}
else
{
$path = $details->path;
}
$path = $this->placeholder->update_($path);
// make sure we have component to replace
if (strpos((string) $path, 'c0mp0n3nt') !== false)
{
$zipPath = str_replace('c0mp0n3nt/', '', (string)
$path);
return str_replace(
'c0mp0n3nt/', $this->paths->component_path .
'/', (string) $path
);
}
$this->app->enqueueMessage(
Text::sprintf('COM_COMPONENTBUILDER_HR_HTHREECZEROMPZERONTHREENT_ISSUE_FOUNDHTHREEPTHE_PATH_S_COULD_NOT_BE_USEDP',
$path
), 'Error'
);
return null;
}
/**
* Get the new name
*
* @param object $details The item details
* @param string $item The item name
* @param string $name The name
* @param string|null $fileName The custom file name
*
* @return string The new name
* @since 3.2.0
*/
private function getNewName(object $details, string $item,
string &$name, ?string $fileName = null): string
{
// do the file need renaming
if ($details->rename)
{
if (!empty($fileName))
{
$name = $name . '_' . $fileName;
}
if ($details->rename === 'new')
{
$item = $details->newName;
}
elseif (!empty($fileName))
{
$item = str_replace(
$details->rename, $fileName, $item
);
}
else
{
$item = str_replace(
$details->rename, $name, $item
);
}
}
return $this->placeholder->update_($item);
}
}
src/Componentbuilder/Compiler/Utilities/Unique.php000064400000003442151162054170016355
0ustar00<?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\Utilities;
/**
* Compiler Creating an Unique Code/String
*
* @since 3.2.0
*/
abstract class Unique
{
/**
* Unique Code/Strings
*
* @var array
* @since 3.2.0
*/
protected static array $unique = [];
/**
* Unique Areas Code/Strings
*
* @var array
* @since 3.2.0
*/
protected static array $areas = [];
/**
* Creating an unique local key
*
* @param int $size The key size
*
* @return string The unique local key
*
*/
public static function get($size): string
{
$unique = (isset(self::$unique[$size])) ? end(self::$unique[$size]) :
null;
if(!$unique)
{
$unique = substr("vvvvvvvvvvvvvvvvvvvvvvvvvvvvvv", 0, $size);
self::$unique[$size] = [];
}
while(in_array($unique, self::$unique[$size]))
{
$unique++;
}
self::$unique[$size][] = $unique;
return $unique;
}
/**
* Creating an Unique Code
*
* @param string $code
* @param string $target
*
* @return string
* @since 3.2.0
*/
public static function code(string $code, string $target =
'both'): string
{
if (!isset(self::$areas[$target])
|| !in_array(
$code, self::$areas[$target]
))
{
self::$areas[$target][] = $code;
return $code;
}
// make sure it is unique
return self::code($code . self::get(1));
}
}
src/Componentbuilder/Compiler/Utilities/Xml.php000064400000014147151162054170015653
0ustar00<?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\Utilities;
use Joomla\CMS\Factory;
use Joomla\CMS\Application\CMSApplication;
use Joomla\CMS\Language\Text;
use VDM\Joomla\Componentbuilder\Compiler\Factory as Compiler;
use VDM\Joomla\Componentbuilder\Compiler\Config;
use VDM\Joomla\Utilities\FormHelper;
/**
* Compiler Utilities Xml
*
* @since 3.2.0
*/
final class Xml
{
/**
* Compiler Config
*
* @var Config
* @since 3.2.0
*/
protected Config $config;
/**
* Application object.
*
* @var CMSApplication
* @since 3.2.0
**/
protected CMSApplication $app;
/**
* Constructor
*
* @param Config|null $config The compiler config object.
* @param CMSApplication|null $app The CMS Application object.
*
* @since 3.2.0
*/
public function __construct(?Config $config = null, ?CMSApplication $app =
null)
{
$this->config = $config ?: Compiler::_('Config');
$this->app = $app ?: Factory::getApplication();
}
/**
* get the field xml
*
* @param array $attributes The array of attributes
* @param array $options The options to apply to the XML
element
*
* @return \SimpleXMLElement|null
* @since 3.2.0
*/
public function get(array $attributes, ?array $options = null):
?\SimpleXMLElement
{
return FormHelper::xml($attributes, $options);
}
/**
* xmlAppend
*
* @param \SimpleXMLElement $xml The XML element reference in
which to inject a comment
* @param mixed $node A SimpleXMLElement node to append
to the XML element reference,
* or a stdClass object containing
a comment attribute to be injected
* before the XML node and a
fieldXML attribute containing a SimpleXMLElement
*
* @return void
* @since 3.2.0
*/
public function append(\SimpleXMLElement &$xml, $node)
{
FormHelper::append($xml, $node);
}
/**
* xmlComment
*
* @param \SimpleXMLElement $xml The XML element reference in
which to inject a comment
* @param string $comment The comment to inject
*
* @return void
* @since 3.2.0
*/
public function comment(\SimpleXMLElement &$xml, string $comment)
{
FormHelper::comment($xml, $comment);
}
/**
* xmlAddAttributes
*
* @param \SimpleXMLElement $xml The XML element reference in
which to inject a comment
* @param array $attributes The attributes to apply to
the XML element
*
* @return void
* @since 3.2.0
*/
public function attributes(\SimpleXMLElement &$xml, array $attributes
= [])
{
FormHelper::attributes($xml, $attributes);
}
/**
* xmlAddOptions
*
* @param \SimpleXMLElement $xml The XML element reference in
which to inject a comment
* @param array $options The options to apply to the
XML element
*
* @return void
* @since 3.2.0
*/
public function options(\SimpleXMLElement &$xml, array $options = [])
{
FormHelper::options($xml, $options);
}
/**
* XML Pretty Print
*
* @param \SimpleXMLElement $xml The XML element containing a
node to be output
* @param string $nodename node name of the input xml
element to print out. this is done to omit the <?xml... tag
*
* @return string XML output
* @since 3.2.0
*/
public function pretty(\SimpleXMLElement $xml, string $nodename): string
{
$dom = dom_import_simplexml($xml)->ownerDocument;
$dom->formatOutput = true;
$xmlString = $dom->saveXML(
$dom->getElementsByTagName($nodename)->item(0)
);
// make sure Tidy is enabled
if ($this->config->get('tidy', false))
{
$tidy = new \Tidy();
$tidy->parseString(
$xmlString, [
'indent' => true,
'indent-spaces' => 8,
'input-xml' => true,
'output-xml' => true,
'indent-attributes' => true,
'wrap-attributes' => true,
'wrap' => false
]
);
$tidy->cleanRepair();
return $this->indent((string) $tidy, ' ', 8, true, false);
}
// set tidy warning only once
elseif ($this->config->set_tidy_warning)
{
// set the warning only once
$this->config->set('set_tidy_warning', false);
// now set the warning
$this->app->enqueueMessage(
Text::_('COM_COMPONENTBUILDER_HR_HTHREETIDY_ERRORHTHREE'),
'Error'
);
$this->app->enqueueMessage(
Text::sprintf('COM_COMPONENTBUILDER_YOU_MUST_ENABLE_THE_BTIDYB_EXTENSION_IN_YOUR_PHPINI_FILE_SO_WE_CAN_TIDY_UP_YOUR_XML_IF_YOU_NEED_HELP_PLEASE_A_SSTART_HEREA',
'href="https://github.com/vdm-io/Joomla-Component-Builder/issues/197#issuecomment-351181754"
target="_blank"'), 'Error'
);
}
return $xmlString;
}
/**
* xmlIndent
*
* @param string $string The XML input
* @param string $char Character or characters to use as the
repeated indent
* @param int $depth number of times to repeat the indent
character
* @param bool $skipfirst Skip the first line of the input.
* @param bool $skiplast Skip the last line of the input;
*
* @return string XML output
* @since 3.2.0
*/
public function indent(string $string, string $char = ' ', int
$depth = 0,
bool $skipfirst = false, bool $skiplast = false): string
{
$output = array();
$lines = explode("\n", $string);
$first = true;
$last = count($lines) - 1;
foreach ($lines as $i => $line)
{
$output[] = (($first && $skipfirst) || $i === $last &&
$skiplast)
? $line : str_repeat($char, $depth) . $line;
$first = false;
}
return implode("\n", $output);
}
}
src/Componentbuilder/Compiler/Utilities/index.html000064400000000054151162054170016367
0ustar00<html><body
bgcolor="#FFFFFF"></body></html>src/Componentbuilder/Compiler/index.html000064400000000054151162054170014414
0ustar00<html><body
bgcolor="#FFFFFF"></body></html>src/Componentbuilder/Crypt.php000064400000014234151162054170012464
0ustar00<?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;
use VDM\Joomla\Componentbuilder\Crypt\FOF;
use VDM\Joomla\Componentbuilder\Crypt\Aes;
use VDM\Joomla\Componentbuilder\Crypt\Aes\Legacy;
use VDM\Joomla\Componentbuilder\Crypt\Password;
use VDM\Joomla\Componentbuilder\Interfaces\Cryptinterface;
use VDM\Joomla\Utilities\StringHelper;
/**
* Crypto Class
*
* @since 3.2.0
*/
class Crypt
{
/**
* The Crypt AES FOF class
* replacement class
*
* @var FOF
* @since 3.2.0
*/
protected FOF $fof;
/**
* The Crypt AES CBC class
*
* @var Aes
* @since 3.2.0
*/
protected Aes $aes;
/**
* The Crypt AES Legacy class
*
* @var Legacy
* @since 3.2.0
*/
protected Legacy $legacy;
/**
* The Password class
*
* @var Password
* @since 3.2.0
*/
protected Password $password;
/**
* Active encryption options
*
* @var array
* @since 3.2.0
*/
protected array $options = [
'basic' => 'fof',
'medium' => 'fof',
'local' => 'aes'
];
/**
* Active passwords
*
* @var array
* @since 3.2.0
*/
protected array $passwords = [];
/**
* Constructor
*
* @param FOF $fof The FOF class
* @param Aes $aes The AES CBC class
* @param Legacy $legacy The AES Legacy class
* @param Password $password The Password class
*
* @since 3.2.0
*/
public function __construct(FOF $fof, Aes $aes, Legacy $legacy, Password
$password)
{
$this->fof = $fof;
$this->aes = $aes;
$this->legacy = $legacy;
$this->password = $password;
}
/**
* Encrypt a string as needed
*
* @param string $string The string to encrypt
* @param string $method The encryption method to use
* @param string|null $password The password
*
* @return string
* @since 3.2.0
**/
public function encrypt(string $string, string $method,
?string $password = null): string
{
if (($password = $this->getPassword($method, $password)) !== null
&& ($name = $this->getClassName($method)) !== null)
{
return $this->{$name}->encrypt($string, $password);
}
return $string;
}
/**
* Decrypt a string as needed
*
* @param string $string The string to decrypt
* @param string $method The encryption method to use
* @param string|null $default The default password
*
* @return string|null
* @since 3.2.0
**/
public function decrypt(string $string, string $method,
?string $default = null): ?string
{
if (($password = $this->getPassword($method, $default)) !== null
&& ($name = $this->getClassName($method)) !== null)
{
return $this->{$name}->decrypt($string, $password);
}
return null;
}
/**
* Check if a decryption method exist and is supported
*
* @param string $method The encryption method to find
*
* @return bool true if it exist
* @since 3.2.0
**/
public function exist(string $method): bool
{
return is_string($this->getClassName($method)) ?? false;
}
/**
* Get crypto class name to use
*
* @param string $method The encryption method to find
*
* @return string|null The crypto class name
* @since 3.2.0
**/
private function getClassName(string $method): ?string
{
if (($name = $this->getClassNameFromRegistry($method)) !== null)
{
return $name;
}
return $this->getClassNameFromOptions($method);
}
/**
* Get the crypto class name from the registry
*
* @param string $method The encryption method to use
*
* @return string|null The crypto class name, or null if not found
* @since 3.2.0
**/
private function getClassNameFromRegistry(string $method): ?string
{
$name = $this->name($method);
if (isset($this->{$name}) && $this->{$name} instanceof
Cryptinterface)
{
return $name;
}
return null;
}
/**
* Get the crypto class name for the given encryption method and options
*
* @param string $method The encryption method to use
*
* @return string|null The crypto class name, or null if not found
* @since 3.2.0
**/
private function getClassNameFromOptions(string $method): ?string
{
$key = $this->getPasswordKey($method);
if (isset($this->options[$key]))
{
$name = $this->options[$key];
if (isset($this->{$name}) && $this->{$name} instanceof
Cryptinterface)
{
return $name;
}
}
return null;
}
/**
* Get the password
*
* @param string $method The encryption method to find
* @param string|null $password The password
*
* @return string|null the password or null
* @since 3.2.0
**/
private function getPassword(string $method, ?string $password = null):
?string
{
if (StringHelper::check($password))
{
return $password;
}
// get password key name
$key = $this->getPasswordKey($method);
if (empty($this->passwords[$key]))
{
$this->passwords[$key] = $this->password->get($key);
}
return $this->passwords[$key];
}
/**
* Get the key
*
* @param string $method The encryption method to find
*
* @return string the password key name
* @since 3.2.0
**/
private function getPasswordKey(string $method): string
{
if (($pos = strpos($method, '.')) !== false)
{
return substr($method, 0, $pos);
}
return $method;
}
/**
* Get the class name
*
* @param string $method The encryption method to find
*
* @return string the class name
* @since 3.2.0
**/
private function name(string $method): string
{
if (($pos = strpos($method, '.')) !== false)
{
return substr($method, $pos + 1);
}
return $method;
}
}
src/Componentbuilder/Crypt/Aes.php000064400000005671151162054170013201
0ustar00<?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\Crypt;
use phpseclib3\Crypt\AES as BASEAES;
use phpseclib3\Exception\BadDecryptionException;
use VDM\Joomla\Componentbuilder\Crypt\Random;
use VDM\Joomla\Componentbuilder\Interfaces\Cryptinterface;
/**
* Class for Aes Encryption
*
* @since 3.2.0
*/
class Aes implements Cryptinterface
{
/**
* The Aes class
*
* @var BASEAES
* @since 3.2.0
*/
protected BASEAES $aes;
/**
* The Random class
*
* @var Random
* @since 3.2.0
*/
protected Random $random;
/**
* The block size
*
* @var int
* @since 3.2.0
*/
protected int $size = 256;
/**
* Constructor
*
* @param BASEAES $aes The Aes class
* @param Random $random The Random class
*
* @since 3.2.0
*/
public function __construct(BASEAES $aes, Random $random)
{
$this->aes = $aes;
$this->random = $random;
// we set the length once
$this->aes->setKeyLength($this->size);
// enable padding
$this->aes->enablePadding();
}
/**
* Encrypt a string as needed
*
* @param string $string The string to encrypt
* @param string $key The encryption key
*
* @return string
* @since 3.2.0
**/
public function encrypt(string $string, string $key): string
{
// we get the IV length
$iv_length = (int) $this->aes->getBlockLength() >> 3;
// get the IV value
$iv = $this->random::string($iv_length);
// Load the IV
$this->aes->setIV($iv);
// set the password
$this->aes->setPassword($key, 'pbkdf2',
'sha256', 'VastDevelopmentMethod/salt');
// encrypt the string, and base 64 encode the result
return base64_encode($iv . $this->aes->encrypt($string));
}
/**
* Decrypt a string as needed
*
* @param string $string The string to decrypt
* @param string $key The decryption key
*
* @return string|null
* @since 3.2.0
**/
public function decrypt(string $string, string $key): ?string
{
// we get the IV length
$iv_length = (int) $this->aes->getBlockLength() >> 3;
// remove base 64 encoding
$string = base64_decode($string);
// get the IV
$iv = substr($string, 0, $iv_length);
// remove the IV
$string = substr($string, $iv_length);
// set the IV
$this->aes->setIV($iv);
// set the password
$this->aes->setPassword($key, 'pbkdf2',
'sha256', 'VastDevelopmentMethod/salt');
try {
return $this->aes->decrypt($string);
} catch (\Exception $ex) {
return null;
}
}
}
src/Componentbuilder/Crypt/Aes/Legacy.php000064400000005126151162054170014400
0ustar00<?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\Crypt\Aes;
use phpseclib3\Crypt\AES as BASEAES;
use VDM\Joomla\Componentbuilder\Interfaces\Cryptinterface;
/**
* Legacy Class for Aes Encryption
*
* @since 3.2.0
*/
class Legacy implements Cryptinterface
{
/**
* The Aes class
*
* @var BASEAES
* @since 3.2.0
*/
protected BASEAES $aes;
/**
* The block size
*
* @var int
* @since 3.2.0
*/
protected int $size = 128;
/**
* Constructor
*
* @param BASEAES $aes The Aes class
*
* @since 3.2.0
*/
public function __construct(BASEAES $aes)
{
$this->aes = $aes;
// we set the length once
$this->aes->setKeyLength($this->size);
// enable padding
$this->aes->enablePadding();
}
/**
* Encrypt a string as needed
*
* @param string $string The string to encrypt
* @param string $key The encryption key
*
* @return string
* @since 3.2.0
**/
public function encrypt(string $string, string $key): string
{
// we get the IV length
$iv_length = (int) $this->aes->getBlockLength() >> 3;
// get the IV value
$iv = str_repeat("\0", $iv_length);
// Load the IV
$this->aes->setIV($iv);
// set the password
$this->aes->setPassword($key, 'pbkdf2',
'sha256', 'VastDevelopmentMethod/salt');
// encrypt the string, and base 64 encode the result
return base64_encode($this->aes->encrypt($string));
}
/**
* Decrypt a string as needed
*
* @param string $string The string to decrypt
* @param string $key The decryption key
*
* @return string|null
* @since 3.2.0
**/
public function decrypt(string $string, string $key): ?string
{
// remove base 64 encoding
$string = base64_decode($string);
// we get the IV length
$iv_length = (int) $this->aes->getBlockLength() >> 3;
// get the IV value
$iv = str_repeat("\0", $iv_length);
// Load the IV
$this->aes->setIV($iv);
// set the password
$this->aes->setPassword($key, 'pbkdf2',
'sha256', 'VastDevelopmentMethod/salt');
try {
return $this->aes->decrypt($string);
} catch (\Exception $ex) {
return null;
}
}
}
src/Componentbuilder/Crypt/Aes/index.html000064400000000054151162054170014453
0ustar00<html><body
bgcolor="#FFFFFF"></body></html>src/Componentbuilder/Crypt/FOF.php000064400000002725151162054170013100
0ustar00<?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\Crypt;
use VDM\Joomla\FOF\Encrypt\AES;
use VDM\Joomla\Componentbuilder\Interfaces\Cryptinterface;
/**
* Temp Class for FOFEncryptAes
*
* @since 3.2.0
*/
class FOF implements Cryptinterface
{
/**
* Encrypt a string as needed
*
* @param string $string The string to encrypt
* @param string $key The encryption key
*
* @return string
* @since 3.2.0
**/
public function encrypt(string $string, string $key): string
{
// Get the encryption object.
$aes = new Aes($key, 128);
return $aes->decryptString($string);
}
/**
* Decrypt a string as needed
*
* @param string $string The string to decrypt
* @param string $key The decryption key
*
* @return string|null
* @since 3.2.0
**/
public function decrypt(string $string, string $key): ?string
{
// Get the encryption object.
$aes = new Aes($key, 128);
try {
return $aes->decryptString($string);
} catch (\Exception $ex) {
return null;
}
}
}
src/Componentbuilder/Crypt/KeyLoader.php000064400000001114151162054170014334
0ustar00<?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\Crypt;
use phpseclib3\Crypt\PublicKeyLoader;
/**
* KeyLoader Class
*
* @since 3.2.0
*/
class KeyLoader extends PublicKeyLoader
{
}
src/Componentbuilder/Crypt/Password.php000064400000002757151162054170014275
0ustar00<?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\Crypt;
use Joomla\CMS\Language\Text;
use VDM\Joomla\Utilities\Component\Helper;
/**
* Password Class
*
* @since 3.2.0
*/
class Password
{
/**
* Get the type of password
* Example: $this->get('basic',
'default-password');
*
* @param string $type The value of password to get
* @param string|null $default The default password if the type
is not found
*
* @return string|null
* @since 3.2.0
*/
public function get(string $type, ?string $default = null): ?string
{
// we have a local key for JCB only use
if ('local' === $type)
{
return $this->local();
}
elseif (($password = Helper::_('getCryptKey', [$type,
$default])) !== null)
{
return $password;
}
return $default;
}
/**
* Get the local password
*
* @return string
* @since 3.2.0
*/
private function local(): string
{
return base64_decode(
Text::sprintf(
'COM_COMPONENTBUILDER_VJRZDESSMHBTRWFIFTYTWVZEROAESFLVVXJTMTHREEJTWOIXM',
'QzdmV', '9kQ'
)
);
}
}
src/Componentbuilder/Crypt/Random.php000064400000001110151162054170013671
0ustar00<?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\Crypt;
use phpseclib3\Crypt\Random as CryptRandom;
/**
* Random Class
*
* @since 3.2.0
*/
class Random extends CryptRandom
{
}
src/Componentbuilder/Crypt/index.html000064400000000054151162054170013743
0ustar00<html><body
bgcolor="#FFFFFF"></body></html>src/Componentbuilder/Extrusion/Helper/Builder.php000064400000025053151162054170016171
0ustar00<?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\Extrusion\Helper;
use Joomla\CMS\Factory;
// use
VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper;
(for Joomla 4 and above)
use VDM\Joomla\Utilities\StringHelper;
use VDM\Joomla\Utilities\GetHelperExtrusion as GetHelper;
use VDM\Joomla\Componentbuilder\Extrusion\Helper\Mapping;
/**
* Builder class
*
* @since 3.2.0
*/
class Builder extends Mapping
{
/**
* Some default fields
*/
public $user;
public $today;
public array $views = [];
public array $admin_fields = [];
protected array $fields = [];
protected array $title = [];
protected array $description = [];
protected array $alias = [];
protected array $list = [];
/**
* Field that should not be used in name, alias, disc, and list view
* (TODO) We may need to set this dynamicly
*/
protected array $avoidList = ['not_required'];
/***
* Constructor
*/
public function __construct(&$data)
{
// first we run the perent constructor
if (parent::__construct($data))
{
// always reset the building values if found
$data['buildcomp'] = 0;
$data['buildcompsql'] = '';
// set some globals
$this->user = Factory::getUser();
$this->today = Factory::getDate()->toSql();
// no start the building of the views and fields
if ($this->setBuild())
{
return true;
}
}
return false;
}
/**
* The building function
* To build the views and fields that are needed
*/
protected function setBuild()
{
foreach ($this->map as $view => $fields)
{
// set this field with all its needed data
foreach ($fields as $field)
{
$this->setField($view, $field);
}
// set this view with all its needed data
$this->setView($view);
}
return true;
}
/**
* The building function for views
*/
protected function setView(string $name): bool
{
// set the view object
$object = new \stdClass();
$object->system_name = StringHelper::safe($name, 'W') .
' (dynamic build)';
$object->name_single = $name;
$object->name_list = $name. 's';
$object->short_description = $name. ' view (dynamic
build)';
$object->type = 1;
$object->description = $name. ' view (dynamic build)';
$object->add_fadein = 1;
$object->add_sql = (isset($this->addSql[$name])) ?
$this->addSql[$name]: 0;
$object->source = (isset($this->source[$name])) ?
$this->source[$name]: 0;
$object->sql = (isset($this->sql[$name])) ?
base64_encode($this->sql[$name]): '';
$object->addpermissions =
'{"action":["view.edit","view.edit.own","view.edit.state","view.create","view.delete","view.access"],"implementation":["3","3","3","3","3","3"]}';
$object->created = $this->today;
$object->created_by = $this->user->id;
$object->published = 1;
// empty values for sql sake
$object->addlinked_views = '';
$object->addtables = '';
$object->addtabs = '';
$object->ajax_input = '';
$object->css_view = '';
$object->css_views = '';
$object->custom_button = '';
$object->html_import_view = '';
$object->javascript_view_file = '';
$object->javascript_view_footer = '';
$object->javascript_views_file = '';
$object->javascript_views_footer = '';
$object->php_after_cancel = '';
$object->php_after_delete = '';
$object->php_after_publish = '';
$object->php_ajaxmethod = '';
$object->php_allowadd = '';
$object->php_allowedit = '';
$object->php_batchcopy = '';
$object->php_batchmove = '';
$object->php_before_cancel = '';
$object->php_before_delete = '';
$object->php_before_publish = '';
$object->php_before_save = '';
$object->php_controller = '';
$object->php_controller_list = '';
$object->php_document = '';
$object->php_getform = '';
$object->php_getitem = '';
$object->php_getitems = '';
$object->php_getitems_after_all = '';
$object->php_getlistquery = '';
$object->php_import = '';
$object->php_import_display = '';
$object->php_import_ext = '';
$object->php_import_headers = '';
$object->php_import_save = '';
$object->php_import_setdata = '';
$object->php_model = '';
$object->php_model_list = '';
$object->php_postsavehook = '';
$object->php_save = '';
// add to data base
if
($this->db->insertObject('#__componentbuilder_admin_view',
$object))
{
// make sure the access of asset is set
$id = $this->db->insertid();
\ComponentbuilderHelper::setAsset($id, 'admin_view');
// load the views
$this->views[] = $id;
// load the admin view fields
return $this->addFields($name, $id);
}
return false;
}
/**
* Add the fields to the view
*/
protected function addFields(string $view, int $view_id): bool
{
if (isset($this->fields[$view]))
{
// set some defaults
$addField = array ();
$fixLink = (isset($this->title[$view])) ? 0 : 1;
// build the field data... hmmm
foreach ($this->fields[$view] as $nr => $id)
{
$alignment = 1;
if ($nr % 2 == 0)
{
$alignment = 2;
}
// some defaults
$isTitle = (isset($this->title[$view]) &&
$this->title[$view] == $id) ? 1 : 0;
$isAlias = (isset($this->alias[$view]) &&
$this->alias[$view] == $id) ? 1 : 0;
$isList = ($key = array_search($id, $this->list[$view])) ? 1 : 0;
$isLink = ($isTitle) ? 1 : (($isList && $fixLink) ? 1 : 0);
if ($isLink)
{
$fixLink = 0;
}
// load the field values
$addField['addfields'.$nr]['field'] = $id;
$addField['addfields'.$nr]['list'] = $isList;
$addField['addfields'.$nr]['order_list'] = ($key) ?
$key : 0;
$addField['addfields'.$nr]['title'] = $isTitle;
$addField['addfields'.$nr]['alias'] = $isAlias;
$addField['addfields'.$nr]['sort'] = $isList;
$addField['addfields'.$nr]['search'] = $isList;
$addField['addfields'.$nr]['filter'] = $isList;
$addField['addfields'.$nr]['link'] = $isLink;
$addField['addfields'.$nr]['tab'] = 1;
$addField['addfields'.$nr]['alignment'] = ($isTitle
|| $isAlias) ? 4 : $alignment;
$addField['addfields'.$nr]['order_edit'] = $nr;
$addField['addfields'.$nr]['permission'] = 0;
}
// set the field object
$object = new \stdClass();
$object->admin_view = $view_id;
$object->addfields = json_encode($addField, JSON_FORCE_OBJECT);
$object->created = $this->today;
$object->created_by = $this->user->id;
$object->published = 1;
// add to data base
return
$this->db->insertObject('#__componentbuilder_admin_fields',
$object);
}
return false;
}
/**
* The building function for fields
*/
protected function setField(string $view, array $field): bool
{
if (($fieldType =
$this->getFieldTypeId($field['fieldType'])) !== null)
{
// set the field object
$object = new \stdClass();
$object->name = $field['label'] . ' (dynamic
build)';
$object->fieldtype = $fieldType;
$object->datatype = $field['dataType'];
$object->indexes = $field['key'];
$object->null_switch = $field['null'];
$object->datalenght = $field['size'];
$object->datalenght_other = $field['sizeOther'];
$object->datadefault = $field['default'];
$object->datadefault_other = $field['defaultOther'];
$object->created = $this->today;
$object->created_by = $this->user->id;
$object->published = 1;
$object->store = 0;
$object->xml = $this->setFieldXML($field, $fieldType);
// empty values for sql sake
$object->css_view = '';
$object->css_views = '';
$object->initiator_on_get_model = '';
$object->initiator_on_save_model = '';
$object->on_get_model_field = '';
$object->on_save_model_field = '';
$object->javascript_view_footer = '';
$object->javascript_views_footer = '';
// add to data base
if ($this->db->insertObject('#__componentbuilder_field',
$object))
{
// make sure the access of asset is set
$id = $this->db->insertid();
\ComponentbuilderHelper::setAsset($id, 'field');
// check if any field for this field was already set, if not set array
if (!isset($this->fields[$view]))
{
$this->fields[$view] = [];
}
// load the field
$this->fields[$view][] = $id;
if (!isset($this->list[$view]))
{
$this->list[$view] = [];
}
// insure that some fields are avoided
if (!in_array($field['name'], $this->avoidList))
{
// set the name/title field if found
if (!isset($this->title[$view]) &&
(stripos($field['name'], 'name') !== false ||
stripos($field['name'], 'title') !== false))
{
$this->title[$view] = $id;
$this->list[$view][] = $id;
}
// set the alias field if found
elseif (!isset($this->alias[$id]) &&
stripos($field['name'], 'alias') !== false)
{
$this->alias[$view] = $id;
}
// set the alias field if found
elseif (!isset($this->description[$id]) &&
stripos($field['name'], 'desc') !== false)
{
$this->description[$view] = $id;
$this->list[$view][] = $id;
}
elseif ('Text' == $field['fieldType'] &&
count($this->list[$view]) < 5)
{
$this->list[$view][] = $id;
}
}
return true;
}
}
return false;
}
/**
* get the field type id from system
*/
protected function getFieldTypeId(string $fieldTypeName): ?int
{
// load the field settings
if (($id = GetHelper::var('fieldtype', $fieldTypeName,
'name', 'id')) !== null)
{
return (int) $id;
}
return null;
}
/**
* The building function for field xml
*/
protected function setFieldXML(array $field, int $fieldId): string
{
// load the field settings
$settings = [];
$settings['name'] = $field['name'];
$settings['description'] = 'The
'.strtolower($field['label']) . ' is set here.';
$settings['message'] = "Error! Please add some
".strtolower($field['label'])." here.";
$settings['label'] = $field['label'];
$settings['default'] = ($field['default'] ==
'Other') ? $field['defaultOther'] :
$field['default'];
$settings['hint'] = $field['label'] .'
Here!';
// okay set the xml field values
if ($fieldOptions =
\ComponentbuilderHelper::getFieldTypeProperties($fieldId, 'id',
$settings))
{
return json_encode($fieldOptions['values']);
}
return '';
}
}
src/Componentbuilder/Extrusion/Helper/Extrusion.php000064400000006570151162054210016601
0ustar00<?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\Extrusion\Helper;
use Joomla\CMS\Language\Text;
use VDM\Joomla\Utilities\ArrayHelper;
use VDM\Joomla\Utilities\GetHelperExtrusion as GetHelper;
use VDM\Joomla\Componentbuilder\Extrusion\Helper\Builder;
/**
* Extrusion class
*
* @since 3.2.0
*/
class Extrusion extends Builder
{
/***
* Constructor
*/
public function __construct(&$data)
{
// first we run the perent constructor
if (parent::__construct($data))
{
// link the view data to the component
if ($this->setAdminViews($data['id']))
{
$this->app->enqueueMessage(
Text::_('COM_COMPONENTBUILDER_ALL_THE_FIELDS_AND_VIEWS_FROM_YOUR_SQL_DUMP_HAS_BEEN_CREATED_AND_LINKED_TO_THIS_COMPONENT'),
'Success'
);
return true;
}
}
return false;
}
/**
* link the build views to the component
*/
protected function setAdminViews(&$component_id)
{
// check if views were set
if (ArrayHelper::check($this->views))
{
$count = 0;
if (ArrayHelper::check($this->addadmin_views))
{
$count = (int) count((array)$this->addadmin_views) + 3;
}
// set the admin view data linking
foreach ($this->views as $nr => $id)
{
$pointer = $count + $nr;
$this->addadmin_views['addadmin_views'.$pointer]['adminview']
= $id;
$this->addadmin_views['addadmin_views'.$pointer]['icomoon']
= 'joomla';
$this->addadmin_views['addadmin_views'.$pointer]['mainmenu']
= 1;
$this->addadmin_views['addadmin_views'.$pointer]['dashboard_add']
= 1;
$this->addadmin_views['addadmin_views'.$pointer]['dashboard_list']
= 1;
$this->addadmin_views['addadmin_views'.$pointer]['submenu']
= 1;
$this->addadmin_views['addadmin_views'.$pointer]['checkin']
= 1;
$this->addadmin_views['addadmin_views'.$pointer]['history']
= 1;
$this->addadmin_views['addadmin_views'.$pointer]['metadata']
= 1;
$this->addadmin_views['addadmin_views'.$pointer]['access']
= 1;
$this->addadmin_views['addadmin_views'.$pointer]['port']
= 1;
$this->addadmin_views['addadmin_views'.$pointer]['edit_create_site_view']
= 0;
$this->addadmin_views['addadmin_views'.$pointer]['order']
= $pointer + 1;
}
}
if (isset($this->addadmin_views) &&
ArrayHelper::check($this->addadmin_views))
{
// set the field object
$object = new \stdClass();
$object->joomla_component = $component_id;
$object->addadmin_views = json_encode($this->addadmin_views,
JSON_FORCE_OBJECT);
$object->created = $this->today;
$object->created_by = $this->user->id;
$object->published = 1;
// check if it is already set
if ($item_id = GetHelper::var('component_admin_views',
$component_id, 'joomla_component', 'id'))
{
// set ID
$object->id = (int) $item_id;
return
$this->db->updateObject('#__componentbuilder_component_admin_views',
$object, 'id');
}
// add to data base
return
$this->db->insertObject('#__componentbuilder_component_admin_views',
$object);
}
return false;
}
}
src/Componentbuilder/Extrusion/Helper/Mapping.php000064400000034326151162054210016174
0ustar00<?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\Extrusion\Helper;
use Joomla\CMS\Factory;
use Joomla\CMS\Language\Text;
// use Joomla\Database\DatabaseDriver; (for Joomla 4 and above)
use VDM\Joomla\Utilities\StringHelper;
use VDM\Joomla\Utilities\JsonHelper;
use VDM\Joomla\Utilities\GetHelperExtrusion as GetHelper;
use VDM\Joomla\Utilities\ArrayHelper;
/**
* Mapping class
*
* @since 3.2.0
*/
class Mapping
{
/**
* Some default fields
*/
protected $buildcompsql;
public $id;
public $name_code;
public array $addadmin_views = [];
public array $addSql = [];
public array $source = [];
public array $sql = [];
/**
* The map of the needed fields and views
*/
public $map;
/**
* The app to load messages mostly
*/
public $app;
/**
* The database
*/
protected $db;
/**
* The needed set of keys needed to set
*/
protected array $setting = ['id' => 'default',
'buildcompsql' => 'base64', 'name_code'
=> 'safeString'];
/**
* The needed set of keys needed to set
*/
protected array $notRequired = [
'id', 'asset_id', 'published',
'created_by', 'modified_by', 'created',
'modified',
'checked_out','checked_out_time',
'version', 'hits', 'access',
'ordering',
'metakey', 'metadesc', 'metadata',
'params'
];
/**
* The datatypes and it linked field types (basic)
* (TODO) We may need to set this dynamicly
*/
protected array $dataTypes = [
'VARCHAR' => 'Text', 'CHAR' =>
'Text',
'MEDIUMTEXT' => 'Textarea', 'LONGTEXT'
=> 'Textarea',
'TEXT' => 'Textarea', 'DATETIME' =>
'Calendar',
'DATE' => 'Text', 'TIME' =>
'Text', 'TINYINT' => 'Text',
'BIGINT' => 'Text', 'INT' =>
'Text', 'FLOAT' => 'Text',
'DECIMAL' => 'Text', 'DOUBLE' =>
'Text'
];
/**
* The datasize identifiers
*/
protected array $dataSize = [
'CHAR', 'VARCHAR', 'INT',
'TINYINT',
'BIGINT', 'FLOAT', 'DECIMAL',
'DOUBLE'
];
/**
* The default identifiers
*/
protected $defaults = [
'', 0, 1, "CURRENT_TIMESTAMP", "DATETIME"
]; // Other
/**
* The sizes identifiers
*/
protected $sizes = [
"1", "7", "10", "11",
"50", "64", "100", "255",
"1024", "2048"
]; // Other
/**
* Constructor
*/
public function __construct($data = false)
{
// set the app to insure messages can be set
$this->app = Factory::getApplication();
// check that we have data
if (ArrayHelper::check($data))
{
// make sure we have an id
if (isset($data['id']) && $data['id'] >
0)
{
if (isset($data['buildcomp']) && 1 ==
$data['buildcomp'] &&
isset($data['buildcompsql']))
{
foreach ($data as $key => $value)
{
if (isset($this->setting[$key]))
{
switch($this->setting[$key])
{
case 'base64':
// set needed value
$this->$key = base64_decode((string) $value);
break;
case 'json':
// set needed value
$this->$key = json_decode((string) $value, true);
break;
case 'safeString':
// set needed value
$this->$key = StringHelper::check($value);
break;
default :
$this->$key = $value;
break;
}
}
}
// get linked admin views
$addadmin_views = GetHelper::var('component_admin_views',
$data['id'], 'joomla_component',
'addadmin_views');
if (JsonHelper::check($addadmin_views))
{
$this->addadmin_views = json_decode((string) $addadmin_views,
true);
}
// set the map of the views needed
if ($this->setMap())
{
return true;
}
}
return false;
}
$this->app->enqueueMessage(
Text::_('COM_COMPONENTBUILDER_PLEASE_TRY_AGAIN_THIS_ERROR_USUALLY_HAPPENS_IF_IT_IS_A_NEW_COMPONENT_BECAUSE_WE_NEED_A_COMPONENT_ID_TO_DO_THIS_BUILD_WITH_YOUR_SQL_DUMP'),
'Error'
);
return false;
}
$this->app->enqueueMessage(
Text::_('COM_COMPONENTBUILDER_COULD_NOT_FIND_THE_DATA_NEEDED_TO_CONTINUE'),
'Error'
);
return false;
}
/**
* The mapping function
* To Map the views and fields that are needed
*/
protected function setMap(): bool
{
// set the database to make needed DB calls
$this->db = Factory::getDbo();
// start parsing the sql dump data
$queries = \JDatabaseDriver::splitSql($this->buildcompsql);
if (ArrayHelper::check($queries))
{
foreach ($queries as $sql)
{
// only use create table queries
if (strpos($sql, 'CREATE TABLE IF NOT EXISTS') !== false ||
strpos($sql, 'CREATE TABLE') !== false)
{
if (($tableName = $this->getTableName($sql)) !== null)
{
// now get the fields/columns of this view/table
if (($fields = $this->getFields($sql)) !== null)
{
// make sure it is all lower case from here on
$tableName = strtolower($tableName);
$this->map[$tableName] = $fields;
}
}
else
{
continue;
}
}
// get the insert data if set
if (strpos($sql, 'INSERT INTO `') !== false)
{
if ($tableName = $this->getTableName($sql))
{
$tableName = strtolower($tableName);
$this->addSql[$tableName] = 1;
$this->source[$tableName] = 2;
$this->sql[$tableName] = $sql;
}
}
}
// check if the mapping was done
if (ArrayHelper::check($this->map))
{
return true;
}
}
return false;
}
/**
* Get the table name
*/
protected function getTableName(string $sql): ?string
{
if (strpos($sql, '`#__') !== false)
{
// get table name
$tableName = GetHelper::between($sql, '`#__', "`");
}
elseif (strpos($sql, "'#__") !== false)
{
// get table name
$tableName = GetHelper::between($sql, "'#__",
"'");
}
elseif (strpos($sql, "CREATE TABLE `") !== false)
{
// get table name
$tableName = GetHelper::between($sql, "CREATE TABLE `",
"`");
}
elseif (strpos($sql, "CREATE TABLE IF NOT EXISTS `") !==
false)
{
// get table name
$tableName = GetHelper::between($sql, "CREATE TABLE IF NOT EXISTS
`", "`");
}
// if it still was not found
if (!isset($tableName) || !StringHelper::check($tableName))
{
// skip this query
return null;
}
// clean the table name (so only view name remain)
if (strpos($tableName, $this->name_code) !== false)
{
$tableName = trim(str_replace($this->name_code, '',
$tableName), '_');
}
// if found
if (StringHelper::check($tableName))
{
return $tableName;
}
// skip this query
return null;
}
/**
* Extracts the details of fields from a table based on SQL query.
*
* @param string $sql SQL query to create a table.
*
* @return array|null Returns an array of field details or null if no
fields are found.
* @since 3.2.1
*/
protected function getFields(string $sql): ?array
{
$columns = $this->getColumns($sql);
if ($columns === null)
{
return null;
}
$fields = [];
foreach ($columns as $name => $data)
{
if (in_array(strtolower($name), $this->notRequired))
{
continue;
}
$fields[] = $this->prepareFieldDetails($name, $data);
}
return !empty($fields) ? $fields : null;
}
/**
* Prepares detailed array of field data.
*
* @param string $name Name of the field.
* @param object $data Data object containing field information.
*
* @return array Returns array containing detailed field information.
* @since 3.2.1
*/
protected function prepareFieldDetails(string $name, object $data): array
{
if (JsonHelper::check($data->Comment))
{
$data->config = json_decode($data->Comment);
}
$field = [
'name' => $name,
'label' => $this->getLabel($data, $name),
'dataType' => $this->getDataType($data),
'fieldType' => $this->getType($data),
'size' => $this->getSize($data),
'sizeOther' => '',
'default' => $this->getDefault($data),
'defaultOther' => '',
'null' => $this->getNullValue($data),
'key' => $this->getKeyStatus($data),
'row' => $data
];
$this->handleSizeOther($field);
$this->handleDefaultOther($field);
return $field;
}
/**
* Handles non-standard sizes by setting appropriate labels.
*
* @param array $field Reference to the field array to update.
* @since 3.2.1
*/
protected function handleSizeOther(array &$field): void
{
if (!in_array($field['size'], $this->sizes) &&
!empty($field['size']))
{
$field['sizeOther'] = $field['size'];
$field['size'] = 'Other';
}
}
/**
* Handles non-standard defaults by setting appropriate labels.
*
* @param array $field Reference to the field array to update.
* @since 3.2.1
*/
protected function handleDefaultOther(array &$field): void
{
if (!in_array($field['default'], $this->defaults) &&
!empty($field['default']))
{
$field['defaultOther'] = $field['default'];
$field['default'] = 'Other';
}
}
/**
* Extracts columns from the SQL statement and retrieves details.
*
* @param string $sql SQL statement to extract column information.
*
* @return array|null Array of columns if successful, null otherwise.
* @since 3.2.1
*/
protected function getColumns(string $sql): ?array
{
$columnDefinitions = $this->extractColumnDefinitions($sql);
if (!$columnDefinitions)
{
$this->app->enqueueMessage('Invalid SQL provided for table
creation.', 'error');
return null;
}
$tmpTableName = 'jcb_extrusion_' . uniqid();
$createSql = "CREATE TABLE $tmpTableName
($columnDefinitions)";
try
{
$this->db->setQuery($createSql)->execute();
$columns = $this->db->getTableColumns($tmpTableName, false);
$this->db->setQuery("DROP TABLE IF EXISTS
$tmpTableName")->execute();
return $columns;
}
catch (\Exception $e)
{
$this->app->enqueueMessage($e->getMessage(),
'error');
return null;
}
}
/**
* Extracts the column definitions from the provided SQL statement.
*
* @param string $sql SQL statement for table creation.
*
* @return string|null Extracted column definitions as a string or null if
definitions cannot be extracted.
* @since 3.2.1
*/
protected function extractColumnDefinitions(string $sql): ?string
{
$sql = preg_replace('/--.*?[\r\n]/', '', $sql); //
Remove single-line comments
$sql = preg_replace('/\/\*.*?\*\//s', '', $sql); //
Remove multi-line comments
$firstParenthesisPos = strpos($sql, '(');
$lastParenthesisPos = strrpos($sql, ')');
if ($firstParenthesisPos === false || $lastParenthesisPos === false)
{
return null;
}
return substr($sql, $firstParenthesisPos + 1, $lastParenthesisPos -
$firstParenthesisPos - 1);
}
/**
* Retrieves the human-readable label for a field based on its metadata or
name.
*
* @param object $data Field metadata.
* @param string $name Field name.
*
* @return string Human-readable label for the field.
* @since 3.2.1
*/
protected function getLabel(object $data, string $name): string
{
if (isset($data->config->label))
{
return $data->config->label;
}
return StringHelper::safe($name, 'W'); // Default label is the
field name converted to title case
}
/**
* Determines the data type for a field based on its SQL type.
*
* @param object $data Field metadata containing type information.
*
* @return string Standardized data type.
* @since 3.2.1
*/
private function getDataType(object $data): string
{
if (preg_match('/^(\w+)/', $data->Type, $matches))
{
return strtoupper($matches[1]);
}
return 'TEXT'; // Default to TEXT if type cannot be determined
}
/**
* Determines the appropriate form field type for a data field based on
its data type.
*
* @param object $data Field metadata.
*
* @return string Form field type suitable for the data type.
* @since 3.2.1
*/
protected function getType(object $data): string
{
if (isset($data->config->type))
{
return $data->config->type;
}
return $this->dataTypes[$data->Type] ?? 'Text'; //
Default to 'Text' if no specific type is configured
}
/**
* Retrieves the size or dimensions of a field from its SQL type
definition.
*
* @param object $data Field metadata containing type information.
*
* @return string|null Size or dimensions of the field, or null if not
applicable.
* @since 3.2.1
*/
protected function getSize(object $data)
{
if (preg_match('/\((\d+)(?:,(\d+))?\)/', $data->Type,
$matches))
{
return isset($matches[2]) ? "{$matches[1]},{$matches[2]}" :
(int) $matches[1];
}
return null; // Return null if size information is not available
}
/**
* Determines the default value for a field from its metadata.
*
* @param object $data Field metadata.
*
* @return string Default value of the field.
* @since 3.2.1
*/
protected function getDefault(object $data): string
{
if (!empty($data->Default) && $data->Default !==
"''")
{
return $data->Default;
}
return ''; // Return an empty string if no default is
specified
}
/**
* Retrieves the nullability status of a field from its SQL definition.
*
* @param object $data Field metadata.
*
* @return string 'NOT NULL' if the field is not nullable,
otherwise 'NULL'.
* @since 3.2.1
*/
protected function getNullValue(object $data): string
{
return strtoupper($data->Null) === 'NO' ? 'NOT
NULL' : 'NULL';
}
/**
* Determines whether a field is a key and the type of key if applicable.
*
* @param object $data Field metadata.
*
* @return int Key status as an integer (0: not a key, 1: unique key, 2:
primary key).
* @since 3.2.1
*/
protected function getKeyStatus(object $data): int
{
$key = strtoupper($data->Key);
if ($key === 'PRI')
{
return 2; // Primary key
}
elseif ($key === 'UNI')
{
return 1; // Unique key
}
return 0; // Not a key
}
}
src/Componentbuilder/Extrusion/Helper/index.html000064400000000054151162054210016054
0ustar00<html><body
bgcolor="#FFFFFF"></body></html>src/Componentbuilder/Fieldtype/Config.php000064400000007666151162054210014523
0ustar00<?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\Fieldtype;
use Joomla\Registry\Registry as JoomlaRegistry;
use Joomla\CMS\Factory as JoomlaFactory;
use VDM\Joomla\Utilities\GetHelper;
use VDM\Joomla\Utilities\StringHelper;
use VDM\Joomla\Componentbuilder\Utilities\RepoHelper;
use VDM\Joomla\Componentbuilder\Abstraction\BaseConfig;
/**
* Compiler Configurations
*
* All these functions are accessed via the direct name without the get:
* example: $this->component_code_name calls:
$this->getComponentcodename()
*
* All values once called are cached, yet can be updated directly:
* example: $this->component_code_name = 'new_code_name'; //
be warned!
*
* @since 5.0.3
*/
class Config extends BaseConfig
{
/**
* The Global Joomla Configuration
*
* @var JoomlaRegistry
* @since 5.0.3
*/
protected JoomlaRegistry $config;
/**
* Constructor
*
* @param Input|null $input Input
* @param Registry|null $params The component parameters
* @param Registry|null $config The Joomla configuration
*
* @throws \Exception
* @since 5.0.3
*/
public function __construct(?Input $input = null, ?JoomlaRegistry $params
= null, ?JoomlaRegistry $config = null)
{
parent::__construct($input, $params);
$this->config = $config ?: JoomlaFactory::getConfig();
}
/**
* get Gitea Username
*
* @return string the access token
* @since 5.0.3
*/
protected function getGiteausername(): ?string
{
return $this->params->get('gitea_username');
}
/**
* get Gitea Access Token
*
* @return string the access token
* @since 5.0.3
*/
protected function getGiteatoken(): ?string
{
return $this->params->get('gitea_token');
}
/**
* Get fieldtype core organisation
*
* @return string The fieldtype core organisation
* @since 5.0.3
*/
protected function getJoomlafieldtypecoreorganisation(): string
{
// the VDM default organisation is [joomla]
$organisation = 'joomla';
return
$this->params->get('joomla_fieldtype_core_organisation',
$organisation);
}
/**
* Get Joomla fieldtype init repos
*
* @return array The init repositories on Gitea
* @since 5.0.3
*/
protected function getJoomlafieldtypeinitrepos(): array
{
// some defaults repos we need by JCB
$repos = [];
// get the users own power repo (can overwrite all)
if (!empty($this->gitea_username))
{
$repos[$this->gitea_username . '.joomla-fieldtypes'] =
(object) ['organisation' => $this->gitea_username,
'repository' => 'joomla-fieldtypes',
'read_branch' => 'master'];
}
$repos[$this->joomla_fieldtype_core_organisation .
'.joomla-fieldtypes'] = (object) ['organisation' =>
$this->joomla_fieldtype_core_organisation, 'repository' =>
'joomla-fieldtypes', 'read_branch' =>
'master'];
return $repos;
}
/**
* Get joomla fieldtype approved paths
*
* @return array The approved paths to the repositories on Gitea
* @since 5.0.3
*/
protected function getApprovedjoomlapaths(): array
{
// some defaults repos we need by JCB
$approved = $this->joomla_fieldtype_init_repos;
$paths = RepoHelper::get(3); // Joomla Field Type = 3
if ($paths !== null)
{
foreach ($paths as $path)
{
$owner = $path->organisation ?? null;
$repo = $path->repository ?? null;
if ($owner !== null && $repo !== null)
{
// we make sure to get only the objects
$approved = ["{$owner}.{$repo}" => $path] + $approved;
}
}
}
return array_values($approved);
}
}
src/Componentbuilder/Fieldtype/Factory.php000064400000003027151162054210014710
0ustar00<?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\Fieldtype;
use Joomla\DI\Container;
use VDM\Joomla\Componentbuilder\Fieldtype\Service\Fieldtype as Power;
use VDM\Joomla\Service\Database;
use VDM\Joomla\Service\Model;
use VDM\Joomla\Service\Data;
use VDM\Joomla\Componentbuilder\Service\Gitea;
use VDM\Joomla\Componentbuilder\Power\Service\Gitea as GiteaPower;
use VDM\Joomla\Gitea\Service\Utilities as GiteaUtilities;
use VDM\Joomla\Interfaces\FactoryInterface;
use VDM\Joomla\Abstraction\Factory as ExtendingFactory;
/**
* Field Type Power Factory
*
* @since 5.0.3
*/
abstract class Factory extends ExtendingFactory implements FactoryInterface
{
/**
* Create a container object
*
* @return Container
* @since 5.0.3
*/
protected static function createContainer(): Container
{
return (new Container())
->registerServiceProvider(new Power())
->registerServiceProvider(new Database())
->registerServiceProvider(new Model())
->registerServiceProvider(new Data())
->registerServiceProvider(new Gitea())
->registerServiceProvider(new GiteaPower())
->registerServiceProvider(new GiteaUtilities());
}
}
src/Componentbuilder/Fieldtype/Grep.php000064400000010634151162054210014200
0ustar00<?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\Fieldtype;
use Joomla\CMS\Language\Text;
use VDM\Joomla\Interfaces\GrepInterface;
use VDM\Joomla\Abstraction\Grep as ExtendingGrep;
/**
* Global Resource Empowerment Platform
*
* The Grep feature will try to find your joomla power in the
repositories listed in the global
* Options of JCB in the super powers tab, and if it can't be found
there will try the global core
* Super powers of JCB. All searches are performed according the
[algorithm:cascading]
* See documentation for more details:
https://git.vdm.dev/joomla/super-powers/wiki
*
* @since 5.0.3
*/
final class Grep extends ExtendingGrep implements GrepInterface
{
/**
* Order of global search
*
* @var array
* @since 5.0.3
**/
protected array $order = ['remote'];
/**
* Search for a remote item
*
* @param string $guid The global unique id of the item
*
* @return object|null
* @since 5.0.3
*/
protected function searchRemote(string $guid): ?object
{
// check if it exists remotely
if (($path = $this->existsRemotely($guid)) !== null)
{
return $this->getRemote($path, $guid);
}
return null;
}
/**
* Get a remote joomla power
*
* @param object $path The repository path details
* @param string $guid The global unique id of the power
*
* @return object|null
* @since 5.0.3
*/
protected function getRemote(object $path, string $guid): ?object
{
$power = null;
if (empty($path->index->{$guid}->path))
{
return $power;
}
// get the branch name
$branch = $this->getBranchName($path);
// load the base and token if set
$this->contents->load_($path->base ?? null, $path->token ??
null);
// get the settings
if (($power = $this->loadRemoteFile($path->organisation,
$path->repository, $path->index->{$guid}->path .
'/item.json', $branch)) !== null &&
isset($power->guid))
{
// set the git details in params
$path_guid = $path->guid ?? null;
if ($path_guid !== null)
{
// get the Settings meta
if (($meta = $this->contents->metadata($path->organisation,
$path->repository, $path->index->{$guid}->path .
'/item.json', $branch)) !== null &&
isset($meta->sha))
{
if (isset($power->params) && is_object($power->params)
&&
isset($power->params->source) &&
is_array($power->params->source))
{
$power->params->source[$path_guid . '-settings'] =
$meta->sha;
}
else
{
$power->params = (object) [
'source' => [$path_guid . '-settings' =>
$meta->sha]
];
}
}
// get the README meta
if (($meta = $this->contents->metadata($path->organisation,
$path->repository, $path->index->{$guid}->path .
'/README.md', $branch)) !== null &&
isset($meta->sha))
{
if (isset($power->params) && is_object($power->params)
&&
isset($power->params->source) &&
is_array($power->params->source))
{
$power->params->source[$path_guid . '-readme'] =
$meta->sha;
}
else
{
$power->params = (object) [
'source' => [$path_guid . '-readme' =>
$meta->sha]
];
}
}
}
}
// reset back to the global base and token
$this->contents->reset_();
return $power;
}
/**
* Set repository messages and errors based on given conditions.
*
* @param string $message The message to set (if error)
* @param string $path Path value
* @param string $repository Repository name
* @param string $organisation Organisation name
* @param string|null $base Base URL
*
* @return void
* @since 5.0.3
*/
protected function setRemoteIndexMessage(string $message, string $path,
string $repository, string $organisation, ?string $base): void
{
$this->app->enqueueMessage(
Text::sprintf('COM_COMPONENTBUILDER_PJOOMLA_FIELD_TYPEB_REPOSITORY_AT_BSSB_GAVE_THE_FOLLOWING_ERRORBR_SP',
$this->contents->api(), $path, $message),
'Error'
);
}
}
src/Componentbuilder/Fieldtype/Readme/Item.php000064400000011036151162054210015373
0ustar00<?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\Fieldtype\Readme;
use VDM\Joomla\Interfaces\Readme\ItemInterface;
/**
* Compiler Field Type Item Readme
*
* @since 5.0.3
*/
final class Item implements ItemInterface
{
/**
* Get an item readme
*
* @param object $item An item details.
*
* @return string
* @since 3.2.2
*/
public function get(object $item): string
{
// build readme
$readme = ["```
██╗ ██████╗ ██████╗ ███╗
███╗██╗ █████╗
███████╗██╗███████╗██╗
██████╗ ████████╗██╗
██╗██████╗ ███████╗
██║██╔═══██╗██╔═══██╗████╗
████║██║ ██╔══██╗
██╔════╝██║██╔════╝██║
██╔══██╗ ╚══██╔══╝╚██╗
██╔╝██╔══██╗██╔════╝
██║██║ ██║██║
██║██╔████╔██║██║
███████║ █████╗ ██║█████╗
██║ ██║ ██║ ██║
╚████╔╝ ██████╔╝█████╗
██ ██║██║ ██║██║
██║██║╚██╔╝██║██║
██╔══██║ ██╔══╝ ██║██╔══╝
██║ ██║ ██║ ██║ ╚██╔╝
██╔═══╝ ██╔══╝
╚█████╔╝╚██████╔╝╚██████╔╝██║
╚═╝ ██║███████╗██║ ██║
██║
██║███████╗███████╗██████╔╝
██║ ██║ ██║ ███████╗
╚════╝ ╚═════╝ ╚═════╝ ╚═╝
╚═╝╚══════╝╚═╝ ╚═╝ ╚═╝
╚═╝╚══════╝╚══════╝╚═════╝
╚═╝ ╚═╝ ╚═╝ ╚══════╝
```"];
// system name
$readme[] = "# " . $item->name;
if (!empty($item->description))
{
$readme[] = "\n" . $item->description;
}
elseif (!empty($item->short_description))
{
$readme[] = "\n" . $item->short_description;
}
$readme[] = "\nThe Joomla! field types within this repository
provide an essential mechanism for integrating Joomla-related field type
into the Joomla Component Builder (JCB). Each field type is meticulously
designed to ensure compatibility and ease of use within the JCB framework,
allowing developers to effortlessly incorporate and manage custom fields in
their components. By utilizing the reset functionality, users can
seamlessly update individual field types to align with the latest versions
maintained in our core repository, ensuring that their projects benefit
from the most up-to-date features and fixes. Additionally, for those who
prefer a more personalized approach, the repository can be forked, enabling
developers to maintain and distribute their customized field types
independently from the broader JCB community. This level of flexibility
underscores the open-source nature of JCB, offering you the freedom to
adapt and extend your components according to your specific needs, while
still benefiting from a robust, community-driven ecosystem.";
// yes you can remove this, but why?
$readme[] = "\n---\n```
██╗ ██████╗██████╗
██║██╔════╝██╔══██╗
██║██║ ██████╔╝
██ ██║██║ ██╔══██╗
╚█████╔╝╚██████╗██████╔╝
╚════╝ ╚═════╝╚═════╝
```\n> Build with [Joomla Component
Builder](https://git.vdm.dev/joomla/Component-Builder)\n\n";
return implode("\n", $readme);
}
}
src/Componentbuilder/Fieldtype/Readme/Main.php000064400000024215151162054210015364
0ustar00<?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\Fieldtype\Readme;
use VDM\Joomla\Interfaces\Readme\MainInterface;
/**
* Field Type Main Readme
*
* @since 5.0.3
*/
final class Main implements MainInterface
{
/**
* Get Main Readme
*
* @param array $items All items of this repository.
*
* @return string
* @since 3.2.0
*/
public function get(array $items): string
{
// build readme
$readme = ["```
██╗ ██████╗ ██████╗ ███╗
███╗██╗ █████╗
██║██╔═══██╗██╔═══██╗████╗
████║██║ ██╔══██╗
██║██║ ██║██║
██║██╔████╔██║██║
███████║
██ ██║██║ ██║██║
██║██║╚██╔╝██║██║
██╔══██║
╚█████╔╝╚██████╔╝╚██████╔╝██║
╚═╝ ██║███████╗██║ ██║
╚════╝ ╚═════╝ ╚═════╝ ╚═╝
╚═╝╚══════╝╚═╝ ╚═╝
███████╗██╗███████╗██╗
██████╗ ████████╗██╗
██╗██████╗
███████╗███████╗
██╔════╝██║██╔════╝██║
██╔══██╗ ╚══██╔══╝╚██╗
██╔╝██╔══██╗██╔════╝██╔════╝
█████╗ ██║█████╗ ██║ ██║
██║ ██║ ╚████╔╝
██████╔╝█████╗ ███████╗
██╔══╝ ██║██╔══╝ ██║ ██║
██║ ██║ ╚██╔╝ ██╔═══╝
██╔══╝ ╚════██║
██║
██║███████╗███████╗██████╔╝
██║ ██║ ██║
███████╗███████║
╚═╝
╚═╝╚══════╝╚══════╝╚═════╝
╚═╝ ╚═╝ ╚═╝
╚══════╝╚══════╝
```"];
// default description of super powers
$readme[] = "\n### What is JCB Joomla Field Types?\nThe Joomla field
types provide a powerful way to map Joomla-related field types, enabling
seamless integration with Joomla Component Builder (JCB). This repository
serves as a centralized system for maintaining, updating, and distributing
these field types throughout the JCB ecosystem.\n
\n
When you need to update any field type in JCB, simply select the desired
field type and click the \"reset\" button. This action will
automatically sync the selected field type with its corresponding version
hosted in our core repository, ensuring you always have the latest
updates.\n
\n
Moreover, if you wish to tailor the field types to your specific needs, you
can fork the repository and point your JCB instance to your fork. This
allows you to maintain and update field types independently from the main
JCB community, offering the flexibility that is at the heart of open-source
philosophy.\n
\n
We believe this approach empowers you to extend and customize JCB to fit
your unique requirements, exemplifying the true spirit of freedom in
software development. We trust you will find this capability both useful
and aligned with the expectations of how open-source software should
function.\n";
// get the readme body
$readme[] = $this->readmeBuilder($items);
// yes you can remove this, but why?
$readme[] = "\n---\n```
██╗ ██████╗ ██████╗ ███╗
███╗██╗ █████╗
██║██╔═══██╗██╔═══██╗████╗
████║██║ ██╔══██╗
██║██║ ██║██║
██║██╔████╔██║██║
███████║
██ ██║██║ ██║██║
██║██║╚██╔╝██║██║
██╔══██║
╚█████╔╝╚██████╔╝╚██████╔╝██║
╚═╝ ██║███████╗██║ ██║
╚════╝ ╚═════╝ ╚═════╝ ╚═╝
╚═╝╚══════╝╚═╝ ╚═╝
██████╗ ██████╗ ███╗
███╗██████╗ ██████╗ ███╗
██╗███████╗███╗
██╗████████╗
██╔════╝██╔═══██╗████╗
████║██╔══██╗██╔═══██╗████╗
██║██╔════╝████╗
██║╚══██╔══╝
██║ ██║
██║██╔████╔██║██████╔╝██║
██║██╔██╗ ██║█████╗
██╔██╗ ██║ ██║
██║ ██║
██║██║╚██╔╝██║██╔═══╝ ██║
██║██║╚██╗██║██╔══╝
██║╚██╗██║ ██║
╚██████╗╚██████╔╝██║ ╚═╝
██║██║ ╚██████╔╝██║
╚████║███████╗██║ ╚████║
██║
╚═════╝ ╚═════╝ ╚═╝
╚═╝╚═╝ ╚═════╝ ╚═╝
╚═══╝╚══════╝╚═╝ ╚═══╝
╚═╝
██████╗ ██╗ ██╗██╗██╗
██████╗ ███████╗██████╗
██╔══██╗██║ ██║██║██║
██╔══██╗██╔════╝██╔══██╗
██████╔╝██║ ██║██║██║
██║ ██║█████╗ ██████╔╝
██╔══██╗██║ ██║██║██║
██║ ██║██╔══╝ ██╔══██╗
██████╔╝╚██████╔╝██║███████╗██████╔╝███████╗██║
██║
╚═════╝ ╚═════╝
╚═╝╚══════╝╚═════╝
╚══════╝╚═╝ ╚═╝
```\n> Build with [Joomla Component
Builder](https://git.vdm.dev/joomla/Component-Builder)\n\n";
return implode("\n", $readme);
}
/**
* The readme builder
*
* @param array $classes The powers.
*
* @return string
* @since 3.2.0
*/
private function readmeBuilder(array &$items): string
{
$classes = [];
foreach ($items as $guid => $power)
{
// add to the sort bucket
$classes[] = [
'name' => $power['name'],
'link' => $this->indexLinkPower($power)
];
}
return $this->readmeModel($classes);
}
/**
* Sort and model the readme classes
*
* @param array $classes The powers.
*
* @return string
* @since 3.2.0
*/
private function readmeModel(array &$classes): string
{
$this->sortClasses($classes);
return $this->generateIndex($classes);
}
/**
* Generate the index string for classes
*
* @param array $classes The sorted classes
*
* @return string The index string
*/
private function generateIndex(array &$classes): string
{
$result = "# Index of Joomla! Field Types\n";
foreach ($classes as $class)
{
// Add the class details
$result .= "\n - " . $class['link'];
}
return $result;
}
/**
* Sort the flattened array using a single sorting function
*
* @param array $classes The classes to sort
*
* @since 3.2.0
*/
private function sortClasses(array &$classes): void
{
usort($classes, function ($a, $b) {
return $this->compareName($a, $b);
});
}
/**
* Compare the name of two classes
*
* @param array $a First class
* @param array $b Second class
*
* @return int Comparison result
* @since 3.2.0
*/
private function compareName(array $a, array $b): int
{
return strcmp($a['name'], $b['name']);
}
/**
* Build the Link to the power in this repository
*
* @param array $power The power details.
*
* @return string
* @since 3.2.0
*/
private function indexLinkPower(array &$power): string
{
$name = $power['name'] ?? 'error';
return '**' . $name . "** | "
. $this->linkPowerRepo($power) . ' | '
. $this->linkPowerSettings($power) . ' | '
. $this->linkPowerDesc($power);
}
/**
* Build the Link to the power in this repository
*
* @param array $power The power details.
*
* @return string
* @since 3.2.0
*/
private function linkPowerRepo(array &$power): string
{
$path = $power['path'] ?? 'error';
return '[Details](' . $path . ')';
}
/**
* Build the Link to the power settings in this repository
*
* @param array $power The power details.
*
* @return string
* @since 3.2.0
*/
private function linkPowerSettings(array &$power): string
{
$settings = $power['settings'] ?? 'error';
return '[Settings](' . $settings . ')';
}
/**
* Get the short description
*
* @param array $power The power details.
*
* @return string
* @since 3.2.0
*/
private function linkPowerDesc(array &$power): string
{
$jpk = $power['desc'] ?? '';
return $jpk;
}
}
src/Componentbuilder/Fieldtype/Readme/index.html000064400000000054151162054210015757
0ustar00<html><body
bgcolor="#FFFFFF"></body></html>src/Componentbuilder/Fieldtype/Remote/Get.php000064400000001450151162054210015251
0ustar00<?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\Fieldtype\Remote;
use VDM\Joomla\Interfaces\Remote\GetInterface;
use VDM\Joomla\Abstraction\Remote\Get as ExtendingGet;
/**
* Remote Get Field Type of JCB
*
* @since 5.0.3
*/
final class Get extends ExtendingGet implements GetInterface
{
/**
* Table Name
*
* @var string
* @since 5.0.3
*/
protected string $table = 'fieldtype';
}
src/Componentbuilder/Fieldtype/Remote/Set.php000064400000012360151162054210015267
0ustar00<?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\Fieldtype\Remote;
use VDM\Joomla\Interfaces\Remote\SetInterface;
use VDM\Joomla\Abstraction\Remote\Set as ExtendingSet;
/**
* Set Field Type based on global unique ids to remote repository
*
* @since 5.0.3
*/
final class Set extends ExtendingSet implements SetInterface
{
/**
* Table Name
*
* @var string
* @since 5.0.3
*/
protected string $table = 'fieldtype';
/**
* Area Name
*
* @var string
* @since 5.0.3
*/
protected string $area = 'Joomla Field Type';
/**
* Prefix Key
*
* @var string
* @since 5.0.3
*/
protected string $prefix_key = '';
/**
* The item map
*
* @var array
* @since 5.0.3
*/
protected array $map = [
'name' => 'name',
'short_description' => 'short_description',
'description' => 'description',
'properties' => 'properties',
'has_defaults' => 'has_defaults',
'datatype' => 'datatype',
'datalenght' => 'datalenght',
'datalenght_other' => 'datalenght_other',
'datadefault' => 'datadefault',
'datadefault_other' => 'datadefault_other',
'indexes' => 'indexes',
'null_switch' => 'null_switch',
'store' => 'store',
'guid' => 'guid'
];
/**
* The index map
*
* @var array
* @since 5.0.3
*/
protected array $index_map = [
'name' => 'index_map_IndexName',
'desc' => 'index_map_ShortDescription',
'settings' => 'index_map_IndexSettingsPath',
'path' => 'index_map_IndexPath',
'guid' => 'index_map_IndexGUID'
];
/**
* update an existing item (if changed)
*
* @param object $item
* @param object $existing
* @param object $repo
*
* @return bool
* @since 5.0.3
*/
protected function updateItem(object $item, object $existing, object
$repo): bool
{
// make sure there was a change
$sha = $existing->params->source[$repo->guid .
'-settings'] ?? null;
$existing = $this->mapItem($existing);
if ($sha === null || $this->areObjectsEqual($item, $existing))
{
return false;
}
$this->git->update(
$repo->organisation, // The owner name.
$repo->repository, // The repository name.
'src/' . $item->guid . '/' .
$this->getSettingsPath(), // The file path.
json_encode($item, JSON_PRETTY_PRINT), // The file content.
'Update ' . $item->name, // The commit message.
$sha, // The blob SHA of the old file.
$repo->write_branch // The branch name.
);
return true;
}
/**
* create a new item
*
* @param object $item
* @param object $repo
*
* @return void
* @since 5.0.3
*/
protected function createItem(object $item, object $repo): void
{
$this->git->create(
$repo->organisation, // The owner name.
$repo->repository, // The repository name.
'src/' . $item->guid . '/' .
$this->getSettingsPath(), // The file path.
json_encode($item, JSON_PRETTY_PRINT), // The file content.
'Create ' . $item->name, // The commit message.
$repo->write_branch // The branch name.
);
}
/**
* update an existing item readme
*
* @param object $item
* @param object $existing
* @param object $repo
*
* @return void
* @since 5.0.3
*/
protected function updateItemReadme(object $item, object $existing, object
$repo): void
{
// make sure there was a change
$sha = $existing->params->source[$repo->guid .
'-readme'] ?? null;
if ($sha === null)
{
return;
}
$this->git->update(
$repo->organisation, // The owner name.
$repo->repository, // The repository name.
'src/' . $item->guid . '/README.md', // The file
path.
$this->itemReadme->get($item), // The file content.
'Update ' . $item->name . ' readme file', // The
commit message.
$sha, // The blob SHA of the old file.
$repo->write_branch // The branch name.
);
}
/**
* create a new item readme
*
* @param object $item
* @param object $repo
*
* @return void
* @since 5.0.3
*/
protected function createItemReadme(object $item, object $repo): void
{
$this->git->create(
$repo->organisation, // The owner name.
$repo->repository, // The repository name.
'src/' . $item->guid . '/README.md', // The file
path.
$this->itemReadme->get($item), // The file content.
'Create ' . $item->name . ' readme file', // The
commit message.
$repo->write_branch // The branch name.
);
}
/**
* Get the item name for the index values
*
* @param object $item
*
* @return string|null
* @since 5.0.3
*/
protected function index_map_IndexName(object $item): ?string
{
return $item->name ?? null;
}
/**
* Get the item Short Description for the index values
*
* @param object $item
*
* @return string|null
* @since 5.0.3
*/
protected function index_map_ShortDescription(object $item): ?string
{
return $item->short_description ?? null;
}
}
src/Componentbuilder/Fieldtype/Remote/index.html000064400000000054151162054210016015
0ustar00<html><body
bgcolor="#FFFFFF"></body></html>src/Componentbuilder/Fieldtype/Service/Fieldtype.php000064400000010316151162054210016625
0ustar00<?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\Fieldtype\Service;
use Joomla\DI\Container;
use Joomla\DI\ServiceProviderInterface;
use VDM\Joomla\Componentbuilder\Fieldtype\Config;
use VDM\Joomla\Componentbuilder\Table;
use VDM\Joomla\Componentbuilder\Fieldtype\Grep;
use VDM\Joomla\Componentbuilder\Fieldtype\Remote\Get;
use VDM\Joomla\Componentbuilder\Fieldtype\Remote\Set;
use VDM\Joomla\Componentbuilder\Fieldtype\Readme\Item as ItemReadme;
use VDM\Joomla\Componentbuilder\Fieldtype\Readme\Main as MainReadme;
/**
* Field Type Service Provider
*
* @since 5.0.3
*/
class Fieldtype implements ServiceProviderInterface
{
/**
* Registers the service provider with a DI container.
*
* @param Container $container The DI container.
*
* @return void
* @since 3.2.1
*/
public function register(Container $container)
{
$container->alias(Config::class, 'Config')
->share('Config', [$this, 'getConfig'], true);
$container->alias(Table::class, 'Table')
->share('Table', [$this, 'getTable'], true);
$container->alias(Grep::class, 'Joomla.Fieldtype.Grep')
->share('Joomla.Fieldtype.Grep', [$this,
'getGrep'], true);
$container->alias(Get::class,
'Joomla.Fieldtype.Remote.Get')
->share('Joomla.Fieldtype.Remote.Get', [$this,
'getRemoteGet'], true);
$container->alias(Set::class,
'Joomla.Fieldtype.Remote.Set')
->share('Joomla.Fieldtype.Remote.Set', [$this,
'getRemoteSet'], true);
$container->alias(ItemReadme::class,
'Joomla.Fieldtype.Readme.Item')
->share('Joomla.Fieldtype.Readme.Item', [$this,
'getItemReadme'], true);
$container->alias(MainReadme::class,
'Joomla.Fieldtype.Readme.Main')
->share('Joomla.Fieldtype.Readme.Main', [$this,
'getMainReadme'], true);
}
/**
* Get The Config Class.
*
* @param Container $container The DI container.
*
* @return Config
* @since 3.2.1
*/
public function getConfig(Container $container): Config
{
return new Config();
}
/**
* Get The Table Class.
*
* @param Container $container The DI container.
*
* @return Table
* @since 3.2.1
*/
public function getTable(Container $container): Table
{
return new Table();
}
/**
* Get The Grep Class.
*
* @param Container $container The DI container.
*
* @return Grep
* @since 3.2.1
*/
public function getGrep(Container $container): Grep
{
return new Grep(
$container->get('Gitea.Repository.Contents'),
$container->get('Config')->approved_joomla_paths
);
}
/**
* Get The Remote Get Class.
*
* @param Container $container The DI container.
*
* @return Get
* @since 3.2.1
*/
public function getRemoteGet(Container $container): Get
{
return new Get(
$container->get('Joomla.Fieldtype.Grep'),
$container->get('Data.Item')
);
}
/**
* Get The Remote Set Class.
*
* @param Container $container The DI container.
*
* @return Set
* @since 3.2.2
*/
public function getRemoteSet(Container $container): Set
{
return new Set(
$container->get('Config')->approved_joomla_paths,
$container->get('Joomla.Fieldtype.Grep'),
$container->get('Data.Items'),
$container->get('Joomla.Fieldtype.Readme.Item'),
$container->get('Joomla.Fieldtype.Readme.Main'),
$container->get('Gitea.Repository.Contents')
);
}
/**
* Get The Item Class.
*
* @param Container $container The DI container.
*
* @return ItemReadme
* @since 3.2.1
*/
public function getItemReadme(Container $container): ItemReadme
{
return new ItemReadme();
}
/**
* Get The Main Class.
*
* @param Container $container The DI container.
*
* @return MainReadme
* @since 3.2.1
*/
public function getMainReadme(Container $container): MainReadme
{
return new MainReadme();
}
}
src/Componentbuilder/Fieldtype/Service/index.html000064400000000054151162054210016162
0ustar00<html><body
bgcolor="#FFFFFF"></body></html>src/Componentbuilder/Fieldtype/index.html000064400000000054151162054210014562
0ustar00<html><body
bgcolor="#FFFFFF"></body></html>src/Componentbuilder/Interfaces/Architecture/Plugin/MainXMLInterface.php000064400000001413151162054210022402
0ustar00<?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\Interfaces\Architecture\Plugin;
/**
* Main XML Interface
*
* @since 5.0.0
*/
interface MainXMLInterface
{
/**
* Generates the main XML for the plugin.
*
* @param object $plugin The plugin object.
*
* @return string The generated XML.
* @since 5.0.2
*/
public function get(object $plugin): string;
}
src/Componentbuilder/Interfaces/Architecture/Plugin/index.html000064400000000054151162054210020600
0ustar00<html><body
bgcolor="#FFFFFF"></body></html>src/Componentbuilder/Interfaces/Cryptinterface.php000064400000002067151162054210016424
0ustar00<?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\Interfaces;
/**
* The Crypt Interface
*/
interface Cryptinterface
{
/**
* Encrypt a string as needed
*
* @param string $string The string to encrypt
* @param string $key The encryption key
*
* @return string
* @since 3.2.0
**/
public function encrypt(string $string, string $key): string;
/**
* Decrypt a string as needed
*
* @param string $string The string to decrypt
* @param string $key The decryption key
*
* @return string|null
* @since 3.2.0
**/
public function decrypt(string $string, string $key): ?string;
}
src/Componentbuilder/Interfaces/Plugin/InfusionInterface.php000064400000001600151162054210020303
0ustar00<?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\Interfaces\Plugin;
/**
* Plug-in Infusion Interface
*
* @since 5.0.2
*/
interface InfusionInterface
{
/**
* Infuse the plugin data into the content.
*
* This method processes each plugin in the data set, triggering events
* before and after infusion, setting placeholders, and adding content
* such as headers, classes, and XML configurations.
*
* @return void
* @since 5.0.2
*/
public function set(): void;
}
src/Componentbuilder/Interfaces/Plugin/StructureInterface.php000064400000001271151162054210020515
0ustar00<?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\Interfaces\Plugin;
/**
* Structure Interface
*
* @since 5.0.0
*/
interface StructureInterface
{
/**
* Build the Plug-ins files, folders, url's and configure
*
* @return void
* @since 5.0.0
*/
public function build();
}
src/Componentbuilder/Interfaces/Plugin/index.html000064400000000054151162054210016156
0ustar00<html><body
bgcolor="#FFFFFF"></body></html>src/Componentbuilder/Interfaces/Serverinterface.php000064400000001775151162054210016576
0ustar00<?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\Interfaces;
/**
* The Core Server Interface
*/
interface Serverinterface
{
/**
* set the server details
*
* @param object $details The server details
*
* @return self
* @since 3.2.0
**/
public function set(object $details);
/**
* move a file to server with the FTP client
*
* @param string $localPath The full local path to the file
* @param string $fileName The file name
*
* @return bool
* @since 3.2.0
**/
public function move(string $localPath, string $fileName): bool;
}
src/Componentbuilder/Interfaces/index.html000064400000000054151162054210014720
0ustar00<html><body
bgcolor="#FFFFFF"></body></html>src/Componentbuilder/JoomlaPower/Config.php000064400000007605151162054210015025
0ustar00<?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\JoomlaPower;
use Joomla\Registry\Registry as JoomlaRegistry;
use Joomla\CMS\Factory as JoomlaFactory;
use VDM\Joomla\Utilities\GetHelper;
use VDM\Joomla\Utilities\StringHelper;
use VDM\Joomla\Componentbuilder\Utilities\RepoHelper;
use VDM\Joomla\Componentbuilder\Abstraction\BaseConfig;
/**
* Compiler Configurations
*
* All these functions are accessed via the direct name without the get:
* example: $this->component_code_name calls:
$this->getComponentcodename()
*
* All values once called are cached, yet can be updated directly:
* example: $this->component_code_name = 'new_code_name'; //
be warned!
*
* @since 3.2.0
*/
class Config extends BaseConfig
{
/**
* The Global Joomla Configuration
*
* @var JoomlaRegistry
* @since 3.2.0
*/
protected JoomlaRegistry $config;
/**
* Constructor
*
* @param Input|null $input Input
* @param Registry|null $params The component parameters
* @param Registry|null $config The Joomla configuration
*
* @throws \Exception
* @since 3.2.0
*/
public function __construct(?Input $input = null, ?JoomlaRegistry $params
= null, ?JoomlaRegistry $config = null)
{
parent::__construct($input, $params);
$this->config = $config ?: JoomlaFactory::getConfig();
}
/**
* get Gitea Username
*
* @return string the access token
* @since 3.2.0
*/
protected function getGiteausername(): ?string
{
return $this->params->get('gitea_username');
}
/**
* get Gitea Access Token
*
* @return string the access token
* @since 3.2.0
*/
protected function getGiteatoken(): ?string
{
return $this->params->get('gitea_token');
}
/**
* Get super power core organisation
*
* @return string The super power core organisation
* @since 3.2.0
*/
protected function getJoomlapowerscoreorganisation(): string
{
// the VDM default organisation is [joomla]
$organisation = 'joomla';
return
$this->params->get('joomla_powers_core_organisation',
$organisation);
}
/**
* Get Joomla power init repos
*
* @return array The init repositories on Gitea
* @since 3.2.0
*/
protected function getJoomlapowersinitrepos(): array
{
// some defaults repos we need by JCB
$repos = [];
// get the users own power repo (can overwrite all)
if (!empty($this->gitea_username))
{
$repos[$this->gitea_username . '.joomla-powers'] = (object)
['organisation' => $this->gitea_username,
'repository' => 'joomla-powers',
'read_branch' => 'master'];
}
$repos[$this->joomla_powers_core_organisation .
'.joomla-powers'] = (object) ['organisation' =>
$this->joomla_powers_core_organisation, 'repository' =>
'joomla-powers', 'read_branch' =>
'master'];
return $repos;
}
/**
* Get joomla power approved paths
*
* @return array The approved paths to the repositories on Gitea
* @since 3.2.0
*/
protected function getApprovedjoomlapaths(): array
{
// some defaults repos we need by JCB
$approved = $this->joomla_powers_init_repos;
$paths = RepoHelper::get(2); // Joomla Power = 2
if ($paths !== null)
{
foreach ($paths as $path)
{
$owner = $path->organisation ?? null;
$repo = $path->repository ?? null;
if ($owner !== null && $repo !== null)
{
// we make sure to get only the objects
$approved = ["{$owner}.{$repo}" => $path] + $approved;
}
}
}
return array_values($approved);
}
}
src/Componentbuilder/JoomlaPower/Factory.php000064400000003030151162054210015213
0ustar00<?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\JoomlaPower;
use Joomla\DI\Container;
use VDM\Joomla\Componentbuilder\JoomlaPower\Service\JoomlaPower as Power;
use VDM\Joomla\Service\Database;
use VDM\Joomla\Service\Model;
use VDM\Joomla\Service\Data;
use VDM\Joomla\Componentbuilder\Service\Gitea;
use VDM\Joomla\Componentbuilder\Power\Service\Gitea as GiteaPower;
use VDM\Joomla\Gitea\Service\Utilities as GiteaUtilities;
use VDM\Joomla\Interfaces\FactoryInterface;
use VDM\Joomla\Abstraction\Factory as ExtendingFactory;
/**
* Joomla Power Factory
*
* @since 3.2.0
*/
abstract class Factory extends ExtendingFactory implements FactoryInterface
{
/**
* Create a container object
*
* @return Container
* @since 3.2.0
*/
protected static function createContainer(): Container
{
return (new Container())
->registerServiceProvider(new Power())
->registerServiceProvider(new Database())
->registerServiceProvider(new Model())
->registerServiceProvider(new Data())
->registerServiceProvider(new Gitea())
->registerServiceProvider(new GiteaPower())
->registerServiceProvider(new GiteaUtilities());
}
}
src/Componentbuilder/JoomlaPower/Grep.php000064400000010626151162054210014512
0ustar00<?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\JoomlaPower;
use Joomla\CMS\Language\Text;
use VDM\Joomla\Interfaces\GrepInterface;
use VDM\Joomla\Abstraction\Grep as ExtendingGrep;
/**
* Global Resource Empowerment Platform
*
* The Grep feature will try to find your joomla power in the
repositories listed in the global
* Options of JCB in the super powers tab, and if it can't be found
there will try the global core
* Super powers of JCB. All searches are performed according the
[algorithm:cascading]
* See documentation for more details:
https://git.vdm.dev/joomla/super-powers/wiki
*
* @since 3.2.1
*/
final class Grep extends ExtendingGrep implements GrepInterface
{
/**
* Order of global search
*
* @var array
* @since 3.2.1
**/
protected array $order = ['remote'];
/**
* Search for a remote item
*
* @param string $guid The global unique id of the item
*
* @return object|null
* @since 3.2.0
*/
protected function searchRemote(string $guid): ?object
{
// check if it exists remotely
if (($path = $this->existsRemotely($guid)) !== null)
{
return $this->getRemote($path, $guid);
}
return null;
}
/**
* Get a remote joomla power
*
* @param object $path The repository path details
* @param string $guid The global unique id of the power
*
* @return object|null
* @since 3.2.0
*/
protected function getRemote(object $path, string $guid): ?object
{
$power = null;
if (empty($path->index->{$guid}->path))
{
return $power;
}
// get the branch name
$branch = $this->getBranchName($path);
// load the base and token if set
$this->contents->load_($path->base ?? null, $path->token ??
null);
// get the settings
if (($power = $this->loadRemoteFile($path->organisation,
$path->repository, $path->index->{$guid}->path .
'/item.json', $branch)) !== null &&
isset($power->guid))
{
// set the git details in params
$path_guid = $path->guid ?? null;
if ($path_guid !== null)
{
// get the Settings meta
if (($meta = $this->contents->metadata($path->organisation,
$path->repository, $path->index->{$guid}->path .
'/item.json', $branch)) !== null &&
isset($meta->sha))
{
if (isset($power->params) && is_object($power->params)
&&
isset($power->params->source) &&
is_array($power->params->source))
{
$power->params->source[$path_guid . '-settings'] =
$meta->sha;
}
else
{
$power->params = (object) [
'source' => [$path_guid . '-settings' =>
$meta->sha]
];
}
}
// get the README meta
if (($meta = $this->contents->metadata($path->organisation,
$path->repository, $path->index->{$guid}->path .
'/README.md', $branch)) !== null &&
isset($meta->sha))
{
if (isset($power->params) && is_object($power->params)
&&
isset($power->params->source) &&
is_array($power->params->source))
{
$power->params->source[$path_guid . '-readme'] =
$meta->sha;
}
else
{
$power->params = (object) [
'source' => [$path_guid . '-readme' =>
$meta->sha]
];
}
}
}
}
// reset back to the global base and token
$this->contents->reset_();
return $power;
}
/**
* Set repository messages and errors based on given conditions.
*
* @param string $message The message to set (if error)
* @param string $path Path value
* @param string $repository Repository name
* @param string $organisation Organisation name
* @param string|null $base Base URL
*
* @return void
* @since 3.2.0
*/
protected function setRemoteIndexMessage(string $message, string $path,
string $repository, string $organisation, ?string $base): void
{
$this->app->enqueueMessage(
Text::sprintf('COM_COMPONENTBUILDER_PJOOMLA_POWERB_REPOSITORY_AT_BSSB_GAVE_THE_FOLLOWING_ERRORBR_SP',
$this->contents->api(), $path, $message),
'Error'
);
}
}
src/Componentbuilder/JoomlaPower/Readme/Item.php000064400000007702151162054210015711
0ustar00<?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\JoomlaPower\Readme;
use VDM\Joomla\Interfaces\Readme\ItemInterface;
/**
* Compiler Joomla Power Item Readme
* @since 3.2.0
*/
final class Item implements ItemInterface
{
/**
* Get an item readme
*
* @param object $item An item details.
*
* @return string
* @since 3.2.2
*/
public function get(object $item): string
{
// build readme
$readme = ["```
██╗ ██████╗ ██████╗ ███╗
███╗██╗ █████╗ ██████╗
██████╗ ██╗
██╗███████╗██████╗
██║██╔═══██╗██╔═══██╗████╗
████║██║ ██╔══██╗
██╔══██╗██╔═══██╗██║
██║██╔════╝██╔══██╗
██║██║ ██║██║
██║██╔████╔██║██║
███████║ ██████╔╝██║
██║██║ █╗ ██║█████╗
██████╔╝
██ ██║██║ ██║██║
██║██║╚██╔╝██║██║
██╔══██║ ██╔═══╝ ██║
██║██║███╗██║██╔══╝
██╔══██╗
╚█████╔╝╚██████╔╝╚██████╔╝██║
╚═╝ ██║███████╗██║ ██║
██║
╚██████╔╝╚███╔███╔╝███████╗██║
██║
╚════╝ ╚═════╝ ╚═════╝ ╚═╝
╚═╝╚══════╝╚═╝ ╚═╝ ╚═╝
╚═════╝ ╚══╝╚══╝
╚══════╝╚═╝ ╚═╝
```"];
// system name
$readme[] = "# " . $item->system_name;
if (!empty($item->description))
{
$readme[] = "\n" . $item->description;
}
$readme[] = "\nThe Joomla! Power feature allows you to use Joomla
classes in your project without manually managing their namespaces. JCB
will automatically add the correct namespaces to your files. If Joomla
classes change in future versions, such as from Joomla 3 to 5, JCB will
update them for you.\n\nHowever, if there are breaking changes in function
names, you may need to make some manual adjustments. The Joomla Power Key
(JPK) helps you easily search for these classes.\n\nBy using the JPK
(Joomla Power Key) in your custom code (replacing the class name in your
code with the JPK), JCB will automatically pull the Joomla! Power from the
repository into your project.\n\nTo add this specific power to your project
in JCB:\n\n> simply use this JPK\n```\n" . 'Joomla---' .
str_replace('-', '_', $item->guid) .
'---Power' . "\n```\n> remember to replace the `---` with
`___` to activate this Joomla! Power in your code";
// yes you can remove this, but why?
$readme[] = "\n---\n```
██╗ ██████╗██████╗
██║██╔════╝██╔══██╗
██║██║ ██████╔╝
██ ██║██║ ██╔══██╗
╚█████╔╝╚██████╗██████╔╝
╚════╝ ╚═════╝╚═════╝
```\n> Build with [Joomla Component
Builder](https://git.vdm.dev/joomla/Component-Builder)\n\n";
return implode("\n", $readme);
}
}
src/Componentbuilder/JoomlaPower/Readme/Main.php000064400000024074151162054210015700
0ustar00<?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\JoomlaPower\Readme;
use VDM\Joomla\Interfaces\Readme\MainInterface;
/**
* Compiler Power Main Readme
* @since 3.2.0
*/
final class Main implements MainInterface
{
/**
* Get Main Readme
*
* @param array $items All items of this repository.
*
* @return string
* @since 3.2.0
*/
public function get(array $items): string
{
// build readme
$readme = ["```
██╗ ██████╗ ██████╗ ███╗
███╗██╗ █████╗
██║██╔═══██╗██╔═══██╗████╗
████║██║ ██╔══██╗
██║██║ ██║██║
██║██╔████╔██║██║
███████║
██ ██║██║ ██║██║
██║██║╚██╔╝██║██║
██╔══██║
╚█████╔╝╚██████╔╝╚██████╔╝██║
╚═╝ ██║███████╗██║ ██║
╚════╝ ╚═════╝ ╚═════╝ ╚═╝
╚═╝╚══════╝╚═╝ ╚═╝
██████╗ ██████╗ ██╗
██╗███████╗██████╗
███████╗
██╔══██╗██╔═══██╗██║
██║██╔════╝██╔══██╗██╔════╝
██████╔╝██║ ██║██║ █╗
██║█████╗
██████╔╝███████╗
██╔═══╝ ██║
██║██║███╗██║██╔══╝
██╔══██╗╚════██║
██║
╚██████╔╝╚███╔███╔╝███████╗██║
██║███████║
╚═╝ ╚═════╝ ╚══╝╚══╝
╚══════╝╚═╝ ╚═╝╚══════╝
```"];
// default description of super powers
$readme[] = "\n### What is JCB Joomla Powers?\nThe Joomla Component
Builder (JCB) Joomla Power features are designed to enhance JCB's
functionality and streamline the development process. The Joomla powers
enable developers to effectively leverage Joomla classes in their custom
code without needing to manually add the `use` statements for those classes
to the file headers. JCB automatically updates these `use` statements in
the necessary headers when it detects a Joomla power key in the custom
code.\n
\n
By doing this, we can control the `use` statements dynamically from a
central point. This is particularly beneficial when transitioning from
Joomla 3 to Joomla 4, as it allows us to seamlessly switch from certain
classes to their respective Joomla framework classes and vice versa.
Maintaining these `use` statements in the Joomla Power area ensures that
JCB handles the inclusion and updating of class names to prevent conflicts
with other classes.\n
\n
This approach is convenient and allows developers to focus on the bespoke
parts of their application logic without worrying about class
declarations.\n
\nThis repository contains an index (see below) of all the Joomla! Powers
within the JCB core GUI. These Joomla! Powers are automatically added to
the repository by our maintainers, ensuring a well-organized and accessible
collection of Joomla Classes are maintained.\n";
// get the readme body
$readme[] = $this->readmeBuilder($items);
// yes you can remove this, but why?
$readme[] = "\n---\n```
██╗ ██████╗ ██████╗ ███╗
███╗██╗ █████╗
██║██╔═══██╗██╔═══██╗████╗
████║██║ ██╔══██╗
██║██║ ██║██║
██║██╔████╔██║██║
███████║
██ ██║██║ ██║██║
██║██║╚██╔╝██║██║
██╔══██║
╚█████╔╝╚██████╔╝╚██████╔╝██║
╚═╝ ██║███████╗██║ ██║
╚════╝ ╚═════╝ ╚═════╝ ╚═╝
╚═╝╚══════╝╚═╝ ╚═╝
██████╗ ██████╗ ███╗
███╗██████╗ ██████╗ ███╗
██╗███████╗███╗
██╗████████╗
██╔════╝██╔═══██╗████╗
████║██╔══██╗██╔═══██╗████╗
██║██╔════╝████╗
██║╚══██╔══╝
██║ ██║
██║██╔████╔██║██████╔╝██║
██║██╔██╗ ██║█████╗
██╔██╗ ██║ ██║
██║ ██║
██║██║╚██╔╝██║██╔═══╝ ██║
██║██║╚██╗██║██╔══╝
██║╚██╗██║ ██║
╚██████╗╚██████╔╝██║ ╚═╝
██║██║ ╚██████╔╝██║
╚████║███████╗██║ ╚████║
██║
╚═════╝ ╚═════╝ ╚═╝
╚═╝╚═╝ ╚═════╝ ╚═╝
╚═══╝╚══════╝╚═╝ ╚═══╝
╚═╝
██████╗ ██╗ ██╗██╗██╗
██████╗ ███████╗██████╗
██╔══██╗██║ ██║██║██║
██╔══██╗██╔════╝██╔══██╗
██████╔╝██║ ██║██║██║
██║ ██║█████╗ ██████╔╝
██╔══██╗██║ ██║██║██║
██║ ██║██╔══╝ ██╔══██╗
██████╔╝╚██████╔╝██║███████╗██████╔╝███████╗██║
██║
╚═════╝ ╚═════╝
╚═╝╚══════╝╚═════╝
╚══════╝╚═╝ ╚═╝
```\n> Build with [Joomla Component
Builder](https://git.vdm.dev/joomla/Component-Builder)\n\n";
return implode("\n", $readme);
}
/**
* The readme builder
*
* @param array $classes The powers.
*
* @return string
* @since 3.2.0
*/
private function readmeBuilder(array &$items): string
{
$classes = [];
foreach ($items as $guid => $power)
{
// add to the sort bucket
$classes[] = [
'name' => $power['name'],
'link' => $this->indexLinkPower($power)
];
}
return $this->readmeModel($classes);
}
/**
* Sort and model the readme classes
*
* @param array $classes The powers.
*
* @return string
* @since 3.2.0
*/
private function readmeModel(array &$classes): string
{
$this->sortClasses($classes);
return $this->generateIndex($classes);
}
/**
* Generate the index string for classes
*
* @param array $classes The sorted classes
*
* @return string The index string
*/
private function generateIndex(array &$classes): string
{
$result = "# Index of Joomla! Powers\n";
foreach ($classes as $class)
{
// Add the class details
$result .= "\n - " . $class['link'];
}
$result .= "\n> remember to replace the `---` with `___` in the
JPK to activate that Joomla! Power in your code";
return $result;
}
/**
* Sort the flattened array using a single sorting function
*
* @param array $classes The classes to sort
*
* @since 3.2.0
*/
private function sortClasses(array &$classes): void
{
usort($classes, function ($a, $b) {
return $this->compareName($a, $b);
});
}
/**
* Compare the name of two classes
*
* @param array $a First class
* @param array $b Second class
*
* @return int Comparison result
* @since 3.2.0
*/
private function compareName(array $a, array $b): int
{
return strcmp($a['name'], $b['name']);
}
/**
* Build the Link to the power in this repository
*
* @param array $power The power details.
*
* @return string
* @since 3.2.0
*/
private function indexLinkPower(array &$power): string
{
$name = $power['name'] ?? 'error';
return '**' . $name . "** | "
. $this->linkPowerRepo($power) . ' | '
. $this->linkPowerSettings($power) . ' | JPK: `'
. $this->linkPowerJPK($power) .'`';
}
/**
* Build the Link to the power in this repository
*
* @param array $power The power details.
*
* @return string
* @since 3.2.0
*/
private function linkPowerRepo(array &$power): string
{
$path = $power['path'] ?? 'error';
return '[Details](' . $path . ')';
}
/**
* Build the Link to the power settings in this repository
*
* @param array $power The power details.
*
* @return string
* @since 3.2.0
*/
private function linkPowerSettings(array &$power): string
{
$settings = $power['settings'] ?? 'error';
return '[Settings](' . $settings . ')';
}
/**
* Get the JoomlaPowerKey (JPK)
*
* @param array $power The power details.
*
* @return string
* @since 3.2.0
*/
private function linkPowerJPK(array &$power): string
{
$jpk = $power['jpk'] ?? 'error';
return $jpk;
}
}
src/Componentbuilder/JoomlaPower/Readme/index.html000064400000000054151162054210016270
0ustar00<html><body
bgcolor="#FFFFFF"></body></html>src/Componentbuilder/JoomlaPower/Remote/Get.php000064400000001457151162054210015571
0ustar00<?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\JoomlaPower\Remote;
use VDM\Joomla\Interfaces\Remote\GetInterface;
use VDM\Joomla\Abstraction\Remote\Get as ExtendingGet;
/**
* Remote Get Joomla Power of JCB
*
* @since 3.2.0
*/
final class Get extends ExtendingGet implements GetInterface
{
/**
* Table Name
*
* @var string
* @since 3.2.1
*/
protected string $table = 'joomla_power';
}
src/Componentbuilder/JoomlaPower/Remote/Set.php000064400000010654151162054210015604
0ustar00<?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\JoomlaPower\Remote;
use VDM\Joomla\Interfaces\Remote\SetInterface;
use VDM\Joomla\Abstraction\Remote\Set as ExtendingSet;
/**
* Set JoomlaPower based on global unique ids to remote repository
*
* @since 3.2.2
*/
final class Set extends ExtendingSet implements SetInterface
{
/**
* Table Name
*
* @var string
* @since 3.2.2
*/
protected string $table = 'joomla_power';
/**
* Area Name
*
* @var string
* @since 3.2.2
*/
protected string $area = 'Joomla Power';
/**
* Prefix Key
*
* @var string
* @since 3.2.2
*/
protected string $prefix_key = 'Joomla---';
/**
* The item map
*
* @var array
* @since 3.2.2
*/
protected array $map = [
'system_name' => 'system_name',
'settings' => 'settings',
'guid' => 'guid',
'description' => 'description'
];
/**
* The index map
*
* @var array
* @since 3.2.2
*/
protected array $index_map = [
'name' => 'index_map_IndexName',
'settings' => 'index_map_IndexSettingsPath',
'path' => 'index_map_IndexPath',
'jpk' => 'index_map_IndexKey',
'guid' => 'index_map_IndexGUID'
];
/**
* update an existing item (if changed)
*
* @param object $item
* @param object $existing
* @param object $repo
*
* @return bool
* @since 3.2.2
*/
protected function updateItem(object $item, object $existing, object
$repo): bool
{
// make sure there was a change
$sha = $existing->params->source[$repo->guid .
'-settings'] ?? null;
$existing = $this->mapItem($existing);
if ($sha === null || $this->areObjectsEqual($item, $existing))
{
return false;
}
$this->git->update(
$repo->organisation, // The owner name.
$repo->repository, // The repository name.
'src/' . $item->guid . '/' .
$this->getSettingsPath(), // The file path.
json_encode($item, JSON_PRETTY_PRINT), // The file content.
'Update ' . $item->system_name, // The commit message.
$sha, // The blob SHA of the old file.
$repo->write_branch // The branch name.
);
return true;
}
/**
* create a new item
*
* @param object $item
* @param object $repo
*
* @return void
* @since 3.2.2
*/
protected function createItem(object $item, object $repo): void
{
$this->git->create(
$repo->organisation, // The owner name.
$repo->repository, // The repository name.
'src/' . $item->guid . '/' .
$this->getSettingsPath(), // The file path.
json_encode($item, JSON_PRETTY_PRINT), // The file content.
'Create ' . $item->system_name, // The commit message.
$repo->write_branch // The branch name.
);
}
/**
* update an existing item readme
*
* @param object $item
* @param object $existing
* @param object $repo
*
* @return void
* @since 3.2.2
*/
protected function updateItemReadme(object $item, object $existing, object
$repo): void
{
// make sure there was a change
$sha = $existing->params->source[$repo->guid .
'-readme'] ?? null;
if ($sha === null)
{
return;
}
$this->git->update(
$repo->organisation, // The owner name.
$repo->repository, // The repository name.
'src/' . $item->guid . '/README.md', // The file
path.
$this->itemReadme->get($item), // The file content.
'Update ' . $item->system_name . ' readme file',
// The commit message.
$sha, // The blob SHA of the old file.
$repo->write_branch // The branch name.
);
}
/**
* create a new item readme
*
* @param object $item
* @param object $repo
*
* @return void
* @since 3.2.2
*/
protected function createItemReadme(object $item, object $repo): void
{
$this->git->create(
$repo->organisation, // The owner name.
$repo->repository, // The repository name.
'src/' . $item->guid . '/README.md', // The file
path.
$this->itemReadme->get($item), // The file content.
'Create ' . $item->system_name . ' readme file',
// The commit message.
$repo->write_branch // The branch name.
);
}
}
src/Componentbuilder/JoomlaPower/Remote/index.html000064400000000054151162054210016326
0ustar00<html><body
bgcolor="#FFFFFF"></body></html>src/Componentbuilder/JoomlaPower/Service/JoomlaPower.php000064400000010247151162054210017452
0ustar00<?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\JoomlaPower\Service;
use Joomla\DI\Container;
use Joomla\DI\ServiceProviderInterface;
use VDM\Joomla\Componentbuilder\JoomlaPower\Config;
use VDM\Joomla\Componentbuilder\Table;
use VDM\Joomla\Componentbuilder\JoomlaPower\Grep;
use VDM\Joomla\Componentbuilder\JoomlaPower\Remote\Get;
use VDM\Joomla\Componentbuilder\JoomlaPower\Remote\Set;
use VDM\Joomla\Componentbuilder\JoomlaPower\Readme\Item as ItemReadme;
use VDM\Joomla\Componentbuilder\JoomlaPower\Readme\Main as MainReadme;
/**
* Joomla Power Service Provider
*
* @since 3.2.1
*/
class JoomlaPower implements ServiceProviderInterface
{
/**
* Registers the service provider with a DI container.
*
* @param Container $container The DI container.
*
* @return void
* @since 3.2.1
*/
public function register(Container $container)
{
$container->alias(Config::class, 'Config')
->share('Config', [$this, 'getConfig'], true);
$container->alias(Table::class, 'Table')
->share('Table', [$this, 'getTable'], true);
$container->alias(Grep::class, 'Joomla.Power.Grep')
->share('Joomla.Power.Grep', [$this, 'getGrep'],
true);
$container->alias(Get::class, 'Joomla.Power.Remote.Get')
->share('Joomla.Power.Remote.Get', [$this,
'getRemoteGet'], true);
$container->alias(Set::class, 'Joomla.Power.Remote.Set')
->share('Joomla.Power.Remote.Set', [$this,
'getRemoteSet'], true);
$container->alias(ItemReadme::class,
'Joomla.Power.Readme.Item')
->share('Joomla.Power.Readme.Item', [$this,
'getItemReadme'], true);
$container->alias(MainReadme::class,
'Joomla.Power.Readme.Main')
->share('Joomla.Power.Readme.Main', [$this,
'getMainReadme'], true);
}
/**
* Get The Config Class.
*
* @param Container $container The DI container.
*
* @return Config
* @since 3.2.1
*/
public function getConfig(Container $container): Config
{
return new Config();
}
/**
* Get The Table Class.
*
* @param Container $container The DI container.
*
* @return Table
* @since 3.2.1
*/
public function getTable(Container $container): Table
{
return new Table();
}
/**
* Get The Grep Class.
*
* @param Container $container The DI container.
*
* @return Grep
* @since 3.2.1
*/
public function getGrep(Container $container): Grep
{
return new Grep(
$container->get('Gitea.Repository.Contents'),
$container->get('Config')->approved_joomla_paths
);
}
/**
* Get The Remote Get Class.
*
* @param Container $container The DI container.
*
* @return Get
* @since 3.2.1
*/
public function getRemoteGet(Container $container): Get
{
return new Get(
$container->get('Joomla.Power.Grep'),
$container->get('Data.Item')
);
}
/**
* Get The Remote Set Class.
*
* @param Container $container The DI container.
*
* @return Set
* @since 3.2.2
*/
public function getRemoteSet(Container $container): Set
{
return new Set(
$container->get('Config')->approved_joomla_paths,
$container->get('Joomla.Power.Grep'),
$container->get('Data.Items'),
$container->get('Joomla.Power.Readme.Item'),
$container->get('Joomla.Power.Readme.Main'),
$container->get('Gitea.Repository.Contents')
);
}
/**
* Get The Item Class.
*
* @param Container $container The DI container.
*
* @return ItemReadme
* @since 3.2.1
*/
public function getItemReadme(Container $container): ItemReadme
{
return new ItemReadme();
}
/**
* Get The Main Class.
*
* @param Container $container The DI container.
*
* @return MainReadme
* @since 3.2.1
*/
public function getMainReadme(Container $container): MainReadme
{
return new MainReadme();
}
}
src/Componentbuilder/JoomlaPower/Service/index.html000064400000000054151162054210016473
0ustar00<html><body
bgcolor="#FFFFFF"></body></html>src/Componentbuilder/PHPConfigurationChecker.php000064400000003613151162054210016021
0ustar00<?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;
use VDM\Joomla\Interfaces\PHPConfigurationCheckerInterface;
use VDM\Joomla\Abstraction\PHPConfigurationChecker as
ExtendingPHPConfigurationChecker;
/**
* Componentbuilder PHP Configuration Checker
*
* @since 5.02
*/
final class PHPConfigurationChecker extends
ExtendingPHPConfigurationChecker implements
PHPConfigurationCheckerInterface
{
/**
* The upload max filesize value
*
* @var string
* @since 5.0.2
**/
protected string $upload_max_filesize = '128M';
/**
* The post max size value
*
* @var string
* @since 5.0.2
**/
protected string $post_max_size = '128M';
/**
* The max execution time value
*
* @var int
* @since 5.0.2
**/
protected int $max_execution_time = 60;
/**
* The max input vars value
*
* @var int
* @since 5.0.2
**/
protected int $max_input_vars = 7000;
/**
* The max input time value
*
* @var int
* @since 5.0.2
**/
protected int $max_input_time = 60;
/**
* The memory limit value
*
* @var string
* @since 5.0.2
**/
protected string $memory_limit = '256M';
/**
* Constructor.
*
* @since 5.0.2
*/
public function __construct($app = null)
{
parent::__construct($app);
// set the required PHP Configures
$this->set('environment.name', 'Componentbuilder
environment');
$this->set('environment.wiki_url',
'git.vdm.dev/joomla/Component-Builder/wiki/PHP-Settings');
}
}
src/Componentbuilder/Package/Database/Insert.php000064400000010743151162054220015663
0ustar00<?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\Package\Database;
use Joomla\CMS\Factory as JoomlaFactory;
use VDM\Joomla\Componentbuilder\Search\Factory;
use VDM\Joomla\Componentbuilder\Search\Config;
use VDM\Joomla\Componentbuilder\Table;
use VDM\Joomla\Componentbuilder\Search\Model\Insert as Model;
use VDM\Joomla\Utilities\ArrayHelper;
/**
* Package Database Insert
*
* @since 3.2.0
*/
class Insert
{
/**
* Search Config
*
* @var Config
* @since 3.2.0
*/
protected Config $config;
/**
* Search Table
*
* @var Table
* @since 3.2.0
*/
protected Table $table;
/**
* Search Model
*
* @var Model
* @since 3.2.0
*/
protected Model $model;
/**
* Database object to query local DB
*
* @var \JDatabaseDriver
* @since 3.2.0
**/
protected \JDatabaseDriver $db;
/**
* Constructor
*
* @param Config|null $config The search config object.
* @param Table|null $table The search table object.
* @param Model|null $model The search get model
object.
* @param \JDatabaseDriver|null $db The database object.
*
* @since 3.2.0
*/
public function __construct(?Config $config = null, ?Table $table = null,
?Model $model = null, ?\JDatabaseDriver $db = null)
{
$this->config = $config ?: Factory::_('Config');
$this->table = $table ?: Factory::_('Table');
$this->model = $model ?: Factory::_('Set.Model');
$this->db = $db ?: JoomlaFactory::getDbo();
}
/**
* Set values to a given table
* Example: $this->value(Value, 23, 'value_key',
'table_name');
*
* @param mixed $value The field value
* @param int $id The item ID
* @param string $field The field key
* @param string|null $table The table
*
* @return bool
* @since 3.2.0
*/
public function value($value, int $id, string $field, ?string $table =
null): bool
{
// load the table
if (empty($table))
{
$table = $this->config->table_name;
}
// check if this is a valid field and table
if ($id > 0 && ($name = $this->table->get($table,
$field, 'name')) !== null)
{
// build the object
$item = new \stdClass();
$item->id = $id;
$item->{$name} = $this->model->value($value, $name, $table);
// Update the column of this table using id as the primary key.
return $this->db->updateObject('#__componentbuilder_' .
$table, $item, 'id');
}
return false;
}
/**
* Set values to a given table
* Example: $this->item(Object, 23, 'table_name');
*
* @param object $item The item to save
* @param string|null $table The table
*
* @return bool
* @since 3.2.0
*/
public function item(object $item, ?string $table = null): bool
{
// load the table
if (empty($table))
{
$table = $this->config->table_name;
}
// check if this is a valid table
if (($fields = $this->table->fields($table)) !== null)
{
// model the item values
foreach ($fields as $field)
{
if (isset($item->{$field}))
{
$item->{$field} = $this->model->value($item->{$field},
$field, $table);
}
}
// Update the column of this table using id as the primary key.
return $this->db->updateObject('#__componentbuilder_' .
$table, $item, 'id');
}
return false;
}
/**
* Set values to a given table
* Example: $this->items(Array, 'table_name');
*
* @param array|null $items The items being saved
* @param string|null $table The table
*
* @return bool
* @since 3.2.0
*/
public function items(?array $items, string $table = null): bool
{
// load the table
if (empty($table))
{
$table = $this->config->table_name;
}
// check if this is a valid table
if (ArrayHelper::check($items))
{
$success = true;
foreach ($items as $item)
{
if (!$this->item($item, $table))
{
$success = false;
break;
}
}
return $success;
}
return false;
}
}
src/Componentbuilder/Package/Database/Load.php000064400000005467151162054220015305
0ustar00<?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\Package\Database;
use VDM\Joomla\Componentbuilder\Package\Factory;
use VDM\Joomla\Componentbuilder\Table;
use VDM\Joomla\Database\Load as Database;
/**
* Package Database Load
*
* @since 3.2.0
*/
class Load
{
/**
* Search Table
*
* @var Table
* @since 3.2.0
*/
protected Table $table;
/**
* Database Load
*
* @var Database
* @since 3.2.0
*/
protected Database $load;
/**
* Constructor
*
* @param Table|null $table The core table object.
* @param Database|null $load The database object.
*
* @since 3.2.0
*/
public function __construct(?Table $table = null, ?Database $load = null)
{
$this->table = $table ?: Factory::_('Table');
$this->load = $load ?: Factory::_('Load');
}
/**
* Get a value from a given table
* Example: $this->value(23, 'value_key',
'table_name');
*
* @param int $id The item ID
* @param string $field The field key
* @param string $table The table
*
* @return mixed
* @since 3.2.0
*/
public function value(int $id, string $field, string $table)
{
// check if this is a valid table
if ($id > 0 && $this->table->exist($table, $field))
{
return $this->load->value(
["a.${field}" => $field], ['a' => $table],
['a.id' => $id]
);
}
return null;
}
/**
* Get values from a given table
* Example: $this->item(23, 'table_name');
*
* @param int $id The item ID
* @param string $table The table
*
* @return object|null
* @since 3.2.0
*/
public function item(int $id, ?string $table): ?object
{
// check if this is a valid table
if ($id > 0 && $this->table->exist($table))
{
return $this->load->item(
['all' => 'a.*'], ['a' => $table],
['a.id' => $id]
);
}
return null;
}
/**
* Get values from a given table
* Example: $this->items($ids, 'table_name');
*
* @param array $ids The item ids
* @param string $table The table
*
* @return array|null
* @since 3.2.0
*/
public function items(array $ids, string $table): ?array
{
// check if this is a valid table
if ($this->table->exist($table))
{
return $this->load->items(
['all' => 'a.*'], ['a' => $table],
['a.id' => $ids]
);
}
return null;
}
}
src/Componentbuilder/Package/Database/index.html000064400000000054151162054220015675
0ustar00<html><body
bgcolor="#FFFFFF"></body></html>src/Componentbuilder/Package/Display/Details.php000064400000017715151162054220015713
0ustar00<?php
/**
* @package FrameworkOnFramework
* @subpackage encrypt
* @copyright Copyright (C) 2010-2016 Nicholas K. Dionysopoulos / Akeeba
Ltd. All rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
* @note This file has been modified by the Joomla! Project and no longer
reflects the original work of its author.
*/
namespace VDM\Joomla\Componentbuilder\Package\Display;
use Joomla\CMS\Language\Text;
use VDM\Joomla\Utilities\StringHelper;
use VDM\Joomla\Utilities\ArrayHelper;
/**
* Package Display Details Class
*
* @since 3.2.0
*/
class Details
{
/**
* The Owner details template
*
* @var array
* @since 3.2.0
*/
private array $owner = [
'company' =>
'COM_COMPONENTBUILDER_DTCOMPANYDTDDSDD',
'owner' => 'COM_COMPONENTBUILDER_DTOWNERDTDDSDD',
'email' => 'COM_COMPONENTBUILDER_DTEMAILDTDDSDD',
'website' =>
'COM_COMPONENTBUILDER_DTWEBSITEDTDDSDD',
'license' =>
'COM_COMPONENTBUILDER_DTLICENSEDTDDSDD',
'copyright' =>
'COM_COMPONENTBUILDER_DTCOPYRIGHTDTDDSDD'
];
/**
* The Component details template
*
* @var array
* @since 3.2.0
*/
private array $component = [
'ul' => [
'companyname' =>
'COM_COMPONENTBUILDER_ICOMPANYI_BSB',
'author' => 'COM_COMPONENTBUILDER_IAUTHORI_BSB',
'email' => 'COM_COMPONENTBUILDER_IEMAILI_BSB',
'website' =>
'COM_COMPONENTBUILDER_IWEBSITEI_BSB',
],
'other' => [
'license' =>
'COM_COMPONENTBUILDER_HFOUR_CLASSNAVHEADERLICENSEHFOURPSP',
'copyright' =>
'COM_COMPONENTBUILDER_HFOUR_CLASSNAVHEADERCOPYRIGHTHFOURPSP'
]
];
/**
* get the JCB package owner details display
*
* @param array $info The package info object
* @param bool $trust The trust switch
*
* @return string
* @since 3.2.0
**/
public function owner(array $info, $trust = false): string
{
$hasOwner = false;
$ownerDetails = '<h2 class="module-title
nav-header">' .
Text::_('COM_COMPONENTBUILDER_PACKAGE_OWNER_DETAILS') .
'</h2>';
$ownerDetails .= '<dl
class="uk-description-list-horizontal">';
// load the list items
foreach ($this->owner as $key => $dd)
{
if ($value = $this->getInfoValue($key, $info))
{
$ownerDetails .= Text::sprintf($dd, $value);
// check if we have a owner/source name
if (('owner' === $key || 'company' === $key)
&& !$hasOwner)
{
$hasOwner = true;
$owner = $value;
}
}
}
$ownerDetails .= '</dl>';
// provide some details to how the user can get a key
if ($hasOwner &&
isset($info['getKeyFrom']['buy_link']) &&
StringHelper::check($info['getKeyFrom']['buy_link']))
{
$ownerDetails .= '<hr />';
$ownerDetails .=
Text::sprintf('COM_COMPONENTBUILDER_BGET_THE_KEY_FROMB_A_SSA',
'class="btn btn-primary" href="' .
$info['getKeyFrom']['buy_link'] . '"
target="_blank" title="get a key from ' . $owner .
'"', $owner);
}
// add more custom links
elseif ($hasOwner &&
isset($info['getKeyFrom']['buy_links']) &&
ArrayHelper::check($info['getKeyFrom']['buy_links']))
{
$buttons = array();
foreach ($info['getKeyFrom']['buy_links'] as
$keyName => $link)
{
$buttons[] =
Text::sprintf('COM_COMPONENTBUILDER_BGET_THE_KEY_FROM_SB_FOR_A_SSA',
$owner, 'class="btn btn-primary" href="' . $link .
'" target="_blank" title="get a key from ' .
$owner . '"', $keyName);
}
$ownerDetails .= '<hr />';
$ownerDetails .= implode('<br />', $buttons);
}
// return the owner details
if (!$hasOwner)
{
$ownerDetails = '<h2>' .
Text::_('COM_COMPONENTBUILDER_PACKAGE_OWNER_DETAILS_NOT_FOUND') .
'</h2>';
if (!$trust)
{
$ownerDetails .= '<p style="color:
#922924;">' .
Text::_('COM_COMPONENTBUILDER_BE_CAUTIOUS_DO_NOT_CONTINUE_UNLESS_YOU_TRUST_THE_ORIGIN_OF_THIS_PACKAGE')
. '</p>';
}
}
return '<div>'.$ownerDetails.'</div>';
}
/**
* Check if info details has owner values set
*
* @param array $info The package info object
*
* @return bool
* @since 3.2.0
**/
public function hasOwner(array &$info): bool
{
if ($this->getInfoValue('owner', $info) ||
$this->getInfoValue('company', $info))
{
return true;
}
return false;
}
/**
* get the JCB package components details display
*
* @param array $info The package info object
*
* @return string
* @since 3.2.0
**/
public function components(array &$info): string
{
// check if these components need a key
$needKey = $this->hasKey($info);
if (isset($info['name']) &&
ArrayHelper::check($info['name']))
{
$cAmount = count((array) $info['name']);
$class2 = ($cAmount == 1) ? 'span12' : 'span6';
$counter = 1;
$display = array();
foreach ($info['name'] as $key => $value)
{
// set the name
$name = $value . ' v' .
$info['component_version'][$key];
if ($cAmount > 1 && $counter == 3)
{
$display[] = '</div>';
$counter = 1;
}
if ($cAmount > 1 && $counter == 1)
{
$display[] = '<div>';
}
$display[] = '<div class="well well-small ' . $class2
. '">';
$display[] = '<h3>';
$display[] = $name;
if ($needKey)
{
$display[] = ' - <em>' .
Text::sprintf('COM_COMPONENTBUILDER_PAIDLOCKED') .
'</em>';
}
else
{
$display[] = ' - <em>' .
Text::sprintf('COM_COMPONENTBUILDER_FREEOPEN') .
'</em>';
}
$display[] = '</h3><h4>';
$display[] = $info['short_description'][$key];
$display[] = '</h4>';
$display[] = '<ul class="uk-list
uk-list-striped">';
// load the list items
foreach ($this->component['ul'] as $li => $value)
{
if (isset($info[$li]) && isset($info[$li][$key]))
{
$display[] = '<li>'.Text::sprintf($value,
$info[$li][$key]).'</li>';
}
}
$display[] = '</ul>';
// if we have a source link we add it
if (isset($info['joomla_source_link']) &&
ArrayHelper::check($info['joomla_source_link']) &&
isset($info['joomla_source_link'][$key]) &&
StringHelper::check($info['joomla_source_link'][$key]))
{
$display[] = '<a class="uk-button uk-button-mini
uk-width-1-1 uk-margin-small-bottom" href="' .
$info['joomla_source_link'][$key] . '"
target="_blank" title="' .
Text::_('COM_COMPONENTBUILDER_SOURCE_CODE_FOR_JOOMLA_COMPONENT')
. ' ('. $name . ')">' .
Text::_('COM_COMPONENTBUILDER_SOURCE_CODE') .
'</a>';
}
// load other
foreach ($this->component['other'] as $other =>
$value)
{
if (isset($info[$other]) && isset($info[$other][$key]))
{
$display[] = Text::sprintf($value, $info[$other][$key]);
}
}
$display[] = '</div>';
$counter++;
}
// close the div if needed
if ($cAmount > 1)
{
$display[] = '</div>';
}
return implode(PHP_EOL, $display);
}
return '<div>' .
Text::_('COM_COMPONENTBUILDER_NO_COMPONENT_DETAILS_FOUND_SO_IT_IS_NOT_SAFE_TO_CONTINUE')
. '</div>';
}
/**
* get the value from INFO array
*
* @param string $key The value key
* @param array $info The package info object
*
* @return string|null
* @since 3.2.0
**/
private function getInfoValue(string $key, array &$info): ?string
{
$source = (isset($info['source']) &&
isset($info['source'][$key])) ? 'source' :
((isset($info['getKeyFrom']) &&
isset($info['getKeyFrom'][$key])) ? 'getKeyFrom' :
null);
if ($source && StringHelper::check($info[$source][$key]))
{
return $info[$source][$key];
}
return null;
}
/**
* Check if the JCB package has a key
*
* @param array $info The package info object
*
* @return bool
* @since 3.2.0
**/
private function hasKey(array &$info): bool
{
// check the package key status
if (!isset($info['key']))
{
if (isset($info['getKeyFrom']) &&
isset($info['getKeyFrom']['owner']))
{
// has a key
$info['key'] = true;
}
else
{
// does not have a key
$info['key'] = false;
}
}
return (bool) $info['key'];
}
}
src/Componentbuilder/Package/Display/index.html000064400000000054151162054220015576
0ustar00<html><body
bgcolor="#FFFFFF"></body></html>src/Componentbuilder/Package/Factory.php000064400000002406151162054220014317
0ustar00<?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\Package;
use Joomla\DI\Container;
use VDM\Joomla\Componentbuilder\Service\Crypt;
use VDM\Joomla\Componentbuilder\Package\Service\Database;
use VDM\Joomla\Componentbuilder\Service\Server;
use VDM\Joomla\Componentbuilder\Package\Service\Display;
use VDM\Joomla\Interfaces\FactoryInterface;
use VDM\Joomla\Abstraction\Factory as ExtendingFactory;
/**
* Package Factory
*
* @since 3.2.0
*/
abstract class Factory extends ExtendingFactory implements FactoryInterface
{
/**
* Create a container object
*
* @return Container
* @since 3.2.0
*/
protected static function createContainer(): Container
{
return (new Container())
->registerServiceProvider(new Database())
->registerServiceProvider(new Crypt())
->registerServiceProvider(new Server())
->registerServiceProvider(new Display());
}
}
src/Componentbuilder/Package/Service/Database.php000064400000005142151162054220016014
0ustar00<?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\Package\Service;
use Joomla\DI\Container;
use Joomla\DI\ServiceProviderInterface;
use VDM\Joomla\Database\Load;
use VDM\Joomla\Database\Insert;
use VDM\Joomla\Componentbuilder\Package\Database\Load as LoadDatabase;
use VDM\Joomla\Componentbuilder\Package\Database\Insert as InsertDatabase;
/**
* Database Service Provider
*
* @since 3.2.0
*/
class Database implements ServiceProviderInterface
{
/**
* Registers the service provider with a DI container.
*
* @param Container $container The DI container.
*
* @return void
* @since 3.2.0
*/
public function register(Container $container)
{
$container->alias(Load::class, 'Load')
->share('Load', [$this, 'getLoad'], true);
$container->alias(Insert::class, 'Insert')
->share('Insert', [$this, 'getInsert'], true);
$container->alias(LoadDatabase::class, 'Load.Database')
->share('Load.Database', [$this,
'getDatabaseLoad'], true);
$container->alias(InsertDatabase::class, 'Insert.Database')
->share('Insert.Database', [$this,
'getDatabaseInsert'], true);
}
/**
* Get the Core Load Database
*
* @param Container $container The DI container.
*
* @return Load
* @since 3.2.0
*/
public function getLoad(Container $container): Load
{
return new Load();
}
/**
* Get the Core Insert Database
*
* @param Container $container The DI container.
*
* @return Insert
* @since 3.2.0
*/
public function getInsert(Container $container): Insert
{
return new Insert();
}
/**
* Get the Load Database
*
* @param Container $container The DI container.
*
* @return LoadDatabase
* @since 3.2.0
*/
public function getDatabaseLoad(Container $container): LoadDatabase
{
return new LoadDatabase(
$container->get('Table'),
$container->get('Load')
);
}
/**
* Get the Insert Database
*
* @param Container $container The DI container.
*
* @return InsertDatabase
* @since 3.2.0
*/
public function getDatabaseInsert(Container $container): InsertDatabase
{
return new InsertDatabase(
$container->get('Table'),
$container->get('Insert')
);
}
}
src/Componentbuilder/Package/Service/Display.php000064400000002411151162054220015711
0ustar00<?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\Package\Service;
use Joomla\DI\Container;
use Joomla\DI\ServiceProviderInterface;
use VDM\Joomla\Componentbuilder\Package\Display\Details;
/**
* Display Service Provider
*
* @since 3.2.0
*/
class Display implements ServiceProviderInterface
{
/**
* Registers the service provider with a DI container.
*
* @param Container $container The DI container.
*
* @return void
* @since 3.2.0
*/
public function register(Container $container)
{
$container->alias(Details::class, 'Display.Details')
->share('Display.Details', [$this, 'getDetails'],
true);
}
/**
* Get the Display Details
*
* @param Container $container The DI container.
*
* @return Details
* @since 3.2.0
*/
public function getDetails(Container $container): Details
{
return new Details();
}
}
src/Componentbuilder/Package/Service/index.html000064400000000054151162054220015571
0ustar00<html><body
bgcolor="#FFFFFF"></body></html>src/Componentbuilder/Package/index.html000064400000000054151162054220014171
0ustar00<html><body
bgcolor="#FFFFFF"></body></html>src/Componentbuilder/Power/Config.php000064400000013125151162054220013656
0ustar00<?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\Power;
use Joomla\Registry\Registry as JoomlaRegistry;
use Joomla\CMS\Factory as JoomlaFactory;
use Joomla\Input\Input;
use VDM\Joomla\Utilities\GetHelper;
use VDM\Joomla\Utilities\StringHelper;
use VDM\Joomla\Componentbuilder\Utilities\RepoHelper;
use VDM\Joomla\Componentbuilder\Abstraction\BaseConfig;
/**
* Compiler Configurations
*
* All these functions are accessed via the direct name without the get:
* example: $this->component_code_name calls:
$this->getComponentcodename()
*
* All values once called are cached, yet can be updated directly:
* example: $this->component_code_name = 'new_code_name'; //
be warned!
*
* @since 3.2.0
*/
class Config extends BaseConfig
{
/**
* The Global Joomla Configuration
*
* @var JoomlaRegistry
* @since 3.2.0
*/
protected JoomlaRegistry $config;
/**
* Constructor
*
* @param Input|null $input Input
* @param JoomlaRegistry|null $params The component parameters
* @param JoomlaRegistry|null $config The Joomla configuration
*
* @throws \Exception
* @since 3.2.0
*/
public function __construct(?Input $input = null, ?JoomlaRegistry $params
= null, ?JoomlaRegistry $config = null)
{
parent::__construct($input, $params);
$this->config = $config ?: JoomlaFactory::getConfig();
}
/**
* get Gitea Username
*
* @return string the access token
* @since 3.2.0
*/
protected function getGiteausername(): ?string
{
return $this->params->get('gitea_username');
}
/**
* get Gitea Access Token
*
* @return string the access token
* @since 3.2.0
*/
protected function getGiteatoken(): ?string
{
return $this->params->get('gitea_token');
}
/**
* Get super power core organisation
*
* @return string The super power core organisation
* @since 3.2.0
*/
protected function getSuperpowerscoreorganisation(): string
{
// the VDM default organisation is [joomla]
$organisation = 'joomla';
return $organisation;
}
/**
* Get super power init repos
*
* @return array The init repositories on Gitea
* @since 3.2.0
*/
protected function getSuperpowersinitrepos(): array
{
// some defaults repos we need by JCB
$repos = [];
// get the users own power repo (can overwrite all)
if ($this->gitea_username !== null)
{
$repos[$this->gitea_username . '.super-powers'] = (object)
[
'organisation' => $this->gitea_username,
'repository' => 'super-powers',
'read_branch' => 'master'
];
}
$repos[$this->super_powers_core_organisation .
'.super-powers'] = (object) [
'organisation' =>
$this->super_powers_core_organisation,
'repository' => 'super-powers',
'read_branch' => 'master'
];
$repos[$this->super_powers_core_organisation . '.gitea'] =
(object) [
'organisation' =>
$this->super_powers_core_organisation,
'repository' => 'gitea',
'read_branch' => 'master'
];
$repos[$this->super_powers_core_organisation . '.openai'] =
(object) [
'organisation' =>
$this->super_powers_core_organisation,
'repository' => 'openai',
'read_branch' => 'master'
];
return $repos;
}
/**
* get temporary path
*
* @return string The temporary path
* @since 3.2.0
*/
protected function getTmppath(): string
{
// get the temporary path
return $this->config->get('tmp_path');
}
/**
* Get switch to add super powers
*
* @return bool Switch to add super powers
* @since 3.2.0
*/
protected function getAddsuperpowers(): bool
{
return (bool) $this->params->get('powers_repository',
0);
}
/**
* Get switch to add own super powers
*
* @return bool Switch to add own super powers
* @since 3.2.0
*/
protected function getAddownpowers(): bool
{
if ($this->add_super_powers)
{
return (bool)
$this->params->get('super_powers_repositories', 0);
}
return false;
}
/**
* Get local super powers repository path
*
* @return string The path to the local repository
* @since 3.2.0
*/
protected function getLocalpowersrepositorypath(): string
{
$default = $this->tmp_path . '/super_powers';
if (!$this->add_super_powers)
{
return $default;
}
return $this->params->get('local_powers_repository_path',
$default);
}
/**
* Get super power approved paths
*
* @return array The approved paths to the repositories on Gitea
* @since 3.2.0
*/
protected function getApprovedpaths(): array
{
// some defaults repos we need by JCB
$approved = $this->super_powers_init_repos;
$paths = RepoHelper::get(1); // super powers = 1
if ($paths !== null)
{
foreach ($paths as $path)
{
$owner = $path->organisation ?? null;
$repo = $path->repository ?? null;
if ($owner !== null && $repo !== null)
{
// we make sure to get only the objects
$approved = ["{$owner}.{$repo}" => $path] + $approved;
}
}
}
return array_values($approved);
}
/**
* get indentation value
*
* @return string Indentation value
* @since 3.2.2
*/
protected function getIndentationvalue(): string
{
return "\t";
}
}
src/Componentbuilder/Power/Factory.php000064400000003136151162054220014061
0ustar00<?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\Power;
use Joomla\DI\Container;
use VDM\Joomla\Componentbuilder\Power\Service\Power;
use VDM\Joomla\Service\Database;
use VDM\Joomla\Service\Model;
use VDM\Joomla\Service\Data;
use VDM\Joomla\Componentbuilder\Power\Service\Generator;
use VDM\Joomla\Componentbuilder\Service\Gitea;
use VDM\Joomla\Componentbuilder\Power\Service\Gitea as GiteaPower;
use VDM\Joomla\Gitea\Service\Utilities as GiteaUtilities;
use VDM\Joomla\Interfaces\FactoryInterface;
use VDM\Joomla\Abstraction\Factory as ExtendingFactory;
/**
* Power Factory
*
* @since 3.2.0
*/
abstract class Factory extends ExtendingFactory implements FactoryInterface
{
/**
* Create a container object
*
* @return Container
* @since 3.2.0
*/
protected static function createContainer(): Container
{
return (new Container())
->registerServiceProvider(new Power())
->registerServiceProvider(new Database())
->registerServiceProvider(new Model())
->registerServiceProvider(new Data())
->registerServiceProvider(new Generator())
->registerServiceProvider(new Gitea())
->registerServiceProvider(new GiteaPower())
->registerServiceProvider(new GiteaUtilities());
}
}
src/Componentbuilder/Power/Generator.php000064400000004131151162054220014374
0ustar00<?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\Power;
use VDM\Joomla\Componentbuilder\Power\Generator\ClassInjectorBuilder as
ClassInjector;
use VDM\Joomla\Componentbuilder\Power\Generator\ServiceProviderBuilder as
ServiceProvider;
/**
* Power code Generator of JCB
*
* @since 3.2.0
*/
final class Generator
{
/**
* The ClassInjectorBuilder Class.
*
* @var ClassInjector
* @since 3.2.0
*/
protected ClassInjector $classinjector;
/**
* The ServiceProviderBuilder Class.
*
* @var ServiceProvider
* @since 3.2.0
*/
protected ServiceProvider $serviceprovider;
/**
* Constructor.
*
* @param ClassInjector $classinjector The ClassInjectorBuilder
Class.
* @param ServiceProvider $serviceprovider The ServiceProviderBuilder
Class.
*
* @since 3.2.0
*/
public function __construct(ClassInjector $classinjector, ServiceProvider
$serviceprovider)
{
$this->classinjector = $classinjector;
$this->serviceprovider = $serviceprovider;
}
/**
* Get the class code.
*
* @param array $power The power being saved
*
* @return string|null
* @since 3.2.0
*/
public function get(array $power): ?string
{
// create dependency injection (when the main_class_code is empty)
if (empty($power['main_class_code']) &&
!empty($power['use_selection']) &&
is_array($power['use_selection']))
{
if (strpos($power['implements_custom'],
'ServiceProviderInterface') !== false)
{
if (($code = $this->serviceprovider->getCode($power)) !== null)
{
return $code;
}
}
elseif (($code = $this->classinjector->getCode($power)) !== null)
{
return $code;
}
}
return null;
}
}
src/Componentbuilder/Power/Generator/Bucket.php000064400000001230151162054220015606
0ustar00<?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\Power\Generator;
use VDM\Joomla\Interfaces\Registryinterface;
use VDM\Joomla\Abstraction\Registry;
/**
* Power Bucket
*
* @since 3.2.0
*/
final class Bucket extends Registry implements Registryinterface
{
}
src/Componentbuilder/Power/Generator/ClassInjector.php000064400000013641151162054220017145
0ustar00<?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\Power\Generator;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Indent;
/**
* Power code Generator for the Class Injection of JCB
*
* @since 3.2.0
*/
final class ClassInjector
{
/**
* The version
*
* @var string
* @since 3.2.0
**/
protected string $version;
/**
* The properties
*
* @var array
* @since 3.2.0
**/
protected array $properties = [];
/**
* The comments
*
* @var array
* @since 3.2.0
**/
protected array $comments = [];
/**
* The arguments
*
* @var array
* @since 3.2.0
**/
protected array $arguments = [];
/**
* The assignments
*
* @var array
* @since 3.2.0
**/
protected array $assignments = [];
/**
* Get the generated class code
*
* @return string|null
* @since 3.2.0
*/
public function getCode(): ?string
{
if ($this->properties === [])
{
return null;
}
$code = [];
$code[] = implode(PHP_EOL . PHP_EOL, $this->properties) . PHP_EOL;
$code[] = Indent::_(1) . "/**";
$code[] = Indent::_(1) . " * Constructor.";
$code[] = Indent::_(1) . " *";
$code[] = $this->getComments();
$code[] = Indent::_(1) . " *";
$code[] = Indent::_(1) . " * @since {$this->version}";
$code[] = Indent::_(1) . " */";
$code[] = Indent::_(1) . "public function __construct(" .
$this->getArguments() . ")";
$code[] = Indent::_(1) . "{";
$code[] = implode(PHP_EOL, $this->assignments);
$code[] = Indent::_(1) . "}";
$this->properties = [];
$this->comments = [];
$this->arguments = [];
$this->assignments = [];
return implode(PHP_EOL, $code);
}
/**
* Set the class since version
*
* @param string $version The variable version format.
*
* @return void
* @since 3.2.0
*/
public function setVersion(string $version): void
{
$this->version = $version;
}
/**
* Set the class property
*
* @param string $classname The variable name in lowerCamelCase
format.
* @param string $ClassName The type hint in PascalCase format.
* @param string $description The variable description format.
*
* @return void
* @since 3.2.0
*/
public function setProperty(string $classname, string $ClassName, string
$description): void
{
$this->properties[] = implode(PHP_EOL, [
Indent::_(1) . "/**",
Indent::_(1) . " * {$description}",
Indent::_(1) . " *",
Indent::_(1) . " * @var {$ClassName}",
Indent::_(1) . " * @since {$this->version}",
Indent::_(1) . " */",
Indent::_(1) . "protected {$ClassName} \${$classname};"
]);
}
/**
* Set the comment for the constructor parameter.
*
* @param string $classname The variable name in lowerCamelCase
format.
* @param string $ClassName The type hint in PascalCase format.
* @param string $description The variable description format.
*
* @return void
* @since 3.2.0
*/
public function setComment(string $classname, string $ClassName, string
$description): void
{
$this->comments[] = [$ClassName, $classname, $description];
}
/**
* Set the constructor argument.
*
* @param string $classname The variable name in lowerCamelCase format.
* @param string $ClassName The type hint in PascalCase format.
*
* @return void
* @since 3.2.0
*/
public function setArgument(string $classname, string $ClassName): void
{
$this->arguments[] = "{$ClassName} \${$classname}";
}
/**
* Set the assignment code inside the constructor.
*
* @param string $classname The variable name in lowerCamelCase
format.
*
* @return void
* @since 3.2.0
*/
public function setAssignment(string $classname): void
{
$this->assignments[] = Indent::_(2) . "\$this->{$classname} =
\${$classname};";
}
/**
* Get the comments for the constructor parameter.
*
* @return string
* @since 3.2.0
*/
private function getComments(): string
{
$max_lengths = array_reduce($this->comments, function($carry,
$comment) {
foreach ($comment as $index => $part)
{
$carry[$index] = max($carry[$index] ?? 0, strlen($part));
}
return $carry;
}, []);
$max_lengths[0] = $max_lengths[0] + 2;
$max_lengths[1] = $max_lengths[1] + 2;
$comments = array_map(function($comment) use ($max_lengths) {
return Indent::_(1) . " * @param " .
str_pad($comment[0], $max_lengths[0]) . " $" .
str_pad($comment[1], $max_lengths[1]) . " " .
$comment[2];
}, $this->comments);
return implode(PHP_EOL, $comments);
}
/**
* Format the arguments to ensure they fit within a specified line
length.
* Arguments are added to the line until the max length is reached.
* Then, they are pushed to a new line with appropriate indentation.
*
* @return string Formatted arguments
* @since 3.2.0
*/
private function getArguments(): string
{
$maxLength = 60; // or any other preferred line length
$lines = [];
$currentLineContent = '';
foreach ($this->arguments as $argument)
{
$proposedContent = $currentLineContent ? $currentLineContent . ',
' . $argument : $argument;
if (strlen($proposedContent) >= $maxLength)
{
$lines[] = $currentLineContent;
$currentLineContent = Indent::_(2) . $argument;
}
else
{
$currentLineContent = $proposedContent;
}
}
// Append the last line if it has content
if ($currentLineContent)
{
$lines[] = $currentLineContent;
}
return implode(',' . PHP_EOL, $lines);
}
}
src/Componentbuilder/Power/Generator/ClassInjectorBuilder.php000064400000013134151162054220020451
0ustar00<?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\Power\Generator;
use VDM\Joomla\Componentbuilder\Power\Generator\Search;
use VDM\Joomla\Componentbuilder\Power\Generator\ClassInjector;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Indent;
/**
* Power Class Injector Builder of JCB
*
* @since 3.2.0
*/
final class ClassInjectorBuilder
{
/**
* The Search Class.
*
* @var Search
* @since 3.2.0
*/
protected Search $search;
/**
* The Class Injector Class.
*
* @var ClassInjector
* @since 3.2.0
*/
protected ClassInjector $classinjector;
/**
* Constructor.
*
* @param Search $search The Search Class.
* @param ClassInjector $classinjector The Class Injector Class.
*
* @since 3.2.0
*/
public function __construct(Search $search, ClassInjector $classinjector)
{
$this->search = $search;
$this->classinjector = $classinjector;
}
/**
* Get the injection code.
*
* @param array $power The power being saved
*
* @return string|null
* @since 3.2.0
*/
public function getCode(array $power): ?string
{
$this->setVersion($this->extractSinceVersion($power['description'])
?? $power['power_version'] ?? '1.0.0');
foreach ($power['use_selection'] as $use_selection)
{
if (!$this->valid($use_selection['use']))
{
continue;
}
if (($name = $this->getName($use_selection['use'],
$use_selection['as'])) === null)
{
continue;
}
if (($description =
$this->getDescription($use_selection['use'])) === null)
{
continue;
}
$this->setProperty($name, $description);
$this->setComment($name, $description);
$this->setArgument($name);
$this->setAssignment($name);
}
return $this->getDependencyInjectionCode();
}
/**
* Check that this is a valid injection class.
*
* @param string $guid The class GUID of the power
*
* @return bool
* @since 3.2.0
*/
private function valid(string $guid): bool
{
return $this->search->validInject($guid);
}
/**
* Get the class name.
*
* @param string $guid The class GUID of the power
* @param string $as The as name
*
* @return string|null
* @since 3.2.0
*/
private function getName(string $guid, string $as = 'default'):
?string
{
return $this->search->name($guid, $as);
}
/**
* Get the class description.
*
* @param string $guid The class GUID of the power
*
* @return string|null
* @since 3.2.0
*/
private function getDescription(string $guid): ?string
{
return $this->search->description($guid);
}
/**
* Get the dependency injection code.
*
* @return string|null
* @since 3.2.0
*/
private function getDependencyInjectionCode(): ?string
{
return $this->classinjector->getCode();
}
/**
* Set the class since version.
*
* @param string $version The class since version
*
* @return void
* @since 3.2.0
*/
private function setVersion(string $version): void
{
$this->classinjector->setVersion($version);
}
/**
* Set the class property.
*
* @param string $name The class name
* @param string $description The class description
*
* @return void
* @since 3.2.0
*/
private function setProperty(string $name, string $description): void
{
$this->classinjector->setProperty(
strtolower($name),
$name,
$description
);
}
/**
* Set the class comment for the constructor parameter.
*
* @param string $name The class name
* @param string $description The class description
*
* @return void
* @since 3.2.0
*/
private function setComment(string $name, string $description): void
{
$this->classinjector->setComment(
strtolower($name),
$name,
$description
);
}
/**
* Set the class constructor argument.
*
* @param string $name The class name
*
* @return void
* @since 3.2.0
*/
private function setArgument(string $name): void
{
$this->classinjector->setArgument(
strtolower($name),
$name
);
}
/**
* Get the assignment code inside the constructor.
*
* @param string $name The class name
*
* @return void
* @since 3.2.0
*/
private function setAssignment(string $name): void
{
$this->classinjector->setAssignment(
strtolower($name)
);
}
/**
* Extract the '@since' version number from a given string.
*
* This function checks the provided string for a '@since'
annotation
* and retrieves the subsequent version number. If no '@since'
* annotation is found or no version number is provided after the
* annotation, the function will return null.
*
* @param string $inputString The input string to search.
*
* @return string|null The version number if found, or null if not.
* @since 3.2.0
*/
private function extractSinceVersion(string $inputString): ?string
{
// Use regex to match the @since pattern and capture the version number
if (preg_match('/@since\s+([\d\.]+)/', $inputString,
$matches))
{
return $matches[1];
}
// If no match is found, return null
return null;
}
}
src/Componentbuilder/Power/Generator/Search.php000064400000026633151162054220015614
0ustar00<?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\Power\Generator;
use VDM\Joomla\Data\Action\Load as Database;
use VDM\Joomla\Componentbuilder\Power\Parser;
use VDM\Joomla\Componentbuilder\Power\Generator\Bucket;
use VDM\Joomla\Utilities\String\ClassfunctionHelper;
/**
* Power code Generator Search of JCB
*
* @since 3.2.0
*/
final class Search
{
/**
* The Database Class
*
* @var Database
* @since 3.2.0
**/
protected Database $database;
/**
* The Code Parser Class
*
* @var Parser
* @since 3.2.0
**/
protected Parser $parser;
/**
* The found powers
*
* @var Bucket
* @since 3.2.0
**/
protected Bucket $bucket;
/**
* Constructor.
*
* @param Database $database The Database object.
* @param Parser $parser The parser object.
* @param Bucket $bucket The bucket object.
*
* @since 3.2.0
*/
public function __construct(Database $database, Parser $parser, Bucket
$bucket)
{
$this->database = $database;
$this->parser = $parser;
$this->bucket = $bucket;
}
/**
* Get the power object
*
* @param string $guid The global unique id of the power
*
* @return object|null
* @since 3.2.0
*/
public function power(string $guid): ?object
{
if (($power = $this->bucket->get("power.{$guid}")) ===
null)
{
if (($power =
$this->database->table('power')->item(['guid'
=> $guid])) === null)
{
return null;
}
$this->bucket->set("power.{$guid}", $power);
}
return $power;
}
/**
* Get the power alias to use in container calls
*
* @param string $guid The global unique id of the power
* @param string $className The current class name
*
* @return string
* @since 3.2.0
*/
public function alias(string $guid, string $className): string
{
if (($alias = $this->bucket->get("alias.{$guid}")) !==
null)
{
return $alias;
}
// load the service providers where its already linked
if (($service_providers = $this->serviceProviders($guid)) !== null)
{
foreach ($service_providers as $service_provider)
{
$dependency_name =
$this->getServiceProviderDependencyName($service_provider, $guid) ??
$className;
if (($alias = $this->getAliasFromServiceProvider($service_provider,
$dependency_name)) === null)
{
continue;
}
break;
}
}
if (empty($alias))
{
// build it based on the class name and namespace of this power
$alias = $this->getAliasFromPower($guid);
}
// finally we set the alias for later use
$alias = $alias ?? "Set.Me.$className";
$alias = trim($alias);
$this->bucket->set("alias.{$guid}", $alias);
return $alias;
}
/**
* Check if a power class is valid to inject into another class
*
* @param string $guid The global unique id of the power
*
* @return bool True if class can (should) be injected
* @since 3.2.0
*/
public function validInject(string $guid): bool
{
if (($valid_inject =
$this->bucket->get("valid_inject.{$guid}")) !== null)
{
return $valid_inject;
}
if (($power = $this->power($guid)) === null)
{
return false;
}
// Types: [class, abstract class, final class, interface, trait]
// Allowed: [class, final class, interface]
if ($power->type === 'class' || $power->type ===
'final class' || $power->type === 'interface')
{
$this->bucket->set("valid_inject.{$guid}", true);
return true;
}
$this->bucket->set("valid_inject.{$guid}", false);
return false;
}
/**
* Get the power class name
*
* @param string $guid The global unique id of the power
* @param string $as The use AS value
*
* @return string|null
* @since 3.2.0
*/
public function name(string $guid, string $as = 'default'):
?string
{
if ($as !== 'default')
{
return $as;
}
if (($name = $this->bucket->get("name.{$guid}")) !==
null)
{
return $name;
}
if (($power = $this->power($guid)) === null)
{
return null;
}
if (strpos($power->name, '[') !== false)
{
$name = 'DynamicClassName';
}
else
{
$name = ClassfunctionHelper::safe($power->name);
}
$name = trim($name);
$this->bucket->set("name.{$guid}", $name);
return $name;
}
/**
* Get the power class description
*
* @param string $guid The global unique id of the power
*
* @return string|null
* @since 3.2.0
*/
public function description(string $guid): ?string
{
if (($description =
$this->bucket->get("description.{$guid}")) !== null)
{
return $description;
}
if (($power = $this->power($guid)) === null)
{
return null;
}
if (strpos($power->name, '[') !== false)
{
$description = 'The Dynamic {$power->name} Name';
}
else
{
$description = "The {$power->name} Class.";
}
$this->bucket->set("description.{$guid}", $description);
return $description;
}
/**
* Get all service providers where this power is linked
*
* @param string $guid The global unique id of the power
*
* @return array|null
* @since 3.2.0
*/
public function serviceProviders(string $guid): ?array
{
if (($service_providers =
$this->bucket->get("service_providers.{$guid}")) === null)
{
if (($powers =
$this->database->table('power')->items([
'use_selection' => [
'operator' => 'LIKE',
'value' => "'%{$guid}%'",
'quote' => false
],
'implements_custom' => [
'operator' => 'LIKE',
'value' =>
"'%ServiceProviderInterface%'",
'quote' => false
]
])) === null)
{
return null;
}
$service_providers = [];
foreach ($powers as $power)
{
$this->bucket->set("power.{$power->guid}", $power);
$service_providers[] = $power->guid;
}
$this->bucket->set("service_providers.{$guid}",
$service_providers);
}
return $service_providers;
}
/**
* Get all the power dependencies
*
* @param string $guid The global unique id of the power
*
* @return array|null
* @since 3.2.0
*/
public function dependencies(string $guid): ?array
{
if (($dependencies =
$this->bucket->get("dependencies.{$guid}")) !== null)
{
return $dependencies;
}
if (($power = $this->power($guid)) === null)
{
return null;
}
if (empty($power->use_selection) ||
!is_object($power->use_selection))
{
return null;
}
$dependencies = [];
foreach ($power->use_selection as $use_selection)
{
if (!$this->validInject($use_selection->use))
{
continue;
}
if (($name = $this->name($use_selection->use,
$use_selection->as)) === null)
{
continue;
}
$dependencies[] = $this->alias($use_selection->use, $name);
}
if ($dependencies === [])
{
return null;
}
$this->bucket->set("dependencies.{$guid}",
$dependencies);
return $dependencies;
}
/**
* Retrieves the alias form linked service provider.
*
* @param string $guid The global unique id of the power
* @param string $className The current class name
*
* @return string|null Returns the alias if found, otherwise returns
null.
* @since 3.2.0
*/
private function getAliasFromServiceProvider(string $guid, string
$className): ?string
{
if (($power = $this->power($guid)) === null ||
empty($power->main_class_code))
{
return null;
}
$code = $this->parser->code($power->main_class_code);
if (empty($code['methods']))
{
return null;
}
$method = null;
foreach ($code['methods'] as $_method)
{
if ($_method['name'] === 'register' &&
strlen($_method['body']) > 5)
{
$method = $_method['body'];
break;
}
}
if (empty($method))
{
return null;
}
return $this->getAliasFromRegisterMethod($method, $className);
}
/**
* Retrieves the alias for a given class from a provided string.
*
* @param string $content The string to search.
* @param string $className The name of the class whose alias is to be
retrieved.
*
* @return string|null Returns the alias if found, otherwise returns
null.
* @since 3.2.0
*/
private function getAliasFromRegisterMethod(string $content, string
$className): ?string
{
// Escaping any special characters in the class name to use in regex
$escapedClassName = preg_quote($className, '/');
// Regular expression to match the pattern where class name and its alias
are specified
$pattern =
"/\\\$container->alias\s*\(\s*{$escapedClassName}::class\s*,\s*['\"](.*?)['\"]\s*\)\s*->/s";
if (preg_match($pattern, $content, $matches))
{
return $matches[1];
}
return null;
}
/**
* Retrieves the alias form linked service provider.
*
* @param string $guid The global unique id of the power
*
* @return string|null Returns the alias if found, otherwise returns
null.
* @since 3.2.0
*/
private function getAliasFromPower(string $guid): ?string
{
if (($power = $this->power($guid)) === null ||
empty($power->namespace))
{
return null;
}
return $this->getAliasFromNamespace($power->namespace);
}
/**
* Converts the namespace of a power into an class alias
*
* @param string $input The namespaced string to process.
*
* @return string The modified string.
* @since 3.2.0
*/
private function getAliasFromNamespace(string $input): string
{
// 1. Split on backslash to get the components of the namespace path.
$parts = explode('\\', $input);
// 2. Consider only the last part after the final backslash for further
processing.
$lastSegment = end($parts);
// 3. Get the part after the first dot.
$target = (strpos($lastSegment, '.') !== false)
? substr($lastSegment, strpos($lastSegment, '.') + 1)
: $lastSegment;
// 4. Split on dots.
$dotParts = explode('.', $target);
// 5. Modify segments with camel case words.
$modifiedDotParts = array_map(function ($part) {
return preg_replace('/(?<=[a-z])(?=[A-Z])/', '.',
$part);
}, $dotParts);
// 6. Implode the array with dots and return.
return implode('.', $modifiedDotParts);
}
/**
* Get dependency name linked to service provider
*
* @param string $serviceProvider The global unique id of the
(service provider) power
* @param string $dependency The global unique id of the
(dependency) power
*
* @return string|null
* @since 3.2.0
*/
private function getServiceProviderDependencyName(string $serviceProvider,
string $dependency): ?string
{
if (($power = $this->power($serviceProvider)) === null)
{
return null;
}
if (empty($power->use_selection) ||
!is_object($power->use_selection))
{
return null;
}
foreach ($power->use_selection as $use_selection)
{
if ($use_selection->use !== $dependency)
{
continue;
}
if (($name = $this->name($use_selection->use,
$use_selection->as)) === null)
{
continue;
}
return $name;
}
return null;
}
}
src/Componentbuilder/Power/Generator/ServiceProvider.php000064400000013145151162054220017514
0ustar00<?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\Power\Generator;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Indent;
/**
* Power code Generator for the Service Provider of JCB
*
* @since 3.2.0
*/
final class ServiceProvider
{
/**
* The version
*
* @var string
* @since 3.2.0
**/
protected string $version;
/**
* The register lines
*
* @var array
* @since 3.2.0
**/
protected array $registerlines = [];
/**
* The get functions
*
* @var array
* @since 3.2.0
**/
protected array $getfunctions = [];
/**
* Get the generated class code
*
* @return string|null
* @since 3.2.0
*/
public function getCode(): ?string
{
if ($this->registerlines === [])
{
return null;
}
$code = [];
$code[] = Indent::_(1) . "/**";
$code[] = Indent::_(1) . " * Registers the service provider with a
DI container.";
$code[] = Indent::_(1) . " *";
$code[] = Indent::_(1) . " * @param Container \$container The DI
container.";
$code[] = Indent::_(1) . " *";
$code[] = Indent::_(1) . " * @return void";
$code[] = Indent::_(1) . " * @since {$this->version}";
$code[] = Indent::_(1) . " */";
$code[] = Indent::_(1) . "public function register(Container
\$container)";
$code[] = Indent::_(1) . "{";
$code[] = implode(PHP_EOL . PHP_EOL, $this->registerlines);
$code[] = Indent::_(1) . "}";
$code[] = PHP_EOL . implode(PHP_EOL . PHP_EOL, $this->getfunctions);
$this->registerlines = [];
$this->getfunctions = [];
return implode(PHP_EOL, $code);
}
/**
* Set the class since version
*
* @param string $version The variable version format.
*
* @return void
* @since 3.2.0
*/
public function setVersion(string $version): void
{
$this->version = $version;
}
/**
* Set the class alias and share code for the service provider register.
*
* @param string $className The variable name in lowerCamelCase
format.
* @param string $functionName The function name in lowerCamelCase
format.
* @param string $alias The variable alias format.
*
* @return void
* @since 3.2.0
*/
public function setRegisterLine(string $className, string $functionName,
string $alias): void
{
$this->registerlines[] = implode(PHP_EOL , [
$this->getAlias($className, $alias),
$this->getShare($functionName, $alias)
]);
}
/**
* Set the class get function for the service provider.
*
* @param string $className The variable name in
lowerCamelCase format.
* @param string $functionName The function name in
lowerCamelCase format.
* @param string $description The function description.
* @param array|null $dependencies The class dependencies aliases.
*
* @return void
* @since 3.2.0
*/
public function setGetFunction(string $className, string $functionName,
string $description, ?array $dependencies = null): void
{
$this->getfunctions[] = implode(PHP_EOL , [
Indent::_(1) . "/**",
Indent::_(1) . " * $description",
Indent::_(1) . " *",
Indent::_(1) . " * @param Container \$container The DI
container.",
Indent::_(1) . " *",
Indent::_(1) . " * @return $className",
Indent::_(1) . " * @since {$this->version}",
Indent::_(1) . " */",
Indent::_(1) . "public function $functionName(Container
\$container): $className",
Indent::_(1) . "{",
$this->getDependencies($className, $dependencies),
Indent::_(1) . "}"
]);
}
/**
* Generates the class alias for the service provider.
*
* @param string $className The variable name in lowerCamelCase
format.
* @param string $alias The variable alias format.
*
* @return string Generated class alias code.
* @since 3.2.0
*/
protected function getAlias(string $className, string $alias): string
{
return Indent::_(2) . "\$container->alias({$className}::class,
'{$alias}')";
}
/**
* Generates the class share for the service provider.
*
* @param string $functionName The function name in lowerCamelCase
format.
* @param string $alias The variable alias format.
*
* @return string Generated class share code.
* @since 3.2.0
*/
protected function getShare(string $functionName, string $alias): string
{
return Indent::_(3) . "->share('$alias', [\$this,
'$functionName'], true);";
}
/**
* Generates the class dependencies.
*
* @param string $className The variable name in
lowerCamelCase format.
* @param array|null $dependencies The class dependencies aliases.
*
* @return string Generated class and its dependencies code if found.
* @since 3.2.0
*/
protected function getDependencies(string $className, ?array $dependencies
= null): string
{
$bucket = [];
if (!empty($dependencies))
{
$bucket[] = Indent::_(2) . "return new $className(";
$bucket[] = Indent::_(3) . "\$container->get('"
. implode(
"')," . PHP_EOL . Indent::_(3) .
"\$container->get('"
, $dependencies
) . "')";
$bucket[] = Indent::_(2) . ");";
}
else
{
$bucket[] = Indent::_(2) . "return new $className();";
}
return implode(PHP_EOL , $bucket);
}
}
src/Componentbuilder/Power/Generator/ServiceProviderBuilder.php000064400000016700151162054220021023
0ustar00<?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\Power\Generator;
use VDM\Joomla\Componentbuilder\Power\Generator\Search;
use VDM\Joomla\Componentbuilder\Power\Generator\ServiceProvider;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Indent;
/**
* Power Service Provider Builder of JCB
*
* @since 3.2.0
*/
final class ServiceProviderBuilder
{
/**
* The Search Class.
*
* @var Search
* @since 3.2.0
*/
protected Search $search;
/**
* The Service Provider Class.
*
* @var ServiceProvider
* @since 3.2.0
*/
protected ServiceProvider $serviceprovider;
/**
* Constructor.
*
* @param Search $search The Search Class.
* @param ServiceProvider $serviceprovider The Service Provider
Class.
*
* @since 3.2.0
*/
public function __construct(Search $search, ServiceProvider
$serviceprovider)
{
$this->search = $search;
$this->serviceprovider = $serviceprovider;
}
/**
* Get the service provider code.
*
* @param array $power The power being saved
*
* @return string|null
* @since 3.2.0
*/
public function getCode(array $power): ?string
{
$this->setVersion($this->extractSinceVersion($power['description']
?? '') ?? $power['power_version'] ??
'1.0.0');
if (!empty($power['use_selection']))
{
$this->setRegisterLines($power['use_selection']);
$this->setGetFunctions($power['use_selection']);
}
return $this->getServiceProviderCode();
}
/**
* Set the class alias and share code for the service provider register.
*
* @param array $useSelections The use (in class) selections
*
* @return void
* @since 3.2.0
*/
private function setRegisterLines(array $useSelections): void
{
foreach ($useSelections as $use_selection)
{
if (!$this->valid($use_selection['use']))
{
continue;
}
if (($name = $this->getName($use_selection['use'],
$use_selection['as'])) === null)
{
continue;
}
$function_name = $this->getFunctionName($name);
$alias = $this->getAlias($use_selection['use'], $name);
$this->setRegisterLine($name, $function_name, $alias);
}
}
/**
* Set the class get function for the service provider.
*
* @param array $useSelections The use (in class) selections
*
* @return void
* @since 3.2.0
*/
private function setGetFunctions(array $useSelections): void
{
foreach ($useSelections as $use_selection)
{
if (!$this->valid($use_selection['use']))
{
continue;
}
if (($name = $this->getName($use_selection['use'],
$use_selection['as'])) === null)
{
continue;
}
if (($description =
$this->getDescription($use_selection['use'])) === null)
{
continue;
}
$function_name = $this->getFunctionName($name);
$dependencies =
$this->getDependencies($use_selection['use']);
$this->setGetFunction($name, $function_name, "Get
$description", $dependencies);
}
}
/**
* Check that this is a valid injection class.
*
* @param string $guid The class GUID of the power
*
* @return bool
* @since 3.2.0
*/
private function valid(string $guid): bool
{
return $this->search->validInject($guid);
}
/**
* Get the class name.
*
* @param string $guid The class GUID of the power
* @param string $as The as name
*
* @return string|null
* @since 3.2.0
*/
private function getName(string $guid, string $as = 'default'):
?string
{
return $this->search->name($guid, $as);
}
/**
* Get the function name.
*
* @param string $name The class name
*
* @return string
* @since 3.2.0
*/
private function getFunctionName(string $name): string
{
return "get{$name}";
}
/**
* Get the dependencies of a class
*
* @param string $guid The class GUID of the power
*
* @return array|null
* @since 3.2.0
*/
private function getDependencies(string $guid): ?array
{
return $this->search->dependencies($guid);
}
/**
* Get the class description.
*
* @param string $guid The class GUID of the power
*
* @return string|null
* @since 3.2.0
*/
private function getDescription(string $guid): ?string
{
return $this->search->description($guid);
}
/**
* Get the class alias
*
* @param string $guid The class GUID of the power
* @param string $className The class name
*
* @return string
* @since 3.2.0
*/
private function getAlias(string $guid, string $className): string
{
return $this->search->alias($guid, $className);
}
/**
* Get the service provider code.
*
* @return string|null
* @since 3.2.0
*/
private function getServiceProviderCode(): ?string
{
return $this->serviceprovider->getCode();
}
/**
* Set the class since version.
*
* @param string $version The class since version
*
* @return void
* @since 3.2.0
*/
private function setVersion(string $version): void
{
$this->serviceprovider->setVersion($version);
}
/**
* Set the class alias and share code for the service provider register.
*
* @param string $className The variable name in lowerCamelCase
format.
* @param string $functionName The function name in lowerCamelCase
format.
* @param string $alias The variable alias format.
*
* @return void
* @since 3.2.0
*/
public function setRegisterLine(string $className, string $functionName,
string $alias): void
{
$this->serviceprovider->setRegisterLine($className, $functionName,
$alias);
}
/**
* Set the class get function for the service provider.
*
* @param string $className The variable name in
lowerCamelCase format.
* @param string $functionName The function name in
lowerCamelCase format.
* @param string $description The function description.
* @param array|null $dependencies The class dependencies aliases.
*
* @return void
* @since 3.2.0
*/
public function setGetFunction(string $className, string $functionName,
string $description, ?array $dependencies = null): void
{
$this->serviceprovider->setGetFunction($className, $functionName,
$description, $dependencies);
}
/**
* Extract the '@since' version number from a given string.
*
* This function checks the provided string for a '@since'
annotation
* and retrieves the subsequent version number. If no '@since'
* annotation is found or no version number is provided after the
* annotation, the function will return null.
*
* @param string $inputString The input string to search.
*
* @return string|null The version number if found, or null if not.
* @since 3.2.0
*/
private function extractSinceVersion(string $inputString): ?string
{
// Use regex to match the @since pattern and capture the version number
if (preg_match('/@since\s+([\d\.]+)/', $inputString,
$matches))
{
return $matches[1];
}
// If no match is found, return null
return null;
}
}
src/Componentbuilder/Power/Generator/index.html000064400000000054151162054220015660
0ustar00<html><body
bgcolor="#FFFFFF"></body></html>src/Componentbuilder/Power/Grep.php000064400000016052151162054220013350
0ustar00<?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\Power;
use Joomla\CMS\Language\Text;
use VDM\Joomla\Utilities\FileHelper;
use VDM\Joomla\Utilities\JsonHelper;
use VDM\Joomla\Interfaces\GrepInterface;
use VDM\Joomla\Abstraction\Grep as ExtendingGrep;
/**
* Global Resource Empowerment Platform
*
* The Grep feature will try to find your power in the repositories
listed in the global
* Options of JCB in the super powers tab, and if it can't be found
there will try the global core
* Super powers of JCB. All searches are performed according the the
[algorithm:cascading]
* See documentation for more details:
https://git.vdm.dev/joomla/super-powers/wiki
*
* @since 3.2.0
*/
final class Grep extends ExtendingGrep implements GrepInterface
{
/**
* The index file path
*
* @var string
* @since 3.2.2
*/
protected string $index_path = 'super-powers.json';
/**
* Search for a local item
*
* @param string $guid The global unique id of the item
*
* @return object|null
* @since 3.2.0
*/
protected function searchLocal(string $guid): ?object
{
// check if it exists locally
if (($path = $this->existsLocally($guid)) !== null)
{
return $this->getLocal($path, $guid);
}
return null;
}
/**
* Search for a remote item
*
* @param string $guid The global unique id of the item
*
* @return object|null
* @since 3.2.0
*/
protected function searchRemote(string $guid): ?object
{
// check if it exists remotely
if (($path = $this->existsRemotely($guid)) !== null)
{
return $this->getRemote($path, $guid);
}
return null;
}
/**
* Get a local power
*
* @param object $path The repository path details
* @param string $guid The global unique id of the power
*
* @return object|null
* @since 3.2.0
*/
protected function getLocal(object $path, string $guid): ?object
{
if (empty($path->local->{$guid}->settings) ||
empty($path->local->{$guid}->code))
{
return null;
}
// get the settings
if (($settings = FileHelper::getContent($path->full_path .
'/' . $path->local->{$guid}->settings, null)) !== null
&&
JsonHelper::check($settings))
{
$power = json_decode($settings);
// get the code
if (($code = FileHelper::getContent($path->full_path . '/'
. $path->local->{$guid}->power, null)) !== null)
{
$power->main_class_code = $code;
return $power;
}
}
return null;
}
/**
* Get a remote power
*
* @param object $path The repository path details
* @param string $guid The global unique id of the power
*
* @return object|null
* @since 3.2.0
*/
protected function getRemote(object $path, string $guid): ?object
{
$power = null;
if (empty($path->index->{$guid}->settings) ||
empty($path->index->{$guid}->code))
{
return $power;
}
// get the branch name
$branch = $this->getBranchName($path);
// load the base and token if set
$this->contents->load_($path->base ?? null, $path->token ??
null);
// get the settings
if (($power = $this->loadRemoteFile($path->organisation,
$path->repository, $path->index->{$guid}->settings, $branch))
!== null &&
isset($power->guid))
{
// get the code
if (($code = $this->loadRemoteFile($path->organisation,
$path->repository, $path->index->{$guid}->power, $branch)) !==
null)
{
// set the git details in params
$power->main_class_code = $code;
}
// set the git details in params
$path_guid = $path->guid ?? null;
if ($path_guid !== null)
{
// get the Settings meta
if (($meta = $this->contents->metadata($path->organisation,
$path->repository, $path->index->{$guid}->settings, $branch))
!== null &&
isset($meta->sha))
{
if (isset($power->params) && is_object($power->params)
&&
isset($power->params->source) &&
is_array($power->params->source))
{
$power->params->source[$path_guid . '-settings'] =
$meta->sha;
}
else
{
$power->params = (object) [
'source' => [$path_guid . '-settings' =>
$meta->sha]
];
}
}
// get the power meta
if (($meta = $this->contents->metadata($path->organisation,
$path->repository, $path->index->{$guid}->power, $branch)) !==
null &&
isset($meta->sha))
{
if (isset($power->params) && is_object($power->params)
&&
isset($power->params->source) &&
is_array($power->params->source))
{
$power->params->source[$path_guid . '-power'] =
$meta->sha;
}
else
{
$power->params = (object) [
'source' => [$path_guid . '-power' =>
$meta->sha]
];
}
}
// get the README meta
if (($meta = $this->contents->metadata($path->organisation,
$path->repository, $path->index->{$guid}->path .
'/README.md', $branch)) !== null &&
isset($meta->sha))
{
if (isset($power->params) && is_object($power->params)
&&
isset($power->params->source) &&
is_array($power->params->source))
{
$power->params->source[$path_guid . '-readme'] =
$meta->sha;
}
else
{
$power->params = (object) [
'source' => [$path_guid . '-readme' =>
$meta->sha]
];
}
}
}
}
// reset back to the global base and token
$this->contents->reset_();
return $power;
}
/**
* Set repository messages and errors based on given conditions.
*
* @param string $message The message to set (if error)
* @param string $path Path value
* @param string $repository Repository name
* @param string $organisation Organisation name
* @param string|null $base Base URL
*
* @return void
* @since 3.2.0
*/
protected function setRemoteIndexMessage(string $message, string $path,
string $repository, string $organisation, ?string $base): void
{
if ($repository === 'super-powers' && $organisation !==
'joomla' && (empty($base) || $base ===
'https://git.vdm.dev'))
{
// Give heads-up about the overriding feature
$this->app->enqueueMessage(
Text::sprintf(
'<p>Super Power</b> repository at
<b>https://git.vdm.dev/%s</b> can be used to override any
power!<br />But has not yet been set in your account at
https://git.vdm.dev/%s<br /><small>This is an optional
feature.</small>',
$path,
$organisation
),
'Message'
);
}
else
{
// Give error
$this->app->enqueueMessage(
Text::sprintf(
'<p>Super Power</b> repository at
<b>%s/%s</b> gave the following error!<br
/>%s</p>',
$this->contents->api(),
$path,
$message
),
'Error'
);
}
}
}
src/Componentbuilder/Power/Parser.php000064400000043016151162054230013710
0ustar00<?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\Power;
/**
* Compiler Power Parser
* Very basic php class methods parser, does not catch all
edge-cases!
* Use this only on code that are following standard good practices
* Suggested improvements are welcome
* @since 3.2.0
*/
final class Parser
{
/**
* Get properties and method declarations and other details from the given
code.
*
* @param string $code The code containing class properties &
methods
*
* @return array An array of properties & method declarations of the
given code
* @since 3.2.0
*/
public function code(string $code): array
{
return [
'properties' => $this->properties($code),
'methods' => $this->methods($code)
];
}
/**
* Get the class body
*
* @param string $code The class as a string
*
* @return string|null The class body, or null if not found
* @since 3.2.0
**/
public function getClassCode(string $code): ?string
{
// Match class, final class, abstract class, interface, and trait
$pattern = '/(?:class|final class|abstract
class|interface|trait)\s+[a-zA-Z0-9_]+\s*(?:extends\s+[a-zA-Z0-9_]+\s*)?(?:implements\s+[a-zA-Z0-9_]+(?:\s*,\s*[a-zA-Z0-9_]+)*)?\s*\{/s';
// Split the input code based on the class declaration pattern
$parts = preg_split($pattern, $code, 2, PREG_SPLIT_DELIM_CAPTURE);
$body = $parts[1] ?? '';
if ($body !== '')
{
// Remove leading and trailing white space
$body = trim($body);
// Remove the first opening curly brace if it exists
if (mb_substr($body, 0, 1) === '{')
{
$body = mb_substr($body, 1);
}
// Remove the last closing curly brace if it exists
if (mb_substr($body, -1) === '}')
{
$body = mb_substr($body, 0, -1);
}
return $body;
}
// No class body found, return null
return null;
}
/**
* Get the class license
*
* @param string $code The class as a string
*
* @return string|null The class license, or null if not found
* @since 3.2.0
**/
public function getClassLicense(string $code): ?string
{
// Check if the file starts with '<?php'
if (substr($code, 0, 5) !== '<?php')
{
return null;
}
// Trim the '<?php' part
$code = ltrim(substr($code, 5));
// Check if the next part starts with '/*'
if (substr($code, 0, 2) !== '/*')
{
return null;
}
// Find the position of the closing comment '*/'
$endCommentPos = strpos($code, '*/');
// If the closing comment '*/' is found, extract and return the
license
if ($endCommentPos !== false)
{
$license = substr($code, 2, $endCommentPos - 2);
return trim($license);
}
// No license found, return null
return null;
}
/**
* Extracts the first consecutive `use` statements from the given PHP
class.
*
* @param string $code The PHP class as a string
*
* @return array|null An array of consecutive `use` statements
* @since 3.2.0
*/
public function getUseStatements(string $code): ?array
{
// Match class, final class, abstract class, interface, and trait
$pattern = '/(?:class|final class|abstract
class|interface|trait)\s+[a-zA-Z0-9_]+\s*(?:extends\s+[a-zA-Z0-9_]+\s*)?(?:implements\s+[a-zA-Z0-9_]+(?:\s*,\s*[a-zA-Z0-9_]+)*)?\s*\{/s';
// Split the input code based on the class declaration pattern
$parts = preg_split($pattern, $code, 2, PREG_SPLIT_DELIM_CAPTURE);
$header = $parts[0] ?? '';
$use_statements = [];
$found_first_use = false;
if ($header !== '')
{
$lines = explode(PHP_EOL, $header);
foreach ($lines as $line)
{
if (strpos($line, 'use ') === 0)
{
$use_statements[] = trim($line);
$found_first_use = true;
}
elseif ($found_first_use && trim($line) === '')
{
break;
}
}
}
return $found_first_use ? $use_statements : null;
}
/**
* Extracts trait use statements from the given code.
*
* @param string $code The code containing class traits
*
* @return array|null An array of trait names
* @since 3.2.0
*/
public function getTraits(string $code): ?array
{
// regex to target trait use statements
$traitPattern =
'/^\s*use\s+[\p{L}0-9\\\\_]+(?:\s*,\s*[\p{L}0-9\\\\_]+)*\s*;/mu';
preg_match_all($traitPattern, $code, $matches, PREG_SET_ORDER);
if ($matches != [])
{
$traitNames = [];
foreach ($matches as $n => $match)
{
$declaration = $match[0] ?? null;
if ($declaration !== null)
{
$names = preg_replace('/\s*use\s+/', '',
$declaration);
$names = preg_replace('/\s*;/', '', $names);
$names = preg_split('/\s*,\s*/', $names);
$traitNames = array_merge($traitNames, $names);
}
}
return $traitNames;
}
return null;
}
/**
* Extracts properties declarations and other details from the given
code.
*
* @param string $code The code containing class properties
*
* @return array|null An array of properties declarations and details
* @since 3.2.0
*/
private function properties(string $code): ?array
{
// regex to target all properties
$access = '(?<access>var|public|protected|private)';
$type = '(?<type>(?:\?|)[\p{L}0-9\\\\]*\s+)?';
$static = '(?<static>static)?';
$name = '\$(?<name>\p{L}[\p{L}0-9]*)';
$default =
'(?:\s*=\s*(?<default>\[[^\]]*\]|\d+|\'[^\']*?\'|"[^"]*?"|false|true|null))?';
$property_pattern =
"/\b{$access}\s*{$type}{$static}\s*{$name}{$default};/u";
preg_match_all($property_pattern, $code, $matches, PREG_SET_ORDER);
if ($matches != [])
{
$properties = [];
foreach ($matches as $n => $match)
{
$declaration = $match[0] ?? null;
if (is_string($declaration))
{
$comment = $this->extractDocBlock($code, $declaration);
$declaration = trim(preg_replace('/\s{2,}/', ' ',
preg_replace('/[\r\n]+/', ' ', $declaration)));
$properties[] = [
'name' => isset($match['name']) ?
'$' . $match['name'] : 'error',
'access' => $match['access'] ??
'public',
'type' => isset($match['type']) ?
trim($match['type']) : null,
'static' => (bool) $match['static'] ?? false,
'default' => $match['default'] ?? null,
'comment' => $comment,
'declaration' => $declaration
];
}
}
return $properties;
}
return null;
}
/**
* Extracts method declarations and other details from the given code.
*
* @param string $code The code containing class methods
*
* @return array|null An array of method declarations and details
* @since 3.2.0
*/
private function methods(string $code): ?array
{
// regex to target all methods/functions
$final_modifier = '(?P<final_modifier>final)?\s*';
$abstract_modifier =
'(?P<abstract_modifier>abstract)?\s*';
$access_modifier =
'(?P<access_modifier>public|protected|private)?\s*';
$static_modifier = '(?P<static_modifier>static)?\s*';
$modifier =
"{$final_modifier}{$abstract_modifier}{$access_modifier}{$static_modifier}";
$name = '(?P<name>\w+)';
$arguments = '(?P<arguments>\(.*?\))?';
$return_type =
'(?P<return_type>\s*:\s*(?:\?[\w\\\\]+|\\\\?[\w\\\\]+(?:\|\s*(?:\?[\w\\\\]+|\\\\?[\w\\\\]+))*)?)?';
$method_pattern =
"/(^\s*?\b{$modifier}function\s+{$name}{$arguments}{$return_type})/sm";
preg_match_all($method_pattern, $code, $matches, PREG_SET_ORDER);
if ($matches != [])
{
$methods = [];
foreach ($matches as $n => $match)
{
$full_declaration = $match[0] ?? null;
if (is_string($full_declaration))
{
$comment = $this->extractDocBlock($code, $full_declaration);
$full_declaration = trim(preg_replace('/\s{2,}/', '
',
preg_replace('/[\r\n]+/', ' ',
$full_declaration)));
// extract method's body
$start_pos = strpos($code, $full_declaration) +
strlen($full_declaration);
$method_body = $this->extractMethodBody($code, $start_pos);
// now load what we found
$methods[] = [
'name' => $match['name'] ??
'error',
'access' => $match['access_modifier'] ??
'public',
'static' => (bool) $match['static_modifier']
?? false,
'final' => (bool) $match['final_modifier'] ??
false,
'abstract' => (bool)
$match['abstract_modifier'] ?? false,
'return_type' =>
$this->extractReturnType($match['return_type'] ?? null,
$comment),
'since' => $this->extractSinceVersion($comment),
'deprecated' =>
$this->extractDeprecatedVersion($comment),
'arguments' =>
$this->extractFunctionArgumentDetails($comment,
$match['arguments'] ?? null),
'comment' => $comment,
'declaration' => str_replace(["\r\n",
"\r", "\n"], '', $full_declaration),
'body' => $method_body
];
}
}
return $methods;
}
return null;
}
/**
* Extracts the PHPDoc block for a given function declaration.
*
* @param string $code The source code containing the function
* @param string $declaration The part of the function declaration
*
* @return string|null The PHPDoc block, or null if not found
* @since 3.2.0
*/
private function extractDocBlock(string $code, string $declaration):
?string
{
// Split the code string with the function declaration
$parts = explode($declaration, $code);
if (count($parts) < 2)
{
// Function declaration not found in the code
return null;
}
// Get the part with the comment (if any)
$comment = $parts[0];
// Split the last part using the comment block start marker
$commentParts = preg_split('/(})?\s+(?=\s*\/\*)(\*)?/',
$comment);
// Get the last comment block
$lastCommentPart = end($commentParts);
// Search for the comment block in the last comment part
if (preg_match('/(\/\*\*[\s\S]*?\*\/)\s*$/u', $lastCommentPart,
$matches))
{
$comment = $matches[1] ?? null;
// check if we actually have a comment
if ($comment)
{
return $this->removeWhiteSpaceFromComment($comment);
}
}
return null;
}
/**
* Extracts method body based on starting position of method declaration.
*
* @param string $code The class code
* @param string $startPos The starting position of method declaration
*
* @return string|null Method body or null if not found
* @since 3.2.0
*/
private function extractMethodBody(string $code, int $startPos): ?string
{
$braces_count = 0;
$in_method = false;
$method_body = "";
for ($i = $startPos; $i < strlen($code); $i++) {
if ($code[$i] === '{')
{
$braces_count++;
if (!$in_method)
{
$in_method = true;
continue;
}
}
if ($code[$i] === '}')
{
$braces_count--;
}
if ($in_method)
{
$method_body .= $code[$i];
}
if ($braces_count <= 0 && $in_method)
{
// remove the closing brace
$method_body = substr($method_body, 0, -1);
break;
}
}
return $in_method ? $method_body : null;
}
/**
* Extracts the function argument details.
*
* @param string|null $comment The function comment if found
* @param string|null $arguments The arguments found on function
declaration
*
* @return array|null The function argument details
* @since 3.2.0
*/
private function extractFunctionArgumentDetails(?string $comment, ?string
$arguments): ?array
{
$arg_types_from_declaration =
$this->extractArgTypesArguments($arguments);
$arg_types_from_comments = null;
if ($comment)
{
$arg_types_from_comments =
$this->extractArgTypesFromComment($comment);
}
// merge the types
if ($arg_types_from_declaration)
{
return $this->mergeArgumentTypes($arg_types_from_declaration,
$arg_types_from_comments);
}
return null;
}
/**
* Extracts the function return type.
*
* @param string|null $returnType The return type found in declaration
* @param string|null $comment The function comment if found
*
* @return string|null The function return type
* @since 3.2.0
*/
private function extractReturnType(?string $returnType, ?string $comment):
?string
{
if ($returnType === null && $comment)
{
return $this->extractReturnTypeFromComment($comment);
}
return trim(trim($returnType, ':'));
}
/**
* Extracts argument types from a given comment.
*
* @param string $comment The comment containing the argument types
*
* @return array|null An array of argument types
* @since 3.2.0
*/
private function extractArgTypesFromComment(string $comment): ?array
{
preg_match_all('/@param\s+((?:[^\s|]+(?:\|)?)+)?\s+\$([^\s]+)/',
$comment, $matches, PREG_SET_ORDER);
if ($matches !== [])
{
$arg_types = [];
foreach ($matches as $match)
{
$arg = $match[2] ?? null;
$type = $match[1] ?: null;
if (is_string($arg))
{
$arg_types['$' .$arg] = $type;
}
}
return $arg_types;
}
return null;
}
/**
* Extracts argument types from a given declaration.
*
* @param string|null $arguments The arguments found on function
declaration
*
* @return array|null An array of argument types
* @since 3.2.0
*/
private function extractArgTypesArguments(?string $arguments): ?array
{
if ($arguments)
{
$args = preg_split('/,(?![^()\[\]]*(\)|\]))/',
trim($arguments, '()'));
if ($args !== [])
{
$argument_types = [];
foreach ($args as $arg)
{
$eqPos = strpos($arg, '=');
if ($eqPos !== false)
{
$arg_parts = [
substr($arg, 0, $eqPos),
substr($arg, $eqPos + 1)
];
}
else
{
$arg_parts = [$arg];
}
if
(preg_match('/(?:(\??(?:\w+|\\\\[\w\\\\]+)(?:\|\s*\??(?:\w+|\\\\[\w\\\\]+))*)\s+)?\$(\w+)/',
$arg_parts[0], $arg_matches))
{
$type = $arg_matches[1] ?: null;
$name = $arg_matches[2] ?: null;
$default = isset($arg_parts[1]) ? preg_replace('/\s{2,}/',
' ',
preg_replace('/[\r\n]+/', ' ',
trim($arg_parts[1]))) : null;
if (is_string($name))
{
$argument_types['$' . $name] = [
'type' => $type,
'default' => $default,
];
}
}
}
return $argument_types;
}
}
return null;
}
/**
* Extracts return type from a given declaration.
*
* @param string $comment The comment containing the return type
*
* @return string|null The return type
* @since 3.2.0
*/
private function extractReturnTypeFromComment(string $comment): ?string
{
if (preg_match('/@return\s+((?:[^\s|]+(?:\|)?)+)/', $comment,
$matches))
{
return $matches[1] ?: null;
}
return null;
}
/**
* Extracts the version number from the @since tag in the given comment.
*
* @param string|null $comment The comment containing the @since tag and
version number
*
* @return string|null The extracted version number or null if not found
* @since 3.2.0
*/
private function extractSinceVersion(?string $comment): ?string
{
if (is_string($comment) &&
preg_match('/@since\s+(v?\d+(?:\.\d+)*(?:-(?:alpha|beta|rc)\d*)?)/',
$comment, $matches))
{
return $matches[1] ?: null;
}
return null;
}
/**
* Extracts the version number from the deprecated tag in the given
comment.
*
* @param string|null $comment The comment containing the deprecated tag
and version number
*
* @return string|null The extracted version number or null if not found
* @since 3.2.0
*/
private function extractDeprecatedVersion(?string $comment): ?string
{
if (is_string($comment) &&
preg_match('/@deprecated\s+(v?\d+(?:\.\d+)*(?:-(?:alpha|beta|rc)\d*)?)/',
$comment, $matches))
{
return $matches[1] ?: null;
}
return null;
}
/**
* Remove all white space from each line of the comment
*
* @param string $comment The function declaration containing the return
type
*
* @return string The return comment
* @since 3.2.0
*/
private function removeWhiteSpaceFromComment(string $comment): string
{
// Remove comment markers and leading/trailing whitespace
$comment = preg_replace('/^\/\*\*[\r\n\s]*|[\r\n\s]*\*\/$/m',
'', $comment);
$comment = preg_replace('/^[\s]*\*[\s]?/m', '',
$comment);
// Split the comment into lines
$lines = preg_split('/\r\n|\r|\n/', $comment);
// Remove white spaces from each line
$trimmedLines = array_map('trim', $lines);
// Join the lines back together
return implode("\n", array_filter($trimmedLines));
}
/**
* Merges the types from the comments and the arguments.
*
* @param array $argTypesFromDeclaration An array of argument
types and default values from the declaration
* @param array|null $argTypesFromComments An array of argument
types from the comments
*
* @return array A merged array of argument information
* @since 3.2.0
*/
private function mergeArgumentTypes(array $argTypesFromDeclaration, ?array
$argTypesFromComments): array
{
$mergedArguments = [];
foreach ($argTypesFromDeclaration as $name => $declarationInfo)
{
$mergedArguments[$name] = [
'name' => $name,
'type' => $declarationInfo['type'] ?:
$argTypesFromComments[$name] ?? null,
'default' => $declarationInfo['default'] ?:
null,
];
}
return $mergedArguments;
}
}
src/Componentbuilder/Power/Plantuml.php000064400000025162151162054230014252
0ustar00<?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\Power;
/**
* Power Plantuml Builder
* @since 3.2.0
*/
class Plantuml
{
/**
* Get a namespace diagram of a group of class
*
* @param string $namespace the namespace name
* @param string $classes the ready build class uml
*
* @return string
* @since 3.2.0
*/
public function namespaceDiagram(string $namespace, string $classes):
string
{
$namespace_depth = substr_count($namespace, '\\');
$namespace_color = $this->getNamespaceColor($namespace_depth);
// Set the scale of the diagram
// $plant_uml = "scale 0.8\n\n";
// Add namespace
$plant_uml = "namespace $namespace #$namespace_color {\n\n";
// Add class
$plant_uml .= $classes;
$plant_uml .= "}\n";
return $plant_uml;
}
/**
* Get a class basic diagram of a class
*
* @param array $power the class being built
* @param array $code the class code being built
*
* @return string
* @since 3.2.0
*/
public function classBasicDiagram(array $power, array $code): string
{
// Set some global values
$class_name = $power['name'];
$class_type = $power['type'];
// set the class color
$class_color = $this->getClassColor($class_type);
// set the class type label
$type_label = $this->getClassTypeLable($class_type);
// set the class type tag
$type_tag = $this->getClassTypeTag($class_type);
// Add class
$plant_uml = "\n $type_label $class_name $type_tag #$class_color
{\n";
// Add properties
if (isset($code['properties']) &&
is_array($code['properties']))
{
$plant_uml .=
$this->generatePropertiesPlantUML($code['properties'], '
');
}
// Add methods
if (isset($code['methods']) &&
is_array($code['methods']))
{
$plant_uml .=
$this->generateBasicMethodsPlantUML($code['methods']);
}
$plant_uml .= " }\n";
return $plant_uml;
}
/**
* Get a class detailed diagram of a class
*
* @param array $power the class being built
* @param array $code the class code being built
*
* @return string
* @since 3.2.0
*/
public function classDetailedDiagram(array $power, array $code): string
{
// Set some global values
$class_name = $power['name'];
$class_type = $power['type'];
// set the class color
$class_color = $this->getClassColor($class_type);
// set the class type label
$type_label = $this->getClassTypeLable($class_type);
// set the class type tag
$type_tag = $this->getClassTypeTag($class_type);
// Add class
$plant_uml = "\n$type_label $class_name $type_tag #$class_color
{\n";
// Add properties
if (isset($code['properties']) &&
is_array($code['properties']))
{
$plant_uml .=
$this->generatePropertiesPlantUML($code['properties'], '
');
}
// Add methods
if (isset($code['methods']) &&
is_array($code['methods']))
{
list($methods_plant_uml, $notes) =
$this->generateDetailedMethodsPlantUML($code['methods'],
$class_name);
$plant_uml .= $methods_plant_uml;
}
$plant_uml .= "}\n";
if (!empty($notes))
{
$plant_uml .= $this->generateNotesPlantUML($notes);
}
return $plant_uml;
}
/**
* Generate properties PlantUML
*
* @param array $properties
* @param string $space
*
* @return string
* @since 3.2.0
*/
private function generatePropertiesPlantUML(array $properties, string
$space): string
{
$plant_uml = "";
foreach ($properties as $property)
{
$access_sign = $this->getAccessSign($property['access']);
$static = $property['static'] ? '{static} ' :
'';
$type = $property['type'] ? $property['type'] .
' ' : '';
$plant_uml .= "{$space}$access_sign
$static{$type}{$property['name']}\n";
}
return $plant_uml;
}
/**
* Generate detailed methods PlantUML
*
* @param array $methods
* @param string $class_name
*
* @return array
* @since 3.2.0
*/
private function generateDetailedMethodsPlantUML(array $methods, string
$class_name): array
{
$plant_uml = "";
$notes = [];
foreach ($methods as $method)
{
$notes = $this->generateMethodNotes($method, $class_name, $notes);
$access_sign = $this->getAccessSign($method['access']);
$arguments = '';
if ($method['arguments'])
{
$arguments = $this->generateMethodArgumentsAndNotes(
$method['arguments'], $class_name,
$method['name'], $notes);
$arguments = implode(', ', $arguments);
}
$static = $method['static'] ? '{static} ' :
'';
$abstract = $method['abstract'] ? '{abstract} ' :
'';
$return_type = $method['return_type'] ? " :
{$method['return_type']}" : '';
$plant_uml .= " $access_sign
{$abstract}$static{$method['name']}({$arguments})$return_type\n";
}
return [$plant_uml, $notes];
}
/**
* Generate basic methods PlantUML
*
* @param array $properties
*
* @return string
* @since 3.2.0
*/
private function generateBasicMethodsPlantUML(array $methods): string
{
$plant_uml = "";
foreach ($methods as $method)
{
$access_sign = $this->getAccessSign($method['access']);
$static = $method['static'] ? '{static} ' :
'';
$abstract = $method['abstract'] ? '{abstract} ' :
'';
$return_type = $method['return_type'] ? " :
{$method['return_type']}" : '';
$plant_uml .= " $access_sign
{$abstract}$static{$method['name']}()$return_type\n";
}
return $plant_uml;
}
/**
* Generate method arguments and notes
*
* @param array $arguments
* @param string $class_name
* @param string $method_name
* @param array $notes
*
* @return array
* @since 3.2.0
*/
private function generateMethodArgumentsAndNotes(array $arguments, string
$class_name,
string $method_name, array &$notes): array
{
$formatted_arguments = [];
$notes_bucket = [];
$limit = 2;
foreach ($arguments as $name => $arg)
{
$arg_type = $arg['type'] ? "{$arg['type']}
" : '';
$arg_default = $arg['default'] ? " =
{$arg['default']}" : '';
$arg_statment = "{$arg_type}$name{$arg_default}";
if ($limit == 0)
{
$formatted_arguments[] = "...";
$limit = -1;
}
elseif ($limit > 0)
{
$formatted_arguments[] = $arg_statment;
$limit--;
}
$notes_bucket[] = $arg_statment;
}
if ($limit == -1)
{
$notes["{$class_name}::{$method_name}"][] = "\n
arguments:\n " . implode("\n ", $notes_bucket);
}
return $formatted_arguments;
}
/**
* Generate method notes
*
* @param array $method
* @param string $class_name
* @param array $notes
*
* @return array
*/
private function generateMethodNotes(array $method, string $class_name,
array &$notes): array
{
$notes_key = "{$class_name}::{$method['name']}";
if (is_string($method['comment']) &&
strlen($method['comment']) > 4)
{
$notes[$notes_key][] = trim(preg_replace("/^@.*[\r\n]*/m",
'', $method['comment'])) . "\n";
}
if (is_string($method['since']) &&
strlen($method['since']) > 3)
{
$notes[$notes_key][] = "since: {$method['since']}";
}
if (is_string($method['return_type']) &&
strlen($method['return_type']) > 1)
{
$notes[$notes_key][] = "return:
{$method['return_type']}";
}
if (is_string($method['deprecated']) &&
strlen($method['deprecated']) > 3)
{
$notes[$notes_key][] = "deprecated:
{$method['deprecated']}";
}
return $notes;
}
/**
* Generate notes PlantUML
*
* @param array $notes
*
* @return string
* @since 3.2.0
*/
private function generateNotesPlantUML(array $notes): string
{
$plant_uml = "";
$note_count = count($notes);
$positions = ['right', 'left'];
$position_index = 0;
foreach ($notes as $area => $note)
{
if ($note_count <= 7)
{
$position = 'right';
}
else
{
$position = $positions[$position_index % 2];
$position_index++;
}
$plant_uml .= "\nnote $position of {$area}\n";
$plant_uml .= " " . implode("\n ", $note) .
"\n";
$plant_uml .= "end note\n";
}
return $plant_uml;
}
/**
* Get the access sign based on the access level.
*
* @param string $access The access level.
*
* @return string The corresponding access sign.
* @since 3.2.0
*/
private function getAccessSign(string $access): string
{
switch ($access)
{
case 'private':
return '-';
case 'protected':
return '#';
case 'public':
return '+';
case 'var':
return '+';
default:
return '';
}
}
/**
* Get the correct class type.
*
* @param string $type The class type.
*
* @return string The correct class type label.
* @since 3.2.0
*/
private function getClassTypeLable(string $type): string
{
$class_type_updater = [
'final class' => 'class',
'abstract class' => 'abstract',
'trait' => 'class'
];
return $class_type_updater[$type] ?? $type;
}
/**
* Get the extra class type tag.
*
* @param string $type The class type.
*
* @return string The correct class type label.
* @since 3.2.0
*/
private function getClassTypeTag(string $type): string
{
$class_type_updater = [
'final class' => '<< (F,LightGreen)
>>',
'trait' => '<< (T,Orange) >>'
];
return $class_type_updater[$type] ?? '';
}
/**
* Get class color based on class type.
*
* @param string $classType The class type.
*
* @return string The corresponding color.
* @since 3.2.0
*/
private function getClassColor(string $classType): string
{
$class_colors = [
'class' => 'Gold',
'final class' => 'RoyalBlue',
'abstract class' => 'Orange',
'interface' => 'Lavender',
'trait' => 'Turquoise'
];
return $class_colors[$classType] ?? 'Green';
}
/**
* Get namespace color based on namespace depth.
*
* @param int $namespaceDepth The depth of the namespace.
*
* @return string The corresponding color.
* @since 3.2.0
*/
private function getNamespaceColor(int $namespaceDepth): string
{
$namespace_colors = [
'lightgrey',
'Azure',
'DarkCyan',
'Olive',
'LightGreen',
'DeepSkyBlue',
'Wheat',
'Coral',
'Beige',
'DeepPink',
'DeepSkyBlue'
];
return $namespace_colors[$namespaceDepth % count($namespace_colors)] ??
'lightgrey';
}
}
src/Componentbuilder/Power/Readme/Item.php000064400000010263151162054230014545
0ustar00<?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\Power\Readme;
use VDM\Joomla\Componentbuilder\Power\Plantuml;
use VDM\Joomla\Interfaces\Readme\ItemInterface;
/**
* Compiler Power Item Readme
* @since 3.2.0
*/
final class Item implements ItemInterface
{
/**
* Compiler Powers Plantuml Builder
*
* @var Plantuml
* @since 3.2.0
**/
protected Plantuml $plantuml;
/**
* Constructor.
*
* @param Plantuml $plantuml The powers plantuml builder object.
*
* @since 3.2.0
*/
public function __construct(Plantuml $plantuml)
{
$this->plantuml = $plantuml;
}
/**
* Get an item readme
*
* @param object $item An item details.
*
* @return string
* @since 3.2.2
*/
public function get(object $item): string
{
// build readme
$readme = ["```
██████╗ ██████╗ ██╗
██╗███████╗██████╗
██╔══██╗██╔═══██╗██║
██║██╔════╝██╔══██╗
██████╔╝██║ ██║██║ █╗
██║█████╗ ██████╔╝
██╔═══╝ ██║
██║██║███╗██║██╔══╝
██╔══██╗
██║
╚██████╔╝╚███╔███╔╝███████╗██║
██║
╚═╝ ╚═════╝ ╚══╝╚══╝
╚══════╝╚═╝ ╚═╝
```"];
// add the class diagram
$parsed_class_code = [];
if (isset($item->parsed_class_code) &&
is_array($item->parsed_class_code))
{
$parsed_class_code = $item->parsed_class_code;
}
$readme[] = "# " . $item->type . " " .
$item->code_name . " (Details)";
$readme[] = "> namespace: **" . $item->_namespace .
"**";
if (!empty($item->extends_name))
{
$readme[] = "> extends: **" . $item->extends_name .
"**";
}
$readme[] = "\n```uml\n@startuml" .
$this->plantuml->classDetailedDiagram(
['name' => $item->code_name, 'type' =>
$item->type],
$parsed_class_code
) . " \n@enduml\n```";
$readme[] = "\nThe Power feature in JCB allows you to write PHP
classes and their implementations, making it easy to include them in your
Joomla project. JCB handles linking, autoloading, namespacing, and folder
structure creation for you.\n\nBy using the SPK (Super Power Key) in your
custom code (replacing the class name in your code with the SPK), JCB will
automatically pull the power from the repository into your project. This
makes it available in your JCB instance, allowing you to edit it and
include the class in your generated Joomla component.\n\nJCB uses
placeholders like [[[`NamespacePrefix`]]] and [[[`ComponentNamespace`]]] in
namespacing to prevent collisions and improve reusability across different
JCB systems. You can also set the **JCB powers path** globally or per
component under the **Dynamic Integration** tab, providing flexibility and
easy maintainability.\n\nTo add this specific Power to your project in
JCB:\n\n> simply use this SPK\n```\n" . 'Super---' .
str_replace('-', '_', $item->guid) .
'---Power' . "\n```\n> remember to replace the `---` with
`___` to activate this Power in your code";
// yes you can remove this, but why?
$readme[] = "\n---\n```
██╗ ██████╗██████╗
██║██╔════╝██╔══██╗
██║██║ ██████╔╝
██ ██║██║ ██╔══██╗
╚█████╔╝╚██████╗██████╔╝
╚════╝ ╚═════╝╚═════╝
```\n> Build with [Joomla Component
Builder](https://git.vdm.dev/joomla/Component-Builder)\n\n";
return implode("\n", $readme);
}
}
src/Componentbuilder/Power/Readme/Main.php000064400000030340151162054230014531
0ustar00<?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\Power\Readme;
use VDM\Joomla\Interfaces\Readme\MainInterface;
/**
* Compiler Power Main Readme
* @since 3.2.0
*/
final class Main implements MainInterface
{
/**
* Get Main Readme
*
* @param array $items All items of this repository.
*
* @return string
* @since 3.2.0
*/
public function get(array $items): string
{
// build readme
$readme = ["```
███████╗██╗ ██╗██████╗
███████╗██████╗
██╔════╝██║
██║██╔══██╗██╔════╝██╔══██╗
███████╗██║
██║██████╔╝█████╗
██████╔╝
╚════██║██║ ██║██╔═══╝
██╔══╝ ██╔══██╗
███████║╚██████╔╝██║
███████╗██║ ██║
╚══════╝ ╚═════╝ ╚═╝
╚══════╝╚═╝ ╚═╝
██████╗ ██████╗ ██╗
██╗███████╗██████╗
███████╗
██╔══██╗██╔═══██╗██║
██║██╔════╝██╔══██╗██╔════╝
██████╔╝██║ ██║██║ █╗
██║█████╗
██████╔╝███████╗
██╔═══╝ ██║
██║██║███╗██║██╔══╝
██╔══██╗╚════██║
██║
╚██████╔╝╚███╔███╔╝███████╗██║
██║███████║
╚═╝ ╚═════╝ ╚══╝╚══╝
╚══════╝╚═╝ ╚═╝╚══════╝
```"];
// default description of super powers
$readme[] = "\n### What is JCB Super Powers?\nThe Joomla Component
Builder (JCB) Super Power features are designed to enhance JCB's
functionality and streamline the development process. These Super Powers
enable developers to efficiently manage and share their custom powers
across multiple JCB instances through repositories hosted on
[https://git.vdm.dev/[username]/[repository-name]](https://git.vdm.dev).
JCB Super Powers are managed using a combination of layers, events, tasks,
methods, switches, and algorithms, which work together to provide powerful
customization and extensibility options. More details on JCB Super Powers
can be found in the [Super Powers
Documentation](https://git.vdm.dev/joomla/super-powers/wiki).\n\nIn
summary, JCB Super Powers offer a flexible and efficient way to manage and
share functionalities between JCB instances. By utilizing a sophisticated
system of layers, events, tasks, methods, switches, and algorithms,
developers can seamlessly integrate JCB core powers and their custom
powers. For more information on how to work with JCB Super Powers, refer to
the [Super Powers User
Guide](https://git.vdm.dev/joomla/super-powers/wiki).\n\n### What can I
find here?\nThis repository contains an index (see below) of all the
approved powers within the JCB GUI. During the compilation of a component,
these powers are automatically added to the repository, ensuring a
well-organized and accessible collection of functionalities.\n";
// get the readme body
$readme[] = $this->readmeBuilder($items);
// yes you can remove this, but why?
$readme[] = "\n---\n```
██╗ ██████╗ ██████╗ ███╗
███╗██╗ █████╗
██║██╔═══██╗██╔═══██╗████╗
████║██║ ██╔══██╗
██║██║ ██║██║
██║██╔████╔██║██║
███████║
██ ██║██║ ██║██║
██║██║╚██╔╝██║██║
██╔══██║
╚█████╔╝╚██████╔╝╚██████╔╝██║
╚═╝ ██║███████╗██║ ██║
╚════╝ ╚═════╝ ╚═════╝ ╚═╝
╚═╝╚══════╝╚═╝ ╚═╝
██████╗ ██████╗ ███╗
███╗██████╗ ██████╗ ███╗
██╗███████╗███╗
██╗████████╗
██╔════╝██╔═══██╗████╗
████║██╔══██╗██╔═══██╗████╗
██║██╔════╝████╗
██║╚══██╔══╝
██║ ██║
██║██╔████╔██║██████╔╝██║
██║██╔██╗ ██║█████╗
██╔██╗ ██║ ██║
██║ ██║
██║██║╚██╔╝██║██╔═══╝ ██║
██║██║╚██╗██║██╔══╝
██║╚██╗██║ ██║
╚██████╗╚██████╔╝██║ ╚═╝
██║██║ ╚██████╔╝██║
╚████║███████╗██║ ╚████║
██║
╚═════╝ ╚═════╝ ╚═╝
╚═╝╚═╝ ╚═════╝ ╚═╝
╚═══╝╚══════╝╚═╝ ╚═══╝
╚═╝
██████╗ ██╗ ██╗██╗██╗
██████╗ ███████╗██████╗
██╔══██╗██║ ██║██║██║
██╔══██╗██╔════╝██╔══██╗
██████╔╝██║ ██║██║██║
██║ ██║█████╗ ██████╔╝
██╔══██╗██║ ██║██║██║
██║ ██║██╔══╝ ██╔══██╗
██████╔╝╚██████╔╝██║███████╗██████╔╝███████╗██║
██║
╚═════╝ ╚═════╝
╚═╝╚══════╝╚═════╝
╚══════╝╚═╝ ╚═╝
```\n> Build with [Joomla Component
Builder](https://git.vdm.dev/joomla/Component-Builder)\n\n";
return implode("\n", $readme);
}
/**
* The readme builder
*
* @param array $classes The powers.
*
* @return string
* @since 3.2.0
*/
private function readmeBuilder(array &$items): string
{
$classes = [];
foreach ($items as $guid => $power)
{
// add to the sort bucket
$classes[] = [
'namespace' => $power['namespace'],
'type' => $power['type'],
'name' => $power['name'],
'link' => $this->indexLinkPower($power)
];
}
return $this->readmeModel($classes);
}
/**
* Sort and model the readme classes
*
* @param array $classes The powers.
*
* @return string
* @since 3.2.0
*/
private function readmeModel(array &$classes): string
{
$this->sortClasses($classes, $this->defineTypeOrder());
return $this->generateIndex($classes);
}
/**
* Generate the index string for classes
*
* @param array $classes The sorted classes
*
* @return string The index string
*/
private function generateIndex(array &$classes): string
{
$result = "# Index of powers\n";
$current_namespace = null;
foreach ($classes as $class)
{
if ($class['namespace'] !== $current_namespace)
{
$current_namespace = $class['namespace'];
$result .= "\n- **Namespace**: [{$current_namespace}](#" .
strtolower(str_replace('\\', '-',
$current_namespace)) . ")\n";
}
// Add the class details
$result .= "\n - " . $class['link'];
}
$result .= "\n> remember to replace the `---` with `___` in the
SPK to activate that Power in your code";
return $result;
}
/**
* Define the order of types for sorting purposes
*
* @return array The order of types
* @since 3.2.0
*/
private function defineTypeOrder(): array
{
return [
'interface' => 1,
'abstract' => 2,
'abstract class' => 2,
'final' => 3,
'final class' => 3,
'class' => 4,
'trait' => 5
];
}
/**
* Sort the flattened array using a single sorting function
*
* @param array $classes The classes to sort
* @param array $typeOrder The order of types
* @since 3.2.0
*/
private function sortClasses(array &$classes, array $typeOrder): void
{
usort($classes, function ($a, $b) use ($typeOrder) {
$namespaceDiff = $this->compareNamespace($a, $b);
if ($namespaceDiff !== 0)
{
return $namespaceDiff;
}
$typeDiff = $this->compareType($a, $b, $typeOrder);
if ($typeDiff !== 0)
{
return $typeDiff;
}
return $this->compareName($a, $b);
});
}
/**
* Compare the namespace of two classes
*
* @param array $a First class
* @param array $b Second class
*
* @return int Comparison result
* @since 3.2.0
*/
private function compareNamespace(array $a, array $b): int
{
$namespaceDepthDiff = substr_count($a['namespace'],
'\\') - substr_count($b['namespace'], '\\');
if ($namespaceDepthDiff === 0)
{
return strcmp($a['namespace'], $b['namespace']);
}
return $namespaceDepthDiff;
}
/**
* Compare the type of two classes
*
* @param array $a First class
* @param array $b Second class
* @param array $typeOrder The order of types
*
* @return int Comparison result
* @since 3.2.0
*/
private function compareType(array $a, array $b, array $typeOrder): int
{
return $typeOrder[$a['type']] <=>
$typeOrder[$b['type']];
}
/**
* Compare the name of two classes
*
* @param array $a First class
* @param array $b Second class
*
* @return int Comparison result
* @since 3.2.0
*/
private function compareName(array $a, array $b): int
{
return strcmp($a['name'], $b['name']);
}
/**
* Build the Link to the power in this repository
*
* @param array $power The power details.
*
* @return string
* @since 3.2.0
*/
private function indexLinkPower(array &$power): string
{
$type = $power['type'] ?? 'error';
$name = $power['name'] ?? 'error';
return '**' . $type . ' ' . $name . "** |
"
. $this->linkPowerRepo($power) . ' | '
. $this->linkPowerCode($power) . ' | '
. $this->linkPowerSettings($power) . ' | SPK: `'
. $this->linkPowerSPK($power) .'`';
}
/**
* Build the Link to the power in this repository
*
* @param array $power The power details.
*
* @return string
* @since 3.2.0
*/
private function linkPowerRepo(array &$power): string
{
$path = $power['path'] ?? 'error';
return '[Details](' . $path . ')';
}
/**
* Build the Link to the power settings in this repository
*
* @param array $power The power details.
*
* @return string
* @since 3.2.0
*/
private function linkPowerCode(array &$power): string
{
$code = $power['code'] ?? 'error';
return '[Code](' . $code . ')';
}
/**
* Build the Link to the power settings in this repository
*
* @param array $power The power details.
*
* @return string
* @since 3.2.0
*/
private function linkPowerSettings(array &$power): string
{
$settings = $power['settings'] ?? 'error';
return '[Settings](' . $settings . ')';
}
/**
* Get the SuperPowerKey (SPK)
*
* @param array $power The power details.
*
* @return string
* @since 3.2.0
*/
private function linkPowerSPK(array &$power): string
{
$spk = $power['spk'] ?? 'error';
return $spk;
}
}
src/Componentbuilder/Power/Readme/index.html000064400000000054151162054230015130
0ustar00<html><body
bgcolor="#FFFFFF"></body></html>src/Componentbuilder/Power/Remote/Get.php000064400000001433151162054240014424
0ustar00<?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\Power\Remote;
use VDM\Joomla\Interfaces\Remote\GetInterface;
use VDM\Joomla\Abstraction\Remote\Get as ExtendingGet;
/**
* Remote Get Power of JCB
*
* @since 3.2.0
*/
final class Get extends ExtendingGet implements GetInterface
{
/**
* Table Name
*
* @var string
* @since 3.2.1
*/
protected string $table = 'power';
}
src/Componentbuilder/Power/Remote/Set.php000064400000050075151162054240014446
0ustar00<?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\Power\Remote;
use VDM\Joomla\Interfaces\GrepInterface as Grep;
use VDM\Joomla\Interfaces\Data\ItemsInterface as Items;
use VDM\Joomla\Interfaces\Readme\ItemInterface as ItemReadme;
use VDM\Joomla\Interfaces\Readme\MainInterface as MainReadme;
use VDM\Joomla\Interfaces\Git\Repository\ContentsInterface as Git;
use VDM\Joomla\Componentbuilder\Power\Parser;
use VDM\Joomla\Utilities\String\NamespaceHelper;
use VDM\Joomla\Utilities\ArrayHelper;
use VDM\Joomla\Utilities\StringHelper;
use VDM\Joomla\Utilities\String\ClassfunctionHelper;
use VDM\Joomla\Utilities\GuidHelper;
use VDM\Joomla\Interfaces\Remote\SetInterface;
use VDM\Joomla\Abstraction\Remote\Set as ExtendingSet;
/**
* Set Power based on global unique ids to remote repository
*
* @since 5.0.2
*/
final class Set extends ExtendingSet implements SetInterface
{
/**
* Table Name
*
* @var string
* @since 5.0.3
*/
protected string $table = 'power';
/**
* Area Name
*
* @var string
* @since 5.0.3
*/
protected string $area = 'Super Power';
/**
* Prefix Key
*
* @var string
* @since 5.0.3
*/
protected string $prefix_key = 'Super---';
/**
* The item map
*
* @var array
* @since 5.0.3
*/
protected array $map = [
'add_head' => 'add_head',
'description' => 'description',
'extends' => 'extends',
'extendsinterfaces' => 'extendsinterfaces',
'guid' => 'guid',
'head' => 'head',
'use_selection' => 'use_selection',
'implements' => 'implements',
'load_selection' => 'load_selection',
'name' => 'name',
'power_version' => 'power_version',
'system_name' => 'system_name',
'type' => 'type',
'namespace' => 'namespace',
'composer' => 'composer',
'add_licensing_template' =>
'add_licensing_template',
'licensing_template' => 'licensing_template',
'main_class_code' => 'main_class_code'
];
/**
* The index map
*
* @var array
* @since 5.0.3
*/
protected array $index_map = [
'name' => 'index_map_IndexName',
'type' => 'index_map_TypeName',
'namespace' => 'index_map_NameSpace',
'code' => 'index_map_CodePath',
'power' => 'index_map_PowerPath',
'settings' => 'index_map_IndexSettingsPath',
'path' => 'index_map_IndexPath',
'spk' => 'index_map_IndexKey',
'guid' => 'index_map_IndexGUID'
];
/**
* The item settings file path
*
* @var string
* @since 5.0.3
*/
protected string $settings_path = 'settings.json';
/**
* The index settings file path
*
* @var string
* @since 5.0.3
*/
protected string $index_settings_path = 'super-powers.json';
/**
* The Parser Class.
*
* @var Parser|null
* @since 5.0.2
*/
protected ?Parser $parser;
/**
* Constructor.
*
* @param array $repos The active repos
* @param Grep $grep The Grep Class.
* @param Items $items The Items Class.
* @param ItemReadme $itemReadme The Item Readme Class.
* @param MainReadme $mainReadme The Main Readme Class.
* @param Git $git The Contents Class.
* @param string|null $table The table name.
* @param string|null $settingsPath The settings path.
* @param string|null $settingsIndexPath The index settings path.
* @param Parser|null $parser The Parser Class.
*
* @since 3.2.2
*/
public function __construct(array $repos, Grep $grep, Items $items,
ItemReadme $itemReadme, MainReadme $mainReadme, Git $git,
?string $table = null, ?string $settingsPath = null,
?string $settingsIndexPath = null, ?Parser $parser = null)
{
parent::__construct($repos, $grep, $items, $itemReadme, $mainReadme,
$git, $table, $settingsPath, $settingsIndexPath);
$this->parser = $parser;
}
/**
* Map a single item value (extends)
*
* @param object $item The item to be mapped
* @param array $item The bucket to to place new values
* @param string $map The item map to be mapped
*
* @return void
* @since 5.0.2
*/
protected function mapItemValue_extends(object &$item, array
&$power): void
{
if ($item->type !== 'interface')
{
$value = $item->extends ?? '';
$extends_custom = $item->extends_custom ?? null;
if ($value == -1 && $extends_custom !== null)
{
$power['extends_name'] = ClassfunctionHelper::safe(
$this->updatePlaceholders((string) $extends_custom)
);
$power['extends_custom'] = $extends_custom;
$power['extends'] = -1;
}
elseif (GuidHelper::valid($value))
{
$name = GuidHelper::item($value, 'power', 'a.name',
'componentbuilder');
if ($name !== null)
{
$power['extends_name'] = ClassfunctionHelper::safe(
$this->updatePlaceholders($name)
);
}
}
else
{
$power['extends'] = '';
}
// always rest these for normal classes
$power['extendsinterfaces'] = null;
$power['extendsinterfaces_custom'] = '';
}
}
/**
* Map a single item value (extendsinterfaces)
*
* @param object $item The item to be mapped
* @param array $item The bucket to to place new values
* @param string $map The item map to be mapped
*
* @return void
* @since 5.0.2
*/
protected function mapItemValue_extendsinterfaces(object &$item, array
&$power): void
{
if ($item->type === 'interface')
{
$values = $item->extendsinterfaces ?? null;
if (!empty($values))
{
$values = (array) $values;
$extends_names = [];
$extendsinterfaces_custom = $item->extendsinterfaces_custom ??
null;
foreach ($values as $value)
{
if ($value == -1 &&
StringHelper::check($extendsinterfaces_custom))
{
$extends_names[] = ClassfunctionHelper::safe(
$this->updatePlaceholders($extendsinterfaces_custom)
);
$power['extendsinterfaces_custom'] =
$extendsinterfaces_custom;
$extendsinterfaces_custom = null;
}
elseif (GuidHelper::valid($value))
{
$name = GuidHelper::item($value, 'power',
'a.name', 'componentbuilder');
if ($name !== null)
{
$extends_names[] = ClassfunctionHelper::safe(
$this->updatePlaceholders($name)
);
}
}
}
if ($extends_names !== [])
{
$power['extendsinterfaces'] = array_values($values);
$power['extends_name'] = implode(', ',
$extends_names);
}
}
else
{
$power['extendsinterfaces'] = null;
$power['extendsinterfaces_custom'] = '';
}
// always rest these for interfaces
$power['extends'] = '';
$power['extends_custom'] = '';
}
}
/**
* Map a single item value (use_selection)
*
* @param object $item The item to be mapped
* @param array $item The bucket to to place new values
* @param string $map The item map to be mapped
*
* @return void
* @since 5.0.2
*/
protected function mapItemValue_use_selection(object &$item, array
&$power): void
{
$value = $item->use_selection ?? null;
if (!empty($value))
{
$value = (array) $value;
$power['use_selection'] = $value;
}
else
{
$power['use_selection'] = null;
}
}
/**
* Map a single item value (load_selection)
*
* @param object $item The item to be mapped
* @param array $item The bucket to to place new values
* @param string $map The item map to be mapped
*
* @return void
* @since 5.0.2
*/
protected function mapItemValue_load_selection(object &$item, array
&$power): void
{
$value = $item->load_selection ?? null;
if (!empty($value))
{
$value = (array) $value;
$power['load_selection'] = $value;
}
else
{
$power['load_selection'] = null;
}
}
/**
* Map a single item value (composer)
*
* @param object $item The item to be mapped
* @param array $item The bucket to to place new values
* @param string $map The item map to be mapped
*
* @return void
* @since 5.0.2
*/
protected function mapItemValue_composer(object &$item, array
&$power): void
{
$value = $item->composer ?? null;
if (!empty($value))
{
$value = (array) $value;
$power['composer'] = array_values($value);
}
else
{
$power['composer'] = '';
}
}
/**
* Map a single item value (implements)
*
* @param object $item The item to be mapped
* @param array $item The bucket to to place new values
* @param string $map The item map to be mapped
*
* @return void
* @since 5.0.2
*/
protected function mapItemValue_implements(object &$item, array
&$power): void
{
$values = $item->implements ?? '';
if (!empty($values))
{
$values = (array) $values;
$implement_names = [];
$implements_custom = $item->implements_custom ?? null;
foreach ($values as $value)
{
if ($value == -1 && StringHelper::check($implements_custom))
{
$implement_names[] = ClassfunctionHelper::safe(
$this->updatePlaceholders($implements_custom)
);
$implements_custom = null;
}
elseif (GuidHelper::valid($value))
{
$name = GuidHelper::item($value, 'power',
'a.name', 'componentbuilder');
if ($name !== null)
{
$implement_names[] = ClassfunctionHelper::safe(
$this->updatePlaceholders($name)
);
}
}
}
if ($implement_names !== [])
{
$power['implements'] = array_values($values);
$power['implement_names'] = $implement_names;
}
else
{
$power['implements'] = null;
}
}
}
/**
* update an existing item (if changed)
*
* @param object $item
* @param object $existing
* @param object $repo
*
* @return bool
* @since 5.0.3
*/
protected function updateItem(object $item, object $existing, object
$repo): bool
{
// make sure there was a change
$sha = $existing->params->source[$repo->guid .
'-settings'] ?? null;
$_existing = $this->mapItem($existing);
if ($sha === null || $this->areObjectsEqual($item, $_existing))
{
return false;
}
else
{
// strip these values form the settings
$code = (string) $item->main_class_code ?? '';
$extends_name = (string) $item->extends_name ?? '';
$implement_names = (string) $item->implement_names ?? '';
unset($item->main_class_code);
unset($item->extends_name);
unset($item->implement_names);
$this->git->update(
$repo->organisation, // The owner name.
$repo->repository, // The repository name.
'src/' . $item->guid . '/' .
$this->getSettingsPath(), // The file path.
json_encode($item, JSON_PRETTY_PRINT), // The file content.
'Update ' . $item->system_name . ' settings', //
The commit message.
$sha, // The blob SHA of the old file.
$repo->write_branch // The branch name.
);
$item->main_class_code = $code;
$item->extends_name = $extends_name;
$item->implement_names = $implement_names;
}
return $this->updatePower($item, $existing, $repo);
}
/**
* update an existing power code (if changed)
*
* @param object $item
* @param object $existing
* @param object $repo
*
* @return bool
* @since 5.0.3
*/
protected function updatePower(object $item, object $existing, object
$repo): bool
{
// make sure there was a change
$sha = $existing->params->source[$repo->guid .
'-power'] ?? null;
if ($sha === null)
{
return false;
}
// Calculate the new SHA from the current content
$power = $item->main_class_code ?? '';
$newSha = sha1("blob " . strlen($power) . "\0" .
$power);
// Check if the new SHA matches the existing SHA
if ($sha === $newSha)
{
return false;
}
$this->git->update(
$repo->organisation, // The owner name.
$repo->repository, // The repository name.
'src/' . $item->guid . '/code.power', // The file
path.
$power, // The file content.
'Update ' . $item->system_name . ' code', // The
commit message.
$sha, // The blob SHA of the old file.
$repo->write_branch // The branch name.
);
return true;
}
/**
* create a new item
*
* @param object $item
* @param object $repo
*
* @return void
* @since 5.0.3
*/
protected function createItem(object $item, object $repo): void
{
// strip these values form the settings
$code = (string) $item->main_class_code ?? '';
$extends_name = (string) $item->extends_name ?? '';
$implement_names = (string) $item->implement_names ?? '';
unset($item->main_class_code);
unset($item->extends_name);
unset($item->implement_names);
$this->git->create(
$repo->organisation, // The owner name.
$repo->repository, // The repository name.
'src/' . $item->guid . '/' .
$this->getSettingsPath(), // The file path.
json_encode($item, JSON_PRETTY_PRINT), // The file content.
'Create ' . $item->system_name . ' settings', //
The commit message.
$repo->write_branch // The branch name.
);
$item->main_class_code = $code;
$item->extends_name = $extends_name;
$item->implement_names = $implement_names;
$this->createPower($item, $repo);
}
/**
* create a new power
*
* @param object $item
* @param object $repo
*
* @return void
* @since 5.0.3
*/
protected function createPower(object $item, object $repo): void
{
$this->git->create(
$repo->organisation, // The owner name.
$repo->repository, // The repository name.
'src/' . $item->guid . '/code.power', // The file
path.
$item->main_class_code, // The file content.
'Create ' . $item->system_name . ' code', // The
commit message.
$repo->write_branch // The branch name.
);
}
/**
* update an existing item readme
*
* @param object $item
* @param object $existing
* @param object $repo
*
* @return void
* @since 5.0.3
*/
protected function updateItemReadme(object $item, object $existing, object
$repo): void
{
// make sure there was a change
$sha = $existing->params->source[$repo->guid .
'-readme'] ?? null;
if ($sha === null)
{
return;
}
if ($this->parser !== null)
{
$item->parsed_class_code =
$this->parser->code($item->main_class_code);
}
$item->code_name = $this->index_map_IndexName($item);
$item->_namespace = $this->index_map_NameSpace($item);
$readme = $this->itemReadme->get($item);
$newSha = sha1("blob " . strlen($readme) . "\0" .
$readme);
// Check if the new SHA matches the existing SHA
if ($sha === $newSha)
{
return;
}
$this->git->update(
$repo->organisation, // The owner name.
$repo->repository, // The repository name.
'src/' . $item->guid . '/README.md', // The file
path.
$readme, // The file content.
'Update ' . $item->system_name . ' readme file',
// The commit message.
$sha, // The blob SHA of the old file.
$repo->write_branch // The branch name.
);
}
/**
* create a new item readme
*
* @param object $item
* @param object $repo
*
* @return void
* @since 5.0.3
*/
protected function createItemReadme(object $item, object $repo): void
{
if ($this->parser !== null)
{
$item->parsed_class_code =
$this->parser->code($item->main_class_code);
}
$item->code_name = $this->index_map_IndexName($item);
$item->_namespace = $this->index_map_NameSpace($item);
$this->git->create(
$repo->organisation, // The owner name.
$repo->repository, // The repository name.
'src/' . $item->guid . '/README.md', // The file
path.
$this->itemReadme->get($item), // The file content.
'Create ' . $item->system_name . ' readme file',
// The commit message.
$repo->write_branch // The branch name.
);
}
/**
* check that we have a target repo of this item
*
* @param object $item The item
* @param object $repo The current repo
*
* @return bool
* @since 5.0.3
*/
protected function targetRepo(object $item, object $repo): bool
{
if (!isset($item->approved) || $item->approved != 1 ||
!isset($item->approved_paths) ||
!is_array($item->approved_paths))
{
return false;
}
$repo_path =
"{$repo->organisation}/{$repo->repository}";
foreach ($item->approved_paths as $approved_path)
{
if ($repo_path === $approved_path)
{
return true;
}
}
return false;
}
/**
* Get the item name for the index values
*
* @param object $item
*
* @return string|null
* @since 5.0.3
*/
protected function index_map_IndexName(object $item): ?string
{
$name = $item->name ?? null;
if ($name !== null)
{
return ClassfunctionHelper::safe(
$this->updatePlaceholders($name)
);
}
return null;
}
/**
* Get the item type for the index values
*
* @param object $item
*
* @return string|null
* @since 5.0.3
*/
protected function index_map_TypeName(object $item): ?string
{
return $item->type ?? null;
}
/**
* Get the item code path for the index values
*
* @param object $item
*
* @return string|null
* @since 5.0.3
*/
protected function index_map_CodePath(object $item): ?string
{
return $this->index_map_IndexPath($item) . '/code.php';
}
/**
* Get the item power path for the index values
*
* @param object $item
*
* @return string|null
* @since 5.0.3
*/
protected function index_map_PowerPath(object $item): ?string
{
return $this->index_map_IndexPath($item) . '/code.power';
}
/**
* Get the item namespace for the index values
*
* @param object $item
*
* @return string|null
* @since 5.0.3
*/
protected function index_map_NameSpace(object $item): ?string
{
return $this->getNamespace($item->namespace ?? '',
$item->name ?? '');
}
/**
* Set the namespace for this power
*
* @param string $namespace The raw namespace
* @param string $className The class name
*
* @return string|null
* @since 5.0.3
*/
protected function getNamespace(string $namespace, string $className):
?string
{
// set namespace
$namespace = $this->updatePlaceholders($namespace);
// validate namespace
if (strpos($namespace, '\\') === false)
{
// we break out here
return null;
}
// setup the path array
$path_array = (array) explode('\\', $namespace);
// make sure it has two or more
if (ArrayHelper::check($path_array) <= 1)
{
// we break out here
return null;
}
// get the file and class name (the last value in array)
$file_name = array_pop($path_array);
// do we have src folders
if (strpos($file_name, '.') !== false)
{
// we have src folders in the namespace
$src_array = (array) explode('.', $file_name);
// get the file and class name (the last value in array)
$file_name = array_pop($src_array);
// namespace array
$namespace_array = [...$path_array, ...$src_array];
}
else
{
// namespace array
$namespace_array = $path_array;
}
// the last value is the same as the class name
if ($file_name !== $className)
{
// we break out here
return null;
}
// make sure the arrays are namespace safe
$namespace_array =
array_map(
fn($val) => $this->getCleanNamespace($val),
$namespace_array
);
// set the actual class namespace
return implode('\\', $namespace_array);
}
/**
* Get Clean Namespace without use or ; as part of the name space
*
* @param string $namespace The actual name space
*
* @return string
* @since 5.0.3
*/
protected function getCleanNamespace(string $namespace): string
{
// trim possible (use) or (;) or (starting or ending \) added to the
namespace
return NamespaceHelper::safe(str_replace(['use ',
';'], '', $namespace));
}
}
src/Componentbuilder/Power/Remote/index.html000064400000000054151162054240015167
0ustar00<html><body
bgcolor="#FFFFFF"></body></html>src/Componentbuilder/Power/Service/Generator.php000064400000011321151162054240015775
0ustar00<?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\Power\Service;
use Joomla\DI\Container;
use Joomla\DI\ServiceProviderInterface;
use VDM\Joomla\Componentbuilder\Power\Generator as PowerGenerator;
use VDM\Joomla\Componentbuilder\Power\Generator\ClassInjectorBuilder;
use VDM\Joomla\Componentbuilder\Power\Generator\ServiceProviderBuilder;
use VDM\Joomla\Componentbuilder\Power\Generator\Search;
use VDM\Joomla\Componentbuilder\Power\Generator\ClassInjector;
use VDM\Joomla\Componentbuilder\Power\Generator\ServiceProvider;
use VDM\Joomla\Componentbuilder\Power\Generator\Bucket;
/**
* Generator Service Provider
*
* @since 3.2.0
*/
class Generator implements ServiceProviderInterface
{
/**
* Registers the service provider with a DI container.
*
* @param Container $container The DI container.
*
* @return void
* @since 3.2.0
*/
public function register(Container $container)
{
$container->alias(PowerGenerator::class, 'Power.Generator')
->share('Power.Generator', [$this,
'getGenerator'], true);
$container->alias(ClassInjectorBuilder::class,
'Power.Generator.Class.Injector.Builder')
->share('Power.Generator.Class.Injector.Builder', [$this,
'getClassInjectorBuilder'], true);
$container->alias(ServiceProviderBuilder::class,
'Power.Generator.Service.Provider.Builder')
->share('Power.Generator.Service.Provider.Builder', [$this,
'getServiceProviderBuilder'], true);
$container->alias(Search::class, 'Power.Generator.Search')
->share('Power.Generator.Search', [$this,
'getSearch'], true);
$container->alias(ClassInjector::class,
'Power.Generator.Class.Injector')
->share('Power.Generator.Class.Injector', [$this,
'getClassInjector'], true);
$container->alias(ServiceProvider::class,
'Power.Generator.Service.Provider')
->share('Power.Generator.Service.Provider', [$this,
'getServiceProvider'], true);
$container->alias(Bucket::class, 'Power.Generator.Bucket')
->share('Power.Generator.Bucket', [$this,
'getBucket'], true);
}
/**
* Get the Generator
*
* @param Container $container The DI container.
*
* @return PowerGenerator
* @since 3.2.0
*/
public function getGenerator(Container $container): PowerGenerator
{
return new PowerGenerator(
$container->get('Power.Generator.Class.Injector.Builder'),
$container->get('Power.Generator.Service.Provider.Builder')
);
}
/**
* Get the Generator Class Injector Builder
*
* @param Container $container The DI container.
*
* @return ClassInjectorBuilder
* @since 3.2.0
*/
public function getClassInjectorBuilder(Container $container):
ClassInjectorBuilder
{
return new ClassInjectorBuilder(
$container->get('Power.Generator.Search'),
$container->get('Power.Generator.Class.Injector')
);
}
/**
* Get the Generator Service Provider Builder
*
* @param Container $container The DI container.
*
* @return ServiceProviderBuilder
* @since 3.2.0
*/
public function getServiceProviderBuilder(Container $container):
ServiceProviderBuilder
{
return new ServiceProviderBuilder(
$container->get('Power.Generator.Search'),
$container->get('Power.Generator.Service.Provider')
);
}
/**
* Get the Generator Search
*
* @param Container $container The DI container.
*
* @return Search
* @since 3.2.0
*/
public function getSearch(Container $container): Search
{
return new Search(
$container->get('Data.Load'),
$container->get('Power.Parser'),
$container->get('Power.Generator.Bucket')
);
}
/**
* Get the Generator Class Injector
*
* @param Container $container The DI container.
*
* @return ClassInjector
* @since 3.2.0
*/
public function getClassInjector(Container $container): ClassInjector
{
return new ClassInjector();
}
/**
* Get the Generator Service Provider
*
* @param Container $container The DI container.
*
* @return ServiceProvider
* @since 3.2.0
*/
public function getServiceProvider(Container $container): ServiceProvider
{
return new ServiceProvider();
}
/**
* Get the Generator Bucket
*
* @param Container $container The DI container.
*
* @return Bucket
* @since 3.2.0
*/
public function getBucket(Container $container): Bucket
{
return new Bucket();
}
}
src/Componentbuilder/Power/Service/Gitea.php000064400000002634151162054240015107
0ustar00<?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\Power\Service;
use Joomla\DI\Container;
use Joomla\DI\ServiceProviderInterface;
use VDM\Joomla\Gitea\Repository\Contents;
/**
* Power Gitea Service Provider
*
* @since 3.2.0
*/
class Gitea implements ServiceProviderInterface
{
/**
* Registers the service provider with a DI container.
*
* @param Container $container The DI container.
*
* @return void
* @since 3.2.0
*/
public function register(Container $container)
{
$container->alias(Contents::class,
'Gitea.Repository.Contents')
->share('Gitea.Repository.Contents', [$this,
'getContents'], true);
}
/**
* Get the Contents class
*
* @param Container $container The DI container.
*
* @return Contents
* @since 3.2.0
*/
public function getContents(Container $container): Contents
{
return new Contents(
$container->get('Gitea.Utilities.Http'),
$container->get('Gitea.Dynamic.Uri'),
$container->get('Gitea.Utilities.Response')
);
}
}
src/Componentbuilder/Power/Service/Power.php000064400000011715151162054240015152
0ustar00<?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\Power\Service;
use Joomla\DI\Container;
use Joomla\DI\ServiceProviderInterface;
use VDM\Joomla\Componentbuilder\Power\Config;
use VDM\Joomla\Componentbuilder\Table;
use VDM\Joomla\Componentbuilder\Power\Grep;
use VDM\Joomla\Componentbuilder\Power\Remote\Get;
use VDM\Joomla\Componentbuilder\Power\Remote\Set;
use VDM\Joomla\Componentbuilder\Power\Parser;
use VDM\Joomla\Componentbuilder\Power\Plantuml;
use VDM\Joomla\Componentbuilder\Power\Readme\Item as ItemReadme;
use VDM\Joomla\Componentbuilder\Power\Readme\Main as MainReadme;
/**
* Power Service Provider
*
* @since 3.2.0
*/
class Power implements ServiceProviderInterface
{
/**
* Registers the service provider with a DI container.
*
* @param Container $container The DI container.
*
* @return void
* @since 3.2.0
*/
public function register(Container $container)
{
$container->alias(Config::class, 'Config')
->share('Config', [$this, 'getConfig'], true);
$container->alias(Table::class, 'Table')
->share('Table', [$this, 'getTable'], true);
$container->alias(Grep::class, 'Power.Grep')
->share('Power.Grep', [$this, 'getGrep'], true);
$container->alias(Get::class, 'Power.Remote.Get')
->share('Power.Remote.Get', [$this,
'getRemoteGet'], true);
$container->alias(Set::class, 'Power.Remote.Set')
->share('Power.Remote.Set', [$this,
'getRemoteSet'], true);
$container->alias(Parser::class, 'Power.Parser')
->share('Power.Parser', [$this, 'getParser'],
true);
$container->alias(Plantuml::class, 'Power.Plantuml')
->share('Power.Plantuml', [$this, 'getPlantuml'],
true);
$container->alias(ItemReadme::class, 'Power.Readme.Item')
->share('Power.Readme.Item', [$this,
'getItemReadme'], true);
$container->alias(MainReadme::class, 'Power.Readme.Main')
->share('Power.Readme.Main', [$this,
'getMainReadme'], true);
}
/**
* Get The Config Class.
*
* @param Container $container The DI container.
*
* @return Config
* @since 3.2.0
*/
public function getConfig(Container $container): Config
{
return new Config();
}
/**
* Get The Table Class.
*
* @param Container $container The DI container.
*
* @return Table
* @since 3.2.0
*/
public function getTable(Container $container): Table
{
return new Table();
}
/**
* Get The Grep Class.
*
* @param Container $container The DI container.
*
* @return Grep
* @since 3.2.0
*/
public function getGrep(Container $container): Grep
{
return new Grep(
$container->get('Gitea.Repository.Contents'),
$container->get('Config')->approved_paths,
$container->get('Config')->local_powers_repository_path
);
}
/**
* Get The Remote Get Class.
*
* @param Container $container The DI container.
*
* @return Get
* @since 3.2.0
*/
public function getRemoteGet(Container $container): Get
{
return new Get(
$container->get('Power.Grep'),
$container->get('Data.Item')
);
}
/**
* Get The Remote Set Class.
*
* @param Container $container The DI container.
*
* @return Set
* @since 5.0.3
*/
public function getRemoteSet(Container $container): Set
{
return new Set(
$container->get('Config')->approved_paths,
$container->get('Power.Grep'),
$container->get('Data.Items'),
$container->get('Power.Readme.Item'),
$container->get('Power.Readme.Main'),
$container->get('Gitea.Repository.Contents'), null, null,
null,
$container->get('Power.Parser')
);
}
/**
* Get The Readme Class.
*
* @param Container $container The DI container.
*
* @return ItemReadme
* @since 5.0.3
*/
public function getItemReadme(Container $container): ItemReadme
{
return new ItemReadme(
$container->get('Power.Plantuml')
);
}
/**
* Get The Readme Class.
*
* @param Container $container The DI container.
*
* @return MainReadme
* @since 5.0.3
*/
public function getMainReadme(Container $container): MainReadme
{
return new MainReadme();
}
/**
* Get The Parser Class.
*
* @param Container $container The DI container.
*
* @return Parser
* @since 3.2.0
*/
public function getParser(Container $container): Parser
{
return new Parser();
}
/**
* Get The Plantuml Class.
*
* @param Container $container The DI container.
*
* @return Plantuml
* @since 5.0.3
*/
public function getPlantuml(Container $container): Plantuml
{
return new Plantuml();
}
}
src/Componentbuilder/Power/Service/index.html000064400000000054151162054240015334
0ustar00<html><body
bgcolor="#FFFFFF"></body></html>src/Componentbuilder/Power/index.html000064400000000054151162054240013734
0ustar00<html><body
bgcolor="#FFFFFF"></body></html>src/Componentbuilder/Search/Abstraction/Engine.php000064400000004350151162054240016242
0ustar00<?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\Search\Abstraction;
use VDM\Joomla\Componentbuilder\Search\Factory;
use VDM\Joomla\Componentbuilder\Search\Config;
/**
* Search Engine
*
* @since 3.2.0
*/
abstract class Engine
{
/**
* Search Config
*
* @var Config
* @since 3.2.0
*/
protected Config $config;
/**
* Search Value
*
* @var string|null
* @since 3.2.0
*/
protected ?string $searchValue;
/**
* Replace Value
*
* @var string
* @since 3.2.0
*/
protected string $replaceValue;
/**
* Search Should Match Case
*
* @var int
* @since 3.2.0
*/
protected int $matchCase = 0;
/**
* Search Should Match Whole Word
*
* @var int
* @since 3.2.0
*/
protected int $wholeWord = 0;
/**
* Start marker
*
* @var string
* @since 3.2.0
*/
protected string $start = '';
/**
* End marker
*
* @var string
* @since 3.2.0
*/
protected string $end = '';
/**
* Constructor
*
* @param Config|null $config The search config object.
*
* @since 3.2.0
*/
public function __construct(?Config $config = null)
{
$this->config = $config ?: Factory::_('Config');
// set search value
$this->searchValue = $this->config->search_value;
// set replace value
$this->replaceValue = $this->config->replace_value;
// set match case
$this->matchCase = $this->config->match_case;
// set whole word
$this->wholeWord = $this->config->whole_word;
// set start marker
$this->start = $this->config->marker_start;
// set end marker
$this->end = $this->config->marker_end;
}
/**
* we count every line being searched
*
* @since 3.2.0
*/
protected function lineCounter()
{
// we count every line we search
$this->config->line_counter += 1;
}
}
src/Componentbuilder/Search/Abstraction/index.html000064400000000054151162054240016316
0ustar00<html><body
bgcolor="#FFFFFF"></body></html>src/Componentbuilder/Search/Agent.php000064400000024375151162054240013633
0ustar00<?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\Search;
use Joomla\CMS\Language\Text;
use VDM\Joomla\Componentbuilder\Search\Factory;
use VDM\Joomla\Componentbuilder\Search\Config;
use VDM\Joomla\Componentbuilder\Search\Database\Load;
use VDM\Joomla\Componentbuilder\Search\Database\Insert;
use VDM\Joomla\Componentbuilder\Search\Agent\Find;
use VDM\Joomla\Componentbuilder\Search\Agent\Replace;
use VDM\Joomla\Componentbuilder\Search\Agent\Search;
use VDM\Joomla\Componentbuilder\Search\Agent\Update;
use VDM\Joomla\Componentbuilder\Table;
/**
* Search Agent
*
* @since 3.2.0
*/
class Agent
{
/**
* Search Config
*
* @var Config
* @since 3.2.0
*/
protected Config $config;
/**
* Search Load Database
*
* @var Load
* @since 3.2.0
*/
protected Load $load;
/**
* Search Insert Database
*
* @var Insert
* @since 3.2.0
*/
protected Insert $insert;
/**
* Search Find
*
* @var Find
* @since 3.2.0
*/
protected Find $find;
/**
* Search Replace
*
* @var Replace
* @since 3.2.0
*/
protected Replace $replace;
/**
* Search
*
* @var Search
* @since 3.2.0
*/
protected Search $search;
/**
* Update
*
* @var Update
* @since 3.2.0
*/
protected Update $update;
/**
* Table
*
* @var Table
* @since 3.2.0
*/
protected Table $table;
/**
* Return value to search view
*
* @var string
* @since 3.2.0
*/
protected string $return;
/**
* Marker start and end values
*
* @var array
* @since 3.2.0
*/
protected array $marker;
/**
* Marker start and end html values
*
* @var array
* @since 3.2.0
*/
protected array $markerHtml;
/**
* Constructor
*
* @param Config|null $config The search config object.
* @param Load|null $load The search load database
object.
* @param Insert|null $insert The search insert database
object.
* @param Find|null $find The search find object.
* @param Replace|null $replace The search replace object.
* @param Search|null $search The search object.
* @param Update|null $update The update object.
* @param Table|null $table The table object.
*
* @since 3.2.0
*/
public function __construct(?Config $config = null, ?Load $load = null,
?Insert $insert = null, ?Find $find = null, ?Replace $replace = null,
?Search $search = null, ?Update $update = null, ?Table $table = null)
{
$this->config = $config ?: Factory::_('Config');
$this->load = $load ?: Factory::_('Load.Database');
$this->insert = $insert ?: Factory::_('Insert.Database');
$this->find = $find ?: Factory::_('Agent.Find');
$this->replace = $replace ?: Factory::_('Agent.Replace');
$this->search = $search ?: Factory::_('Agent.Search');
$this->update = $update ?: Factory::_('Agent.Update');
$this->table = $table ?: Factory::_('Table');
}
/**
* Get the value of a field in a row and table
*
* @param int $id The item ID
* @param string $field The field key
* @param mixed $line The field line
* @param string|null $table The table
* @param bool $update The switch to triger an update (default
is false)
*
* @return string|null
* @since 3.2.0
*/
public function getValue(int $id, string $field, $line = null,
?string $table = null, bool $update = false): ?string
{
// set the table name
if (empty($table))
{
$table = $this->config->table_name;
}
if (($value = $this->load->value($id, $field, $table)) !== null)
{
// we only return strings that can load in an editor
if (is_string($value))
{
// try to update the value if required
if ($update && ($updated_value =
$this->update->value($value, $line)) !== null)
{
return $updated_value;
}
return $value;
}
return '// VALUE CAN NOT BE LOADED (AT THIS TIME) SINCE ITS NOT A
STRING';
}
return null;
}
/**
* Set the value of a field in a row and table
*
* @param mixed $value The field value
* @param int $id The item ID
* @param string $field The field key
* @param string|null $table The table
*
* @return bool
* @since 3.2.0
*/
public function setValue($value, int $id, string $field, ?string $table =
null): bool
{
// set the table name
if (empty($table))
{
$table = $this->config->table_name;
}
return $this->insert->value($value, $id, $field, $table);
}
/**
* Return Table Ready Search Results
*
* @param string|null $table The table being searched
*
* @return array|null
* @since 3.2.0
*/
public function table(?string $table = null): ?array
{
// set the table name
if (empty($table))
{
$table = $this->config->table_name;
}
if(($values = $this->find($table)) !== null)
{
// build return value
$this->setReturnValue();
// set the markers
$this->setMarkers();
// start table bucket
$table_rows = [];
foreach ($values as $id => $fields)
{
foreach ($fields as $field => $lines)
{
foreach ($lines as $line => $code)
{
$table_rows[] = $this->getRow($code, $table, $field, $id, $line);
}
}
}
return $table_rows;
}
return null;
}
/**
* Search the posted table for the search value and return all
*
* @param string|null $table The table being searched
*
* @return array|null
* @since 3.2.0
*/
public function find(?string $table = null): ?array
{
// set the table name
if (empty($table))
{
$table = $this->config->table_name;
}
$set = 1;
// continue loading items until all are searched
while(($items = $this->load->items($table, $set)) !== null)
{
$this->find->items($items, $table);
$set++;
}
return $this->search->get($table);
}
/**
* Search the posted table for the search value, and replace all
*
* @param string|null $table The table being searched
*
* @return int
* @since 3.2.0
*/
public function replace(?string $table = null): int
{
// set the table name
if (empty($table))
{
$table = $this->config->table_name;
}
$set = 1;
$replaced = 0;
// continue loading items until all was loaded
while(($items = $this->load->items($table, $set)) !== null)
{
// search for items
$this->find->items($items, $table);
// update those found
$this->replace->items($this->find->get($table), $table);
// update the database
if ($this->insert->items($this->replace->get($table),
$table))
{
$replaced++;
}
// reset found items
$this->find->reset($table);
$this->replace->reset($table);
$set++;
}
// we return the number of times we replaced
return $replaced;
}
/**
* Return prepared code string for table
*
* @param string $code The code value fro the table
* @param string|null $table The table
* @param string $field The field key
* @param int $id The the row id
* @param mixed $line The code line where found
*
* @return array
* @since 3.2.0
*/
protected function getRow(string $code, string $table, string $field, int
$id, $line): array
{
return [
'edit' => $this->getRowEditButton($table, $field, $id,
$line),
'code' => $this->getRowCode($code),
'table' => $table,
'field' => $field,
'id' => $id,
'line' => $line
];
}
/**
* Return prepared code string for table
*
* @param string $code The code value fro the table
*
* @return string
* @since 3.2.0
*/
protected function getRowCode(string $code): string
{
return str_replace($this->marker, $this->markerHtml,
htmlentities($code));
}
/**
* Get the Item button to edit an item
*
* @param string|null $view The single view
* @param string $field The field key
* @param int $id The the row id
* @param mixed $line The code line where found
*
* @return string
* @since 3.2.0
*/
protected function getRowEditButton(string $view, string $field, int $id,
$line): string
{
// get list view
$views = $this->table->get($view, $field, 'list');
$tab = $this->table->get($view, $field, 'tab_name');
// return edit link
return '<a class="hasTooltip btn btn-mini"
href="index.php?option=com_componentbuilder' .
'&view=' . $views .
'&task=' . $view . '.edit' .
'&id=' . $id .
'&open_tab=' . $tab .
'&open_field=' . $field .
'&return=' . $this->return . '"
title="' .
Text::sprintf('COM_COMPONENTBUILDER_EDIT_S_S_DIRECTLY', $view,
$field) . '." ><span
class="icon-edit"></span></a>';
}
/**
* Set the return value for this search
*
* @return void
* @since 3.2.0
*/
protected function setReturnValue()
{
// set the return value so the search auto load on return
$this->return =
urlencode(base64_encode('index.php?option=com_componentbuilder&view=search'
.
'&type_search=' . (int) $this->config->type_search
.
'&match_case=' . (int) $this->config->match_case .
'&whole_word=' . (int) $this->config->whole_word .
'®ex_search=' . (int) $this->config->regex_search
.
'&search_value=' . (string) urlencode((string)
$this->config->search_value) .
'&replace_value=' . (string) urlencode((string)
$this->config->replace_value)));
}
/**
* Set the markers of the found code
*
* @return void
* @since 3.2.0
*/
protected function setMarkers()
{
// set the markers
$this->marker = [$this->config->marker_start,
$this->config->marker_end];
$this->markerHtml = ['<span
class="found_code">','</span>'];
}
}
src/Componentbuilder/Search/Agent/Find.php000064400000007345151162054240014511
0ustar00<?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\Search\Agent;
use VDM\Joomla\Utilities\ArrayHelper;
use VDM\Joomla\Utilities\ObjectHelper;
use VDM\Joomla\Componentbuilder\Search\Factory;
use VDM\Joomla\Componentbuilder\Search\Config;
use VDM\Joomla\Componentbuilder\Search\Agent\Search;
use VDM\Joomla\Componentbuilder\Search\Interfaces\FindInterface;
/**
* Search Agent Find
*
* @since 3.2.0
*/
class Find implements FindInterface
{
/**
* Found Values
*
* @var array
* @since 3.2.0
*/
protected array $found = [];
/**
* Search Config
*
* @var Config
* @since 3.2.0
*/
protected Config $config;
/**
* Search
*
* @var Search
* @since 3.2.0
*/
protected Search $search;
/**
* Constructor
*
* @param Config|null $config The search config object.
* @param Search|null $search The search object.
*
* @since 3.2.0
*/
public function __construct(?Config $config = null, ?Search $search =
null)
{
$this->config = $config ?: Factory::_('Config');
$this->search = $search ?: Factory::_('Agent.Search');
}
/**
* Get found values
*
* @param string|null $table The table being searched
*
* @return array|null
* @since 3.2.0
*/
public function get(?string $table = null): ?array
{
// set the table name
if (empty($table))
{
$table = $this->config->table_name;
}
if (isset($this->found[$table]))
{
return $this->found[$table];
}
return null;
}
/**
* Search over an item fields
*
* @param object $item The item object of fields to search
through
* @param int|null $id The item id
* @param string|null $table The table being searched
*
* @return void
* @since 3.2.0
*/
public function item(object $item, ?int $id =null, ?string $table = null)
{
// set the table name
if (empty($table))
{
$table = $this->config->table_name;
}
// set the item id
if (empty($id))
{
$id = $item->id;
}
if (ObjectHelper::check($item))
{
foreach ($item as $field => $value)
{
if ($field !== 'id' &&
$this->search->value($value, $id, $field, $table))
{
if (empty($this->found[$table][$id]))
{
$this->found[$table][$id] = new \stdClass();
$this->found[$table][$id]->id = $id;
}
$this->found[$table][$id]->{$field} = $value;
}
}
}
}
/**
* Search over an array of items
*
* @param array|null $items The array of items to search through
* @param string|null $table The table being searched
*
* @return void
* @since 3.2.0
*/
public function items(?array $items = null, ?string $table = null)
{
// set the table name
if (empty($table))
{
$table = $this->config->table_name;
}
if (ArrayHelper::check($items))
{
foreach ($items as $id => $item)
{
$this->item($item, $id, $table);
}
}
}
/**
* Reset all found values of a table
*
* @param string|null $table The table being searched
*
* @return void
* @since 3.2.0
*/
public function reset(?string $table = null)
{
// set the table name
if (empty($table))
{
$table = $this->config->table_name;
}
// empty or unset the table active values
unset($this->found[$table]);
}
}
src/Componentbuilder/Search/Agent/Replace.php000064400000007435151162054240015204
0ustar00<?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\Search\Agent;
use VDM\Joomla\Utilities\ArrayHelper;
use VDM\Joomla\Utilities\ObjectHelper;
use VDM\Joomla\Componentbuilder\Search\Factory;
use VDM\Joomla\Componentbuilder\Search\Config;
use VDM\Joomla\Componentbuilder\Search\Agent\Update;
use VDM\Joomla\Componentbuilder\Search\Interfaces\ReplaceInterface;
/**
* Search Agent Replace
*
* @since 3.2.0
*/
class Replace implements ReplaceInterface
{
/**
* Updated Values
*
* @var array
* @since 3.2.0
*/
protected array $updated = [];
/**
* Search Config
*
* @var Config
* @since 3.2.0
*/
protected Config $config;
/**
* Update
*
* @var Update
* @since 3.2.0
*/
protected Update $update;
/**
* Constructor
*
* @param Config|null $config The search config object.
* @param Update|null $update The update object.
*
* @since 3.2.0
*/
public function __construct(?Config $config = null, ?Update $update =
null)
{
$this->config = $config ?: Factory::_('Config');
$this->update = $update ?: Factory::_('Agent.Update');
}
/**
* Get updated values
*
* @param string|null $table The table being searched
*
* @return array|null
* @since 3.2.0
*/
public function get(?string $table = null): ?array
{
// set the table name
if (empty($table))
{
$table = $this->config->table_name;
}
if (isset($this->updated[$table]))
{
return $this->updated[$table];
}
return null;
}
/**
* Search over an item fields
*
* @param object $item The item object of fields to search
through
* @param int|null $id The item id
* @param string|null $table The table being searched
*
* @return void
* @since 3.2.0
*/
public function item(object $item, ?int $id =null, ?string $table = null)
{
// set the table name
if (empty($table))
{
$table = $this->config->table_name;
}
// set the item id
if (empty($id))
{
$id = $item->id;
}
if (ObjectHelper::check($item))
{
foreach ($item as $field => $value)
{
if ($field !== 'id' && ($_value =
$this->update->value($value)) !== null)
{
if (empty($this->updated[$table][$id]))
{
$this->updated[$table][$id] = new \stdClass();
$this->updated[$table][$id]->id = $id;
}
// add updated value
$this->updated[$table][$id]->{$field} = $_value;
}
}
}
}
/**
* Search over an array of items
*
* @param array|null $items The array of items to search through
* @param string|null $table The table being searched
*
* @return void
* @since 3.2.0
*/
public function items(?array $items = null, ?string $table = null)
{
// set the table name
if (empty($table))
{
$table = $this->config->table_name;
}
if (ArrayHelper::check($items))
{
foreach ($items as $id => $item)
{
$this->item($item, $id, $table);
}
}
}
/**
* Reset all updated values of a table
*
* @param string|null $table The table being searched
*
* @return void
* @since 3.2.0
*/
public function reset(?string $table = null)
{
// set the table name
if (empty($table))
{
$table = $this->config->table_name;
}
// empty or unset the table active values
unset($this->updated[$table]);
}
}
src/Componentbuilder/Search/Agent/Search.php000064400000015214151162054240015030
0ustar00<?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\Search\Agent;
use VDM\Joomla\Utilities\ArrayHelper;
use VDM\Joomla\Utilities\StringHelper;
use VDM\Joomla\Componentbuilder\Search\Factory;
use VDM\Joomla\Componentbuilder\Search\Config;
use VDM\Joomla\Componentbuilder\Search\Interfaces\SearchTypeInterface as
SearchEngine;
use VDM\Joomla\Componentbuilder\Search\Interfaces\SearchInterface;
/**
* Search Agent Search
*
* @since 3.2.0
*/
class Search implements SearchInterface
{
/**
* Search results found
*
* @var array
* @since 3.2.0
*/
protected array $found = [];
/**
* Search Config
*
* @var Config
* @since 3.2.0
*/
protected Config $config;
/**
* Search Engine
*
* @var SearchEngine
* @since 3.2.0
*/
protected SearchEngine $search;
/**
* Constructor
*
* @param Config|null $config The search config
object.
* @param SearchEngine|null $search The search engine object.
*
* @since 3.2.0
*/
public function __construct(?Config $config = null, ?SearchEngine $search
= null)
{
$this->config = $config ?: Factory::_('Config');
$this->search = $search ?: Factory::_('Search');
}
/**
* Get found values
*
* @param string $table The table being searched
*
* @return array|null
* @since 3.2.0
*/
public function get(string $table): ?array
{
if (isset($this->found[$table]))
{
return $this->found[$table];
}
return null;
}
/**
* Search inside a value
*
* @param mixed $value The field value
* @param int $id The item ID
* @param string $field The field key
* @param string $table The table
*
* @return bool
* @since 3.2.0
*/
public function value($value, int $id, string $field, string $table):
bool
{
// search the mixed value
$found = $this->searchValue($value);
// check if we found any match
if (ArrayHelper::check($found))
{
foreach ($found as $line => $line_value)
{
// may not be needed... but being old school
$this->prep($id, $field, $table);
// load the detail into our multidimensional array... lol
// Table->Item_id->Field_name->Line_number = marked_full_line
// Search Example: soon...
// Marked Line Example: Soon....
$this->found[$table][$id][$field][$line] = $line_value;
}
return true;
}
return false;
}
/**
* Empty the found values
*
* @param string $table The table being searched
*
* @return void
* @since 3.2.0
*/
public function reset(string $table)
{
unset($this->found[$table]);
}
/**
* Search inside a string
*
* @param mixed $value The field value
*
* @return array|null
* @since 3.2.0
*/
protected function searchValue($value): ?array
{
// check if this is an array
$found = null;
// I know this is a little crazy... TODO refactor into recursion
functions
// the possibility of searching sub-forms in sub-forms
if (ArrayHelper::check($value))
{
// first layer
foreach ($value as $keys => $rows)
{
if (ArrayHelper::check($rows))
{
// second layer
foreach ($rows as $key => $row)
{
if (ArrayHelper::check($row))
{
// third layer
foreach ($row as $ke => $ro)
{
if (ArrayHelper::check($ro))
{
// forth layer
foreach ($ro as $k => $r)
{
if (StringHelper::check($r) && ($_found =
$this->string($r)) !== null)
{
foreach ($_found as $_n => $_f)
{
$found[$keys . '.' . $key . '.' . $ke .
'.' . $k . '.' . $_n] = $_f;
}
}
}
}
elseif (StringHelper::check($ro) && ($_found =
$this->string($ro)) !== null)
{
foreach ($_found as $_n => $_f)
{
$found[$keys. '.' . $key . '.' . $ke .
'.' . $_n] = $_f;
}
}
}
}
elseif (StringHelper::check($row) && ($_found =
$this->string($row)) !== null)
{
foreach ($_found as $_n => $_f)
{
$found[$keys. '.' . $key . '.' . $_n] = $_f;
}
}
}
}
elseif (StringHelper::check($rows) && ($_found =
$this->string($rows)) !== null)
{
foreach ($_found as $_n => $_f)
{
$found[$keys. '.' . $_n] = $_f;
}
}
}
}
elseif (StringHelper::check($value))
{
$found = $this->string($value);
}
return $found;
}
/**
* Search inside a string
*
* @param string $value The field value
*
* @return array|null
* @since 3.2.0
*/
protected function string(string $value): ?array
{
// line counter
$line = 1;
// we count every field we search
$this->fieldCounter();
// check if string has a new line
if (\preg_match('/\R/', $value))
{
$search_array = \preg_split('/\R/', $value);
// start search bucket
$found = [];
// loop over the lines
foreach ($search_array as $line_value)
{
if (($_found = $this->search->string($line_value)) !== null)
{
$found[$line] = $_found;
}
// next line
$line++;
}
if (ArrayHelper::check($found))
{
return $found;
}
}
elseif (($found = $this->search->string($value)) !== null)
{
return [$line => $found];
}
return null;
}
/**
* Prep the bucket
*
* @param int $id The item ID
* @param string $field The field key
* @param string $table The table
*
* @return void
* @since 3.2.0
*/
protected function prep(int $id, string $field, string $table)
{
if (empty($this->found[$table]))
{
$this->found[$table] = [];
}
if (empty($this->found[$table][$id]))
{
$this->found[$table][$id] = [];
}
if (empty($this->found[$table][$id][$field]))
{
$this->found[$table][$id][$field] = [];
}
// we should add a call to get the item name if the table has a name
field TODO
}
/**
* we count every field being searched
*
* @since 3.2.0
*/
protected function fieldCounter()
{
// we count every field we search
$this->config->field_counter += 1;
}
}
src/Componentbuilder/Search/Agent/Update.php000064400000013005151162054240015041
0ustar00<?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\Search\Agent;
use VDM\Joomla\Utilities\ArrayHelper;
use VDM\Joomla\Utilities\StringHelper;
use VDM\Joomla\Componentbuilder\Search\Factory;
use VDM\Joomla\Componentbuilder\Search\Interfaces\SearchTypeInterface as
SearchEngine;
/**
* Search Agent Update
*
* @since 3.2.0
*/
class Update
{
/**
* Search Engine
*
* @var SearchEngine
* @since 3.2.0
*/
protected SearchEngine $search;
/**
* Constructor
*
* @param SearchEngine|null $search The search engine object.
*
* @since 3.2.0
*/
public function __construct(?SearchEngine $search = null)
{
$this->search = $search ?: Factory::_('Search');
}
/**
* Update the value
*
* @param mixed $value The field value
* @param mixed $line The line to update (0 = all)
*
* @return mixed
* @since 3.2.0
*/
public function value($value, $line = 0)
{
// update the value
$update = $this->updateValue($value, $line);
// was anything updated
if ($value === $update)
{
return null;
}
return $update;
}
/**
* Update all search-replace instances inside a value
*
* @param mixed $value The field value
* @param mixed $line The line to update (0 = all)
*
* @return mixed
* @since 3.2.0
*/
protected function updateValue($value, $line = 0)
{
// I know this is a little crazy... TODO refactor into recursion
functions
// the possibility of updating sub-forms in sub-forms
if (ArrayHelper::check($value))
{
if (strpos((string) $line, '.') !== false)
{
$line = explode('.', (string) $line);
}
// first layer
foreach ($value as $keys => &$rows)
{
if (ArrayHelper::check($rows))
{
// second layer
foreach ($rows as $key => &$row)
{
if (ArrayHelper::check($row))
{
// third layer
foreach ($row as $ke => &$ro)
{
if (ArrayHelper::check($ro))
{
// forth layer
foreach ($ro as $k => &$r)
{
if (StringHelper::check($r) &&
$this->validateUpdateKey($line, $keys, $key, $ke, $k))
{
$_line = (isset($line[4])) ? $line[4] : 0;
$r = $this->string($r, $_line);
}
}
}
elseif (StringHelper::check($ro) &&
$this->validateUpdateKey($line, $keys, $key, $ke))
{
$_line = (isset($line[3])) ? $line[3] : 0;
$ro = $this->string($ro, $_line);
}
}
}
elseif (StringHelper::check($row) &&
$this->validateUpdateKey($line, $keys, $key))
{
$_line = (isset($line[2])) ? $line[2] : 0;
$row = $this->string($row, $_line);
}
}
}
elseif (StringHelper::check($rows) &&
$this->validateUpdateKey($line, $keys))
{
$_line = (isset($line[1])) ? $line[1] : 0;
$rows = $this->string($rows, $_line);
}
}
}
elseif (StringHelper::check($value))
{
$value = $this->string($value, $line);
}
return $value;
}
/**
* Check if the keys are valid for search when working with arrays
*
* @param int $line The lines array
* @param mixed $keys The line keys
* @param mixed $key The line key
* @param mixed $k The line ke
* @param mixed $k The line k
*
* @return bool
* @since 3.2.0
*/
protected function validateUpdateKey($line, $keys = null, $key = null, $ke
= null, $k = null): bool
{
if (ArrayHelper::check($line))
{
$_keys = (isset($line[0])) ? $line[0] : null;
$_key = (isset($line[1])) ? $line[1] : null;
$_ke = (isset($line[2])) ? $line[2] : null;
$_k = (isset($line[3])) ? $line[3] : null;
if ($keys && $_keys && $_keys !== $keys)
{
return false;
}
if ($key && $_key && $_key !== $key)
{
return false;
}
if ($ke && $_ke && $_ke !== $ke)
{
return false;
}
if ($k && $_k && $_k !== $k)
{
return false;
}
}
return true;
}
/**
* Update all search-replace instances inside a string
*
* @param string $value The field value
* @param int $line The line to update (0 = all)
*
* @return string
* @since 3.2.0
*/
protected function string(string $value, int $line = 0): string
{
// check if string has a new line
if (\preg_match('/\R/', $value) && $line > 0)
{
// line counter
$line_number = 1;
$search_array = \preg_split('/\R/', $value);
// loop over the lines
foreach ($search_array as $nr => $line_value)
{
if ($line_number == $line)
{
$search_array[$nr] = $this->search->replace($line_value);
// since we are targeting on line (and possibly one number)
// this can only happen once, and so we return at this point
return implode(PHP_EOL, $search_array);
}
// next line
$line_number++;
}
// no update took place so we just return the original value
return $value;
}
return $this->search->replace($value);
}
}
src/Componentbuilder/Search/Agent/index.html000064400000000054151162054240015103
0ustar00<html><body
bgcolor="#FFFFFF"></body></html>src/Componentbuilder/Search/Config.php000064400000007503151162054240013774
0ustar00<?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\Search;
use Joomla\CMS\Factory;
use Joomla\Input\Input;
use VDM\Joomla\Abstraction\BaseConfig;
/**
* Search Configurations
*
* @since 3.2.0
*/
class Config extends BaseConfig
{
/**
* Hold a JInput object for easier access to the input variables.
*
* @var Input
* @since 3.2.0
*/
protected Input $input;
/**
* Constructor
*
* @param Input|null $input Input
*
* @throws \Exception
* @since 3.2.0
*/
public function __construct(?Input $input = null)
{
$this->input = $input ?: Factory::getApplication()->input;
// run parent constructor
parent::__construct();
}
/**
* get type search being preformed
*
* @return int the search type 1 = search, 2 = search & replace
* @since 3.2.0
*/
protected function getTypesearch(): ?int
{
return $this->input->get('type_search', 1,
'INT');
}
/**
* get posted search value
*
* @return string|null Raw search value
* @since 3.2.0
*/
protected function getSearchvalue(): ?string
{
return $this->input->get('search_value', null,
'RAW');
}
/**
* get posted replace value
*
* @return string Raw replace value
* @since 3.2.0
*/
protected function getReplacevalue(): string
{
return $this->input->get('replace_value', '',
'RAW');
}
/**
* get posted search match case
*
* @return int Match case
* @since 3.2.0
*/
protected function getMatchcase(): int
{
return $this->input->get('match_case', 0,
'INT');
}
/**
* get posted search whole word
*
* @return int Whole word
* @since 3.2.0
*/
protected function getWholeword(): int
{
return $this->input->get('whole_word', 0,
'INT');
}
/**
* get posted search regex
*
* @return int Regex
* @since 3.2.0
*/
protected function getRegexsearch(): int
{
return $this->input->get('regex_search', 0,
'INT');
}
/**
* get posted component
*
* @return int Component ID
* @since 3.2.0
*/
protected function getComponentid(): int
{
return $this->input->get('component_id', 0,
'INT');
}
/**
* get posted area/table
*
* @return string|null Table name
* @since 3.2.0
*/
protected function getTablename(): ?string
{
return $this->input->get('table_name', null,
'word');
}
/**
* get posted field
*
* @return string|null Field name
* @since 3.2.0
*/
protected function getFieldname(): ?string
{
return $this->input->get('field_name', null,
'word');
}
/**
* get posted item id
*
* @return int Item id
* @since 3.2.0
*/
protected function getItemid(): int
{
return $this->input->get('item_id', 0, 'INT');
}
/**
* get field counter
*
* @return int we start at 0
* @since 3.2.0
*/
protected function getFieldcounter(): int
{
return 0;
}
/**
* get line counter
*
* @return int we start at 0
* @since 3.2.0
*/
protected function getLinecounter(): int
{
return 0;
}
/**
* get the start marker
*
* @return string The string to use as the start marker
* @since 3.2.0
*/
protected function getMarkerstart(): string
{
return '{+' . '|' . '=[';
}
/**
* get the end marker
*
* @return string The string to use as the end marker
* @since 3.2.0
*/
protected function getMarkerend(): string
{
return ']=' . '|' . '+}';
}
}
src/Componentbuilder/Search/Database/Insert.php000064400000010640151162054240015533
0ustar00<?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\Search\Database;
use Joomla\CMS\Factory as JoomlaFactory;
use VDM\Joomla\Componentbuilder\Search\Factory;
use VDM\Joomla\Componentbuilder\Search\Config;
use VDM\Joomla\Componentbuilder\Table;
use VDM\Joomla\Componentbuilder\Search\Model\Insert as Model;
use VDM\Joomla\Utilities\ArrayHelper;
use VDM\Joomla\Componentbuilder\Search\Interfaces\InsertInterface;
/**
* Search Database Set
*
* @since 3.2.0
*/
class Insert implements InsertInterface
{
/**
* Search Config
*
* @var Config
* @since 3.2.0
*/
protected Config $config;
/**
* Search Table
*
* @var Table
* @since 3.2.0
*/
protected Table $table;
/**
* Search Model
*
* @var Model
* @since 3.2.0
*/
protected Model $model;
/**
* Database object to query local DB
*
* @since 3.2.0
**/
protected $db;
/**
* Constructor
*
* @param Config|null $config The search config object.
* @param Table|null $table The search table object.
* @param Model|null $model The search get model
object.
*
* @since 3.2.0
*/
public function __construct(?Config $config = null, ?Table $table = null,
?Model $model = null)
{
$this->config = $config ?: Factory::_('Config');
$this->table = $table ?: Factory::_('Table');
$this->model = $model ?: Factory::_('Insert.Model');
$this->db = JoomlaFactory::getDbo();
}
/**
* Set values to a given table
* Example: $this->value(Value, 23, 'value_key',
'table_name');
*
* @param mixed $value The field value
* @param int $id The item ID
* @param string $field The field key
* @param string|null $table The table
*
* @return bool
* @since 3.2.0
*/
public function value($value, int $id, string $field, ?string $table =
null): bool
{
// load the table
if (empty($table))
{
$table = $this->config->table_name;
}
// check if this is a valid field and table
if ($id > 0 && ($name = $this->table->get($table,
$field, 'name')) !== null)
{
// build the object
$item = new \stdClass();
$item->id = $id;
$item->{$name} = $this->model->value($value, $name, $table);
// Update the column of this table using id as the primary key.
return $this->db->updateObject('#__componentbuilder_' .
$table, $item, 'id');
}
return false;
}
/**
* Set values to a given table
* Example: $this->item(Object, 'table_name');
*
* @param object $item The item to save
* @param string|null $table The table
*
* @return bool
* @since 3.2.0
*/
public function item(object $item, ?string $table = null): bool
{
// load the table
if (empty($table))
{
$table = $this->config->table_name;
}
// check if this is a valid table
if (($fields = $this->table->fields($table)) !== null)
{
// model the item values
foreach ($fields as $field)
{
if (isset($item->{$field}))
{
$item->{$field} = $this->model->value($item->{$field},
$field, $table);
}
}
// Update the column of this table using id as the primary key.
return $this->db->updateObject('#__componentbuilder_' .
$table, $item, 'id');
}
return false;
}
/**
* Set values to a given table
* Example: $this->items(Array, 'table_name');
*
* @param array|null $items The items being saved
* @param string|null $table The table
*
* @return bool
* @since 3.2.0
*/
public function items(?array $items, string $table = null): bool
{
// load the table
if (empty($table))
{
$table = $this->config->table_name;
}
// check if this is a valid table
if (ArrayHelper::check($items))
{
$success = true;
foreach ($items as $item)
{
if (!$this->item($item, $table))
{
$success = false;
break;
}
}
return $success;
}
return false;
}
}
src/Componentbuilder/Search/Database/Load.php000064400000015223151162054240015150
0ustar00<?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\Search\Database;
use Joomla\CMS\Factory as JoomlaFactory;
use VDM\Joomla\Componentbuilder\Search\Factory;
use VDM\Joomla\Componentbuilder\Search\Config;
use VDM\Joomla\Componentbuilder\Table;
use VDM\Joomla\Componentbuilder\Search\Model\Load as Model;
use VDM\Joomla\Database\Load as Database;
use VDM\Joomla\Componentbuilder\Search\Interfaces\LoadInterface;
/**
* Search Database Load
*
* @since 3.2.0
*/
class Load implements LoadInterface
{
/**
* Bundle Size
*
* @var int
* @since 3.2.0
*/
protected int $bundle = 300;
/**
* Search Config
*
* @var Config
* @since 3.2.0
*/
protected Config $config;
/**
* Search Table
*
* @var Table
* @since 3.2.0
*/
protected Table $table;
/**
* Search Model
*
* @var Model
* @since 3.2.0
*/
protected Model $model;
/**
* Database load class
*
* @var Database
* @since 3.2.0
**/
protected Database $load;
/**
* Constructor
*
* @param Config|null $config The search config object.
* @param Table|null $table The search table object.
* @param Model|null $model The search get model object.
* @param Database|null $load The database object.
*
* @since 3.2.0
*/
public function __construct(?Config $config = null, ?Table $table = null,
?Model $model = null, ?Database $load = null)
{
$this->config = $config ?: Factory::_('Config');
$this->table = $table ?: Factory::_('Table');
$this->model = $model ?: Factory::_('Load.Model');
$this->load = $load ?: Factory::_('Load');
}
/**
* Get a value from a given table
* Example: $this->value(23, 'value_key',
'table_name');
*
* @param int $id The item ID
* @param string $field The field key
* @param string|null $table The table
*
* @return mixed
* @since 3.2.0
*/
public function value(int $id, string $field, string $table = null)
{
// load the table
if (empty($table))
{
$table = $this->config->table_name;
}
// check if this is a valid table
if ($id > 0 && $this->table->exist($table, $field)
&&
($value = $this->load->value(
["a.${field}" => $field], // select
['a' => $table], // tables
['a.id' => $id] // where
)) !== null)
{
return $this->model->value(
$value, $field, $table
);
}
return null;
}
/**
* Get values from a given table
* Example: $this->item(23, 'table_name');
*
* @param int $id The item ID
* @param string| null $table The table
*
* @return object|null
* @since 3.2.0
*/
public function item(int $id, string $table = null): ?object
{
// load the table
if (empty($table))
{
$table = $this->config->table_name;
}
// check if this is a valid table
if ($id > 0 && ($fields = $this->setDatabaseFields($table))
!== null &&
($item = $this->load->item(
$fields, // select
['a' => $table], // tables
['a.id' => $id] // where
)) !== null)
{
// return found values
return $this->model->item($item, $table);
}
return null;
}
/**
* Get values from a given table
* Example: $this->items('table_name');
*
* @param string|null $table The table
* @param int $bundle The bundle to return (0 = all)
*
* @return array|null
* @since 3.2.0
*/
public function items(string $table = null, int $bundle = 0): ?array
{
// load the table
if (empty($table))
{
$table = $this->config->table_name;
}
// check if this is a valid table
if ( ($fields = $this->setDatabaseFields($table)) !== null)
{
// add a key to the selection return set
$fields['key'] = 'id';
// get the title value
$title = $this->table->titleName($table);
// set order
$order = ['a.' . $title => 'ASC'];
// select all
$where = null;
// no limit
$limit = null;
// add limitation and pagination
if ($bundle > 0)
{
// get the incremental number
$where = ['a.id' => [
'operator' => '>=',
'value' => $this->next($table, $bundle)
]
];
// only return a limited number
$limit = $this->bundle;
}
if (($items = $this->load->items(
$fields, // select
['a' => $table], // tables
$where,
$order,
$limit
)) !== null)
{
// return found values
return $this->model->items($items, $table);
}
}
return null;
}
/**
* Get next id to call
*
* @param string $table The table
* @param int $bundle The bundle to return
*
* @return int
* @since 3.2.0
*/
protected function next(string $table, int $bundle): int
{
if ($bundle == 1 || $bundle == 0)
{
return 1;
}
if (($number = $this->model->last($table)) !== null)
{
return $number + 1;
}
return $this->incremental($bundle);
}
/**
* Get Incremental number where the set starts
*
* @param int $bundle The bundle to return
*
* @return int
* @since 3.2.0
*/
protected function incremental(int $bundle): int
{
// just in case
if ($bundle == 1 || $bundle == 0)
{
return 1;
}
/** Number two set starts at 301
* 2 x 300 = 600
* 600 - 300 = 300
* 300 + 1 = 301 <--
* Number five set starts at 1201
* 5 x 300 = 1500
* 1500 - 300 = 1200
* 1200 + 1 = 1201 <--
**/
return (($bundle * $this->bundle) - $this->bundle) + 1;
}
/**
* Get Fields ready to use in database call
*
* @param string $table The table which fields we want to get
* @param string $key The table key to which the fields belong
* @param bool $addId The switch to add ID
*
* @return array|null
* @since 3.2.0
*/
protected function setDatabaseFields(string $table, string $key =
'a', bool $addId = true): ?array
{
if (($fields = $this->table->fields($table)) !== null)
{
// add the ID
if ($addId)
{
array_unshift($fields , 'id');
}
$bucket = [];
foreach ($fields as $field)
{
$bucket[$key . '.' . $field] = $field;
}
return $bucket;
}
return null;
}
}
src/Componentbuilder/Search/Database/index.html000064400000000054151162054240015551
0ustar00<html><body
bgcolor="#FFFFFF"></body></html>src/Componentbuilder/Search/Engine/Basic.php000064400000013137151162054240015015
0ustar00<?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\Search\Engine;
use VDM\Joomla\Componentbuilder\Search\Config;
use VDM\Joomla\Utilities\StringHelper;
use VDM\Joomla\Utilities\ArrayHelper;
use VDM\Joomla\Componentbuilder\Search\Interfaces\SearchTypeInterface;
use VDM\Joomla\Componentbuilder\Search\Abstraction\Engine;
/**
* Search Type String
*
* @since 3.2.0
*/
class Basic extends Engine implements SearchTypeInterface
{
/**
* Regex Search Value
*
* @var string
* @since 3.2.0
*/
protected string $regexValue = '';
/**
* Constructor
*
* @param Config|null $config The search config object.
*
* @since 3.2.0
*/
public function __construct(?Config $config = null)
{
parent::__construct($config);
// quote all regular expression characters
$searchValue = preg_quote((string) $this->searchValue,
'/');
$start = ''; $end = '';
// if this is a whole word search we need to do some prep
if ($this->wholeWord == 1)
{
// get first character of search string
$first = mb_substr((string) $this->searchValue, 0, 1);
// get last character of search string
$last = mb_substr((string) $this->searchValue, -1);
// set the start boundary behavior
$start = '(\b)';
if (\preg_match("/\W/", $first))
{
$start = '(\b|\B)';
}
// set the boundary behavior
$end = '(\b)';
if (\preg_match("/\W/", $last))
{
$end = '(\b|\B)';
}
}
// set search based on match case
$case = '';
if ($this->matchCase == 0)
{
$case = 'i';
}
$this->regexValue = "/" . $start . '(' .
$searchValue . ')' . $end . "/" . $case;
}
/**
* Search inside a string
*
* @param string $value The string value
*
* @return string|null The marked string if found, else null
* @since 3.2.0
*/
public function string(string $value): ?string
{
// we count every line
$this->lineCounter();
if (StringHelper::check($this->searchValue))
{
if ($this->wholeWord == 1)
{
return $this->searchWhole($value);
}
else
{
return $this->searchAll($value);
}
}
return null;
}
/**
* Replace found instances inside string value
*
* @param string $value The string value to update
*
* @return string The updated string
* @since 3.2.0
*/
public function replace(string $value): string
{
if (StringHelper::check($this->searchValue))
{
if ($this->wholeWord == 1)
{
return $this->replaceWhole($value);
}
else
{
return $this->replaceAll($value);
}
}
return $value;
}
/**
* Replace whole words
*
* @param string $value The string value
*
* @return string The marked string if found, else null
* @since 3.2.0
*/
protected function replaceWhole(string $value): string
{
if ($this->match($value))
{
return preg_replace(
$this->regexValue . 'm',
"$1" . $this->replaceValue . "$3",
$value
);
}
return $value;
}
/**
* Search for whole words
*
* @param string $value The string value
*
* @return string|null The marked string if found, else null
* @since 3.2.0
*/
protected function searchWhole(string $value): ?string
{
if ($this->match($value))
{
return trim(preg_replace(
$this->regexValue . 'm',
"$1" . $this->start . "$2" . $this->end .
"$3",
$value
));
}
return null;
}
/**
* Math the Regular Expression
*
* @param string $value The string value
*
* @return bool true if match is found
* @since 3.0.9
*/
public function match(string $value): bool
{
$match = [];
preg_match($this->regexValue, $value, $match);
$match = array_filter(
$match,
fn($found) => !empty($found)
);
return (bool) ArrayHelper::check($match);
}
/**
* Search for all instances
*
* @param string $value The string value
*
* @return string|null The marked string if found, else null
* @since 3.2.0
*/
protected function searchAll(string $value): ?string
{
if ($this->matchCase == 1)
{
if (strpos($value, (string) $this->searchValue) !== false)
{
return trim(preg_replace(
$this->regexValue . 'm',
$this->start . "$1" . $this->end,
$value
));
}
}
elseif (stripos($value, (string) $this->searchValue) !== false)
{
return trim(preg_replace(
$this->regexValue . 'm',
$this->start . "$1" . $this->end,
$value
));
}
return null;
}
/**
* Replace for all instances
*
* @param string $value The string value
*
* @return string The marked string if found, else null
* @since 3.2.0
*/
protected function replaceAll(string $value): string
{
if ($this->matchCase == 1)
{
if (strpos($value, (string) $this->searchValue) !== false)
{
return preg_replace(
$this->regexValue . 'm',
(string) $this->replaceValue,
$value
);
}
}
elseif (stripos($value, (string) $this->searchValue) !== false)
{
return preg_replace(
$this->regexValue . 'm',
(string) $this->replaceValue,
$value
);
}
return $value;
}
}
src/Componentbuilder/Search/Engine/Regex.php000064400000005270151162054240015045
0ustar00<?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\Search\Engine;
use VDM\Joomla\Componentbuilder\Search\Config;
use VDM\Joomla\Utilities\StringHelper;
use VDM\Joomla\Utilities\ArrayHelper;
use VDM\Joomla\Componentbuilder\Search\Interfaces\SearchTypeInterface;
use VDM\Joomla\Componentbuilder\Search\Abstraction\Engine;
/**
* Search Type Regex
*
* @since 3.2.0
*/
class Regex extends Engine implements SearchTypeInterface
{
/**
* Regex Search Value
*
* @var string
* @since 3.2.0
*/
protected string $regexValue = '';
/**
* Constructor
*
* @param Config|null $config The search config object.
*
* @since 3.2.0
*/
public function __construct(?Config $config = null)
{
parent::__construct($config);
// set search based on match case
$case = '';
if ($this->matchCase == 0)
{
$case = 'i';
}
$this->regexValue = "/(" . $this->searchValue .
")/" . $case;
}
/**
* Search inside a string
*
* @param string $value The string value
*
* @return string|null The marked string if found, else null
* @since 3.2.0
*/
public function string(string $value): ?string
{
// we count every line
$this->lineCounter();
if (StringHelper::check($this->searchValue) &&
$this->match($value))
{
return trim(preg_replace(
$this->regexValue . 'm',
$this->start . "$1" . $this->end,
$value
));
}
return null;
}
/**
* Replace found instances inside string value
*
* @param string $value The string value to update
*
* @return string The updated string
* @since 3.2.0
*/
public function replace(string $value): string
{
if (StringHelper::check($this->searchValue) &&
$this->match($value))
{
return preg_replace(
$this->regexValue . 'm',
(string) $this->replaceValue,
$value
);
}
return $value;
}
/**
* Math the Regular Expression
*
* @param string $value The string value
*
* @return bool true if match is found
* @since 3.0.9
*/
public function match(string $value): bool
{
$match = [];
preg_match($this->regexValue, $value, $match);
$match = array_filter(
$match,
fn($found) => !empty($found)
);
return (bool) ArrayHelper::check($match);
}
}
src/Componentbuilder/Search/Engine/index.html000064400000000054151162054240015252
0ustar00<html><body
bgcolor="#FFFFFF"></body></html>src/Componentbuilder/Search/Factory.php000064400000002414151162054240014172
0ustar00<?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\Search;
use Joomla\DI\Container;
use VDM\Joomla\Componentbuilder\Search\Service\Search;
use VDM\Joomla\Componentbuilder\Search\Service\Model;
use VDM\Joomla\Componentbuilder\Search\Service\Database;
use VDM\Joomla\Componentbuilder\Search\Service\Agent;
use VDM\Joomla\Interfaces\FactoryInterface;
use VDM\Joomla\Abstraction\Factory as ExtendingFactory;
/**
* Search Factory
*
* @since 3.2.0
*/
abstract class Factory extends ExtendingFactory implements FactoryInterface
{
/**
* Create a container object
*
* @return Container
* @since 3.2.0
*/
protected static function createContainer(): Container
{
return (new Container())
->registerServiceProvider(new Search())
->registerServiceProvider(new Model())
->registerServiceProvider(new Database())
->registerServiceProvider(new Agent());
}
}
src/Componentbuilder/Search/Interfaces/FindInterface.php000064400000003132151162054240017345
0ustar00<?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\Search\Interfaces;
/**
* Search Find Interface
*
* @since 3.2.0
*/
interface FindInterface
{
/**
* Get found values
*
* @param string|null $table The table being searched
*
* @return array|null
* @since 3.2.0
*/
public function get(?string $table = null): ?array;
/**
* Search over an item fields
*
* @param object $item The item object of fields to search
through
* @param int|null $id The item id
* @param string|null $table The table being searched
*
* @return void
* @since 3.2.0
*/
public function item(object $item, ?int $id =null, ?string $table =
null);
/**
* Search over an array of items
*
* @param array|null $items The array of items to search through
* @param string|null $table The table being searched
*
* @return void
* @since 3.2.0
*/
public function items(?array $items = null, ?string $table = null);
/**
* Reset all found values of a table
*
* @param string|null $table The table being searched
*
* @return void
* @since 3.2.0
*/
public function reset(?string $table = null);
}
src/Componentbuilder/Search/Interfaces/InsertInterface.php000064400000003220151162054240017727
0ustar00<?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\Search\Interfaces;
/**
* Search Database Insert Interface
*
* @since 3.2.0
*/
interface InsertInterface
{
/**
* Set values to a given table
* Example: $this->value(Value, 23, 'value_key',
'table_name');
*
* @param mixed $value The field value
* @param int $id The item ID
* @param string $field The field key
* @param string|null $table The table
*
* @return bool
* @since 3.2.0
*/
public function value($value, int $id, string $field, ?string $table =
null): bool;
/**
* Set values to a given table
* Example: $this->item(Object, 23, 'table_name');
*
* @param object $item The item to save
* @param string|null $table The table
*
* @return bool
* @since 3.2.0
*/
public function item(object $item, ?string $table = null): bool;
/**
* Set values to a given table
* Example: $this->items(Array, 'table_name');
*
* @param array $items The items being saved
* @param string|null $table The table
*
* @return bool
* @since 3.2.0
*/
public function items(array $items, string $table = null): bool;
}
src/Componentbuilder/Search/Interfaces/LoadInterface.php000064400000003122151162054240017343
0ustar00<?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\Search\Interfaces;
/**
* Search Database Load Interface
*
* @since 3.2.0
*/
interface LoadInterface
{
/**
* Get a value from a given table
* Example: $this->value(23, 'value_key',
'table_name');
*
* @param int $id The item ID
* @param string $field The field key
* @param string|null $table The table
*
* @return mixed
* @since 3.2.0
*/
public function value(int $id, string $field, string $table = null);
/**
* Get values from a given table
* Example: $this->item(23, 'table_name');
*
* @param int $id The item ID
* @param string| null $table The table
*
* @return object|null
* @since 3.2.0
*/
public function item(int $id, string $table = null): ?object;
/**
* Get values from a given table
* Example: $this->items('table_name');
*
* @param string|null $table The table
* @param int $bundle The bundle to return (0 = all)
*
* @return array|null
* @since 3.2.0
*/
public function items(string $table = null, int $bundle = 0): ?array;
}
src/Componentbuilder/Search/Interfaces/ReplaceInterface.php000064400000003141151162054240020040
0ustar00<?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\Search\Interfaces;
/**
* Search Replace Interface
*
* @since 3.2.0
*/
interface ReplaceInterface
{
/**
* Get updated values
*
* @param string|null $table The table being searched
*
* @return array|null
* @since 3.2.0
*/
public function get(?string $table = null): ?array;
/**
* Search over an item fields
*
* @param object $item The item object of fields to search
through
* @param int|null $id The item id
* @param string|null $table The table being searched
*
* @return void
* @since 3.2.0
*/
public function item(object $item, ?int $id =null, ?string $table =
null);
/**
* Search over an array of items
*
* @param array|null $items The array of items to search through
* @param string|null $table The table being searched
*
* @return void
* @since 3.2.0
*/
public function items(?array $items = null, ?string $table = null);
/**
* Reset all updated values of a table
*
* @param string|null $table The table being searched
*
* @return void
* @since 3.2.0
*/
public function reset(?string $table = null);
}
src/Componentbuilder/Search/Interfaces/SearchInterface.php000064400000002435151162054240017677
0ustar00<?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\Search\Interfaces;
/**
* Search Interface
*
* @since 3.2.0
*/
interface SearchInterface
{
/**
* Get found values
*
* @param string $table The table being searched
*
* @return array|null
* @since 3.2.0
*/
public function get(string $table): ?array;
/**
* Search inside a value
*
* @param mixed $value The field value
* @param int $id The item ID
* @param string $field The field key
* @param string $table The table
*
* @return bool
* @since 3.2.0
*/
public function value($value, int $id, string $field, string $table):
bool;
/**
* Empty the found values
*
* @param string $table The table being searched
*
* @return void
* @since 3.2.0
*/
public function reset(string $table);
}
src/Componentbuilder/Search/Interfaces/SearchTypeInterface.php000064400000002022151162054240020531
0ustar00<?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\Search\Interfaces;
/**
* Search Type Interface
*
* @since 3.2.0
*/
interface SearchTypeInterface
{
/**
* Search inside a string
*
* @param string $value The string value
*
* @return string|null The marked string if found, else null
* @since 3.2.0
*/
public function string(string $value): ?string;
/**
* Replace found instances inside string value
*
* @param string $value The string value to update
*
* @return string The updated string
* @since 3.2.0
*/
public function replace(string $value): string;
}
src/Componentbuilder/Search/Interfaces/index.html000064400000000054151162054240016130
0ustar00<html><body
bgcolor="#FFFFFF"></body></html>src/Componentbuilder/Search/Model/Insert.php000064400000006407151162054240015075
0ustar00<?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\Search\Model;
use VDM\Joomla\Componentbuilder\Search\Factory;
use VDM\Joomla\Componentbuilder\Table;
use VDM\Joomla\Componentbuilder\Search\Config;
use VDM\Joomla\Utilities\ArrayHelper;
use VDM\Joomla\Interfaces\ModelInterface;
use VDM\Joomla\Abstraction\Model;
/**
* Search Insert Model
*
* @since 3.2.0
*/
class Insert extends Model implements ModelInterface
{
/**
* Search Config
*
* @var Config
* @since 3.2.0
*/
protected Config $config;
/**
* Constructor
*
* @param Config|null $config The search config object.
* @param Table|null $table The search table object.
*
* @since 3.2.0
*/
public function __construct(?Config $config = null, ?Table $table = null)
{
parent::__construct($table ?? Factory::_('Table'));
$this->config = $config ?: Factory::_('Config');
}
/**
* Model the value
* Example: $this->value(value, 'field_key',
'table_name');
*
* @param mixed $value The value to model
* @param string $field The field key
* @param string|null $table The table
*
* @return mixed
* @since 3.2.0
*/
public function value($value, string $field, ?string $table = null)
{
// set the table name
if (empty($table))
{
$table = $this->getTable();
}
// check if this is a valid table
if (($store = $this->table->get($table, $field, 'store'))
!== null)
{
// open the value based on the store method
switch($store)
{
case 'base64':
$value = base64_encode((string) $value);
break;
case 'json':
$value = json_encode($value, JSON_FORCE_OBJECT);
break;
}
}
return $value;
}
/**
* Validate before the value is modelled (basic, override in child class)
*
* @param mixed $value The field value
* @param string|null $field The field key
* @param string|null $table The table
*
* @return bool
* @since 3.2.0
*/
protected function validateBefore(&$value, ?string $field = null,
?string $table = null): bool
{
// check values
if (StringHelper::check($value) || ArrayHelper::check($value, true))
{
return true;
}
// remove empty values
return false;
}
/**
* Validate after the value is modelled (basic, override in child class)
*
* @param mixed $value The field value
* @param string|null $field The field key
* @param string|null $table The table
*
* @return bool
* @since 3.2.0
*/
protected function validateAfter(&$value, ?string $field = null,
?string $table = null): bool
{
return true;
}
/**
* Get the current active table
*
* @return string
* @since 3.2.0
*/
protected function getTable(): string
{
return $this->config->table_name;
}
}
src/Componentbuilder/Search/Model/Load.php000064400000011705151162054240014505
0ustar00<?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\Search\Model;
use VDM\Joomla\Componentbuilder\Search\Factory;
use VDM\Joomla\Componentbuilder\Table;
use VDM\Joomla\Componentbuilder\Search\Config;
use VDM\Joomla\Utilities\ArrayHelper;
use VDM\Joomla\Utilities\JsonHelper;
use VDM\Joomla\Utilities\StringHelper;
use VDM\Joomla\Interfaces\ModelInterface;
use VDM\Joomla\Abstraction\Model;
/**
* Search Load Model
*
* @since 3.2.0
*/
class Load extends Model implements ModelInterface
{
/**
* Search Config
*
* @var Config
* @since 3.2.0
*/
protected Config $config;
/**
* Constructor
*
* @param Config|null $config The search config object.
* @param Table|null $table The search table object.
*
* @since 3.2.0
*/
public function __construct(?Config $config = null, ?Table $table = null)
{
parent::__construct($table ?? Factory::_('Table'));
$this->config = $config ?: Factory::_('Config');
}
/**
* Model the value
* Example: $this->value(value, 'value_key',
'table_name');
*
* @param mixed $value The value to model
* @param string $field The field key
* @param string|null $table The table
*
* @return mixed
* @since 3.2.0
*/
public function value($value, string $field, ?string $table = null)
{
// load the table
if (empty($table))
{
$table = $this->getTable();
}
// check if this is a valid table
if (StringHelper::check($value) && ($store =
$this->table->get($table, $field, 'store')) !== null)
{
// open the value based on the store method
switch($store)
{
case 'base64':
$value = base64_decode((string) $value);
break;
case 'json':
// check if there is a json string
if (JsonHelper::check($value))
{
$value = json_decode((string) $value, true);
}
break;
}
}
return $value;
}
/**
* Validate before the value is modelled (basic, override in child class)
*
* @param mixed $value The field value
* @param string|null $field The field key
* @param string|null $table The table
*
* @return bool
* @since 3.2.0
*/
protected function validateBefore(&$value, ?string $field = null,
?string $table = null): bool
{
return true;
}
/**
* Validate after the value is modelled (basic, override in child class)
*
* @param mixed $value The field value
* @param string|null $field The field key
* @param string|null $table The table
*
* @return bool
* @since 3.2.0
*/
protected function validateAfter(&$value, ?string $field = null,
?string $table = null): bool
{
// Start note to self
// Yes we don't search in the field->xml (field) PHP because the
xml is messy
// first of all we need to change that storage method :((( seriously
// and the actual PHP is stored in the xml as base64 with a
[__.o0=base64=Oo.__] key in front of it
// if I can go back and drag you around by your ear... I will, but
okay you did not know better.
// Listen you have tried to fix this a few times already (I lost count)
and by the time you realize how it works
// two hours have been wasted, and you usually only then realize why
it's not fixed in the first place... o boy... just walk now!
// since unless you have three days don't even look further, this
is a huge issue/mess
// and while I agree it needs fixing, it will not take a few hours...
but days
// End note to self
// check values
if (StringHelper::check($value) || ArrayHelper::check($value, true))
{
return true;
}
// remove empty values
return false;
// Start another note to self
// If you're still here
// the problem is not opening the PHP in the xml,
// it is storing it with the updated changes... if any are made via
the search-update methods
// so the only way to fix this is to change the whole way the xml
values in the field table is stored.
// Yes, that is right... all the way back to the field view... and then
to update all places you open that xml values
// and get the values out of the xml string and use them, and if
you've forgotten, that is nearly everywhere,
// and so let the refactoring of the foundation begin... there I saved
you another 3 hours.
// End another note to self
}
/**
* Get the current active table
*
* @return string
* @since 3.2.0
*/
protected function getTable(): string
{
return $this->config->table_name;
}
}
src/Componentbuilder/Search/Model/index.html000064400000000054151162054240015105
0ustar00<html><body
bgcolor="#FFFFFF"></body></html>src/Componentbuilder/Search/Service/Agent.php000064400000006531151162054240015225
0ustar00<?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\Search\Service;
use Joomla\DI\Container;
use Joomla\DI\ServiceProviderInterface;
use VDM\Joomla\Componentbuilder\Search\Agent as SearchAgent;
use VDM\Joomla\Componentbuilder\Search\Agent\Find;
use VDM\Joomla\Componentbuilder\Search\Agent\Replace;
use VDM\Joomla\Componentbuilder\Search\Agent\Search;
use VDM\Joomla\Componentbuilder\Search\Agent\Update;
/**
* Agent Service Provider
*
* @since 3.2.0
*/
class Agent implements ServiceProviderInterface
{
/**
* Registers the service provider with a DI container.
*
* @param Container $container The DI container.
*
* @return void
* @since 3.2.0
*/
public function register(Container $container)
{
$container->alias(SearchAgent::class, 'Agent')
->share('Agent', [$this, 'getAgent'], true);
$container->alias(Find::class, 'Agent.Find')
->share('Agent.Find', [$this, 'getFind'], true);
$container->alias(Replace::class, 'Agent.Replace')
->share('Agent.Replace', [$this, 'getReplace'],
true);
$container->alias(Search::class, 'Agent.Search')
->share('Agent.Search', [$this, 'getSearch'],
true);
$container->alias(Update::class, 'Agent.Update')
->share('Agent.Update', [$this, 'getUpdate'],
true);
}
/**
* Get the Search Agent
*
* @param Container $container The DI container.
*
* @return SearchAgent
* @since 3.2.0
*/
public function getAgent(Container $container): SearchAgent
{
return new SearchAgent(
$container->get('Config'),
$container->get('Load.Database'),
$container->get('Insert.Database'),
$container->get('Agent.Find'),
$container->get('Agent.Replace'),
$container->get('Agent.Search'),
$container->get('Agent.Update'),
$container->get('Table')
);
}
/**
* Get the Search Agent Find
*
* @param Container $container The DI container.
*
* @return Find
* @since 3.2.0
*/
public function getFind(Container $container): Find
{
return new Find(
$container->get('Config'),
$container->get('Agent.Search')
);
}
/**
* Get the Search Agent Replace
*
* @param Container $container The DI container.
*
* @return Replace
* @since 3.2.0
*/
public function getReplace(Container $container): Replace
{
return new Replace(
$container->get('Config'),
$container->get('Agent.Update')
);
}
/**
* Get the Search Agent Search
*
* @param Container $container The DI container.
*
* @return Search
* @since 3.2.0
*/
public function getSearch(Container $container): Search
{
return new Search(
$container->get('Config'),
$container->get('Search')
);
}
/**
* Get the Search Agent Update
*
* @param Container $container The DI container.
*
* @return Update
* @since 3.2.0
*/
public function getUpdate(Container $container): Update
{
return new Update(
$container->get('Search')
);
}
}
src/Componentbuilder/Search/Service/Database.php000064400000004521151162054240015670
0ustar00<?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\Search\Service;
use Joomla\DI\Container;
use Joomla\DI\ServiceProviderInterface;
use VDM\Joomla\Database\Load;
use VDM\Joomla\Componentbuilder\Search\Database\Load as LoadDatabase;
use VDM\Joomla\Componentbuilder\Search\Database\Insert as InsertDatabase;
/**
* Database Service Provider
*
* @since 3.2.0
*/
class Database implements ServiceProviderInterface
{
/**
* Registers the service provider with a DI container.
*
* @param Container $container The DI container.
*
* @return void
* @since 3.2.0
*/
public function register(Container $container)
{
$container->alias(Load::class, 'Load')
->share('Load', [$this, 'getLoad'], true);
$container->alias(LoadDatabase::class, 'Load.Database')
->share('Load.Database', [$this,
'getDatabaseLoad'], true);
$container->alias(InsertDatabase::class, 'Insert.Database')
->share('Insert.Database', [$this,
'getDatabaseInsert'], true);
}
/**
* Get the Core Load Database
*
* @param Container $container The DI container.
*
* @return Load
* @since 3.2.0
*/
public function getLoad(Container $container): Load
{
return new Load();
}
/**
* Get the Load Database
*
* @param Container $container The DI container.
*
* @return LoadDatabase
* @since 3.2.0
*/
public function getDatabaseLoad(Container $container): LoadDatabase
{
return new LoadDatabase(
$container->get('Config'),
$container->get('Table'),
$container->get('Load.Model'),
$container->get('Load')
);
}
/**
* Get the Insert Database
*
* @param Container $container The DI container.
*
* @return InsertDatabase
* @since 3.2.0
*/
public function getDatabaseInsert(Container $container): InsertDatabase
{
return new InsertDatabase(
$container->get('Config'),
$container->get('Table'),
$container->get('Insert.Model')
);
}
}
src/Componentbuilder/Search/Service/Model.php000064400000003375151162054240015232
0ustar00<?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\Search\Service;
use Joomla\DI\Container;
use Joomla\DI\ServiceProviderInterface;
use VDM\Joomla\Componentbuilder\Search\Model\Load;
use VDM\Joomla\Componentbuilder\Search\Model\Insert;
/**
* Model Service Provider
*
* @since 3.2.0
*/
class Model implements ServiceProviderInterface
{
/**
* Registers the service provider with a DI container.
*
* @param Container $container The DI container.
*
* @return void
* @since 3.2.0
*/
public function register(Container $container)
{
$container->alias(Load::class, 'Load.Model')
->share('Load.Model', [$this, 'getModelLoad'],
true);
$container->alias(Insert::class, 'Insert.Model')
->share('Insert.Model', [$this,
'getModelInsert'], true);
}
/**
* Get the Load Model
*
* @param Container $container The DI container.
*
* @return Load
* @since 3.2.0
*/
public function getModelLoad(Container $container): Load
{
return new Load(
$container->get('Config'),
$container->get('Table')
);
}
/**
* Get the Insert Model
*
* @param Container $container The DI container.
*
* @return Insert
* @since 3.2.0
*/
public function getModelInsert(Container $container): Insert
{
return new Insert(
$container->get('Config'),
$container->get('Table')
);
}
}
src/Componentbuilder/Search/Service/Search.php000064400000006500151162054240015370
0ustar00<?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\Search\Service;
use Joomla\DI\Container;
use Joomla\DI\ServiceProviderInterface;
use VDM\Joomla\Componentbuilder\Search\Config;
use VDM\Joomla\Componentbuilder\Table;
use VDM\Joomla\Componentbuilder\Search\Interfaces\SearchTypeInterface as
SearchEngine;
use VDM\Joomla\Componentbuilder\Search\Engine\Regex;
use VDM\Joomla\Componentbuilder\Search\Engine\Basic;
/**
* Search Service Provider
*
* @since 3.2.0
*/
class Search implements ServiceProviderInterface
{
/**
* Selected search engine
*
* @var int
* @since 3.2.0
**/
protected $searchEngine = 101;
/**
* Registers the service provider with a DI container.
*
* @param Container $container The DI container.
*
* @return void
* @since 3.2.0
*/
public function register(Container $container)
{
$container->alias(Config::class, 'Config')
->share('Config', [$this, 'getConfig'], true);
$container->alias(Table::class, 'Table')
->share('Table', [$this, 'getTable'], true);
$container->alias(Regex::class, 'Search.Regex')
->share('Search.Regex', [$this, 'getRegex'],
true);
$container->alias(Basic::class, 'Search.Basic')
->share('Search.Basic', [$this, 'getBasic'],
true);
$container->alias(SearchEngine::class, 'Search')
->share('Search', [$this, 'getSearch'], true);
}
/**
* Get the Config
*
* @param Container $container The DI container.
*
* @return Config
* @since 3.2.0
*/
public function getConfig(Container $container): Config
{
return new Config();
}
/**
* Get the Table
*
* @param Container $container The DI container.
*
* @return Table
* @since 3.2.0
*/
public function getTable(Container $container): Table
{
return new Table();
}
/**
* Get the Regex Type Search Engine
*
* @param Container $container The DI container.
*
* @return Regex
* @since 3.2.0
*/
public function getRegex(Container $container): Regex
{
return new Regex(
$container->get('Config')
);
}
/**
* Get the Basic Type Search Engine
*
* @param Container $container The DI container.
*
* @return Basic
* @since 3.2.0
*/
public function getBasic(Container $container): Basic
{
return new Basic(
$container->get('Config')
);
}
/**
* Get the Search Engine
*
* @param Container $container The DI container.
*
* @return SearchEngine
* @since 3.2.0
*/
public function getSearch(Container $container): SearchEngine
{
// set the search engine to use for this container
if ($this->searchEngine == 101)
{
$this->searchEngine = (int)
$container->get('Config')->regex_search;
}
// get the correct type of search engine
if ($this->searchEngine == 1)
{
return $container->get('Search.Regex');
}
// the default is the basic
return $container->get('Search.Basic');
}
}
src/Componentbuilder/Search/Service/index.html000064400000000054151162054240015445
0ustar00<html><body
bgcolor="#FFFFFF"></body></html>src/Componentbuilder/Search/index.html000064400000000054151162054240014045
0ustar00<html><body
bgcolor="#FFFFFF"></body></html>src/Componentbuilder/Server.php000064400000007476151162054240012641
0ustar00<?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;
use Joomla\CMS\Factory as JoomlaFactory;
use Joomla\CMS\User\User;
use VDM\Joomla\Componentbuilder\Server\Load;
use VDM\Joomla\Componentbuilder\Server\Ftp;
use VDM\Joomla\Componentbuilder\Server\Sftp;
use VDM\Joomla\Utilities\StringHelper;
/**
* Server Class
*
* @since 3.2.0
*/
class Server
{
/**
* The Loader
*
* @var Load
* @since 3.2.0
*/
protected Load $load;
/**
* The Ftp object
*
* @var Ftp
* @since 3.2.0
**/
protected Ftp $ftp;
/**
* The Sftp object
*
* @var Sftp
* @since 3.2.0
**/
protected Sftp $sftp;
/**
* Current User object
*
* @var User
* @since 3.2.0
*/
protected User $user;
/**
* Constructor
*
* @param Load $load The server details loader object.
* @param Ftp $ftp The server ftp object.
* @param Sftp $sftp The server sftp object.
* @param User|null $user The user object.
*
* @since 3.2.0
*/
public function __construct(Load $load, Ftp $ftp, Sftp $sftp, ?User $user
= null)
{
$this->load = $load;
$this->ftp = $ftp;
$this->sftp = $sftp;
$this->user = $user ?: JoomlaFactory::getUser();
}
/**
* Move File to Server
*
* @param int $id The server local id to use
* @param string $localPath The local path to the file
* @param string $fileName The actual file name
* @param int|null $protocol The protocol to use (if set)
* @param string $permission The permission validation area
*
* @return bool true on success
* @since 3.2.0
*/
public function move(int $id, string $localPath, string $fileName,
?int $protocol = null, string $permission = 'core.export'):
bool
{
// get the server
if ($this->user->authorise($permission,
'com_componentbuilder') &&
(
(
is_numeric($protocol) &&
($protocol == 1 || $protocol == 2)
) || (
($protocol = $this->load->value($id, 'protocol')) !==
null &&
($protocol == 1 || $protocol == 2)
)
)
)
{
// use the FTP protocol
if (1 == $protocol)
{
$protocol = 'ftp';
$fields = [
'name',
'signature'
];
}
// use the SFTP protocol
else
{
$protocol = 'sftp';
$fields = [
'name',
'authentication',
'username',
'host',
'password',
'path',
'port',
'private',
'private_key',
'secret'
];
}
// get the details
if (StringHelper::check($protocol) && ($details =
$this->load->item($id, $fields)) !== null)
{
// now move the file
return $this->{$protocol}->set($details)->move($localPath,
$fileName);
}
}
return false;
}
/**
* Move File to Server (Legacy Signature)
*
* @param string $localPath The local path to the file
* @param string $fileName The actual file name
* @param int $serverID The server local id to use
* @param int $protocol The server protocol to use
* @param string $permission The permission validation area
*
* @return bool true on success
* @since 3.2.0
* @deprecated 4.0
*/
public function legacyMove($localPath, $fileName, $serverID, $protocol =
null, $permission = 'core.export'): bool
{
return $this->move($serverID, $localPath, $fileName, $protocol,
$permission);
}
}
src/Componentbuilder/Server/Ftp.php000064400000006741151162054240013364
0ustar00<?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\Server;
use Joomla\CMS\Client\FtpClient;
use VDM\Joomla\Utilities\StringHelper;
use VDM\Joomla\Utilities\ArrayHelper;
use VDM\Joomla\Utilities\ObjectHelper;
use VDM\Joomla\Componentbuilder\Interfaces\Serverinterface;
/**
* Ftp Class
*
* @since 3.2.0
*/
class Ftp implements Serverinterface
{
/**
* The client object
*
* @var FtpClient|null
* @since 3.2.0
**/
protected ?FtpClient $client = null;
/**
* The server details
*
* @var object
* @since 3.2.0
**/
protected ?object $details = null;
/**
* set the server details
*
* @param object $details The server details
*
* @return Ftp
* @since 3.2.0
**/
public function set(object $details): Ftp
{
// we need to make sure the if the details changed to get a new server
client
if (!ObjectHelper::equal($details, $this->details))
{
// set the details
$this->details = $details;
// reset the client if it was set before
$this->client = null;
}
return $this;
}
/**
* move a file to server with the FTP client
*
* @param string $localPath The full local path to the file
* @param string $fileName The file name
*
* @return bool
* @since 3.2.0
**/
public function move(string $localPath, string $fileName): bool
{
if ($this->connected())
{
return $this->client->store($localPath, $fileName);
}
return false;
}
/**
* Make sure we are connected
*
* @return bool
* @since 3.2.0
**/
private function connected(): bool
{
// check if we have a connection
if ($this->client instanceof FtpClient &&
$this->client->isConnected())
{
return true;
}
$this->client = $this->getClient();
return $this->client instanceof FtpClient;
}
/**
* get the FtpClient object
*
* @return FtpClient|null
* @since 3.2.0
**/
private function getClient(): ?FtpClient
{
// make sure we have a string and it is not default or empty
if (StringHelper::check($this->details->signature))
{
// turn into array of variables
$signature = [];
parse_str((string) $this->details->signature, $signature);
// set options
if (isset($signature['options']) &&
ArrayHelper::check($signature['options']))
{
foreach ($signature['options'] as $o__p0t1on => $vAln3)
{
if ('timeout' === $o__p0t1on)
{
$options[$o__p0t1on] = (int) $vAln3;
}
if ('type' === $o__p0t1on)
{
$options[$o__p0t1on] = (string) $vAln3;
}
}
}
else
{
$options = [];
}
// get ftp object
if (isset($signature['host']) &&
$signature['host'] != 'HOSTNAME' &&
isset($signature['port']) &&
$signature['port'] != 'PORT_INT' &&
isset($signature['username']) &&
$signature['username'] != 'user@name.com' &&
isset($signature['password']) &&
$signature['password'] != 'password')
{
// this is a singleton
return FtpClient::getInstance($host, $port, $options, $username,
$password);
}
}
return null;
}
}
src/Componentbuilder/Server/Load.php000064400000005310151162054240013501
0ustar00<?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\Server;
use VDM\Joomla\Componentbuilder\Compiler\Factory;
use VDM\Joomla\Database\Load as Database;
use VDM\Joomla\Componentbuilder\Server\Model\Load as Model;
/**
* Server Load Class
*
* @since 3.2.0
*/
class Load
{
/**
* Database Load
*
* @var Database
* @since 3.2.0
*/
protected Database $db;
/**
* Model Class
*
* @var Model
* @since 3.2.0
*/
protected Model $model;
/**
* Constructor
*
* @param Database|null $db The database object.
* @param Model|null $model The core crypt object.
*
* @since 3.2.0
*/
public function __construct(?Database $db = null, ?Model $model = null)
{
$this->db = $db ?: Factory::_('Load');
$this->model = $model ?: Factory::_('Model.Server.Load');
}
/**
* Get a value from a given server
* Example: $this->value(23, 'protocol');
*
* @param int $id The item ID
* @param string $field The table field
*
* @return mixed|null
* @since 3.2.0
*/
public function value(int $id, string $field)
{
if ($id > 0 && ($value = $this->db->value(
$this->setDatabaseFields([$field]), ['a' =>
'server'], ['a.id' => $id]
)) !== null)
{
return $this->model->value($value, $field, 'server');
}
return null;
}
/**
* Get values from a given server
* Example: $this->item(23, ['name', 'of',
'fields']);
*
* @param int $id The item ID
* @param array $fields The table fields
*
* @return object|null
* @since 3.2.0
*/
public function item(int $id, array $fields): ?object
{
if ($id > 0 && ($item = $this->db->item(
$this->setDatabaseFields($fields), ['a' =>
'server'], ['a.id' => $id]
)) !== null)
{
return $this->model->item($item, 'server');
}
return null;
}
/**
* Set Fields ready to use in database call
*
* @param array $fields The table
* @param string $key The table key to which the fields belong
*
* @return array
* @since 3.2.0
*/
protected function setDatabaseFields(array $fields, string $key =
'a'): array
{
$bucket = [];
foreach ($fields as $field)
{
$bucket[$key . '.' . $field] = $field;
}
return $bucket;
}
}
src/Componentbuilder/Server/Model/Load.php000064400000007121151162054240014543
0ustar00<?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\Server\Model;
use Joomla\Registry\Registry;
use VDM\Joomla\Componentbuilder\Compiler\Factory;
use VDM\Joomla\Componentbuilder\Crypt;
use VDM\Joomla\Componentbuilder\Table;
use VDM\Joomla\Utilities\StringHelper;
use VDM\Joomla\Utilities\JsonHelper;
use VDM\Joomla\Interfaces\ModelInterface;
use VDM\Joomla\Abstraction\Model;
/**
* Server Model Load Class
*
* @since 3.2.0
*/
class Load extends Model implements ModelInterface
{
/**
* Decryption Class
*
* @var Crypt
* @since 3.2.0
*/
protected Crypt $crypt;
/**
* Constructor
*
* @param Crypt|null $crypt The core crypt object.
* @param Table|null $table The search table object.
*
* @since 3.2.0
*/
public function __construct(?Crypt $crypt = null, ?Table $table = null)
{
parent::__construct($table ?? Factory::_('Table'));
$this->crypt = $crypt ?: Factory::_('Crypt');
}
/**
* Model the value
* Example: $this->value(value, 'value_key',
'table_name');
*
* @param mixed $value The value to model
* @param string $field The field key
* @param string|null $table The table
*
* @return mixed
* @since 3.2.0
*/
public function value($value, string $field, ?string $table = null)
{
// load the table
if (empty($table))
{
$table = $this->getTable();
}
// check if this is a valid table
if (StringHelper::check($value) && ($store =
$this->table->get($table, $field, 'store')) !== null)
{
// open the value based on the store method
switch($store)
{
case 'basic_encryption':
$value = $this->crypt->decrypt($value, 'basic');
break;
case 'medium_encryption':
$value = $this->crypt->decrypt($value, 'medium');
break;
case 'base64':
$value = base64_decode((string) $value);
break;
case 'json':
// check if there is a json string
if (JsonHelper::check($value))
{
$registry = new Registry;
$registry->loadString($value);
$value = $registry->toArray();
}
break;
default:
if ($this->crypt->exist($store))
{
$value = $this->crypt->decrypt($value, $store);
}
break;
}
}
return $value;
}
/**
* Validate before the value is modelled
*
* @param mixed $value The field value
* @param string|null $field The field key
* @param string|null $table The table
*
* @return bool
* @since 3.2.0
*/
protected function validateBefore(&$value, ?string $field = null,
?string $table = null): bool
{
// remove none
return true;
}
/**
* Validate after the value is modelled
*
* @param mixed $value The field value
* @param string|null $field The field key
* @param string|null $table The table
*
* @return bool
* @since 3.2.0
*/
protected function validateAfter(&$value, ?string $field = null,
?string $table = null): bool
{
return true;
}
/**
* Get the current active table
*
* @return string
* @since 3.2.0
*/
protected function getTable(): string
{
return 'server';
}
}
src/Componentbuilder/Server/Model/index.html000064400000000054151162054240015146
0ustar00<html><body
bgcolor="#FFFFFF"></body></html>src/Componentbuilder/Server/Sftp.php000064400000015024151162054240013541
0ustar00<?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\Server;
use Joomla\CMS\Factory;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Application\CMSApplication;
use phpseclib3\Net\SFTP as SftpClient;
use VDM\Joomla\Componentbuilder\Crypt\KeyLoader;
use VDM\Joomla\Utilities\StringHelper;
use VDM\Joomla\Utilities\FileHelper;
use VDM\Joomla\Utilities\ObjectHelper;
use VDM\Joomla\Componentbuilder\Interfaces\Serverinterface;
/**
* Sftp Class
*
* @since 3.2.0
*/
class Sftp implements Serverinterface
{
/**
* The KeyLoader
*
* @var KeyLoader
* @since 3.2.0
*/
protected KeyLoader $key;
/**
* The client object
*
* @var SftpClient|null
* @since 3.2.0
**/
protected ?SftpClient $client = null;
/**
* The server details
*
* @var object
* @since 3.2.0
**/
protected ?object $details = null;
/**
* Application object.
*
* @var CMSApplication
* @since 3.2.0
**/
protected CMSApplication $app;
/**
* Constructor
*
* @param KeyLoader $key The key loader object.
* @param CMSApplication|null $app The app object.
*
* @since 3.2.0
*/
public function __construct(KeyLoader $key, ?CMSApplication $app = null)
{
$this->key = $key;
$this->app = $app ?: Factory::getApplication();
}
/**
* set the server details
*
* @param object $details The server details
*
* @return Sftp
* @since 3.2.0
**/
public function set(object $details): Sftp
{
// we need to make sure the if the details changed to get a new server
client
if (!ObjectHelper::equal($details, $this->details))
{
// set the details
$this->details = $details;
// reset the client if it was set before
$this->client = null;
}
return $this;
}
/**
* move a file to server with the FTP client
*
* @param string $localPath The full local path to the file
* @param string $fileName The file name
*
* @return bool
* @since 3.2.0
**/
public function move(string $localPath, string $fileName): bool
{
if ($this->connected() &&
($data = FileHelper::getContent($localPath, null)) !== null)
{
// get the remote path
$path = '';
if (isset($this->details->path) &&
StringHelper::check($this->details->path) &&
$this->details->path !== '/')
{
$path = trim((string) $this->details->path);
$path = '/' . trim($path, '/') . '/';
}
try
{
return $this->client->put($path . trim($fileName), $data);
}
catch(\Exception $e)
{
$this->app->enqueueMessage(
Text::sprintf('COM_COMPONENTBUILDER_MOVING_OF_THE_S_FAILED',
$fileName) . ': ' . $e->getMessage(),
'Error'
);
}
}
return false;
}
/**
* Make sure we are connected
*
* @return bool
* @since 3.2.0
**/
private function connected(): bool
{
// check if we have a connection
if ($this->client instanceof SftpClient &&
($this->client->isConnected() || $this->client->ping()))
{
return true;
}
$this->client = $this->getClient();
return $this->client instanceof SftpClient;
}
/**
* get the SftpClient object
*
* @return SftpClient|null
* @since 3.2.0
**/
private function getClient(): ?SftpClient
{
// make sure we have a host value set
if (isset($this->details->host) &&
StringHelper::check($this->details->host) &&
isset($this->details->username) &&
StringHelper::check($this->details->username))
{
// insure the port is set
$port = (int)($this->details->port ?? 22);
// open the connection
$sftp = new SftpClient($this->details->host, $port);
// set the passphrase if it exist
$passphrase = (isset($this->details->secret) &&
StringHelper::check(trim($this->details->secret))) ?
trim($this->details->secret) : false;
// set the password if it exist
$password = (isset($this->details->password) &&
StringHelper::check(trim($this->details->password))) ?
trim($this->details->password) : false;
// now login based on authentication type
$key = null;
switch($this->details->authentication)
{
case 1: // password
$key = $password ?? null;
$password = null;
break;
case 2: // private key file
case 3: // both password and private key file
if (isset($this->details->private) &&
StringHelper::check($this->details->private) &&
($private_key = FileHelper::getContent($this->details->private,
null)) !== null)
{
try
{
$key = $this->key::load(trim($private_key), $passphrase);
}
catch(\Exception $e)
{
$this->app->enqueueMessage(
Text::_('COM_COMPONENTBUILDER_LOADING_THE_PRIVATE_KEY_FILE_FAILED')
. ': ' . $e->getMessage(),
'Error'
);
$key = null;
}
}
break;
case 4: // private key field
case 5: // both password and private key field
if (isset($this->details->private_key) &&
StringHelper::check($this->details->private_key))
{
try
{
$key = $this->key::load(trim($this->details->private_key),
$passphrase);
}
catch(\Exception $e)
{
$this->app->enqueueMessage(
Text::_('COM_COMPONENTBUILDER_LOADING_THE_PRIVATE_KEY_TEXT_FAILED')
. ': ' . $e->getMessage(),
'Error'
);
$key = null;
}
}
break;
}
// remove any null bites from the username
$this->details->username = trim($this->details->username);
// login
if (!empty($key) && !empty($password))
{
try
{
$sftp->login($this->details->username, $key, $password);
return $sftp;
}
catch(\Exception $e)
{
$this->app->enqueueMessage(
Text::_('COM_COMPONENTBUILDER_LOGIN_FAILED') . ':
' . $e->getMessage(),
'Error'
);
}
}
elseif (!empty($key))
{
try
{
$sftp->login($this->details->username, $key);
return $sftp;
}
catch(\Exception $e)
{
$this->app->enqueueMessage(
Text::_('COM_COMPONENTBUILDER_LOGIN_FAILED') . ':
' . $e->getMessage(),
'Error'
);
}
}
}
return null;
}
}
src/Componentbuilder/Server/index.html000064400000000054151162054240014106
0ustar00<html><body
bgcolor="#FFFFFF"></body></html>src/Componentbuilder/Service/CoreRules.php000064400000005714151162054240014667
0ustar00<?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\Service;
use Joomla\DI\Container;
use Joomla\DI\ServiceProviderInterface;
use Joomla\CMS\Version;
use VDM\Joomla\Componentbuilder\Compiler\Field\JoomlaThree\CoreRule as
J3CoreRule;
use VDM\Joomla\Componentbuilder\Compiler\Field\JoomlaFour\CoreRule as
J4CoreRule;
use VDM\Joomla\Componentbuilder\Compiler\Field\JoomlaFive\CoreRule as
J5CoreRule;
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\Field\CoreRuleInterface
as CoreRule;
/**
* Joomla Core Rules
*
* @since 3.2.0
*/
class CoreRules implements ServiceProviderInterface
{
/**
* Current Joomla Version We are IN
*
* @var int
* @since 3.2.0
**/
protected $currentVersion;
/**
* Registers the service provider with a DI container.
*
* @param Container $container The DI container.
*
* @return void
* @since 3.2.0
*/
public function register(Container $container)
{
$container->alias(J3CoreRule::class, 'J3.Field.Core.Rule')
->share('J3.Field.Core.Rule', [$this,
'getJ3CoreRule'], true);
$container->alias(J4CoreRule::class, 'J4.Field.Core.Rule')
->share('J4.Field.Core.Rule', [$this,
'getJ4CoreRule'], true);
$container->alias(J5CoreRule::class, 'J5.Field.Core.Rule')
->share('J5.Field.Core.Rule', [$this,
'getJ5CoreRule'], true);
$container->alias(CoreRule::class, 'Field.Core.Rule')
->share('Field.Core.Rule', [$this,
'getCoreRule'], true);
}
/**
* Get The CoreRule Class.
*
* @param Container $container The DI container.
*
* @return J3CoreRule
* @since 3.2.0
*/
public function getJ3CoreRule(Container $container): J3CoreRule
{
return new J3CoreRule();
}
/**
* Get The CoreRule Class.
*
* @param Container $container The DI container.
*
* @return J4CoreRule
* @since 3.2.0
*/
public function getJ4CoreRule(Container $container): J4CoreRule
{
return new J4CoreRule();
}
/**
* Get The CoreRule Class.
*
* @param Container $container The DI container.
*
* @return J5CoreRule
* @since 3.2.0
*/
public function getJ5CoreRule(Container $container): J5CoreRule
{
return new J5CoreRule();
}
/**
* Get The CoreRuleInterface Class.
*
* @param Container $container The DI container.
*
* @return CoreRule
* @since 3.2.0
*/
public function getCoreRule(Container $container): CoreRule
{
if (empty($this->currentVersion))
{
$this->currentVersion = Version::MAJOR_VERSION;
}
return $container->get('J' . $this->currentVersion .
'.Field.Core.Rule');
}
}
src/Componentbuilder/Service/Crypt.php000064400000010516151162054240014061
0ustar00<?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\Service;
use Joomla\DI\Container;
use Joomla\DI\ServiceProviderInterface;
use phpseclib3\Crypt\AES as BASEAES;
use VDM\Joomla\Componentbuilder\Crypt as Crypto;
use VDM\Joomla\Componentbuilder\Crypt\KeyLoader;
use VDM\Joomla\Componentbuilder\Crypt\Random;
use VDM\Joomla\Componentbuilder\Crypt\Password;
use VDM\Joomla\Componentbuilder\Crypt\FOF;
use VDM\Joomla\Componentbuilder\Crypt\Aes;
use VDM\Joomla\Componentbuilder\Crypt\Aes\Legacy;
/**
* Phpseclib Crypt Service Provider
*
* @since 3.2.0
*/
class Crypt implements ServiceProviderInterface
{
/**
* Registers the service provider with a DI container.
*
* @param Container $container The DI container.
*
* @return void
* @since 3.2.0
*/
public function register(Container $container)
{
$container->alias(Crypto::class, 'Crypt')
->share('Crypt', [$this, 'getCrypt'], true);
$container->alias(Random::class, 'Crypt.Random')
->share('Crypt.Random', [$this, 'getRandom'],
true);
$container->alias(Password::class, 'Crypt.Password')
->share('Crypt.Password', [$this, 'getPassword'],
true);
$container->alias(KeyLoader::class, 'Crypt.Key')
->share('Crypt.Key', [$this, 'getKeyLoader'],
true);
$container->alias(BASEAES::class, 'Crypt.AESCBC')
->share('Crypt.AESCBC', [$this, 'getBASEAESCBC'],
false);
$container->alias(FOF::class, 'Crypt.FOF')
->share('Crypt.FOF', [$this, 'getFOF'], true);
$container->alias(Aes::class, 'Crypt.AES.CBC')
->share('Crypt.AES.CBC', [$this, 'getAesCBC'],
true);
$container->alias(Legacy::class, 'Crypt.AES.LEGACY')
->share('Crypt.AES.LEGACY', [$this,
'getAesLEGACY'], true);
}
/**
* Get the Crypto class
*
* @param Container $container The DI container.
*
* @return Crypto
* @since 3.2.0
*/
public function getCrypt(Container $container): Crypto
{
return new Crypto(
$container->get('Crypt.FOF'),
$container->get('Crypt.AES.CBC'),
$container->get('Crypt.AES.LEGACY'),
$container->get('Crypt.Password')
);
}
/**
* Get the Password class
*
* @param Container $container The DI container.
*
* @return Password
* @since 3.2.0
*/
public function getPassword(Container $container): Password
{
return new Password();
}
/**
* Get the Random class
*
* @param Container $container The DI container.
*
* @return Random
* @since 3.2.0
*/
public function getRandom(Container $container): Random
{
return new Random();
}
/**
* Get the KeyLoader class
*
* @param Container $container The DI container.
*
* @return KeyLoader
* @since 3.2.0
*/
public function getKeyLoader(Container $container): KeyLoader
{
return new KeyLoader();
}
/**
* Get the AES Cyper with CBC mode
*
* @param Container $container The DI container.
*
* @return BASEAES
* @since 3.2.0
*/
public function getBASEAESCBC(Container $container): BASEAES
{
return new BASEAES('cbc');
}
/**
* Get the Wrapper AES Cyper with CBC mode
*
* @param Container $container The DI container.
*
* @return Aes
* @since 3.2.0
*/
public function getAesCBC(Container $container): Aes
{
return new Aes(
$container->get('Crypt.AESCBC'),
$container->get('Crypt.Random')
);
}
/**
* Get the Wrapper AES Legacy Cyper with CBC mode
*
* @param Container $container The DI container.
*
* @return Legacy
* @since 3.2.0
*/
public function getAesLEGACY(Container $container): Legacy
{
return new Legacy(
$container->get('Crypt.AESCBC')
);
}
/**
* Get the FOF AES Cyper with CBC mode
*
* @param Container $container The DI container.
*
* @return FOF
* @since 3.2.0
*/
public function getFOF(Container $container): FOF
{
return new FOF(
$container->get('Crypt.AESCBC'),
$container->get('Crypt.Random')
);
}
}
src/Componentbuilder/Service/Gitea.php000064400000004027151162054240014011
0ustar00<?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\Service;
use Joomla\DI\Container;
use Joomla\DI\ServiceProviderInterface;
use VDM\Joomla\Gitea\Utilities\Uri;
use VDM\Joomla\Gitea\Utilities\Http;
/**
* The Gitea Utilities Service
*
* @since 3.2.0
*/
class Gitea implements ServiceProviderInterface
{
/**
* Registers the service provider with a DI container.
*
* @param Container $container The DI container.
*
* @return void
* @since 3.2.0
*/
public function register(Container $container)
{
$container->alias(Uri::class, 'Gitea.Dynamic.Uri')
->share('Gitea.Dynamic.Uri', [$this, 'getUri'],
true);
$container->alias(Http::class, 'Gitea.Utilities.Http')
->share('Gitea.Utilities.Http', [$this,
'getHttp'], true);
}
/**
* Get the Dynamic Uri class
*
* @param Container $container The DI container.
*
* @return Uri
* @since 3.2.0
*/
public function getUri(Container $container): Uri
{
// get the global gitea URL
$add_gitea_url =
$container->get('Config')->get('add_custom_gitea_url',
1);
$gitea_url =
$container->get('Config')->get('custom_gitea_url');
// only load this if we have a custom URL set
if ($add_gitea_url == 2 && !empty($gitea_url) &&
strpos($gitea_url, 'http') !== false)
{
return new Uri($gitea_url);
}
return $container->get('Gitea.Utilities.Uri');
}
/**
* Get the Http class
*
* @param Container $container The DI container.
*
* @return Http
* @since 3.2.0
*/
public function getHttp(Container $container): Http
{
return new Http(
$container->get('Config')->get('gitea_token')
);
}
}
src/Componentbuilder/Service/Server.php000064400000005120151162054240014221
0ustar00<?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\Service;
use Joomla\DI\Container;
use Joomla\DI\ServiceProviderInterface;
use VDM\Joomla\Componentbuilder\Server as Client;
use VDM\Joomla\Componentbuilder\Server\Load;
use VDM\Joomla\Componentbuilder\Server\Ftp;
use VDM\Joomla\Componentbuilder\Server\Sftp;
/**
* Server Service Provider
*
* @since 3.2.0
*/
class Server implements ServiceProviderInterface
{
/**
* Registers the service provider with a DI container.
*
* @param Container $container The DI container.
*
* @return void
* @since 3.2.0
*/
public function register(Container $container)
{
$container->alias(Client::class, 'Server')
->share('Server', [$this, 'getServer'], true);
$container->alias(Load::class, 'Server.Load')
->share('Server.Load', [$this, 'getServerLoad'],
true);
$container->alias(Ftp::class, 'Server.FTP')
->share('Server.FTP', [$this, 'getServerFtp'],
true);
$container->alias(Sftp::class, 'Server.SFTP')
->share('Server.SFTP', [$this, 'getServerSftp'],
true);
}
/**
* Get the Server Client class
*
* @param Container $container The DI container.
*
* @return Client
* @since 3.2.0
*/
public function getServer(Container $container): Client
{
return new Client(
$container->get('Server.Load'),
$container->get('Server.FTP'),
$container->get('Server.SFTP')
);
}
/**
* Get the Server Load class
*
* @param Container $container The DI container.
*
* @return Load
* @since 3.2.0
*/
public function getServerLoad(Container $container): Load
{
return new Load(
$container->get('Load'),
$container->get('Model.Server.Load')
);
}
/**
* Get the Server Ftp class
*
* @param Container $container The DI container.
*
* @return Ftp
* @since 3.2.0
*/
public function getServerFtp(Container $container): Ftp
{
return new Ftp();
}
/**
* Get the Server Sftp class
*
* @param Container $container The DI container.
*
* @return Sftp
* @since 3.2.0
*/
public function getServerSftp(Container $container): Sftp
{
return new Sftp(
$container->get('Crypt.Key')
);
}
}
src/Componentbuilder/Service/index.html000064400000000054151162054240014240
0ustar00<html><body
bgcolor="#FFFFFF"></body></html>src/Componentbuilder/Table.php000064400001052326151162054240012415
0ustar00<?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;
use VDM\Joomla\Interfaces\Tableinterface;
use VDM\Joomla\Abstraction\BaseTable;
/**
* Componentbuilder Tables
*
* @since 3.2.0
*/
final class Table extends BaseTable implements Tableinterface
{
/**
* All areas/views/tables with their field details
*
* @var array
* @since 3.2.0
**/
protected array $tables = [
'joomla_component' => [
'system_name' => [
'name' => 'system_name',
'label' =>
'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_SYSTEM_NAME_LABEL',
'type' => 'text',
'title' => true,
'list' => 'joomla_components',
'store' => NULL,
'tab_name' => 'Details',
'db' => [
'type' => 'VARCHAR(255)',
'default' => '',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'name_code' => [
'name' => 'name_code',
'label' =>
'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_NAME_CODE_LABEL',
'type' => 'text',
'title' => false,
'list' => 'joomla_components',
'store' => NULL,
'tab_name' => 'Details',
'db' => [
'type' => 'VARCHAR(255)',
'default' => '',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'short_description' => [
'name' => 'short_description',
'label' =>
'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_SHORT_DESCRIPTION_LABEL',
'type' => 'text',
'title' => false,
'list' => 'joomla_components',
'store' => NULL,
'tab_name' => 'Details',
'db' => [
'type' => 'VARCHAR(255)',
'default' => '',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'companyname' => [
'name' => 'companyname',
'label' =>
'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_COMPANYNAME_LABEL',
'type' => 'text',
'title' => false,
'list' => 'joomla_components',
'store' => NULL,
'tab_name' => 'Details',
'db' => [
'type' => 'CHAR(64)',
'default' => '',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'created' => [
'name' => 'created',
'label' =>
'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_CREATED_LABEL',
'type' => 'calendar',
'title' => false,
'list' => 'joomla_components',
'store' => NULL,
'tab_name' => 'publishing',
'db' => [
'type' => 'DATETIME',
'default' => '0000-00-00 00:00:00',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'crowdin_project_identifier' => [
'name' => 'crowdin_project_identifier',
'label' =>
'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_CROWDIN_PROJECT_IDENTIFIER_LABEL',
'type' => 'text',
'title' => false,
'list' => 'joomla_components',
'store' => NULL,
'tab_name' => 'Dynamic Integration',
'db' => [
'type' => 'VARCHAR(255)',
'default' => '',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'backup_folder_path' => [
'name' => 'backup_folder_path',
'label' =>
'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_BACKUP_FOLDER_PATH_LABEL',
'type' => 'text',
'title' => false,
'list' => 'joomla_components',
'store' => NULL,
'tab_name' => 'Dynamic Integration',
'db' => [
'type' => 'VARCHAR(255)',
'default' => '',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'sql_uninstall' => [
'name' => 'sql_uninstall',
'label' =>
'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_SQL_UNINSTALL_LABEL',
'type' => 'textarea',
'title' => false,
'list' => 'joomla_components',
'store' => 'base64',
'tab_name' => 'MySQL',
'db' => [
'type' => 'MEDIUMTEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'php_postflight_update' => [
'name' => 'php_postflight_update',
'label' =>
'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_PHP_POSTFLIGHT_UPDATE_LABEL',
'type' => 'editor',
'title' => false,
'list' => 'joomla_components',
'store' => 'base64',
'tab_name' => 'Dash & Install',
'db' => [
'type' => 'MEDIUMTEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'css_site' => [
'name' => 'css_site',
'label' =>
'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_CSS_SITE_LABEL',
'type' => 'editor',
'title' => false,
'list' => 'joomla_components',
'store' => 'base64',
'tab_name' => 'Libs & Helpers',
'db' => [
'type' => 'TEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'mvc_versiondate' => [
'name' => 'mvc_versiondate',
'label' =>
'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_MVC_VERSIONDATE_LABEL',
'type' => 'list',
'title' => false,
'list' => 'joomla_components',
'store' => NULL,
'tab_name' => 'Details',
'db' => [
'type' => 'TINYINT(1)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'remove_line_breaks' => [
'name' => 'remove_line_breaks',
'label' =>
'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_REMOVE_LINE_BREAKS_LABEL',
'type' => 'radio',
'title' => false,
'list' => 'joomla_components',
'store' => NULL,
'tab_name' => 'Details',
'db' => [
'type' => 'TINYINT(1)',
'default' => '1',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'add_placeholders' => [
'name' => 'add_placeholders',
'label' =>
'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_ADD_PLACEHOLDERS_LABEL',
'type' => 'radio',
'title' => false,
'list' => 'joomla_components',
'store' => NULL,
'tab_name' => 'Details',
'db' => [
'type' => 'TINYINT(1)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'php_helper_site' => [
'name' => 'php_helper_site',
'label' =>
'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_PHP_HELPER_SITE_LABEL',
'type' => 'editor',
'title' => false,
'list' => 'joomla_components',
'store' => 'base64',
'tab_name' => 'Libs & Helpers',
'db' => [
'type' => 'MEDIUMTEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'javascript' => [
'name' => 'javascript',
'label' =>
'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_JAVASCRIPT_LABEL',
'type' => 'editor',
'title' => false,
'list' => 'joomla_components',
'store' => 'base64',
'tab_name' => 'Libs & Helpers',
'db' => [
'type' => 'TEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'description' => [
'name' => 'description',
'label' =>
'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_DESCRIPTION_LABEL',
'type' => 'textarea',
'title' => false,
'list' => 'joomla_components',
'store' => NULL,
'tab_name' => 'Details',
'db' => [
'type' => 'TEXT',
'default' => 'EMPTY',
'null_switch' => 'NULL',
'unique_key' => false,
'key' => false,
],
],
'debug_linenr' => [
'name' => 'debug_linenr',
'label' =>
'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_DEBUG_LINENR_LABEL',
'type' => 'radio',
'title' => false,
'list' => 'joomla_components',
'store' => NULL,
'tab_name' => 'Details',
'db' => [
'type' => 'TINYINT(1)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'author' => [
'name' => 'author',
'label' =>
'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_AUTHOR_LABEL',
'type' => 'text',
'title' => false,
'list' => 'joomla_components',
'store' => NULL,
'tab_name' => 'Details',
'db' => [
'type' => 'VARCHAR(255)',
'default' => '',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'php_method_install' => [
'name' => 'php_method_install',
'label' =>
'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_PHP_METHOD_INSTALL_LABEL',
'type' => 'editor',
'title' => false,
'list' => 'joomla_components',
'store' => 'base64',
'tab_name' => 'Dash & Install',
'db' => [
'type' => 'MEDIUMTEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'email' => [
'name' => 'email',
'label' =>
'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_EMAIL_LABEL',
'type' => 'text',
'title' => false,
'list' => 'joomla_components',
'store' => NULL,
'tab_name' => 'Details',
'db' => [
'type' => 'VARCHAR(255)',
'default' => '',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'website' => [
'name' => 'website',
'label' =>
'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_WEBSITE_LABEL',
'type' => 'url',
'title' => false,
'list' => 'joomla_components',
'store' => NULL,
'tab_name' => 'Details',
'db' => [
'type' => 'CHAR(255)',
'default' => '',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'add_sales_server' => [
'name' => 'add_sales_server',
'label' =>
'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_ADD_SALES_SERVER_LABEL',
'type' => 'radio',
'title' => false,
'list' => 'joomla_components',
'store' => NULL,
'tab_name' => 'Dynamic Integration',
'db' => [
'type' => 'TINYINT(1)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'license' => [
'name' => 'license',
'label' =>
'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_LICENSE_LABEL',
'type' => 'textarea',
'title' => false,
'list' => 'joomla_components',
'store' => NULL,
'tab_name' => 'Details',
'db' => [
'type' => 'VARCHAR(255)',
'default' => '',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'add_jcb_powers_path' => [
'name' => 'add_jcb_powers_path',
'label' =>
'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_ADD_JCB_POWERS_PATH_LABEL',
'type' => 'radio',
'title' => false,
'list' => 'joomla_components',
'store' => NULL,
'tab_name' => 'Dynamic Integration',
'db' => [
'type' => 'TINYINT(1)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'bom' => [
'name' => 'bom',
'label' =>
'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_BOM_LABEL',
'type' => 'filelist',
'title' => false,
'list' => 'joomla_components',
'store' => NULL,
'tab_name' => 'Details',
'db' => [
'type' => 'CHAR(64)',
'default' => '',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'image' => [
'name' => 'image',
'label' =>
'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_IMAGE_LABEL',
'type' => 'media',
'title' => false,
'list' => 'joomla_components',
'store' => NULL,
'tab_name' => 'Details',
'db' => [
'type' => 'VARCHAR(255)',
'default' => '',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'php_admin_event' => [
'name' => 'php_admin_event',
'label' =>
'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_PHP_ADMIN_EVENT_LABEL',
'type' => 'editor',
'title' => false,
'list' => 'joomla_components',
'store' => 'base64',
'tab_name' => 'Libs & Helpers',
'db' => [
'type' => 'MEDIUMTEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'copyright' => [
'name' => 'copyright',
'label' =>
'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_COPYRIGHT_LABEL',
'type' => 'textarea',
'title' => false,
'list' => 'joomla_components',
'store' => NULL,
'tab_name' => 'Details',
'db' => [
'type' => 'VARCHAR(255)',
'default' => '',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'php_site_event' => [
'name' => 'php_site_event',
'label' =>
'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_PHP_SITE_EVENT_LABEL',
'type' => 'editor',
'title' => false,
'list' => 'joomla_components',
'store' => 'base64',
'tab_name' => 'Libs & Helpers',
'db' => [
'type' => 'MEDIUMTEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'css_admin' => [
'name' => 'css_admin',
'label' =>
'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_CSS_ADMIN_LABEL',
'type' => 'editor',
'title' => false,
'list' => 'joomla_components',
'store' => 'base64',
'tab_name' => 'Libs & Helpers',
'db' => [
'type' => 'TEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'php_preflight_update' => [
'name' => 'php_preflight_update',
'label' =>
'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_PHP_PREFLIGHT_UPDATE_LABEL',
'type' => 'editor',
'title' => false,
'list' => 'joomla_components',
'store' => 'base64',
'tab_name' => 'Dash & Install',
'db' => [
'type' => 'MEDIUMTEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'component_version' => [
'name' => 'component_version',
'label' =>
'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_COMPONENT_VERSION_LABEL',
'type' => 'text',
'title' => false,
'list' => 'joomla_components',
'store' => NULL,
'tab_name' => 'Details',
'db' => [
'type' => 'CHAR(64)',
'default' => '',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'php_preflight_install' => [
'name' => 'php_preflight_install',
'label' =>
'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_PHP_PREFLIGHT_INSTALL_LABEL',
'type' => 'editor',
'title' => false,
'list' => 'joomla_components',
'store' => 'base64',
'tab_name' => 'Dash & Install',
'db' => [
'type' => 'MEDIUMTEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'preferred_joomla_version' => [
'name' => 'preferred_joomla_version',
'label' =>
'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_PREFERRED_JOOMLA_VERSION_LABEL',
'type' => 'number',
'title' => false,
'list' => 'joomla_components',
'store' => NULL,
'tab_name' => 'Details',
'db' => [
'type' => 'INT(11)',
'default' => '3',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'php_postflight_install' => [
'name' => 'php_postflight_install',
'label' =>
'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_PHP_POSTFLIGHT_INSTALL_LABEL',
'type' => 'editor',
'title' => false,
'list' => 'joomla_components',
'store' => 'base64',
'tab_name' => 'Dash & Install',
'db' => [
'type' => 'MEDIUMTEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'add_powers' => [
'name' => 'add_powers',
'label' =>
'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_ADD_POWERS_LABEL',
'type' => 'radio',
'title' => false,
'list' => 'joomla_components',
'store' => NULL,
'tab_name' => 'Details',
'db' => [
'type' => 'TINYINT(1)',
'default' => '1',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'php_method_uninstall' => [
'name' => 'php_method_uninstall',
'label' =>
'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_PHP_METHOD_UNINSTALL_LABEL',
'type' => 'editor',
'title' => false,
'list' => 'joomla_components',
'store' => 'base64',
'tab_name' => 'Dash & Install',
'db' => [
'type' => 'MEDIUMTEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'sql' => [
'name' => 'sql',
'label' =>
'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_SQL_LABEL',
'type' => 'textarea',
'title' => false,
'list' => 'joomla_components',
'store' => 'base64',
'tab_name' => 'MySQL',
'db' => [
'type' => 'MEDIUMTEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'addreadme' => [
'name' => 'addreadme',
'label' =>
'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_ADDREADME_LABEL',
'type' => 'radio',
'title' => false,
'list' => 'joomla_components',
'store' => NULL,
'tab_name' => 'Readme',
'db' => [
'type' => 'TINYINT(1)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'update_server_url' => [
'name' => 'update_server_url',
'label' =>
'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_UPDATE_SERVER_URL_LABEL',
'type' => 'url',
'title' => false,
'list' => 'joomla_components',
'store' => NULL,
'tab_name' => 'Dynamic Integration',
'db' => [
'type' => 'VARCHAR(255)',
'default' => '',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'add_backup_folder_path' => [
'name' => 'add_backup_folder_path',
'label' =>
'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_ADD_BACKUP_FOLDER_PATH_LABEL',
'type' => 'radio',
'title' => false,
'list' => 'joomla_components',
'store' => NULL,
'tab_name' => 'Dynamic Integration',
'db' => [
'type' => 'TINYINT(1)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'translation_tool' => [
'name' => 'translation_tool',
'label' =>
'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_TRANSLATION_TOOL_LABEL',
'type' => 'list',
'title' => false,
'list' => 'joomla_components',
'store' => NULL,
'tab_name' => 'Dynamic Integration',
'db' => [
'type' => 'TINYINT(1)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'crowdin_username' => [
'name' => 'crowdin_username',
'label' =>
'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_CROWDIN_USERNAME_LABEL',
'type' => 'text',
'title' => false,
'list' => 'joomla_components',
'store' => 'basic_encryption',
'tab_name' => 'Dynamic Integration',
'db' => [
'type' => 'TEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'buildcompsql' => [
'name' => 'buildcompsql',
'label' =>
'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_BUILDCOMPSQL_LABEL',
'type' => 'textarea',
'title' => false,
'list' => 'joomla_components',
'store' => 'base64',
'tab_name' => 'Dynamic Build',
'db' => [
'type' => 'MEDIUMTEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'add_namespace_prefix' => [
'name' => 'add_namespace_prefix',
'label' =>
'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_ADD_NAMESPACE_PREFIX_LABEL',
'type' => 'radio',
'title' => false,
'list' => 'joomla_components',
'store' => NULL,
'tab_name' => 'Settings',
'db' => [
'type' => 'CHAR(1)',
'default' => '',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'namespace_prefix' => [
'name' => 'namespace_prefix',
'label' =>
'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_NAMESPACE_PREFIX_LABEL',
'type' => 'text',
'title' => false,
'list' => 'joomla_components',
'store' => NULL,
'tab_name' => 'Settings',
'db' => [
'type' => 'VARCHAR(255)',
'default' => '',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'add_php_helper_site' => [
'name' => 'add_php_helper_site',
'label' =>
'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_ADD_PHP_HELPER_SITE_LABEL',
'type' => 'radio',
'title' => false,
'list' => 'joomla_components',
'store' => NULL,
'tab_name' => 'Libs & Helpers',
'db' => [
'type' => 'TINYINT(1)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'add_site_event' => [
'name' => 'add_site_event',
'label' =>
'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_ADD_SITE_EVENT_LABEL',
'type' => 'radio',
'title' => false,
'list' => 'joomla_components',
'store' => NULL,
'tab_name' => 'Libs & Helpers',
'db' => [
'type' => 'TINYINT(1)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'add_menu_prefix' => [
'name' => 'add_menu_prefix',
'label' =>
'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_ADD_MENU_PREFIX_LABEL',
'type' => 'radio',
'title' => false,
'list' => 'joomla_components',
'store' => NULL,
'tab_name' => 'Settings',
'db' => [
'type' => 'CHAR(1)',
'default' => '',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'add_javascript' => [
'name' => 'add_javascript',
'label' =>
'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_ADD_JAVASCRIPT_LABEL',
'type' => 'radio',
'title' => false,
'list' => 'joomla_components',
'store' => NULL,
'tab_name' => 'Libs & Helpers',
'db' => [
'type' => 'TINYINT(1)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'menu_prefix' => [
'name' => 'menu_prefix',
'label' =>
'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_MENU_PREFIX_LABEL',
'type' => 'text',
'title' => false,
'list' => 'joomla_components',
'store' => NULL,
'tab_name' => 'Settings',
'db' => [
'type' => 'VARCHAR(100)',
'default' => '',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'add_css_admin' => [
'name' => 'add_css_admin',
'label' =>
'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_ADD_CSS_ADMIN_LABEL',
'type' => 'radio',
'title' => false,
'list' => 'joomla_components',
'store' => NULL,
'tab_name' => 'Libs & Helpers',
'db' => [
'type' => 'TINYINT(1)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'add_css_site' => [
'name' => 'add_css_site',
'label' =>
'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_ADD_CSS_SITE_LABEL',
'type' => 'radio',
'title' => false,
'list' => 'joomla_components',
'store' => NULL,
'tab_name' => 'Libs & Helpers',
'db' => [
'type' => 'TINYINT(1)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'dashboard_type' => [
'name' => 'dashboard_type',
'label' =>
'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_DASHBOARD_TYPE_LABEL',
'type' => 'radio',
'title' => false,
'list' => 'joomla_components',
'store' => NULL,
'tab_name' => 'Dash & Install',
'db' => [
'type' => 'TINYINT(1)',
'default' => '1',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'toignore' => [
'name' => 'toignore',
'label' =>
'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_TOIGNORE_LABEL',
'type' => 'text',
'title' => false,
'list' => 'joomla_components',
'store' => NULL,
'tab_name' => 'Settings',
'db' => [
'type' => 'TEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'dashboard' => [
'name' => 'dashboard',
'label' =>
'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_DASHBOARD_LABEL',
'type' => 'dynamicdashboard',
'title' => false,
'list' => 'joomla_components',
'store' => NULL,
'tab_name' => 'Dash & Install',
'db' => [
'type' => 'VARCHAR(64)',
'default' => '',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'add_php_preflight_install' => [
'name' => 'add_php_preflight_install',
'label' =>
'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_ADD_PHP_PREFLIGHT_INSTALL_LABEL',
'type' => 'radio',
'title' => false,
'list' => 'joomla_components',
'store' => NULL,
'tab_name' => 'Dash & Install',
'db' => [
'type' => 'TINYINT(1)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'add_php_preflight_update' => [
'name' => 'add_php_preflight_update',
'label' =>
'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_ADD_PHP_PREFLIGHT_UPDATE_LABEL',
'type' => 'radio',
'title' => false,
'list' => 'joomla_components',
'store' => NULL,
'tab_name' => 'Dash & Install',
'db' => [
'type' => 'TINYINT(1)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'export_key' => [
'name' => 'export_key',
'label' =>
'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_EXPORT_KEY_LABEL',
'type' => 'text',
'title' => false,
'list' => 'joomla_components',
'store' => 'basic_encryption',
'tab_name' => 'Settings',
'db' => [
'type' => 'TEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'add_php_postflight_install' => [
'name' => 'add_php_postflight_install',
'label' =>
'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_ADD_PHP_POSTFLIGHT_INSTALL_LABEL',
'type' => 'radio',
'title' => false,
'list' => 'joomla_components',
'store' => NULL,
'tab_name' => 'Dash & Install',
'db' => [
'type' => 'TINYINT(1)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'joomla_source_link' => [
'name' => 'joomla_source_link',
'label' =>
'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_JOOMLA_SOURCE_LINK_LABEL',
'type' => 'url',
'title' => false,
'list' => 'joomla_components',
'store' => NULL,
'tab_name' => 'Settings',
'db' => [
'type' => 'VARCHAR(255)',
'default' => '',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'add_php_postflight_update' => [
'name' => 'add_php_postflight_update',
'label' =>
'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_ADD_PHP_POSTFLIGHT_UPDATE_LABEL',
'type' => 'radio',
'title' => false,
'list' => 'joomla_components',
'store' => NULL,
'tab_name' => 'Dash & Install',
'db' => [
'type' => 'TINYINT(1)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'export_buy_link' => [
'name' => 'export_buy_link',
'label' =>
'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_EXPORT_BUY_LINK_LABEL',
'type' => 'url',
'title' => false,
'list' => 'joomla_components',
'store' => NULL,
'tab_name' => 'Settings',
'db' => [
'type' => 'VARCHAR(255)',
'default' => '',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'add_php_method_uninstall' => [
'name' => 'add_php_method_uninstall',
'label' =>
'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_ADD_PHP_METHOD_UNINSTALL_LABEL',
'type' => 'radio',
'title' => false,
'list' => 'joomla_components',
'store' => NULL,
'tab_name' => 'Dash & Install',
'db' => [
'type' => 'TINYINT(1)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'add_php_method_install' => [
'name' => 'add_php_method_install',
'label' =>
'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_ADD_PHP_METHOD_INSTALL_LABEL',
'type' => 'radio',
'title' => false,
'list' => 'joomla_components',
'store' => NULL,
'tab_name' => 'Dash & Install',
'db' => [
'type' => 'TINYINT(1)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'add_sql' => [
'name' => 'add_sql',
'label' =>
'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_ADD_SQL_LABEL',
'type' => 'radio',
'title' => false,
'list' => 'joomla_components',
'store' => NULL,
'tab_name' => 'MySQL',
'db' => [
'type' => 'TINYINT(1)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'addcontributors' => [
'name' => 'addcontributors',
'label' =>
'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_ADDCONTRIBUTORS_LABEL',
'type' => 'subform',
'title' => false,
'list' => 'joomla_components',
'store' => 'json',
'tab_name' => 'Settings',
'db' => [
'type' => 'TEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'add_sql_uninstall' => [
'name' => 'add_sql_uninstall',
'label' =>
'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_ADD_SQL_UNINSTALL_LABEL',
'type' => 'radio',
'title' => false,
'list' => 'joomla_components',
'store' => NULL,
'tab_name' => 'MySQL',
'db' => [
'type' => 'TINYINT(1)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'emptycontributors' => [
'name' => 'emptycontributors',
'label' =>
'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_EMPTYCONTRIBUTORS_LABEL',
'type' => 'radio',
'title' => false,
'list' => 'joomla_components',
'store' => NULL,
'tab_name' => 'Settings',
'db' => [
'type' => 'TINYINT(1)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'assets_table_fix' => [
'name' => 'assets_table_fix',
'label' =>
'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_ASSETS_TABLE_FIX_LABEL',
'type' => 'list',
'title' => false,
'list' => 'joomla_components',
'store' => NULL,
'tab_name' => 'MySQL',
'db' => [
'type' => 'TINYINT(1)',
'default' => '3',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'number' => [
'name' => 'number',
'label' =>
'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_NUMBER_LABEL',
'type' => 'number',
'title' => false,
'list' => 'joomla_components',
'store' => NULL,
'tab_name' => 'Settings',
'db' => [
'type' => 'INT(11)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'readme' => [
'name' => 'readme',
'label' =>
'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_README_LABEL',
'type' => 'editor',
'title' => false,
'list' => 'joomla_components',
'store' => 'base64',
'tab_name' => 'Readme',
'db' => [
'type' => 'TEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'add_update_server' => [
'name' => 'add_update_server',
'label' =>
'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_ADD_UPDATE_SERVER_LABEL',
'type' => 'radio',
'title' => false,
'list' => 'joomla_components',
'store' => NULL,
'tab_name' => 'Dynamic Integration',
'db' => [
'type' => 'TINYINT(1)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'update_server_target' => [
'name' => 'update_server_target',
'label' =>
'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_UPDATE_SERVER_TARGET_LABEL',
'type' => 'radio',
'title' => false,
'list' => 'joomla_components',
'store' => NULL,
'tab_name' => 'Dynamic Integration',
'db' => [
'type' => 'TINYINT(1)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'update_server' => [
'name' => 'update_server',
'label' =>
'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_UPDATE_SERVER_LABEL',
'type' => 'servers',
'title' => false,
'list' => 'joomla_components',
'store' => NULL,
'tab_name' => 'Dynamic Integration',
'db' => [
'type' => 'INT(11)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'sales_server' => [
'name' => 'sales_server',
'label' =>
'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_SALES_SERVER_LABEL',
'type' => 'servers',
'title' => false,
'list' => 'joomla_components',
'store' => NULL,
'tab_name' => 'Dynamic Integration',
'db' => [
'type' => 'INT(11)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'creatuserhelper' => [
'name' => 'creatuserhelper',
'label' =>
'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_CREATUSERHELPER_LABEL',
'type' => 'radio',
'title' => false,
'list' => 'joomla_components',
'store' => NULL,
'tab_name' => 'Libs & Helpers',
'db' => [
'type' => 'TINYINT(1)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'add_git_folder_path' => [
'name' => 'add_git_folder_path',
'label' =>
'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_ADD_GIT_FOLDER_PATH_LABEL',
'type' => 'radio',
'title' => false,
'list' => 'joomla_components',
'store' => NULL,
'tab_name' => 'Dynamic Integration',
'db' => [
'type' => 'TINYINT(1)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'adduikit' => [
'name' => 'adduikit',
'label' =>
'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_ADDUIKIT_LABEL',
'type' => 'list',
'title' => false,
'list' => 'joomla_components',
'store' => NULL,
'tab_name' => 'Libs & Helpers',
'db' => [
'type' => 'TINYINT(1)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'git_folder_path' => [
'name' => 'git_folder_path',
'label' =>
'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_GIT_FOLDER_PATH_LABEL',
'type' => 'text',
'title' => false,
'list' => 'joomla_components',
'store' => NULL,
'tab_name' => 'Dynamic Integration',
'db' => [
'type' => 'VARCHAR(255)',
'default' => '',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'addfootable' => [
'name' => 'addfootable',
'label' =>
'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_ADDFOOTABLE_LABEL',
'type' => 'list',
'title' => false,
'list' => 'joomla_components',
'store' => NULL,
'tab_name' => 'Libs & Helpers',
'db' => [
'type' => 'TINYINT(1)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'jcb_powers_path' => [
'name' => 'jcb_powers_path',
'label' =>
'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_JCB_POWERS_PATH_LABEL',
'type' => 'text',
'title' => false,
'list' => 'joomla_components',
'store' => NULL,
'tab_name' => 'Dynamic Integration',
'db' => [
'type' => 'VARCHAR(255)',
'default' => '',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'add_email_helper' => [
'name' => 'add_email_helper',
'label' =>
'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_ADD_EMAIL_HELPER_LABEL',
'type' => 'radio',
'title' => false,
'list' => 'joomla_components',
'store' => NULL,
'tab_name' => 'Libs & Helpers',
'db' => [
'type' => 'TINYINT(1)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'add_php_helper_both' => [
'name' => 'add_php_helper_both',
'label' =>
'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_ADD_PHP_HELPER_BOTH_LABEL',
'type' => 'radio',
'title' => false,
'list' => 'joomla_components',
'store' => NULL,
'tab_name' => 'Libs & Helpers',
'db' => [
'type' => 'TINYINT(1)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'crowdin_project_api_key' => [
'name' => 'crowdin_project_api_key',
'label' =>
'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_CROWDIN_PROJECT_API_KEY_LABEL',
'type' => 'text',
'title' => false,
'list' => 'joomla_components',
'store' => 'basic_encryption',
'tab_name' => 'Dynamic Integration',
'db' => [
'type' => 'TEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'php_helper_both' => [
'name' => 'php_helper_both',
'label' =>
'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_PHP_HELPER_BOTH_LABEL',
'type' => 'editor',
'title' => false,
'list' => 'joomla_components',
'store' => 'base64',
'tab_name' => 'Libs & Helpers',
'db' => [
'type' => 'MEDIUMTEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'crowdin_account_api_key' => [
'name' => 'crowdin_account_api_key',
'label' =>
'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_CROWDIN_ACCOUNT_API_KEY_LABEL',
'type' => 'text',
'title' => false,
'list' => 'joomla_components',
'store' => 'basic_encryption',
'tab_name' => 'Dynamic Integration',
'db' => [
'type' => 'TEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'add_php_helper_admin' => [
'name' => 'add_php_helper_admin',
'label' =>
'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_ADD_PHP_HELPER_ADMIN_LABEL',
'type' => 'radio',
'title' => false,
'list' => 'joomla_components',
'store' => NULL,
'tab_name' => 'Libs & Helpers',
'db' => [
'type' => 'TINYINT(1)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'buildcomp' => [
'name' => 'buildcomp',
'label' =>
'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_BUILDCOMP_LABEL',
'type' => 'radio',
'title' => false,
'list' => 'joomla_components',
'store' => NULL,
'tab_name' => 'Dynamic Build',
'db' => [
'type' => 'TINYINT(1)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'php_helper_admin' => [
'name' => 'php_helper_admin',
'label' =>
'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_PHP_HELPER_ADMIN_LABEL',
'type' => 'editor',
'title' => false,
'list' => 'joomla_components',
'store' => 'base64',
'tab_name' => 'Libs & Helpers',
'db' => [
'type' => 'MEDIUMTEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'guid' => [
'name' => 'guid',
'label' =>
'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_GUID_LABEL',
'type' => 'text',
'title' => false,
'list' => 'joomla_components',
'store' => NULL,
'tab_name' => 'publishing',
'db' => [
'type' => 'VARCHAR(36)',
'default' => '',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'add_admin_event' => [
'name' => 'add_admin_event',
'label' =>
'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_ADD_ADMIN_EVENT_LABEL',
'type' => 'radio',
'title' => false,
'list' => 'joomla_components',
'store' => NULL,
'tab_name' => 'Libs & Helpers',
'db' => [
'type' => 'TINYINT(1)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'modified' => [
'name' => 'modified',
'label' =>
'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_MODIFIED_LABEL',
'type' => 'calendar',
'title' => false,
'list' => 'joomla_components',
'store' => NULL,
'tab_name' => 'publishing',
'db' => [
'type' => 'DATETIME',
'default' => '0000-00-00 00:00:00',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'name' => [
'name' => 'name',
'label' =>
'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_NAME_LABEL',
'type' => 'text',
'title' => false,
'list' => 'joomla_components',
'store' => NULL,
'tab_name' => 'Details',
'db' => [
'type' => 'CHAR(64)',
'default' => '',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'access' => [
'name' => 'access',
'label' => 'Access',
'type' => 'accesslevel',
'title' => false,
'store' => NULL,
'tab_name' => NULL,
'db' => [
'type' => 'INT(10) unsigned',
'default' => '0',
'key' => true,
'null_switch' => 'NULL',
],
],
'metakey' => [
'name' => 'metakey',
'label' => 'Meta Keywords',
'type' => 'textarea',
'title' => false,
'store' => NULL,
'tab_name' => 'publishing',
'db' => [
'type' => 'TEXT',
],
],
'metadesc' => [
'name' => 'metadesc',
'label' => 'Meta Description',
'type' => 'textarea',
'title' => false,
'store' => NULL,
'tab_name' => 'publishing',
'db' => [
'type' => 'TEXT',
],
],
'metadata' => [
'name' => 'metadata',
'label' => 'Meta Data',
'type' => NULL,
'title' => false,
'store' => 'json',
'tab_name' => 'publishing',
'db' => [
'type' => 'TEXT',
],
],
],
'joomla_module' => [
'system_name' => [
'name' => 'system_name',
'label' =>
'COM_COMPONENTBUILDER_JOOMLA_MODULE_SYSTEM_NAME_LABEL',
'type' => 'text',
'title' => true,
'list' => 'joomla_modules',
'store' => NULL,
'tab_name' => 'HTML',
'db' => [
'type' => 'VARCHAR(255)',
'default' => '',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'target' => [
'name' => 'target',
'label' =>
'COM_COMPONENTBUILDER_JOOMLA_MODULE_TARGET_LABEL',
'type' => 'radio',
'title' => false,
'list' => 'joomla_modules',
'store' => NULL,
'tab_name' => 'HTML',
'db' => [
'type' => 'TINYINT(1)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'description' => [
'name' => 'description',
'label' =>
'COM_COMPONENTBUILDER_JOOMLA_MODULE_DESCRIPTION_LABEL',
'type' => 'textarea',
'title' => false,
'list' => 'joomla_modules',
'store' => NULL,
'tab_name' => 'HTML',
'db' => [
'type' => 'TEXT',
'default' => 'EMPTY',
'null_switch' => 'NULL',
'unique_key' => false,
'key' => false,
],
],
'add_php_method_uninstall' => [
'name' => 'add_php_method_uninstall',
'label' =>
'COM_COMPONENTBUILDER_JOOMLA_MODULE_ADD_PHP_METHOD_UNINSTALL_LABEL',
'type' => 'radio',
'title' => false,
'list' => 'joomla_modules',
'store' => NULL,
'tab_name' => 'Script File',
'db' => [
'type' => 'TINYINT(1)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'add_php_postflight_update' => [
'name' => 'add_php_postflight_update',
'label' =>
'COM_COMPONENTBUILDER_JOOMLA_MODULE_ADD_PHP_POSTFLIGHT_UPDATE_LABEL',
'type' => 'radio',
'title' => false,
'list' => 'joomla_modules',
'store' => NULL,
'tab_name' => 'Script File',
'db' => [
'type' => 'TINYINT(1)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'add_php_postflight_install' => [
'name' => 'add_php_postflight_install',
'label' =>
'COM_COMPONENTBUILDER_JOOMLA_MODULE_ADD_PHP_POSTFLIGHT_INSTALL_LABEL',
'type' => 'radio',
'title' => false,
'list' => 'joomla_modules',
'store' => NULL,
'tab_name' => 'Script File',
'db' => [
'type' => 'TINYINT(1)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'add_php_preflight_uninstall' => [
'name' => 'add_php_preflight_uninstall',
'label' =>
'COM_COMPONENTBUILDER_JOOMLA_MODULE_ADD_PHP_PREFLIGHT_UNINSTALL_LABEL',
'type' => 'radio',
'title' => false,
'list' => 'joomla_modules',
'store' => NULL,
'tab_name' => 'Script File',
'db' => [
'type' => 'TINYINT(1)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'addreadme' => [
'name' => 'addreadme',
'label' =>
'COM_COMPONENTBUILDER_JOOMLA_MODULE_ADDREADME_LABEL',
'type' => 'radio',
'title' => false,
'list' => 'joomla_modules',
'store' => NULL,
'tab_name' => 'Readme',
'db' => [
'type' => 'TINYINT(1)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'default' => [
'name' => 'default',
'label' =>
'COM_COMPONENTBUILDER_JOOMLA_MODULE_DEFAULT_LABEL',
'type' => 'editor',
'title' => false,
'list' => 'joomla_modules',
'store' => 'base64',
'tab_name' => 'HTML',
'db' => [
'type' => 'MEDIUMTEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'snippet' => [
'name' => 'snippet',
'label' =>
'COM_COMPONENTBUILDER_JOOMLA_MODULE_SNIPPET_LABEL',
'type' => 'snippets',
'title' => false,
'list' => 'joomla_modules',
'store' => NULL,
'tab_name' => 'HTML',
'db' => [
'type' => 'INT(11)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'add_sql' => [
'name' => 'add_sql',
'label' =>
'COM_COMPONENTBUILDER_JOOMLA_MODULE_ADD_SQL_LABEL',
'type' => 'radio',
'title' => false,
'list' => 'joomla_modules',
'store' => NULL,
'tab_name' => 'MySQL',
'db' => [
'type' => 'TINYINT(1)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'update_server_target' => [
'name' => 'update_server_target',
'label' =>
'COM_COMPONENTBUILDER_JOOMLA_MODULE_UPDATE_SERVER_TARGET_LABEL',
'type' => 'radio',
'title' => false,
'list' => 'joomla_modules',
'store' => NULL,
'tab_name' => 'Dynamic Integration',
'db' => [
'type' => 'TINYINT(1)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'add_sql_uninstall' => [
'name' => 'add_sql_uninstall',
'label' =>
'COM_COMPONENTBUILDER_JOOMLA_MODULE_ADD_SQL_UNINSTALL_LABEL',
'type' => 'radio',
'title' => false,
'list' => 'joomla_modules',
'store' => NULL,
'tab_name' => 'MySQL',
'db' => [
'type' => 'TINYINT(1)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'update_server' => [
'name' => 'update_server',
'label' =>
'COM_COMPONENTBUILDER_JOOMLA_MODULE_UPDATE_SERVER_LABEL',
'type' => 'servers',
'title' => false,
'list' => 'joomla_modules',
'store' => NULL,
'tab_name' => 'Dynamic Integration',
'db' => [
'type' => 'INT(11)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'add_update_server' => [
'name' => 'add_update_server',
'label' =>
'COM_COMPONENTBUILDER_JOOMLA_MODULE_ADD_UPDATE_SERVER_LABEL',
'type' => 'radio',
'title' => false,
'list' => 'joomla_modules',
'store' => NULL,
'tab_name' => 'Dynamic Integration',
'db' => [
'type' => 'TINYINT(1)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'libraries' => [
'name' => 'libraries',
'label' =>
'COM_COMPONENTBUILDER_JOOMLA_MODULE_LIBRARIES_LABEL',
'type' => 'libraries',
'title' => false,
'list' => 'joomla_modules',
'store' => 'json',
'tab_name' => 'HTML',
'db' => [
'type' => 'TEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'module_version' => [
'name' => 'module_version',
'label' =>
'COM_COMPONENTBUILDER_JOOMLA_MODULE_MODULE_VERSION_LABEL',
'type' => 'text',
'title' => false,
'list' => 'joomla_modules',
'store' => NULL,
'tab_name' => 'HTML',
'db' => [
'type' => 'CHAR(64)',
'default' => '',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'sales_server' => [
'name' => 'sales_server',
'label' =>
'COM_COMPONENTBUILDER_JOOMLA_MODULE_SALES_SERVER_LABEL',
'type' => 'servers',
'title' => false,
'list' => 'joomla_modules',
'store' => NULL,
'tab_name' => 'Dynamic Integration',
'db' => [
'type' => 'INT(11)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'custom_get' => [
'name' => 'custom_get',
'label' =>
'COM_COMPONENTBUILDER_JOOMLA_MODULE_CUSTOM_GET_LABEL',
'type' => 'customgets',
'title' => false,
'list' => 'joomla_modules',
'store' => 'json',
'tab_name' => 'Code',
'db' => [
'type' => 'TEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'php_preflight_update' => [
'name' => 'php_preflight_update',
'label' =>
'COM_COMPONENTBUILDER_JOOMLA_MODULE_PHP_PREFLIGHT_UPDATE_LABEL',
'type' => 'editor',
'title' => false,
'list' => 'joomla_modules',
'store' => 'base64',
'tab_name' => 'Script File',
'db' => [
'type' => 'MEDIUMTEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'php_preflight_uninstall' => [
'name' => 'php_preflight_uninstall',
'label' =>
'COM_COMPONENTBUILDER_JOOMLA_MODULE_PHP_PREFLIGHT_UNINSTALL_LABEL',
'type' => 'editor',
'title' => false,
'list' => 'joomla_modules',
'store' => 'base64',
'tab_name' => 'Script File',
'db' => [
'type' => 'MEDIUMTEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'mod_code' => [
'name' => 'mod_code',
'label' =>
'COM_COMPONENTBUILDER_JOOMLA_MODULE_MOD_CODE_LABEL',
'type' => 'editor',
'title' => false,
'list' => 'joomla_modules',
'store' => 'base64',
'tab_name' => 'Code',
'db' => [
'type' => 'TEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'php_postflight_install' => [
'name' => 'php_postflight_install',
'label' =>
'COM_COMPONENTBUILDER_JOOMLA_MODULE_PHP_POSTFLIGHT_INSTALL_LABEL',
'type' => 'editor',
'title' => false,
'list' => 'joomla_modules',
'store' => 'base64',
'tab_name' => 'Script File',
'db' => [
'type' => 'MEDIUMTEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'add_class_helper' => [
'name' => 'add_class_helper',
'label' =>
'COM_COMPONENTBUILDER_JOOMLA_MODULE_ADD_CLASS_HELPER_LABEL',
'type' => 'list',
'title' => false,
'list' => 'joomla_modules',
'store' => NULL,
'tab_name' => 'Helper',
'db' => [
'type' => 'TINYINT(1)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'php_postflight_update' => [
'name' => 'php_postflight_update',
'label' =>
'COM_COMPONENTBUILDER_JOOMLA_MODULE_PHP_POSTFLIGHT_UPDATE_LABEL',
'type' => 'editor',
'title' => false,
'list' => 'joomla_modules',
'store' => 'base64',
'tab_name' => 'Script File',
'db' => [
'type' => 'MEDIUMTEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'add_class_helper_header' => [
'name' => 'add_class_helper_header',
'label' =>
'COM_COMPONENTBUILDER_JOOMLA_MODULE_ADD_CLASS_HELPER_HEADER_LABEL',
'type' => 'radio',
'title' => false,
'list' => 'joomla_modules',
'store' => NULL,
'tab_name' => 'Helper',
'db' => [
'type' => 'TINYINT(1)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'php_method_uninstall' => [
'name' => 'php_method_uninstall',
'label' =>
'COM_COMPONENTBUILDER_JOOMLA_MODULE_PHP_METHOD_UNINSTALL_LABEL',
'type' => 'editor',
'title' => false,
'list' => 'joomla_modules',
'store' => 'base64',
'tab_name' => 'Script File',
'db' => [
'type' => 'MEDIUMTEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'class_helper_header' => [
'name' => 'class_helper_header',
'label' =>
'COM_COMPONENTBUILDER_JOOMLA_MODULE_CLASS_HELPER_HEADER_LABEL',
'type' => 'editor',
'title' => false,
'list' => 'joomla_modules',
'store' => 'base64',
'tab_name' => 'Helper',
'db' => [
'type' => 'TEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'sql' => [
'name' => 'sql',
'label' =>
'COM_COMPONENTBUILDER_JOOMLA_MODULE_SQL_LABEL',
'type' => 'textarea',
'title' => false,
'list' => 'joomla_modules',
'store' => 'base64',
'tab_name' => 'MySQL',
'db' => [
'type' => 'MEDIUMTEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'class_helper_code' => [
'name' => 'class_helper_code',
'label' =>
'COM_COMPONENTBUILDER_JOOMLA_MODULE_CLASS_HELPER_CODE_LABEL',
'type' => 'editor',
'title' => false,
'list' => 'joomla_modules',
'store' => 'base64',
'tab_name' => 'Helper',
'db' => [
'type' => 'MEDIUMTEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'sql_uninstall' => [
'name' => 'sql_uninstall',
'label' =>
'COM_COMPONENTBUILDER_JOOMLA_MODULE_SQL_UNINSTALL_LABEL',
'type' => 'textarea',
'title' => false,
'list' => 'joomla_modules',
'store' => 'base64',
'tab_name' => 'MySQL',
'db' => [
'type' => 'MEDIUMTEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'fields' => [
'name' => 'fields',
'label' =>
'COM_COMPONENTBUILDER_JOOMLA_MODULE_FIELDS_LABEL',
'type' => 'subform',
'title' => false,
'list' => 'joomla_modules',
'store' => 'json',
'tab_name' => 'Forms & Fields',
'db' => [
'type' => 'TEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'readme' => [
'name' => 'readme',
'label' =>
'COM_COMPONENTBUILDER_JOOMLA_MODULE_README_LABEL',
'type' => 'editor',
'title' => false,
'list' => 'joomla_modules',
'store' => 'base64',
'tab_name' => 'Readme',
'db' => [
'type' => 'TEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'add_php_script_construct' => [
'name' => 'add_php_script_construct',
'label' =>
'COM_COMPONENTBUILDER_JOOMLA_MODULE_ADD_PHP_SCRIPT_CONSTRUCT_LABEL',
'type' => 'radio',
'title' => false,
'list' => 'joomla_modules',
'store' => NULL,
'tab_name' => 'Script File',
'db' => [
'type' => 'TINYINT(1)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'update_server_url' => [
'name' => 'update_server_url',
'label' =>
'COM_COMPONENTBUILDER_JOOMLA_MODULE_UPDATE_SERVER_URL_LABEL',
'type' => 'url',
'title' => false,
'list' => 'joomla_modules',
'store' => NULL,
'tab_name' => 'Dynamic Integration',
'db' => [
'type' => 'VARCHAR(255)',
'default' => '',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'php_script_construct' => [
'name' => 'php_script_construct',
'label' =>
'COM_COMPONENTBUILDER_JOOMLA_MODULE_PHP_SCRIPT_CONSTRUCT_LABEL',
'type' => 'editor',
'title' => false,
'list' => 'joomla_modules',
'store' => 'base64',
'tab_name' => 'Script File',
'db' => [
'type' => 'MEDIUMTEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'add_php_preflight_install' => [
'name' => 'add_php_preflight_install',
'label' =>
'COM_COMPONENTBUILDER_JOOMLA_MODULE_ADD_PHP_PREFLIGHT_INSTALL_LABEL',
'type' => 'radio',
'title' => false,
'list' => 'joomla_modules',
'store' => NULL,
'tab_name' => 'Script File',
'db' => [
'type' => 'TINYINT(1)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'php_preflight_install' => [
'name' => 'php_preflight_install',
'label' =>
'COM_COMPONENTBUILDER_JOOMLA_MODULE_PHP_PREFLIGHT_INSTALL_LABEL',
'type' => 'editor',
'title' => false,
'list' => 'joomla_modules',
'store' => 'base64',
'tab_name' => 'Script File',
'db' => [
'type' => 'MEDIUMTEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'add_sales_server' => [
'name' => 'add_sales_server',
'label' =>
'COM_COMPONENTBUILDER_JOOMLA_MODULE_ADD_SALES_SERVER_LABEL',
'type' => 'radio',
'title' => false,
'list' => 'joomla_modules',
'store' => NULL,
'tab_name' => 'Dynamic Integration',
'db' => [
'type' => 'TINYINT(1)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'add_php_preflight_update' => [
'name' => 'add_php_preflight_update',
'label' =>
'COM_COMPONENTBUILDER_JOOMLA_MODULE_ADD_PHP_PREFLIGHT_UPDATE_LABEL',
'type' => 'radio',
'title' => false,
'list' => 'joomla_modules',
'store' => NULL,
'tab_name' => 'Script File',
'db' => [
'type' => 'TINYINT(1)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'guid' => [
'name' => 'guid',
'label' =>
'COM_COMPONENTBUILDER_JOOMLA_MODULE_GUID_LABEL',
'type' => 'text',
'title' => false,
'list' => 'joomla_modules',
'store' => NULL,
'tab_name' => 'publishing',
'db' => [
'type' => 'VARCHAR(36)',
'default' => '',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'name' => [
'name' => 'name',
'label' =>
'COM_COMPONENTBUILDER_JOOMLA_MODULE_NAME_LABEL',
'type' => 'text',
'title' => false,
'list' => 'joomla_modules',
'store' => NULL,
'tab_name' => 'HTML',
'db' => [
'type' => 'VARCHAR(255)',
'default' => '',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'access' => [
'name' => 'access',
'label' => 'Access',
'type' => 'accesslevel',
'title' => false,
'store' => NULL,
'tab_name' => NULL,
'db' => [
'type' => 'INT(10) unsigned',
'default' => '0',
'key' => true,
'null_switch' => 'NULL',
],
],
],
'joomla_plugin' => [
'system_name' => [
'name' => 'system_name',
'label' =>
'COM_COMPONENTBUILDER_JOOMLA_PLUGIN_SYSTEM_NAME_LABEL',
'type' => 'text',
'title' => true,
'list' => 'joomla_plugins',
'store' => NULL,
'tab_name' => 'Code',
'db' => [
'type' => 'VARCHAR(255)',
'default' => '',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'class_extends' => [
'name' => 'class_extends',
'label' =>
'COM_COMPONENTBUILDER_JOOMLA_PLUGIN_CLASS_EXTENDS_LABEL',
'type' => 'classextends',
'title' => false,
'list' => 'joomla_plugins',
'store' => NULL,
'tab_name' => 'Code',
'db' => [
'type' => 'INT(11)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'joomla_plugin_group' => [
'name' => 'joomla_plugin_group',
'label' =>
'COM_COMPONENTBUILDER_JOOMLA_PLUGIN_JOOMLA_PLUGIN_GROUP_LABEL',
'type' => 'joomlaplugingroups',
'title' => false,
'list' => 'joomla_plugins',
'store' => NULL,
'tab_name' => 'Code',
'db' => [
'type' => 'INT(11)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'add_sql' => [
'name' => 'add_sql',
'label' =>
'COM_COMPONENTBUILDER_JOOMLA_PLUGIN_ADD_SQL_LABEL',
'type' => 'radio',
'title' => false,
'list' => 'joomla_plugins',
'store' => NULL,
'tab_name' => 'MySQL',
'db' => [
'type' => 'TINYINT(1)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'add_php_method_uninstall' => [
'name' => 'add_php_method_uninstall',
'label' =>
'COM_COMPONENTBUILDER_JOOMLA_PLUGIN_ADD_PHP_METHOD_UNINSTALL_LABEL',
'type' => 'radio',
'title' => false,
'list' => 'joomla_plugins',
'store' => NULL,
'tab_name' => 'Script File',
'db' => [
'type' => 'TINYINT(1)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'add_php_postflight_update' => [
'name' => 'add_php_postflight_update',
'label' =>
'COM_COMPONENTBUILDER_JOOMLA_PLUGIN_ADD_PHP_POSTFLIGHT_UPDATE_LABEL',
'type' => 'radio',
'title' => false,
'list' => 'joomla_plugins',
'store' => NULL,
'tab_name' => 'Script File',
'db' => [
'type' => 'TINYINT(1)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'add_php_postflight_install' => [
'name' => 'add_php_postflight_install',
'label' =>
'COM_COMPONENTBUILDER_JOOMLA_PLUGIN_ADD_PHP_POSTFLIGHT_INSTALL_LABEL',
'type' => 'radio',
'title' => false,
'list' => 'joomla_plugins',
'store' => NULL,
'tab_name' => 'Script File',
'db' => [
'type' => 'TINYINT(1)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'sales_server' => [
'name' => 'sales_server',
'label' =>
'COM_COMPONENTBUILDER_JOOMLA_PLUGIN_SALES_SERVER_LABEL',
'type' => 'servers',
'title' => false,
'list' => 'joomla_plugins',
'store' => NULL,
'tab_name' => 'Dynamic Integration',
'db' => [
'type' => 'INT(11)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'add_update_server' => [
'name' => 'add_update_server',
'label' =>
'COM_COMPONENTBUILDER_JOOMLA_PLUGIN_ADD_UPDATE_SERVER_LABEL',
'type' => 'radio',
'title' => false,
'list' => 'joomla_plugins',
'store' => NULL,
'tab_name' => 'Dynamic Integration',
'db' => [
'type' => 'TINYINT(1)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'method_selection' => [
'name' => 'method_selection',
'label' =>
'COM_COMPONENTBUILDER_JOOMLA_PLUGIN_METHOD_SELECTION_LABEL',
'type' => 'subform',
'title' => false,
'list' => 'joomla_plugins',
'store' => 'json',
'tab_name' => 'Code',
'db' => [
'type' => 'TEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'property_selection' => [
'name' => 'property_selection',
'label' =>
'COM_COMPONENTBUILDER_JOOMLA_PLUGIN_PROPERTY_SELECTION_LABEL',
'type' => 'subform',
'title' => false,
'list' => 'joomla_plugins',
'store' => 'json',
'tab_name' => 'Code',
'db' => [
'type' => 'TEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'add_head' => [
'name' => 'add_head',
'label' =>
'COM_COMPONENTBUILDER_JOOMLA_PLUGIN_ADD_HEAD_LABEL',
'type' => 'radio',
'title' => false,
'list' => 'joomla_plugins',
'store' => NULL,
'tab_name' => 'Code',
'db' => [
'type' => 'TINYINT(1)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'add_sql_uninstall' => [
'name' => 'add_sql_uninstall',
'label' =>
'COM_COMPONENTBUILDER_JOOMLA_PLUGIN_ADD_SQL_UNINSTALL_LABEL',
'type' => 'radio',
'title' => false,
'list' => 'joomla_plugins',
'store' => NULL,
'tab_name' => 'MySQL',
'db' => [
'type' => 'TINYINT(1)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'addreadme' => [
'name' => 'addreadme',
'label' =>
'COM_COMPONENTBUILDER_JOOMLA_PLUGIN_ADDREADME_LABEL',
'type' => 'radio',
'title' => false,
'list' => 'joomla_plugins',
'store' => NULL,
'tab_name' => 'Readme',
'db' => [
'type' => 'TINYINT(1)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'head' => [
'name' => 'head',
'label' =>
'COM_COMPONENTBUILDER_JOOMLA_PLUGIN_HEAD_LABEL',
'type' => 'editor',
'title' => false,
'list' => 'joomla_plugins',
'store' => 'base64',
'tab_name' => 'Code',
'db' => [
'type' => 'TEXT',
'default' => 'EMPTY',
'null_switch' => 'NULL',
'unique_key' => false,
'key' => false,
],
],
'update_server_target' => [
'name' => 'update_server_target',
'label' =>
'COM_COMPONENTBUILDER_JOOMLA_PLUGIN_UPDATE_SERVER_TARGET_LABEL',
'type' => 'radio',
'title' => false,
'list' => 'joomla_plugins',
'store' => NULL,
'tab_name' => 'Dynamic Integration',
'db' => [
'type' => 'TINYINT(1)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'main_class_code' => [
'name' => 'main_class_code',
'label' =>
'COM_COMPONENTBUILDER_JOOMLA_PLUGIN_MAIN_CLASS_CODE_LABEL',
'type' => 'editor',
'title' => false,
'list' => 'joomla_plugins',
'store' => 'base64',
'tab_name' => 'Code',
'db' => [
'type' => 'MEDIUMTEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'update_server' => [
'name' => 'update_server',
'label' =>
'COM_COMPONENTBUILDER_JOOMLA_PLUGIN_UPDATE_SERVER_LABEL',
'type' => 'servers',
'title' => false,
'list' => 'joomla_plugins',
'store' => NULL,
'tab_name' => 'Dynamic Integration',
'db' => [
'type' => 'INT(11)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'description' => [
'name' => 'description',
'label' =>
'COM_COMPONENTBUILDER_JOOMLA_PLUGIN_DESCRIPTION_LABEL',
'type' => 'textarea',
'title' => false,
'list' => 'joomla_plugins',
'store' => NULL,
'tab_name' => 'Code',
'db' => [
'type' => 'TEXT',
'default' => 'EMPTY',
'null_switch' => 'NULL',
'unique_key' => false,
'key' => false,
],
],
'php_postflight_install' => [
'name' => 'php_postflight_install',
'label' =>
'COM_COMPONENTBUILDER_JOOMLA_PLUGIN_PHP_POSTFLIGHT_INSTALL_LABEL',
'type' => 'editor',
'title' => false,
'list' => 'joomla_plugins',
'store' => 'base64',
'tab_name' => 'Script File',
'db' => [
'type' => 'MEDIUMTEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'plugin_version' => [
'name' => 'plugin_version',
'label' =>
'COM_COMPONENTBUILDER_JOOMLA_PLUGIN_PLUGIN_VERSION_LABEL',
'type' => 'text',
'title' => false,
'list' => 'joomla_plugins',
'store' => NULL,
'tab_name' => 'Code',
'db' => [
'type' => 'CHAR(64)',
'default' => '',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'php_postflight_update' => [
'name' => 'php_postflight_update',
'label' =>
'COM_COMPONENTBUILDER_JOOMLA_PLUGIN_PHP_POSTFLIGHT_UPDATE_LABEL',
'type' => 'editor',
'title' => false,
'list' => 'joomla_plugins',
'store' => 'base64',
'tab_name' => 'Script File',
'db' => [
'type' => 'MEDIUMTEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'fields' => [
'name' => 'fields',
'label' =>
'COM_COMPONENTBUILDER_JOOMLA_PLUGIN_FIELDS_LABEL',
'type' => 'subform',
'title' => false,
'list' => 'joomla_plugins',
'store' => 'json',
'tab_name' => 'Forms & Fields',
'db' => [
'type' => 'TEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'php_method_uninstall' => [
'name' => 'php_method_uninstall',
'label' =>
'COM_COMPONENTBUILDER_JOOMLA_PLUGIN_PHP_METHOD_UNINSTALL_LABEL',
'type' => 'editor',
'title' => false,
'list' => 'joomla_plugins',
'store' => 'base64',
'tab_name' => 'Script File',
'db' => [
'type' => 'MEDIUMTEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'add_php_script_construct' => [
'name' => 'add_php_script_construct',
'label' =>
'COM_COMPONENTBUILDER_JOOMLA_PLUGIN_ADD_PHP_SCRIPT_CONSTRUCT_LABEL',
'type' => 'radio',
'title' => false,
'list' => 'joomla_plugins',
'store' => NULL,
'tab_name' => 'Script File',
'db' => [
'type' => 'TINYINT(1)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'sql' => [
'name' => 'sql',
'label' =>
'COM_COMPONENTBUILDER_JOOMLA_PLUGIN_SQL_LABEL',
'type' => 'textarea',
'title' => false,
'list' => 'joomla_plugins',
'store' => 'base64',
'tab_name' => 'MySQL',
'db' => [
'type' => 'MEDIUMTEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'php_script_construct' => [
'name' => 'php_script_construct',
'label' =>
'COM_COMPONENTBUILDER_JOOMLA_PLUGIN_PHP_SCRIPT_CONSTRUCT_LABEL',
'type' => 'editor',
'title' => false,
'list' => 'joomla_plugins',
'store' => 'base64',
'tab_name' => 'Script File',
'db' => [
'type' => 'MEDIUMTEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'sql_uninstall' => [
'name' => 'sql_uninstall',
'label' =>
'COM_COMPONENTBUILDER_JOOMLA_PLUGIN_SQL_UNINSTALL_LABEL',
'type' => 'textarea',
'title' => false,
'list' => 'joomla_plugins',
'store' => 'base64',
'tab_name' => 'MySQL',
'db' => [
'type' => 'MEDIUMTEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'add_php_preflight_install' => [
'name' => 'add_php_preflight_install',
'label' =>
'COM_COMPONENTBUILDER_JOOMLA_PLUGIN_ADD_PHP_PREFLIGHT_INSTALL_LABEL',
'type' => 'radio',
'title' => false,
'list' => 'joomla_plugins',
'store' => NULL,
'tab_name' => 'Script File',
'db' => [
'type' => 'TINYINT(1)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'readme' => [
'name' => 'readme',
'label' =>
'COM_COMPONENTBUILDER_JOOMLA_PLUGIN_README_LABEL',
'type' => 'editor',
'title' => false,
'list' => 'joomla_plugins',
'store' => 'base64',
'tab_name' => 'Readme',
'db' => [
'type' => 'TEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'php_preflight_install' => [
'name' => 'php_preflight_install',
'label' =>
'COM_COMPONENTBUILDER_JOOMLA_PLUGIN_PHP_PREFLIGHT_INSTALL_LABEL',
'type' => 'editor',
'title' => false,
'list' => 'joomla_plugins',
'store' => 'base64',
'tab_name' => 'Script File',
'db' => [
'type' => 'MEDIUMTEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'update_server_url' => [
'name' => 'update_server_url',
'label' =>
'COM_COMPONENTBUILDER_JOOMLA_PLUGIN_UPDATE_SERVER_URL_LABEL',
'type' => 'url',
'title' => false,
'list' => 'joomla_plugins',
'store' => NULL,
'tab_name' => 'Dynamic Integration',
'db' => [
'type' => 'VARCHAR(255)',
'default' => '',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'add_php_preflight_update' => [
'name' => 'add_php_preflight_update',
'label' =>
'COM_COMPONENTBUILDER_JOOMLA_PLUGIN_ADD_PHP_PREFLIGHT_UPDATE_LABEL',
'type' => 'radio',
'title' => false,
'list' => 'joomla_plugins',
'store' => NULL,
'tab_name' => 'Script File',
'db' => [
'type' => 'TINYINT(1)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'php_preflight_update' => [
'name' => 'php_preflight_update',
'label' =>
'COM_COMPONENTBUILDER_JOOMLA_PLUGIN_PHP_PREFLIGHT_UPDATE_LABEL',
'type' => 'editor',
'title' => false,
'list' => 'joomla_plugins',
'store' => 'base64',
'tab_name' => 'Script File',
'db' => [
'type' => 'MEDIUMTEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'add_php_preflight_uninstall' => [
'name' => 'add_php_preflight_uninstall',
'label' =>
'COM_COMPONENTBUILDER_JOOMLA_PLUGIN_ADD_PHP_PREFLIGHT_UNINSTALL_LABEL',
'type' => 'radio',
'title' => false,
'list' => 'joomla_plugins',
'store' => NULL,
'tab_name' => 'Script File',
'db' => [
'type' => 'TINYINT(1)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'add_sales_server' => [
'name' => 'add_sales_server',
'label' =>
'COM_COMPONENTBUILDER_JOOMLA_PLUGIN_ADD_SALES_SERVER_LABEL',
'type' => 'radio',
'title' => false,
'list' => 'joomla_plugins',
'store' => NULL,
'tab_name' => 'Dynamic Integration',
'db' => [
'type' => 'TINYINT(1)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'php_preflight_uninstall' => [
'name' => 'php_preflight_uninstall',
'label' =>
'COM_COMPONENTBUILDER_JOOMLA_PLUGIN_PHP_PREFLIGHT_UNINSTALL_LABEL',
'type' => 'editor',
'title' => false,
'list' => 'joomla_plugins',
'store' => 'base64',
'tab_name' => 'Script File',
'db' => [
'type' => 'MEDIUMTEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'guid' => [
'name' => 'guid',
'label' =>
'COM_COMPONENTBUILDER_JOOMLA_PLUGIN_GUID_LABEL',
'type' => 'text',
'title' => false,
'list' => 'joomla_plugins',
'store' => NULL,
'tab_name' => 'publishing',
'db' => [
'type' => 'VARCHAR(36)',
'default' => '',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'name' => [
'name' => 'name',
'label' =>
'COM_COMPONENTBUILDER_JOOMLA_PLUGIN_NAME_LABEL',
'type' => 'text',
'title' => false,
'list' => 'joomla_plugins',
'store' => NULL,
'tab_name' => 'Code',
'db' => [
'type' => 'VARCHAR(255)',
'default' => '',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'access' => [
'name' => 'access',
'label' => 'Access',
'type' => 'accesslevel',
'title' => false,
'store' => NULL,
'tab_name' => NULL,
'db' => [
'type' => 'INT(10) unsigned',
'default' => '0',
'key' => true,
'null_switch' => 'NULL',
],
],
],
'joomla_power' => [
'system_name' => [
'name' => 'system_name',
'label' =>
'COM_COMPONENTBUILDER_JOOMLA_POWER_SYSTEM_NAME_LABEL',
'type' => 'text',
'title' => true,
'list' => 'joomla_powers',
'store' => NULL,
'tab_name' => 'Joomla Power',
'db' => [
'type' => 'VARCHAR(255)',
'default' => '',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'settings' => [
'name' => 'settings',
'label' =>
'COM_COMPONENTBUILDER_JOOMLA_POWER_SETTINGS_LABEL',
'type' => 'subform',
'title' => false,
'list' => 'joomla_powers',
'store' => 'json',
'tab_name' => 'Joomla Power',
'db' => [
'type' => 'TEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'guid' => [
'name' => 'guid',
'label' =>
'COM_COMPONENTBUILDER_JOOMLA_POWER_GUID_LABEL',
'type' => 'text',
'title' => false,
'list' => 'joomla_powers',
'store' => NULL,
'tab_name' => 'publishing',
'db' => [
'type' => 'VARCHAR(36)',
'default' => '',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'description' => [
'name' => 'description',
'label' =>
'COM_COMPONENTBUILDER_JOOMLA_POWER_DESCRIPTION_LABEL',
'type' => 'textarea',
'title' => false,
'list' => 'joomla_powers',
'store' => NULL,
'tab_name' => 'Joomla Power',
'db' => [
'type' => 'TEXT',
'default' => 'EMPTY',
'null_switch' => 'NULL',
'unique_key' => false,
'key' => false,
],
],
'access' => [
'name' => 'access',
'label' => 'Access',
'type' => 'accesslevel',
'title' => false,
'store' => NULL,
'tab_name' => NULL,
'db' => [
'type' => 'INT(10) unsigned',
'default' => '0',
'key' => true,
'null_switch' => 'NULL',
],
],
],
'power' => [
'system_name' => [
'name' => 'system_name',
'label' =>
'COM_COMPONENTBUILDER_POWER_SYSTEM_NAME_LABEL',
'type' => 'text',
'title' => true,
'list' => 'powers',
'store' => NULL,
'tab_name' => 'Code',
'db' => [
'type' => 'VARCHAR(255)',
'default' => '',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'namespace' => [
'name' => 'namespace',
'label' =>
'COM_COMPONENTBUILDER_POWER_NAMESPACE_LABEL',
'type' => 'text',
'title' => false,
'list' => 'powers',
'store' => NULL,
'tab_name' => 'Code',
'db' => [
'type' => 'VARCHAR(255)',
'default' => '',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'type' => [
'name' => 'type',
'label' =>
'COM_COMPONENTBUILDER_POWER_TYPE_LABEL',
'type' => 'list',
'title' => false,
'list' => 'powers',
'store' => NULL,
'tab_name' => 'Code',
'db' => [
'type' => 'VARCHAR(64)',
'default' => '',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'power_version' => [
'name' => 'power_version',
'label' =>
'COM_COMPONENTBUILDER_POWER_POWER_VERSION_LABEL',
'type' => 'text',
'title' => false,
'list' => 'powers',
'store' => NULL,
'tab_name' => 'Code',
'db' => [
'type' => 'CHAR(64)',
'default' => '',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'load_selection' => [
'name' => 'load_selection',
'label' =>
'COM_COMPONENTBUILDER_POWER_LOAD_SELECTION_LABEL',
'type' => 'subform',
'title' => false,
'list' => 'powers',
'store' => 'json',
'tab_name' => 'Code',
'db' => [
'type' => 'TEXT',
'default' => 'EMPTY',
'null_switch' => 'NULL',
'unique_key' => false,
'key' => false,
],
],
'description' => [
'name' => 'description',
'label' =>
'COM_COMPONENTBUILDER_POWER_DESCRIPTION_LABEL',
'type' => 'textarea',
'title' => false,
'list' => 'powers',
'store' => NULL,
'tab_name' => 'Code',
'db' => [
'type' => 'TEXT',
'default' => 'EMPTY',
'null_switch' => 'NULL',
'unique_key' => false,
'key' => false,
],
],
'composer' => [
'name' => 'composer',
'label' =>
'COM_COMPONENTBUILDER_POWER_COMPOSER_LABEL',
'type' => 'subform',
'title' => false,
'list' => 'powers',
'store' => 'json',
'tab_name' => 'Composer',
'db' => [
'type' => 'TEXT',
'default' => 'EMPTY',
'null_switch' => 'NULL',
'unique_key' => false,
'key' => false,
],
],
'licensing_template' => [
'name' => 'licensing_template',
'label' =>
'COM_COMPONENTBUILDER_POWER_LICENSING_TEMPLATE_LABEL',
'type' => 'textarea',
'title' => false,
'list' => 'powers',
'store' => 'base64',
'tab_name' => 'Licensing',
'db' => [
'type' => 'TEXT',
'default' => 'EMPTY',
'null_switch' => 'NULL',
'unique_key' => false,
'key' => false,
],
],
'approved' => [
'name' => 'approved',
'label' =>
'COM_COMPONENTBUILDER_POWER_APPROVED_LABEL',
'type' => 'radio',
'title' => false,
'list' => 'powers',
'store' => NULL,
'tab_name' => 'Super Power',
'db' => [
'type' => 'TINYINT(1)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'extendsinterfaces_custom' => [
'name' => 'extendsinterfaces_custom',
'label' =>
'COM_COMPONENTBUILDER_POWER_EXTENDSINTERFACES_CUSTOM_LABEL',
'type' => 'text',
'title' => false,
'list' => 'powers',
'store' => NULL,
'tab_name' => 'Code',
'db' => [
'type' => 'TEXT',
'default' => 'EMPTY',
'null_switch' => 'NULL',
'unique_key' => false,
'key' => false,
],
],
'add_head' => [
'name' => 'add_head',
'label' =>
'COM_COMPONENTBUILDER_POWER_ADD_HEAD_LABEL',
'type' => 'radio',
'title' => false,
'list' => 'powers',
'store' => NULL,
'tab_name' => 'Code',
'db' => [
'type' => 'TINYINT(1)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'extends' => [
'name' => 'extends',
'label' =>
'COM_COMPONENTBUILDER_POWER_EXTENDS_LABEL',
'type' => 'classpowers',
'title' => false,
'list' => 'powers',
'store' => NULL,
'tab_name' => 'Code',
'db' => [
'type' => 'VARCHAR(36)',
'default' => '',
'null_switch' => 'NULL',
'unique_key' => false,
'key' => false,
],
],
'extends_custom' => [
'name' => 'extends_custom',
'label' =>
'COM_COMPONENTBUILDER_POWER_EXTENDS_CUSTOM_LABEL',
'type' => 'text',
'title' => false,
'list' => 'powers',
'store' => NULL,
'tab_name' => 'Code',
'db' => [
'type' => 'VARCHAR(64)',
'default' => '',
'null_switch' => 'NULL',
'unique_key' => false,
'key' => true,
],
],
'implements_custom' => [
'name' => 'implements_custom',
'label' =>
'COM_COMPONENTBUILDER_POWER_IMPLEMENTS_CUSTOM_LABEL',
'type' => 'text',
'title' => false,
'list' => 'powers',
'store' => NULL,
'tab_name' => 'Code',
'db' => [
'type' => 'VARCHAR(1024)',
'default' => '',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'implements' => [
'name' => 'implements',
'label' =>
'COM_COMPONENTBUILDER_POWER_IMPLEMENTS_LABEL',
'type' => 'interfacepowers',
'title' => false,
'list' => 'powers',
'store' => 'json',
'tab_name' => 'Code',
'db' => [
'type' => 'TEXT',
'default' => 'EMPTY',
'null_switch' => 'NULL',
'unique_key' => false,
'key' => false,
],
],
'property_selection' => [
'name' => 'property_selection',
'label' =>
'COM_COMPONENTBUILDER_POWER_PROPERTY_SELECTION_LABEL',
'type' => 'subform',
'title' => false,
'list' => 'powers',
'store' => 'json',
'tab_name' => 'Code',
'db' => [
'type' => 'TEXT',
'default' => 'EMPTY',
'null_switch' => 'NULL',
'unique_key' => false,
'key' => false,
],
],
'extendsinterfaces' => [
'name' => 'extendsinterfaces',
'label' =>
'COM_COMPONENTBUILDER_POWER_EXTENDSINTERFACES_LABEL',
'type' => 'interfacepowers',
'title' => false,
'list' => 'powers',
'store' => 'json',
'tab_name' => 'Code',
'db' => [
'type' => 'TEXT',
'default' => 'EMPTY',
'null_switch' => 'NULL',
'unique_key' => false,
'key' => false,
],
],
'method_selection' => [
'name' => 'method_selection',
'label' =>
'COM_COMPONENTBUILDER_POWER_METHOD_SELECTION_LABEL',
'type' => 'subform',
'title' => false,
'list' => 'powers',
'store' => 'json',
'tab_name' => 'Code',
'db' => [
'type' => 'TEXT',
'default' => 'EMPTY',
'null_switch' => 'NULL',
'unique_key' => false,
'key' => false,
],
],
'approved_paths' => [
'name' => 'approved_paths',
'label' =>
'COM_COMPONENTBUILDER_POWER_APPROVED_PATHS_LABEL',
'type' => 'superpowerpaths',
'title' => false,
'list' => 'powers',
'store' => 'json',
'tab_name' => 'Super Power',
'db' => [
'type' => 'TEXT',
'default' => 'EMPTY',
'null_switch' => 'NULL',
'unique_key' => false,
'key' => false,
],
],
'head' => [
'name' => 'head',
'label' =>
'COM_COMPONENTBUILDER_POWER_HEAD_LABEL',
'type' => 'editor',
'title' => false,
'list' => 'powers',
'store' => 'base64',
'tab_name' => 'Code',
'db' => [
'type' => 'TEXT',
'default' => 'EMPTY',
'null_switch' => 'NULL',
'unique_key' => false,
'key' => false,
],
],
'use_selection' => [
'name' => 'use_selection',
'label' =>
'COM_COMPONENTBUILDER_POWER_USE_SELECTION_LABEL',
'type' => 'subform',
'title' => false,
'list' => 'powers',
'store' => 'json',
'tab_name' => 'Code',
'db' => [
'type' => 'TEXT',
'default' => 'EMPTY',
'null_switch' => 'NULL',
'unique_key' => false,
'key' => false,
],
],
'add_licensing_template' => [
'name' => 'add_licensing_template',
'label' =>
'COM_COMPONENTBUILDER_POWER_ADD_LICENSING_TEMPLATE_LABEL',
'type' => 'radio',
'title' => false,
'list' => 'powers',
'store' => NULL,
'tab_name' => 'Licensing',
'db' => [
'type' => 'TINYINT(1)',
'default' => '1',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'main_class_code' => [
'name' => 'main_class_code',
'label' =>
'COM_COMPONENTBUILDER_POWER_MAIN_CLASS_CODE_LABEL',
'type' => 'editor',
'title' => false,
'list' => 'powers',
'store' => 'base64',
'tab_name' => 'Code',
'db' => [
'type' => 'MEDIUMTEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'guid' => [
'name' => 'guid',
'label' =>
'COM_COMPONENTBUILDER_POWER_GUID_LABEL',
'type' => 'text',
'title' => false,
'list' => 'powers',
'store' => NULL,
'tab_name' => 'publishing',
'db' => [
'type' => 'VARCHAR(36)',
'default' => '',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'name' => [
'name' => 'name',
'label' =>
'COM_COMPONENTBUILDER_POWER_NAME_LABEL',
'type' => 'text',
'title' => false,
'list' => 'powers',
'store' => NULL,
'tab_name' => 'Code',
'db' => [
'type' => 'VARCHAR(255)',
'default' => '',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'access' => [
'name' => 'access',
'label' => 'Access',
'type' => 'accesslevel',
'title' => false,
'store' => NULL,
'tab_name' => NULL,
'db' => [
'type' => 'INT(10) unsigned',
'default' => '0',
'key' => true,
'null_switch' => 'NULL',
],
],
],
'admin_view' => [
'system_name' => [
'name' => 'system_name',
'label' =>
'COM_COMPONENTBUILDER_ADMIN_VIEW_SYSTEM_NAME_LABEL',
'type' => 'text',
'title' => false,
'list' => 'admin_views',
'store' => NULL,
'tab_name' => 'Details',
'db' => [
'type' => 'VARCHAR(255)',
'default' => '',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'name_single' => [
'name' => 'name_single',
'label' =>
'COM_COMPONENTBUILDER_ADMIN_VIEW_NAME_SINGLE_LABEL',
'type' => 'text',
'title' => false,
'list' => 'admin_views',
'store' => NULL,
'tab_name' => 'Details',
'db' => [
'type' => 'CHAR(64)',
'default' => '',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'short_description' => [
'name' => 'short_description',
'label' =>
'COM_COMPONENTBUILDER_ADMIN_VIEW_SHORT_DESCRIPTION_LABEL',
'type' => 'text',
'title' => false,
'list' => 'admin_views',
'store' => NULL,
'tab_name' => 'Details',
'db' => [
'type' => 'VARCHAR(255)',
'default' => '',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'php_allowedit' => [
'name' => 'php_allowedit',
'label' =>
'COM_COMPONENTBUILDER_ADMIN_VIEW_PHP_ALLOWEDIT_LABEL',
'type' => 'editor',
'title' => false,
'list' => 'admin_views',
'store' => 'base64',
'tab_name' => 'PHP',
'db' => [
'type' => 'MEDIUMTEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'php_postsavehook' => [
'name' => 'php_postsavehook',
'label' =>
'COM_COMPONENTBUILDER_ADMIN_VIEW_PHP_POSTSAVEHOOK_LABEL',
'type' => 'editor',
'title' => false,
'list' => 'admin_views',
'store' => 'base64',
'tab_name' => 'PHP',
'db' => [
'type' => 'MEDIUMTEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'php_before_save' => [
'name' => 'php_before_save',
'label' =>
'COM_COMPONENTBUILDER_ADMIN_VIEW_PHP_BEFORE_SAVE_LABEL',
'type' => 'editor',
'title' => false,
'list' => 'admin_views',
'store' => 'base64',
'tab_name' => 'PHP',
'db' => [
'type' => 'MEDIUMTEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'php_getlistquery' => [
'name' => 'php_getlistquery',
'label' =>
'COM_COMPONENTBUILDER_ADMIN_VIEW_PHP_GETLISTQUERY_LABEL',
'type' => 'editor',
'title' => false,
'list' => 'admin_views',
'store' => 'base64',
'tab_name' => 'PHP',
'db' => [
'type' => 'MEDIUMTEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'php_import_ext' => [
'name' => 'php_import_ext',
'label' =>
'COM_COMPONENTBUILDER_ADMIN_VIEW_PHP_IMPORT_EXT_LABEL',
'type' => 'textarea',
'title' => false,
'list' => 'admin_views',
'store' => 'base64',
'tab_name' => 'Custom Import',
'db' => [
'type' => 'MEDIUMTEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'icon' => [
'name' => 'icon',
'label' =>
'COM_COMPONENTBUILDER_ADMIN_VIEW_ICON_LABEL',
'type' => 'media',
'title' => false,
'list' => 'admin_views',
'store' => NULL,
'tab_name' => 'Details',
'db' => [
'type' => 'VARCHAR(255)',
'default' => '',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'php_after_publish' => [
'name' => 'php_after_publish',
'label' =>
'COM_COMPONENTBUILDER_ADMIN_VIEW_PHP_AFTER_PUBLISH_LABEL',
'type' => 'editor',
'title' => false,
'list' => 'admin_views',
'store' => 'base64',
'tab_name' => 'PHP',
'db' => [
'type' => 'MEDIUMTEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'add_fadein' => [
'name' => 'add_fadein',
'label' =>
'COM_COMPONENTBUILDER_ADMIN_VIEW_ADD_FADEIN_LABEL',
'type' => 'radio',
'title' => false,
'list' => 'admin_views',
'store' => NULL,
'tab_name' => 'Details',
'db' => [
'type' => 'TINYINT(1)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'description' => [
'name' => 'description',
'label' =>
'COM_COMPONENTBUILDER_ADMIN_VIEW_DESCRIPTION_LABEL',
'type' => 'textarea',
'title' => false,
'list' => 'admin_views',
'store' => NULL,
'tab_name' => 'Details',
'db' => [
'type' => 'TEXT',
'default' => 'EMPTY',
'null_switch' => 'NULL',
'unique_key' => false,
'key' => false,
],
],
'icon_category' => [
'name' => 'icon_category',
'label' =>
'COM_COMPONENTBUILDER_ADMIN_VIEW_ICON_CATEGORY_LABEL',
'type' => 'media',
'title' => false,
'list' => 'admin_views',
'store' => NULL,
'tab_name' => 'Details',
'db' => [
'type' => 'VARCHAR(255)',
'default' => '',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'icon_add' => [
'name' => 'icon_add',
'label' =>
'COM_COMPONENTBUILDER_ADMIN_VIEW_ICON_ADD_LABEL',
'type' => 'media',
'title' => false,
'list' => 'admin_views',
'store' => NULL,
'tab_name' => 'Details',
'db' => [
'type' => 'VARCHAR(255)',
'default' => '',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'php_after_cancel' => [
'name' => 'php_after_cancel',
'label' =>
'COM_COMPONENTBUILDER_ADMIN_VIEW_PHP_AFTER_CANCEL_LABEL',
'type' => 'editor',
'title' => false,
'list' => 'admin_views',
'store' => 'base64',
'tab_name' => 'PHP',
'db' => [
'type' => 'MEDIUMTEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'mysql_table_charset' => [
'name' => 'mysql_table_charset',
'label' =>
'COM_COMPONENTBUILDER_ADMIN_VIEW_MYSQL_TABLE_CHARSET_LABEL',
'type' => 'list',
'title' => false,
'list' => 'admin_views',
'store' => NULL,
'tab_name' => 'MySQL',
'db' => [
'type' => 'VARCHAR(64)',
'default' => '1',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'php_batchmove' => [
'name' => 'php_batchmove',
'label' =>
'COM_COMPONENTBUILDER_ADMIN_VIEW_PHP_BATCHMOVE_LABEL',
'type' => 'editor',
'title' => false,
'list' => 'admin_views',
'store' => 'base64',
'tab_name' => 'PHP',
'db' => [
'type' => 'MEDIUMTEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'type' => [
'name' => 'type',
'label' =>
'COM_COMPONENTBUILDER_ADMIN_VIEW_TYPE_LABEL',
'type' => 'list',
'title' => false,
'list' => 'admin_views',
'store' => NULL,
'tab_name' => 'Details',
'db' => [
'type' => 'INT(11)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'php_after_delete' => [
'name' => 'php_after_delete',
'label' =>
'COM_COMPONENTBUILDER_ADMIN_VIEW_PHP_AFTER_DELETE_LABEL',
'type' => 'editor',
'title' => false,
'list' => 'admin_views',
'store' => 'base64',
'tab_name' => 'PHP',
'db' => [
'type' => 'MEDIUMTEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'source' => [
'name' => 'source',
'label' =>
'COM_COMPONENTBUILDER_ADMIN_VIEW_SOURCE_LABEL',
'type' => 'radio',
'title' => false,
'list' => 'admin_views',
'store' => NULL,
'tab_name' => 'MySQL',
'db' => [
'type' => 'TINYINT(1)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'php_import' => [
'name' => 'php_import',
'label' =>
'COM_COMPONENTBUILDER_ADMIN_VIEW_PHP_IMPORT_LABEL',
'type' => 'textarea',
'title' => false,
'list' => 'admin_views',
'store' => 'base64',
'tab_name' => 'Custom Import',
'db' => [
'type' => 'MEDIUMTEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'addpermissions' => [
'name' => 'addpermissions',
'label' =>
'COM_COMPONENTBUILDER_ADMIN_VIEW_ADDPERMISSIONS_LABEL',
'type' => 'subform',
'title' => false,
'list' => 'admin_views',
'store' => 'json',
'tab_name' => 'Settings',
'db' => [
'type' => 'TEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'php_getitems_after_all' => [
'name' => 'php_getitems_after_all',
'label' =>
'COM_COMPONENTBUILDER_ADMIN_VIEW_PHP_GETITEMS_AFTER_ALL_LABEL',
'type' => 'editor',
'title' => false,
'list' => 'admin_views',
'store' => 'base64',
'tab_name' => 'PHP',
'db' => [
'type' => 'MEDIUMTEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'php_getform' => [
'name' => 'php_getform',
'label' =>
'COM_COMPONENTBUILDER_ADMIN_VIEW_PHP_GETFORM_LABEL',
'type' => 'editor',
'title' => false,
'list' => 'admin_views',
'store' => 'base64',
'tab_name' => 'PHP',
'db' => [
'type' => 'MEDIUMTEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'addtabs' => [
'name' => 'addtabs',
'label' =>
'COM_COMPONENTBUILDER_ADMIN_VIEW_ADDTABS_LABEL',
'type' => 'subform',
'title' => false,
'list' => 'admin_views',
'store' => 'json',
'tab_name' => 'Settings',
'db' => [
'type' => 'TEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'php_save' => [
'name' => 'php_save',
'label' =>
'COM_COMPONENTBUILDER_ADMIN_VIEW_PHP_SAVE_LABEL',
'type' => 'editor',
'title' => false,
'list' => 'admin_views',
'store' => 'base64',
'tab_name' => 'PHP',
'db' => [
'type' => 'MEDIUMTEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'php_allowadd' => [
'name' => 'php_allowadd',
'label' =>
'COM_COMPONENTBUILDER_ADMIN_VIEW_PHP_ALLOWADD_LABEL',
'type' => 'editor',
'title' => false,
'list' => 'admin_views',
'store' => 'base64',
'tab_name' => 'PHP',
'db' => [
'type' => 'MEDIUMTEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'php_before_cancel' => [
'name' => 'php_before_cancel',
'label' =>
'COM_COMPONENTBUILDER_ADMIN_VIEW_PHP_BEFORE_CANCEL_LABEL',
'type' => 'editor',
'title' => false,
'list' => 'admin_views',
'store' => 'base64',
'tab_name' => 'PHP',
'db' => [
'type' => 'MEDIUMTEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'addlinked_views' => [
'name' => 'addlinked_views',
'label' =>
'COM_COMPONENTBUILDER_ADMIN_VIEW_ADDLINKED_VIEWS_LABEL',
'type' => 'subform',
'title' => false,
'list' => 'admin_views',
'store' => 'json',
'tab_name' => 'Settings',
'db' => [
'type' => 'TEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'php_batchcopy' => [
'name' => 'php_batchcopy',
'label' =>
'COM_COMPONENTBUILDER_ADMIN_VIEW_PHP_BATCHCOPY_LABEL',
'type' => 'editor',
'title' => false,
'list' => 'admin_views',
'store' => 'base64',
'tab_name' => 'PHP',
'db' => [
'type' => 'MEDIUMTEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'php_before_publish' => [
'name' => 'php_before_publish',
'label' =>
'COM_COMPONENTBUILDER_ADMIN_VIEW_PHP_BEFORE_PUBLISH_LABEL',
'type' => 'editor',
'title' => false,
'list' => 'admin_views',
'store' => 'base64',
'tab_name' => 'PHP',
'db' => [
'type' => 'MEDIUMTEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'alias_builder_type' => [
'name' => 'alias_builder_type',
'label' =>
'COM_COMPONENTBUILDER_ADMIN_VIEW_ALIAS_BUILDER_TYPE_LABEL',
'type' => 'radio',
'title' => false,
'list' => 'admin_views',
'store' => NULL,
'tab_name' => 'Fields',
'db' => [
'type' => 'TINYINT(1)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'php_before_delete' => [
'name' => 'php_before_delete',
'label' =>
'COM_COMPONENTBUILDER_ADMIN_VIEW_PHP_BEFORE_DELETE_LABEL',
'type' => 'editor',
'title' => false,
'list' => 'admin_views',
'store' => 'base64',
'tab_name' => 'PHP',
'db' => [
'type' => 'MEDIUMTEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'php_document' => [
'name' => 'php_document',
'label' =>
'COM_COMPONENTBUILDER_ADMIN_VIEW_PHP_DOCUMENT_LABEL',
'type' => 'editor',
'title' => false,
'list' => 'admin_views',
'store' => 'base64',
'tab_name' => 'PHP',
'db' => [
'type' => 'MEDIUMTEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'mysql_table_row_format' => [
'name' => 'mysql_table_row_format',
'label' =>
'COM_COMPONENTBUILDER_ADMIN_VIEW_MYSQL_TABLE_ROW_FORMAT_LABEL',
'type' => 'list',
'title' => false,
'list' => 'admin_views',
'store' => NULL,
'tab_name' => 'MySQL',
'db' => [
'type' => 'VARCHAR(64)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'alias_builder' => [
'name' => 'alias_builder',
'label' =>
'COM_COMPONENTBUILDER_ADMIN_VIEW_ALIAS_BUILDER_LABEL',
'type' => 'aliasbuilder',
'title' => false,
'list' => 'admin_views',
'store' => 'json',
'tab_name' => 'Fields',
'db' => [
'type' => 'VARCHAR(255)',
'default' => '',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'sql' => [
'name' => 'sql',
'label' =>
'COM_COMPONENTBUILDER_ADMIN_VIEW_SQL_LABEL',
'type' => 'textarea',
'title' => false,
'list' => 'admin_views',
'store' => 'base64',
'tab_name' => 'MySQL',
'db' => [
'type' => 'MEDIUMTEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'php_import_display' => [
'name' => 'php_import_display',
'label' =>
'COM_COMPONENTBUILDER_ADMIN_VIEW_PHP_IMPORT_DISPLAY_LABEL',
'type' => 'textarea',
'title' => false,
'list' => 'admin_views',
'store' => 'base64',
'tab_name' => 'Custom Import',
'db' => [
'type' => 'MEDIUMTEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'add_category_submenu' => [
'name' => 'add_category_submenu',
'label' =>
'COM_COMPONENTBUILDER_ADMIN_VIEW_ADD_CATEGORY_SUBMENU_LABEL',
'type' => 'radio',
'title' => false,
'list' => 'admin_views',
'store' => NULL,
'tab_name' => 'Fields',
'db' => [
'type' => 'TINYINT(1)',
'default' => '1',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'php_import_setdata' => [
'name' => 'php_import_setdata',
'label' =>
'COM_COMPONENTBUILDER_ADMIN_VIEW_PHP_IMPORT_SETDATA_LABEL',
'type' => 'textarea',
'title' => false,
'list' => 'admin_views',
'store' => 'base64',
'tab_name' => 'Custom Import',
'db' => [
'type' => 'MEDIUMTEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'name_list' => [
'name' => 'name_list',
'label' =>
'COM_COMPONENTBUILDER_ADMIN_VIEW_NAME_LIST_LABEL',
'type' => 'text',
'title' => false,
'list' => 'admin_views',
'store' => NULL,
'tab_name' => 'Details',
'db' => [
'type' => 'CHAR(64)',
'default' => '',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'add_php_getlistquery' => [
'name' => 'add_php_getlistquery',
'label' =>
'COM_COMPONENTBUILDER_ADMIN_VIEW_ADD_PHP_GETLISTQUERY_LABEL',
'type' => 'radio',
'title' => false,
'list' => 'admin_views',
'store' => NULL,
'tab_name' => 'PHP',
'db' => [
'type' => 'TINYINT(1)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'add_css_view' => [
'name' => 'add_css_view',
'label' =>
'COM_COMPONENTBUILDER_ADMIN_VIEW_ADD_CSS_VIEW_LABEL',
'type' => 'radio',
'title' => false,
'list' => 'admin_views',
'store' => NULL,
'tab_name' => 'CSS',
'db' => [
'type' => 'TINYINT(1)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'add_php_getform' => [
'name' => 'add_php_getform',
'label' =>
'COM_COMPONENTBUILDER_ADMIN_VIEW_ADD_PHP_GETFORM_LABEL',
'type' => 'radio',
'title' => false,
'list' => 'admin_views',
'store' => NULL,
'tab_name' => 'PHP',
'db' => [
'type' => 'TINYINT(1)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'css_view' => [
'name' => 'css_view',
'label' =>
'COM_COMPONENTBUILDER_ADMIN_VIEW_CSS_VIEW_LABEL',
'type' => 'editor',
'title' => false,
'list' => 'admin_views',
'store' => 'base64',
'tab_name' => 'CSS',
'db' => [
'type' => 'TEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'add_php_before_save' => [
'name' => 'add_php_before_save',
'label' =>
'COM_COMPONENTBUILDER_ADMIN_VIEW_ADD_PHP_BEFORE_SAVE_LABEL',
'type' => 'radio',
'title' => false,
'list' => 'admin_views',
'store' => NULL,
'tab_name' => 'PHP',
'db' => [
'type' => 'TINYINT(1)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'add_css_views' => [
'name' => 'add_css_views',
'label' =>
'COM_COMPONENTBUILDER_ADMIN_VIEW_ADD_CSS_VIEWS_LABEL',
'type' => 'radio',
'title' => false,
'list' => 'admin_views',
'store' => NULL,
'tab_name' => 'CSS',
'db' => [
'type' => 'TINYINT(1)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'add_php_save' => [
'name' => 'add_php_save',
'label' =>
'COM_COMPONENTBUILDER_ADMIN_VIEW_ADD_PHP_SAVE_LABEL',
'type' => 'radio',
'title' => false,
'list' => 'admin_views',
'store' => NULL,
'tab_name' => 'PHP',
'db' => [
'type' => 'TINYINT(1)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'css_views' => [
'name' => 'css_views',
'label' =>
'COM_COMPONENTBUILDER_ADMIN_VIEW_CSS_VIEWS_LABEL',
'type' => 'editor',
'title' => false,
'list' => 'admin_views',
'store' => 'base64',
'tab_name' => 'CSS',
'db' => [
'type' => 'TEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'add_php_postsavehook' => [
'name' => 'add_php_postsavehook',
'label' =>
'COM_COMPONENTBUILDER_ADMIN_VIEW_ADD_PHP_POSTSAVEHOOK_LABEL',
'type' => 'radio',
'title' => false,
'list' => 'admin_views',
'store' => NULL,
'tab_name' => 'PHP',
'db' => [
'type' => 'TINYINT(1)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'add_javascript_view_file' => [
'name' => 'add_javascript_view_file',
'label' =>
'COM_COMPONENTBUILDER_ADMIN_VIEW_ADD_JAVASCRIPT_VIEW_FILE_LABEL',
'type' => 'radio',
'title' => false,
'list' => 'admin_views',
'store' => NULL,
'tab_name' => 'JavaScript',
'db' => [
'type' => 'TINYINT(1)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'add_php_allowadd' => [
'name' => 'add_php_allowadd',
'label' =>
'COM_COMPONENTBUILDER_ADMIN_VIEW_ADD_PHP_ALLOWADD_LABEL',
'type' => 'radio',
'title' => false,
'list' => 'admin_views',
'store' => NULL,
'tab_name' => 'PHP',
'db' => [
'type' => 'TINYINT(1)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'javascript_view_file' => [
'name' => 'javascript_view_file',
'label' =>
'COM_COMPONENTBUILDER_ADMIN_VIEW_JAVASCRIPT_VIEW_FILE_LABEL',
'type' => 'editor',
'title' => false,
'list' => 'admin_views',
'store' => 'base64',
'tab_name' => 'JavaScript',
'db' => [
'type' => 'TEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'add_php_allowedit' => [
'name' => 'add_php_allowedit',
'label' =>
'COM_COMPONENTBUILDER_ADMIN_VIEW_ADD_PHP_ALLOWEDIT_LABEL',
'type' => 'radio',
'title' => false,
'list' => 'admin_views',
'store' => NULL,
'tab_name' => 'PHP',
'db' => [
'type' => 'TINYINT(1)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'add_javascript_view_footer' => [
'name' => 'add_javascript_view_footer',
'label' =>
'COM_COMPONENTBUILDER_ADMIN_VIEW_ADD_JAVASCRIPT_VIEW_FOOTER_LABEL',
'type' => 'radio',
'title' => false,
'list' => 'admin_views',
'store' => NULL,
'tab_name' => 'JavaScript',
'db' => [
'type' => 'TINYINT(1)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'add_php_before_cancel' => [
'name' => 'add_php_before_cancel',
'label' =>
'COM_COMPONENTBUILDER_ADMIN_VIEW_ADD_PHP_BEFORE_CANCEL_LABEL',
'type' => 'radio',
'title' => false,
'list' => 'admin_views',
'store' => NULL,
'tab_name' => 'PHP',
'db' => [
'type' => 'TINYINT(1)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'javascript_view_footer' => [
'name' => 'javascript_view_footer',
'label' =>
'COM_COMPONENTBUILDER_ADMIN_VIEW_JAVASCRIPT_VIEW_FOOTER_LABEL',
'type' => 'editor',
'title' => false,
'list' => 'admin_views',
'store' => 'base64',
'tab_name' => 'JavaScript',
'db' => [
'type' => 'TEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'add_php_after_cancel' => [
'name' => 'add_php_after_cancel',
'label' =>
'COM_COMPONENTBUILDER_ADMIN_VIEW_ADD_PHP_AFTER_CANCEL_LABEL',
'type' => 'radio',
'title' => false,
'list' => 'admin_views',
'store' => NULL,
'tab_name' => 'PHP',
'db' => [
'type' => 'TINYINT(1)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'add_javascript_views_file' => [
'name' => 'add_javascript_views_file',
'label' =>
'COM_COMPONENTBUILDER_ADMIN_VIEW_ADD_JAVASCRIPT_VIEWS_FILE_LABEL',
'type' => 'radio',
'title' => false,
'list' => 'admin_views',
'store' => NULL,
'tab_name' => 'JavaScript',
'db' => [
'type' => 'TINYINT(1)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'add_php_batchcopy' => [
'name' => 'add_php_batchcopy',
'label' =>
'COM_COMPONENTBUILDER_ADMIN_VIEW_ADD_PHP_BATCHCOPY_LABEL',
'type' => 'radio',
'title' => false,
'list' => 'admin_views',
'store' => NULL,
'tab_name' => 'PHP',
'db' => [
'type' => 'TINYINT(1)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'javascript_views_file' => [
'name' => 'javascript_views_file',
'label' =>
'COM_COMPONENTBUILDER_ADMIN_VIEW_JAVASCRIPT_VIEWS_FILE_LABEL',
'type' => 'editor',
'title' => false,
'list' => 'admin_views',
'store' => 'base64',
'tab_name' => 'JavaScript',
'db' => [
'type' => 'TEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'add_php_batchmove' => [
'name' => 'add_php_batchmove',
'label' =>
'COM_COMPONENTBUILDER_ADMIN_VIEW_ADD_PHP_BATCHMOVE_LABEL',
'type' => 'radio',
'title' => false,
'list' => 'admin_views',
'store' => NULL,
'tab_name' => 'PHP',
'db' => [
'type' => 'TINYINT(1)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'add_javascript_views_footer' => [
'name' => 'add_javascript_views_footer',
'label' =>
'COM_COMPONENTBUILDER_ADMIN_VIEW_ADD_JAVASCRIPT_VIEWS_FOOTER_LABEL',
'type' => 'radio',
'title' => false,
'list' => 'admin_views',
'store' => NULL,
'tab_name' => 'JavaScript',
'db' => [
'type' => 'TINYINT(1)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'add_php_before_publish' => [
'name' => 'add_php_before_publish',
'label' =>
'COM_COMPONENTBUILDER_ADMIN_VIEW_ADD_PHP_BEFORE_PUBLISH_LABEL',
'type' => 'radio',
'title' => false,
'list' => 'admin_views',
'store' => NULL,
'tab_name' => 'PHP',
'db' => [
'type' => 'TINYINT(1)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'javascript_views_footer' => [
'name' => 'javascript_views_footer',
'label' =>
'COM_COMPONENTBUILDER_ADMIN_VIEW_JAVASCRIPT_VIEWS_FOOTER_LABEL',
'type' => 'editor',
'title' => false,
'list' => 'admin_views',
'store' => 'base64',
'tab_name' => 'JavaScript',
'db' => [
'type' => 'TEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'add_php_after_publish' => [
'name' => 'add_php_after_publish',
'label' =>
'COM_COMPONENTBUILDER_ADMIN_VIEW_ADD_PHP_AFTER_PUBLISH_LABEL',
'type' => 'radio',
'title' => false,
'list' => 'admin_views',
'store' => NULL,
'tab_name' => 'PHP',
'db' => [
'type' => 'TINYINT(1)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'add_custom_button' => [
'name' => 'add_custom_button',
'label' =>
'COM_COMPONENTBUILDER_ADMIN_VIEW_ADD_CUSTOM_BUTTON_LABEL',
'type' => 'radio',
'title' => false,
'list' => 'admin_views',
'store' => NULL,
'tab_name' => 'Custom Buttons',
'db' => [
'type' => 'INT(1)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'add_php_before_delete' => [
'name' => 'add_php_before_delete',
'label' =>
'COM_COMPONENTBUILDER_ADMIN_VIEW_ADD_PHP_BEFORE_DELETE_LABEL',
'type' => 'radio',
'title' => false,
'list' => 'admin_views',
'store' => NULL,
'tab_name' => 'PHP',
'db' => [
'type' => 'TINYINT(1)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'custom_button' => [
'name' => 'custom_button',
'label' =>
'COM_COMPONENTBUILDER_ADMIN_VIEW_CUSTOM_BUTTON_LABEL',
'type' => 'subform',
'title' => false,
'list' => 'admin_views',
'store' => 'json',
'tab_name' => 'Custom Buttons',
'db' => [
'type' => 'TEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'add_php_after_delete' => [
'name' => 'add_php_after_delete',
'label' =>
'COM_COMPONENTBUILDER_ADMIN_VIEW_ADD_PHP_AFTER_DELETE_LABEL',
'type' => 'radio',
'title' => false,
'list' => 'admin_views',
'store' => NULL,
'tab_name' => 'PHP',
'db' => [
'type' => 'TINYINT(1)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'php_controller' => [
'name' => 'php_controller',
'label' =>
'COM_COMPONENTBUILDER_ADMIN_VIEW_PHP_CONTROLLER_LABEL',
'type' => 'editor',
'title' => false,
'list' => 'admin_views',
'store' => 'base64',
'tab_name' => 'Custom Buttons',
'db' => [
'type' => 'MEDIUMTEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'add_php_document' => [
'name' => 'add_php_document',
'label' =>
'COM_COMPONENTBUILDER_ADMIN_VIEW_ADD_PHP_DOCUMENT_LABEL',
'type' => 'radio',
'title' => false,
'list' => 'admin_views',
'store' => NULL,
'tab_name' => 'PHP',
'db' => [
'type' => 'TINYINT(1)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'php_model' => [
'name' => 'php_model',
'label' =>
'COM_COMPONENTBUILDER_ADMIN_VIEW_PHP_MODEL_LABEL',
'type' => 'editor',
'title' => false,
'list' => 'admin_views',
'store' => 'base64',
'tab_name' => 'Custom Buttons',
'db' => [
'type' => 'MEDIUMTEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'mysql_table_engine' => [
'name' => 'mysql_table_engine',
'label' =>
'COM_COMPONENTBUILDER_ADMIN_VIEW_MYSQL_TABLE_ENGINE_LABEL',
'type' => 'list',
'title' => false,
'list' => 'admin_views',
'store' => NULL,
'tab_name' => 'MySQL',
'db' => [
'type' => 'VARCHAR(64)',
'default' => '1',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'php_controller_list' => [
'name' => 'php_controller_list',
'label' =>
'COM_COMPONENTBUILDER_ADMIN_VIEW_PHP_CONTROLLER_LIST_LABEL',
'type' => 'editor',
'title' => false,
'list' => 'admin_views',
'store' => 'base64',
'tab_name' => 'Custom Buttons',
'db' => [
'type' => 'MEDIUMTEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'mysql_table_collate' => [
'name' => 'mysql_table_collate',
'label' =>
'COM_COMPONENTBUILDER_ADMIN_VIEW_MYSQL_TABLE_COLLATE_LABEL',
'type' => 'list',
'title' => false,
'list' => 'admin_views',
'store' => NULL,
'tab_name' => 'MySQL',
'db' => [
'type' => 'VARCHAR(64)',
'default' => '1',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'php_model_list' => [
'name' => 'php_model_list',
'label' =>
'COM_COMPONENTBUILDER_ADMIN_VIEW_PHP_MODEL_LIST_LABEL',
'type' => 'editor',
'title' => false,
'list' => 'admin_views',
'store' => 'base64',
'tab_name' => 'Custom Buttons',
'db' => [
'type' => 'MEDIUMTEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'add_sql' => [
'name' => 'add_sql',
'label' =>
'COM_COMPONENTBUILDER_ADMIN_VIEW_ADD_SQL_LABEL',
'type' => 'radio',
'title' => false,
'list' => 'admin_views',
'store' => NULL,
'tab_name' => 'MySQL',
'db' => [
'type' => 'TINYINT(1)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'add_php_ajax' => [
'name' => 'add_php_ajax',
'label' =>
'COM_COMPONENTBUILDER_ADMIN_VIEW_ADD_PHP_AJAX_LABEL',
'type' => 'radio',
'title' => false,
'list' => 'admin_views',
'store' => NULL,
'tab_name' => 'PHP',
'db' => [
'type' => 'TINYINT(1)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'addtables' => [
'name' => 'addtables',
'label' =>
'COM_COMPONENTBUILDER_ADMIN_VIEW_ADDTABLES_LABEL',
'type' => 'subform',
'title' => false,
'list' => 'admin_views',
'store' => 'json',
'tab_name' => 'MySQL',
'db' => [
'type' => 'TEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'php_ajaxmethod' => [
'name' => 'php_ajaxmethod',
'label' =>
'COM_COMPONENTBUILDER_ADMIN_VIEW_PHP_AJAXMETHOD_LABEL',
'type' => 'editor',
'title' => false,
'list' => 'admin_views',
'store' => 'base64',
'tab_name' => 'PHP',
'db' => [
'type' => 'MEDIUMTEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'ajax_input' => [
'name' => 'ajax_input',
'label' =>
'COM_COMPONENTBUILDER_ADMIN_VIEW_AJAX_INPUT_LABEL',
'type' => 'subform',
'title' => false,
'list' => 'admin_views',
'store' => 'json',
'tab_name' => 'PHP',
'db' => [
'type' => 'TEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'add_custom_import' => [
'name' => 'add_custom_import',
'label' =>
'COM_COMPONENTBUILDER_ADMIN_VIEW_ADD_CUSTOM_IMPORT_LABEL',
'type' => 'radio',
'title' => false,
'list' => 'admin_views',
'store' => NULL,
'tab_name' => 'Custom Import',
'db' => [
'type' => 'TINYINT(1)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'add_php_getitem' => [
'name' => 'add_php_getitem',
'label' =>
'COM_COMPONENTBUILDER_ADMIN_VIEW_ADD_PHP_GETITEM_LABEL',
'type' => 'radio',
'title' => false,
'list' => 'admin_views',
'store' => NULL,
'tab_name' => 'PHP',
'db' => [
'type' => 'TINYINT(1)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'html_import_view' => [
'name' => 'html_import_view',
'label' =>
'COM_COMPONENTBUILDER_ADMIN_VIEW_HTML_IMPORT_VIEW_LABEL',
'type' => 'textarea',
'title' => false,
'list' => 'admin_views',
'store' => 'base64',
'tab_name' => 'Custom Import',
'db' => [
'type' => 'MEDIUMTEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'php_getitem' => [
'name' => 'php_getitem',
'label' =>
'COM_COMPONENTBUILDER_ADMIN_VIEW_PHP_GETITEM_LABEL',
'type' => 'editor',
'title' => false,
'list' => 'admin_views',
'store' => 'base64',
'tab_name' => 'PHP',
'db' => [
'type' => 'MEDIUMTEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'php_import_headers' => [
'name' => 'php_import_headers',
'label' =>
'COM_COMPONENTBUILDER_ADMIN_VIEW_PHP_IMPORT_HEADERS_LABEL',
'type' => 'textarea',
'title' => false,
'list' => 'admin_views',
'store' => 'base64',
'tab_name' => 'Custom Import',
'db' => [
'type' => 'MEDIUMTEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'add_php_getitems' => [
'name' => 'add_php_getitems',
'label' =>
'COM_COMPONENTBUILDER_ADMIN_VIEW_ADD_PHP_GETITEMS_LABEL',
'type' => 'radio',
'title' => false,
'list' => 'admin_views',
'store' => NULL,
'tab_name' => 'PHP',
'db' => [
'type' => 'TINYINT(1)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'php_import_save' => [
'name' => 'php_import_save',
'label' =>
'COM_COMPONENTBUILDER_ADMIN_VIEW_PHP_IMPORT_SAVE_LABEL',
'type' => 'textarea',
'title' => false,
'list' => 'admin_views',
'store' => 'base64',
'tab_name' => 'Custom Import',
'db' => [
'type' => 'MEDIUMTEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'php_getitems' => [
'name' => 'php_getitems',
'label' =>
'COM_COMPONENTBUILDER_ADMIN_VIEW_PHP_GETITEMS_LABEL',
'type' => 'editor',
'title' => false,
'list' => 'admin_views',
'store' => 'base64',
'tab_name' => 'PHP',
'db' => [
'type' => 'MEDIUMTEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'guid' => [
'name' => 'guid',
'label' =>
'COM_COMPONENTBUILDER_ADMIN_VIEW_GUID_LABEL',
'type' => 'text',
'title' => false,
'list' => 'admin_views',
'store' => NULL,
'tab_name' => 'publishing',
'db' => [
'type' => 'VARCHAR(36)',
'default' => '',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'add_php_getitems_after_all' => [
'name' => 'add_php_getitems_after_all',
'label' =>
'COM_COMPONENTBUILDER_ADMIN_VIEW_ADD_PHP_GETITEMS_AFTER_ALL_LABEL',
'type' => 'radio',
'title' => false,
'list' => 'admin_views',
'store' => NULL,
'tab_name' => 'PHP',
'db' => [
'type' => 'TINYINT(1)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'access' => [
'name' => 'access',
'label' => 'Access',
'type' => 'accesslevel',
'title' => false,
'store' => NULL,
'tab_name' => NULL,
'db' => [
'type' => 'INT(10) unsigned',
'default' => '0',
'key' => true,
'null_switch' => 'NULL',
],
],
],
'custom_admin_view' => [
'system_name' => [
'name' => 'system_name',
'label' =>
'COM_COMPONENTBUILDER_CUSTOM_ADMIN_VIEW_SYSTEM_NAME_LABEL',
'type' => 'text',
'title' => false,
'list' => 'custom_admin_views',
'store' => NULL,
'tab_name' => 'Details',
'db' => [
'type' => 'VARCHAR(255)',
'default' => '',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'name' => [
'name' => 'name',
'label' =>
'COM_COMPONENTBUILDER_CUSTOM_ADMIN_VIEW_NAME_LABEL',
'type' => 'text',
'title' => true,
'list' => 'custom_admin_views',
'store' => NULL,
'tab_name' => 'Details',
'db' => [
'type' => 'VARCHAR(255)',
'default' => '',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'description' => [
'name' => 'description',
'label' =>
'COM_COMPONENTBUILDER_CUSTOM_ADMIN_VIEW_DESCRIPTION_LABEL',
'type' => 'text',
'title' => false,
'list' => 'custom_admin_views',
'store' => NULL,
'tab_name' => 'Details',
'db' => [
'type' => 'VARCHAR(255)',
'default' => '',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'main_get' => [
'name' => 'main_get',
'label' =>
'COM_COMPONENTBUILDER_CUSTOM_ADMIN_VIEW_MAIN_GET_LABEL',
'type' => 'maingets',
'title' => false,
'list' => 'custom_admin_views',
'store' => NULL,
'tab_name' => 'Details',
'db' => [
'type' => 'INT(11)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'add_php_jview_display' => [
'name' => 'add_php_jview_display',
'label' =>
'COM_COMPONENTBUILDER_CUSTOM_ADMIN_VIEW_ADD_PHP_JVIEW_DISPLAY_LABEL',
'type' => 'radio',
'title' => false,
'list' => 'custom_admin_views',
'store' => NULL,
'tab_name' => 'PHP',
'db' => [
'type' => 'TINYINT(1)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'css_document' => [
'name' => 'css_document',
'label' =>
'COM_COMPONENTBUILDER_CUSTOM_ADMIN_VIEW_CSS_DOCUMENT_LABEL',
'type' => 'editor',
'title' => false,
'list' => 'custom_admin_views',
'store' => 'base64',
'tab_name' => 'JavaScript & CSS',
'db' => [
'type' => 'TEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'css' => [
'name' => 'css',
'label' =>
'COM_COMPONENTBUILDER_CUSTOM_ADMIN_VIEW_CSS_LABEL',
'type' => 'editor',
'title' => false,
'list' => 'custom_admin_views',
'store' => 'base64',
'tab_name' => 'JavaScript & CSS',
'db' => [
'type' => 'TEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'js_document' => [
'name' => 'js_document',
'label' =>
'COM_COMPONENTBUILDER_CUSTOM_ADMIN_VIEW_JS_DOCUMENT_LABEL',
'type' => 'editor',
'title' => false,
'list' => 'custom_admin_views',
'store' => 'base64',
'tab_name' => 'JavaScript & CSS',
'db' => [
'type' => 'TEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'javascript_file' => [
'name' => 'javascript_file',
'label' =>
'COM_COMPONENTBUILDER_CUSTOM_ADMIN_VIEW_JAVASCRIPT_FILE_LABEL',
'type' => 'editor',
'title' => false,
'list' => 'custom_admin_views',
'store' => 'base64',
'tab_name' => 'JavaScript & CSS',
'db' => [
'type' => 'TEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'codename' => [
'name' => 'codename',
'label' =>
'COM_COMPONENTBUILDER_CUSTOM_ADMIN_VIEW_CODENAME_LABEL',
'type' => 'text',
'title' => false,
'list' => 'custom_admin_views',
'store' => NULL,
'tab_name' => 'Details',
'db' => [
'type' => 'VARCHAR(255)',
'default' => '',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'default' => [
'name' => 'default',
'label' =>
'COM_COMPONENTBUILDER_CUSTOM_ADMIN_VIEW_DEFAULT_LABEL',
'type' => 'editor',
'title' => false,
'list' => 'custom_admin_views',
'store' => 'base64',
'tab_name' => 'Details',
'db' => [
'type' => 'MEDIUMTEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'snippet' => [
'name' => 'snippet',
'label' =>
'COM_COMPONENTBUILDER_CUSTOM_ADMIN_VIEW_SNIPPET_LABEL',
'type' => 'snippets',
'title' => false,
'list' => 'custom_admin_views',
'store' => NULL,
'tab_name' => 'Details',
'db' => [
'type' => 'INT(11)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'icon' => [
'name' => 'icon',
'label' =>
'COM_COMPONENTBUILDER_CUSTOM_ADMIN_VIEW_ICON_LABEL',
'type' => 'media',
'title' => false,
'list' => 'custom_admin_views',
'store' => NULL,
'tab_name' => 'Details',
'db' => [
'type' => 'VARCHAR(255)',
'default' => '',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'add_php_jview' => [
'name' => 'add_php_jview',
'label' =>
'COM_COMPONENTBUILDER_CUSTOM_ADMIN_VIEW_ADD_PHP_JVIEW_LABEL',
'type' => 'radio',
'title' => false,
'list' => 'custom_admin_views',
'store' => NULL,
'tab_name' => 'PHP',
'db' => [
'type' => 'TINYINT(1)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'context' => [
'name' => 'context',
'label' =>
'COM_COMPONENTBUILDER_CUSTOM_ADMIN_VIEW_CONTEXT_LABEL',
'type' => 'text',
'title' => false,
'list' => 'custom_admin_views',
'store' => NULL,
'tab_name' => 'Details',
'db' => [
'type' => 'VARCHAR(255)',
'default' => '',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'add_js_document' => [
'name' => 'add_js_document',
'label' =>
'COM_COMPONENTBUILDER_CUSTOM_ADMIN_VIEW_ADD_JS_DOCUMENT_LABEL',
'type' => 'radio',
'title' => false,
'list' => 'custom_admin_views',
'store' => NULL,
'tab_name' => 'JavaScript & CSS',
'db' => [
'type' => 'TINYINT(1)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'custom_get' => [
'name' => 'custom_get',
'label' =>
'COM_COMPONENTBUILDER_CUSTOM_ADMIN_VIEW_CUSTOM_GET_LABEL',
'type' => 'customgets',
'title' => false,
'list' => 'custom_admin_views',
'store' => 'json',
'tab_name' => 'Details',
'db' => [
'type' => 'TEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'add_javascript_file' => [
'name' => 'add_javascript_file',
'label' =>
'COM_COMPONENTBUILDER_CUSTOM_ADMIN_VIEW_ADD_JAVASCRIPT_FILE_LABEL',
'type' => 'radio',
'title' => false,
'list' => 'custom_admin_views',
'store' => NULL,
'tab_name' => 'JavaScript & CSS',
'db' => [
'type' => 'TINYINT(1)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'php_ajaxmethod' => [
'name' => 'php_ajaxmethod',
'label' =>
'COM_COMPONENTBUILDER_CUSTOM_ADMIN_VIEW_PHP_AJAXMETHOD_LABEL',
'type' => 'editor',
'title' => false,
'list' => 'custom_admin_views',
'store' => 'base64',
'tab_name' => 'PHP',
'db' => [
'type' => 'MEDIUMTEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'add_css_document' => [
'name' => 'add_css_document',
'label' =>
'COM_COMPONENTBUILDER_CUSTOM_ADMIN_VIEW_ADD_CSS_DOCUMENT_LABEL',
'type' => 'radio',
'title' => false,
'list' => 'custom_admin_views',
'store' => NULL,
'tab_name' => 'JavaScript & CSS',
'db' => [
'type' => 'TINYINT(1)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'add_php_document' => [
'name' => 'add_php_document',
'label' =>
'COM_COMPONENTBUILDER_CUSTOM_ADMIN_VIEW_ADD_PHP_DOCUMENT_LABEL',
'type' => 'radio',
'title' => false,
'list' => 'custom_admin_views',
'store' => NULL,
'tab_name' => 'PHP',
'db' => [
'type' => 'TINYINT(1)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'add_css' => [
'name' => 'add_css',
'label' =>
'COM_COMPONENTBUILDER_CUSTOM_ADMIN_VIEW_ADD_CSS_LABEL',
'type' => 'radio',
'title' => false,
'list' => 'custom_admin_views',
'store' => NULL,
'tab_name' => 'JavaScript & CSS',
'db' => [
'type' => 'TINYINT(1)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'add_php_view' => [
'name' => 'add_php_view',
'label' =>
'COM_COMPONENTBUILDER_CUSTOM_ADMIN_VIEW_ADD_PHP_VIEW_LABEL',
'type' => 'radio',
'title' => false,
'list' => 'custom_admin_views',
'store' => NULL,
'tab_name' => 'PHP',
'db' => [
'type' => 'TINYINT(1)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'add_php_ajax' => [
'name' => 'add_php_ajax',
'label' =>
'COM_COMPONENTBUILDER_CUSTOM_ADMIN_VIEW_ADD_PHP_AJAX_LABEL',
'type' => 'radio',
'title' => false,
'list' => 'custom_admin_views',
'store' => NULL,
'tab_name' => 'PHP',
'db' => [
'type' => 'TINYINT(1)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'libraries' => [
'name' => 'libraries',
'label' =>
'COM_COMPONENTBUILDER_CUSTOM_ADMIN_VIEW_LIBRARIES_LABEL',
'type' => 'libraries',
'title' => false,
'list' => 'custom_admin_views',
'store' => 'json',
'tab_name' => 'Details',
'db' => [
'type' => 'TEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'ajax_input' => [
'name' => 'ajax_input',
'label' =>
'COM_COMPONENTBUILDER_CUSTOM_ADMIN_VIEW_AJAX_INPUT_LABEL',
'type' => 'subform',
'title' => false,
'list' => 'custom_admin_views',
'store' => 'json',
'tab_name' => 'PHP',
'db' => [
'type' => 'TEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'dynamic_get' => [
'name' => 'dynamic_get',
'label' =>
'COM_COMPONENTBUILDER_CUSTOM_ADMIN_VIEW_DYNAMIC_GET_LABEL',
'type' => 'dynamicgets',
'title' => false,
'list' => 'custom_admin_views',
'store' => NULL,
'tab_name' => 'Details',
'db' => [
'type' => 'INT(11)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'php_document' => [
'name' => 'php_document',
'label' =>
'COM_COMPONENTBUILDER_CUSTOM_ADMIN_VIEW_PHP_DOCUMENT_LABEL',
'type' => 'editor',
'title' => false,
'list' => 'custom_admin_views',
'store' => 'base64',
'tab_name' => 'PHP',
'db' => [
'type' => 'MEDIUMTEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'php_view' => [
'name' => 'php_view',
'label' =>
'COM_COMPONENTBUILDER_CUSTOM_ADMIN_VIEW_PHP_VIEW_LABEL',
'type' => 'editor',
'title' => false,
'list' => 'custom_admin_views',
'store' => 'base64',
'tab_name' => 'PHP',
'db' => [
'type' => 'MEDIUMTEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'add_custom_button' => [
'name' => 'add_custom_button',
'label' =>
'COM_COMPONENTBUILDER_CUSTOM_ADMIN_VIEW_ADD_CUSTOM_BUTTON_LABEL',
'type' => 'radio',
'title' => false,
'list' => 'custom_admin_views',
'store' => NULL,
'tab_name' => 'Custom Buttons',
'db' => [
'type' => 'INT(1)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'php_jview_display' => [
'name' => 'php_jview_display',
'label' =>
'COM_COMPONENTBUILDER_CUSTOM_ADMIN_VIEW_PHP_JVIEW_DISPLAY_LABEL',
'type' => 'editor',
'title' => false,
'list' => 'custom_admin_views',
'store' => 'base64',
'tab_name' => 'PHP',
'db' => [
'type' => 'MEDIUMTEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'custom_button' => [
'name' => 'custom_button',
'label' =>
'COM_COMPONENTBUILDER_CUSTOM_ADMIN_VIEW_CUSTOM_BUTTON_LABEL',
'type' => 'subform',
'title' => false,
'list' => 'custom_admin_views',
'store' => 'json',
'tab_name' => 'Custom Buttons',
'db' => [
'type' => 'TEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'php_jview' => [
'name' => 'php_jview',
'label' =>
'COM_COMPONENTBUILDER_CUSTOM_ADMIN_VIEW_PHP_JVIEW_LABEL',
'type' => 'editor',
'title' => false,
'list' => 'custom_admin_views',
'store' => 'base64',
'tab_name' => 'PHP',
'db' => [
'type' => 'MEDIUMTEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'php_controller' => [
'name' => 'php_controller',
'label' =>
'COM_COMPONENTBUILDER_CUSTOM_ADMIN_VIEW_PHP_CONTROLLER_LABEL',
'type' => 'editor',
'title' => false,
'list' => 'custom_admin_views',
'store' => 'base64',
'tab_name' => 'Custom Buttons',
'db' => [
'type' => 'MEDIUMTEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'guid' => [
'name' => 'guid',
'label' =>
'COM_COMPONENTBUILDER_CUSTOM_ADMIN_VIEW_GUID_LABEL',
'type' => 'text',
'title' => false,
'list' => 'custom_admin_views',
'store' => NULL,
'tab_name' => 'publishing',
'db' => [
'type' => 'VARCHAR(36)',
'default' => '',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'php_model' => [
'name' => 'php_model',
'label' =>
'COM_COMPONENTBUILDER_CUSTOM_ADMIN_VIEW_PHP_MODEL_LABEL',
'type' => 'editor',
'title' => false,
'list' => 'custom_admin_views',
'store' => 'base64',
'tab_name' => 'Custom Buttons',
'db' => [
'type' => 'MEDIUMTEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'access' => [
'name' => 'access',
'label' => 'Access',
'type' => 'accesslevel',
'title' => false,
'store' => NULL,
'tab_name' => NULL,
'db' => [
'type' => 'INT(10) unsigned',
'default' => '0',
'key' => true,
'null_switch' => 'NULL',
],
],
],
'site_view' => [
'system_name' => [
'name' => 'system_name',
'label' =>
'COM_COMPONENTBUILDER_SITE_VIEW_SYSTEM_NAME_LABEL',
'type' => 'text',
'title' => false,
'list' => 'site_views',
'store' => NULL,
'tab_name' => 'Details',
'db' => [
'type' => 'VARCHAR(255)',
'default' => '',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'name' => [
'name' => 'name',
'label' =>
'COM_COMPONENTBUILDER_SITE_VIEW_NAME_LABEL',
'type' => 'text',
'title' => true,
'list' => 'site_views',
'store' => NULL,
'tab_name' => 'Details',
'db' => [
'type' => 'VARCHAR(255)',
'default' => '',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'description' => [
'name' => 'description',
'label' =>
'COM_COMPONENTBUILDER_SITE_VIEW_DESCRIPTION_LABEL',
'type' => 'text',
'title' => false,
'list' => 'site_views',
'store' => NULL,
'tab_name' => 'Details',
'db' => [
'type' => 'VARCHAR(255)',
'default' => '',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'main_get' => [
'name' => 'main_get',
'label' =>
'COM_COMPONENTBUILDER_SITE_VIEW_MAIN_GET_LABEL',
'type' => 'maingets',
'title' => false,
'list' => 'site_views',
'store' => NULL,
'tab_name' => 'Details',
'db' => [
'type' => 'INT(11)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'add_php_jview_display' => [
'name' => 'add_php_jview_display',
'label' =>
'COM_COMPONENTBUILDER_SITE_VIEW_ADD_PHP_JVIEW_DISPLAY_LABEL',
'type' => 'radio',
'title' => false,
'list' => 'site_views',
'store' => NULL,
'tab_name' => 'PHP',
'db' => [
'type' => 'TINYINT(1)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'add_php_document' => [
'name' => 'add_php_document',
'label' =>
'COM_COMPONENTBUILDER_SITE_VIEW_ADD_PHP_DOCUMENT_LABEL',
'type' => 'radio',
'title' => false,
'list' => 'site_views',
'store' => NULL,
'tab_name' => 'PHP',
'db' => [
'type' => 'TINYINT(1)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'add_php_view' => [
'name' => 'add_php_view',
'label' =>
'COM_COMPONENTBUILDER_SITE_VIEW_ADD_PHP_VIEW_LABEL',
'type' => 'radio',
'title' => false,
'list' => 'site_views',
'store' => NULL,
'tab_name' => 'PHP',
'db' => [
'type' => 'TINYINT(1)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'js_document' => [
'name' => 'js_document',
'label' =>
'COM_COMPONENTBUILDER_SITE_VIEW_JS_DOCUMENT_LABEL',
'type' => 'editor',
'title' => false,
'list' => 'site_views',
'store' => 'base64',
'tab_name' => 'JavaScript & CSS',
'db' => [
'type' => 'TEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'codename' => [
'name' => 'codename',
'label' =>
'COM_COMPONENTBUILDER_SITE_VIEW_CODENAME_LABEL',
'type' => 'text',
'title' => false,
'list' => 'site_views',
'store' => NULL,
'tab_name' => 'Details',
'db' => [
'type' => 'VARCHAR(255)',
'default' => '',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'javascript_file' => [
'name' => 'javascript_file',
'label' =>
'COM_COMPONENTBUILDER_SITE_VIEW_JAVASCRIPT_FILE_LABEL',
'type' => 'editor',
'title' => false,
'list' => 'site_views',
'store' => 'base64',
'tab_name' => 'JavaScript & CSS',
'db' => [
'type' => 'TEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'context' => [
'name' => 'context',
'label' =>
'COM_COMPONENTBUILDER_SITE_VIEW_CONTEXT_LABEL',
'type' => 'text',
'title' => false,
'list' => 'site_views',
'store' => NULL,
'tab_name' => 'Details',
'db' => [
'type' => 'VARCHAR(255)',
'default' => '',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'default' => [
'name' => 'default',
'label' =>
'COM_COMPONENTBUILDER_SITE_VIEW_DEFAULT_LABEL',
'type' => 'editor',
'title' => false,
'list' => 'site_views',
'store' => 'base64',
'tab_name' => 'Details',
'db' => [
'type' => 'MEDIUMTEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'snippet' => [
'name' => 'snippet',
'label' =>
'COM_COMPONENTBUILDER_SITE_VIEW_SNIPPET_LABEL',
'type' => 'snippets',
'title' => false,
'list' => 'site_views',
'store' => NULL,
'tab_name' => 'Details',
'db' => [
'type' => 'INT(11)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'add_php_jview' => [
'name' => 'add_php_jview',
'label' =>
'COM_COMPONENTBUILDER_SITE_VIEW_ADD_PHP_JVIEW_LABEL',
'type' => 'radio',
'title' => false,
'list' => 'site_views',
'store' => NULL,
'tab_name' => 'PHP',
'db' => [
'type' => 'TINYINT(1)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'custom_get' => [
'name' => 'custom_get',
'label' =>
'COM_COMPONENTBUILDER_SITE_VIEW_CUSTOM_GET_LABEL',
'type' => 'customgets',
'title' => false,
'list' => 'site_views',
'store' => 'json',
'tab_name' => 'Details',
'db' => [
'type' => 'TEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'css_document' => [
'name' => 'css_document',
'label' =>
'COM_COMPONENTBUILDER_SITE_VIEW_CSS_DOCUMENT_LABEL',
'type' => 'editor',
'title' => false,
'list' => 'site_views',
'store' => 'base64',
'tab_name' => 'JavaScript & CSS',
'db' => [
'type' => 'TEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'add_javascript_file' => [
'name' => 'add_javascript_file',
'label' =>
'COM_COMPONENTBUILDER_SITE_VIEW_ADD_JAVASCRIPT_FILE_LABEL',
'type' => 'radio',
'title' => false,
'list' => 'site_views',
'store' => NULL,
'tab_name' => 'JavaScript & CSS',
'db' => [
'type' => 'TINYINT(1)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'css' => [
'name' => 'css',
'label' =>
'COM_COMPONENTBUILDER_SITE_VIEW_CSS_LABEL',
'type' => 'editor',
'title' => false,
'list' => 'site_views',
'store' => 'base64',
'tab_name' => 'JavaScript & CSS',
'db' => [
'type' => 'TEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'add_js_document' => [
'name' => 'add_js_document',
'label' =>
'COM_COMPONENTBUILDER_SITE_VIEW_ADD_JS_DOCUMENT_LABEL',
'type' => 'radio',
'title' => false,
'list' => 'site_views',
'store' => NULL,
'tab_name' => 'JavaScript & CSS',
'db' => [
'type' => 'TINYINT(1)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'php_ajaxmethod' => [
'name' => 'php_ajaxmethod',
'label' =>
'COM_COMPONENTBUILDER_SITE_VIEW_PHP_AJAXMETHOD_LABEL',
'type' => 'editor',
'title' => false,
'list' => 'site_views',
'store' => 'base64',
'tab_name' => 'PHP',
'db' => [
'type' => 'MEDIUMTEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'add_css_document' => [
'name' => 'add_css_document',
'label' =>
'COM_COMPONENTBUILDER_SITE_VIEW_ADD_CSS_DOCUMENT_LABEL',
'type' => 'radio',
'title' => false,
'list' => 'site_views',
'store' => NULL,
'tab_name' => 'JavaScript & CSS',
'db' => [
'type' => 'TINYINT(1)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'libraries' => [
'name' => 'libraries',
'label' =>
'COM_COMPONENTBUILDER_SITE_VIEW_LIBRARIES_LABEL',
'type' => 'libraries',
'title' => false,
'list' => 'site_views',
'store' => 'json',
'tab_name' => 'Details',
'db' => [
'type' => 'TEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'add_css' => [
'name' => 'add_css',
'label' =>
'COM_COMPONENTBUILDER_SITE_VIEW_ADD_CSS_LABEL',
'type' => 'radio',
'title' => false,
'list' => 'site_views',
'store' => NULL,
'tab_name' => 'JavaScript & CSS',
'db' => [
'type' => 'TINYINT(1)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'dynamic_get' => [
'name' => 'dynamic_get',
'label' =>
'COM_COMPONENTBUILDER_SITE_VIEW_DYNAMIC_GET_LABEL',
'type' => 'dynamicgets',
'title' => false,
'list' => 'site_views',
'store' => NULL,
'tab_name' => 'Details',
'db' => [
'type' => 'INT(11)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'add_php_ajax' => [
'name' => 'add_php_ajax',
'label' =>
'COM_COMPONENTBUILDER_SITE_VIEW_ADD_PHP_AJAX_LABEL',
'type' => 'radio',
'title' => false,
'list' => 'site_views',
'store' => NULL,
'tab_name' => 'PHP',
'db' => [
'type' => 'TINYINT(1)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'ajax_input' => [
'name' => 'ajax_input',
'label' =>
'COM_COMPONENTBUILDER_SITE_VIEW_AJAX_INPUT_LABEL',
'type' => 'subform',
'title' => false,
'list' => 'site_views',
'store' => 'json',
'tab_name' => 'PHP',
'db' => [
'type' => 'TEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'add_custom_button' => [
'name' => 'add_custom_button',
'label' =>
'COM_COMPONENTBUILDER_SITE_VIEW_ADD_CUSTOM_BUTTON_LABEL',
'type' => 'radio',
'title' => false,
'list' => 'site_views',
'store' => NULL,
'tab_name' => 'Custom Buttons',
'db' => [
'type' => 'INT(1)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'php_document' => [
'name' => 'php_document',
'label' =>
'COM_COMPONENTBUILDER_SITE_VIEW_PHP_DOCUMENT_LABEL',
'type' => 'editor',
'title' => false,
'list' => 'site_views',
'store' => 'base64',
'tab_name' => 'PHP',
'db' => [
'type' => 'MEDIUMTEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'button_position' => [
'name' => 'button_position',
'label' =>
'COM_COMPONENTBUILDER_SITE_VIEW_BUTTON_POSITION_LABEL',
'type' => 'list',
'title' => false,
'list' => 'site_views',
'store' => NULL,
'tab_name' => 'Custom Buttons',
'db' => [
'type' => 'TINYINT(1)',
'default' => '1',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'php_view' => [
'name' => 'php_view',
'label' =>
'COM_COMPONENTBUILDER_SITE_VIEW_PHP_VIEW_LABEL',
'type' => 'editor',
'title' => false,
'list' => 'site_views',
'store' => 'base64',
'tab_name' => 'PHP',
'db' => [
'type' => 'MEDIUMTEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'php_jview_display' => [
'name' => 'php_jview_display',
'label' =>
'COM_COMPONENTBUILDER_SITE_VIEW_PHP_JVIEW_DISPLAY_LABEL',
'type' => 'editor',
'title' => false,
'list' => 'site_views',
'store' => 'base64',
'tab_name' => 'PHP',
'db' => [
'type' => 'MEDIUMTEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'custom_button' => [
'name' => 'custom_button',
'label' =>
'COM_COMPONENTBUILDER_SITE_VIEW_CUSTOM_BUTTON_LABEL',
'type' => 'subform',
'title' => false,
'list' => 'site_views',
'store' => 'json',
'tab_name' => 'Custom Buttons',
'db' => [
'type' => 'TEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'php_jview' => [
'name' => 'php_jview',
'label' =>
'COM_COMPONENTBUILDER_SITE_VIEW_PHP_JVIEW_LABEL',
'type' => 'editor',
'title' => false,
'list' => 'site_views',
'store' => 'base64',
'tab_name' => 'PHP',
'db' => [
'type' => 'MEDIUMTEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'php_controller' => [
'name' => 'php_controller',
'label' =>
'COM_COMPONENTBUILDER_SITE_VIEW_PHP_CONTROLLER_LABEL',
'type' => 'editor',
'title' => false,
'list' => 'site_views',
'store' => 'base64',
'tab_name' => 'Custom Buttons',
'db' => [
'type' => 'MEDIUMTEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'guid' => [
'name' => 'guid',
'label' =>
'COM_COMPONENTBUILDER_SITE_VIEW_GUID_LABEL',
'type' => 'text',
'title' => false,
'list' => 'site_views',
'store' => NULL,
'tab_name' => 'publishing',
'db' => [
'type' => 'VARCHAR(36)',
'default' => '',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'php_model' => [
'name' => 'php_model',
'label' =>
'COM_COMPONENTBUILDER_SITE_VIEW_PHP_MODEL_LABEL',
'type' => 'editor',
'title' => false,
'list' => 'site_views',
'store' => 'base64',
'tab_name' => 'Custom Buttons',
'db' => [
'type' => 'MEDIUMTEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'access' => [
'name' => 'access',
'label' => 'Access',
'type' => 'accesslevel',
'title' => false,
'store' => NULL,
'tab_name' => NULL,
'db' => [
'type' => 'INT(10) unsigned',
'default' => '0',
'key' => true,
'null_switch' => 'NULL',
],
],
],
'template' => [
'name' => [
'name' => 'name',
'label' =>
'COM_COMPONENTBUILDER_TEMPLATE_NAME_LABEL',
'type' => 'text',
'title' => true,
'list' => 'templates',
'store' => NULL,
'tab_name' => 'Details',
'db' => [
'type' => 'VARCHAR(255)',
'default' => '',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'description' => [
'name' => 'description',
'label' =>
'COM_COMPONENTBUILDER_TEMPLATE_DESCRIPTION_LABEL',
'type' => 'text',
'title' => false,
'list' => 'templates',
'store' => NULL,
'tab_name' => 'Details',
'db' => [
'type' => 'VARCHAR(255)',
'default' => '',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'dynamic_get' => [
'name' => 'dynamic_get',
'label' =>
'COM_COMPONENTBUILDER_TEMPLATE_DYNAMIC_GET_LABEL',
'type' => 'dynamicget',
'title' => false,
'list' => 'templates',
'store' => NULL,
'tab_name' => 'Details',
'db' => [
'type' => 'INT(11)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'php_view' => [
'name' => 'php_view',
'label' =>
'COM_COMPONENTBUILDER_TEMPLATE_PHP_VIEW_LABEL',
'type' => 'editor',
'title' => false,
'list' => 'templates',
'store' => 'base64',
'tab_name' => 'Custom Script',
'db' => [
'type' => 'MEDIUMTEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'add_php_view' => [
'name' => 'add_php_view',
'label' =>
'COM_COMPONENTBUILDER_TEMPLATE_ADD_PHP_VIEW_LABEL',
'type' => 'radio',
'title' => false,
'list' => 'templates',
'store' => NULL,
'tab_name' => 'Custom Script',
'db' => [
'type' => 'TINYINT(1)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'template' => [
'name' => 'template',
'label' =>
'COM_COMPONENTBUILDER_TEMPLATE_TEMPLATE_LABEL',
'type' => 'editor',
'title' => false,
'list' => 'templates',
'store' => 'base64',
'tab_name' => 'Details',
'db' => [
'type' => 'TEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'snippet' => [
'name' => 'snippet',
'label' =>
'COM_COMPONENTBUILDER_TEMPLATE_SNIPPET_LABEL',
'type' => 'snippets',
'title' => false,
'list' => 'templates',
'store' => NULL,
'tab_name' => 'Details',
'db' => [
'type' => 'INT(11)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'libraries' => [
'name' => 'libraries',
'label' =>
'COM_COMPONENTBUILDER_TEMPLATE_LIBRARIES_LABEL',
'type' => 'libraries',
'title' => false,
'list' => 'templates',
'store' => 'json',
'tab_name' => 'Details',
'db' => [
'type' => 'TEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'alias' => [
'name' => 'alias',
'label' =>
'COM_COMPONENTBUILDER_TEMPLATE_ALIAS_LABEL',
'type' => 'text',
'title' => false,
'list' => 'templates',
'store' => NULL,
'tab_name' => 'Details',
'db' => [
'type' => 'VARCHAR(255)',
'default' => '',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'access' => [
'name' => 'access',
'label' => 'Access',
'type' => 'accesslevel',
'title' => false,
'store' => NULL,
'tab_name' => NULL,
'db' => [
'type' => 'INT(10) unsigned',
'default' => '0',
'key' => true,
'null_switch' => 'NULL',
],
],
],
'layout' => [
'name' => [
'name' => 'name',
'label' =>
'COM_COMPONENTBUILDER_LAYOUT_NAME_LABEL',
'type' => 'text',
'title' => true,
'list' => 'layouts',
'store' => NULL,
'tab_name' => 'Details',
'db' => [
'type' => 'VARCHAR(255)',
'default' => '',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'description' => [
'name' => 'description',
'label' =>
'COM_COMPONENTBUILDER_LAYOUT_DESCRIPTION_LABEL',
'type' => 'text',
'title' => false,
'list' => 'layouts',
'store' => NULL,
'tab_name' => 'Details',
'db' => [
'type' => 'VARCHAR(255)',
'default' => '',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'dynamic_get' => [
'name' => 'dynamic_get',
'label' =>
'COM_COMPONENTBUILDER_LAYOUT_DYNAMIC_GET_LABEL',
'type' => 'dynamicget',
'title' => false,
'list' => 'layouts',
'store' => NULL,
'tab_name' => 'Details',
'db' => [
'type' => 'INT(11)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'snippet' => [
'name' => 'snippet',
'label' =>
'COM_COMPONENTBUILDER_LAYOUT_SNIPPET_LABEL',
'type' => 'snippets',
'title' => false,
'list' => 'layouts',
'store' => NULL,
'tab_name' => 'Details',
'db' => [
'type' => 'INT(11)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'php_view' => [
'name' => 'php_view',
'label' =>
'COM_COMPONENTBUILDER_LAYOUT_PHP_VIEW_LABEL',
'type' => 'editor',
'title' => false,
'list' => 'layouts',
'store' => 'base64',
'tab_name' => 'Custom Script',
'db' => [
'type' => 'MEDIUMTEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'add_php_view' => [
'name' => 'add_php_view',
'label' =>
'COM_COMPONENTBUILDER_LAYOUT_ADD_PHP_VIEW_LABEL',
'type' => 'radio',
'title' => false,
'list' => 'layouts',
'store' => NULL,
'tab_name' => 'Custom Script',
'db' => [
'type' => 'TINYINT(1)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'layout' => [
'name' => 'layout',
'label' =>
'COM_COMPONENTBUILDER_LAYOUT_LAYOUT_LABEL',
'type' => 'editor',
'title' => false,
'list' => 'layouts',
'store' => 'base64',
'tab_name' => 'Details',
'db' => [
'type' => 'TEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'libraries' => [
'name' => 'libraries',
'label' =>
'COM_COMPONENTBUILDER_LAYOUT_LIBRARIES_LABEL',
'type' => 'libraries',
'title' => false,
'list' => 'layouts',
'store' => 'json',
'tab_name' => 'Details',
'db' => [
'type' => 'TEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'alias' => [
'name' => 'alias',
'label' =>
'COM_COMPONENTBUILDER_LAYOUT_ALIAS_LABEL',
'type' => 'text',
'title' => false,
'list' => 'layouts',
'store' => NULL,
'tab_name' => 'Details',
'db' => [
'type' => 'VARCHAR(255)',
'default' => '',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'access' => [
'name' => 'access',
'label' => 'Access',
'type' => 'accesslevel',
'title' => false,
'store' => NULL,
'tab_name' => NULL,
'db' => [
'type' => 'INT(10) unsigned',
'default' => '0',
'key' => true,
'null_switch' => 'NULL',
],
],
],
'dynamic_get' => [
'name' => [
'name' => 'name',
'label' =>
'COM_COMPONENTBUILDER_DYNAMIC_GET_NAME_LABEL',
'type' => 'text',
'title' => true,
'list' => 'dynamic_gets',
'store' => NULL,
'tab_name' => 'Main',
'db' => [
'type' => 'VARCHAR(255)',
'default' => '',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'main_source' => [
'name' => 'main_source',
'label' =>
'COM_COMPONENTBUILDER_DYNAMIC_GET_MAIN_SOURCE_LABEL',
'type' => 'list',
'title' => false,
'list' => 'dynamic_gets',
'store' => NULL,
'tab_name' => 'Main',
'db' => [
'type' => 'TINYINT(1)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'gettype' => [
'name' => 'gettype',
'label' =>
'COM_COMPONENTBUILDER_DYNAMIC_GET_GETTYPE_LABEL',
'type' => 'list',
'title' => false,
'list' => 'dynamic_gets',
'store' => NULL,
'tab_name' => 'Main',
'db' => [
'type' => 'TINYINT(1)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'php_calculation' => [
'name' => 'php_calculation',
'label' =>
'COM_COMPONENTBUILDER_DYNAMIC_GET_PHP_CALCULATION_LABEL',
'type' => 'editor',
'title' => false,
'list' => 'dynamic_gets',
'store' => 'base64',
'tab_name' => 'Abacus',
'db' => [
'type' => 'MEDIUMTEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'php_router_parse' => [
'name' => 'php_router_parse',
'label' =>
'COM_COMPONENTBUILDER_DYNAMIC_GET_PHP_ROUTER_PARSE_LABEL',
'type' => 'textarea',
'title' => false,
'list' => 'dynamic_gets',
'store' => 'base64',
'tab_name' => 'Custom Script',
'db' => [
'type' => 'MEDIUMTEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'add_php_after_getitems' => [
'name' => 'add_php_after_getitems',
'label' =>
'COM_COMPONENTBUILDER_DYNAMIC_GET_ADD_PHP_AFTER_GETITEMS_LABEL',
'type' => 'radio',
'title' => false,
'list' => 'dynamic_gets',
'store' => NULL,
'tab_name' => 'Custom Script',
'db' => [
'type' => 'TINYINT(1)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'add_php_router_parse' => [
'name' => 'add_php_router_parse',
'label' =>
'COM_COMPONENTBUILDER_DYNAMIC_GET_ADD_PHP_ROUTER_PARSE_LABEL',
'type' => 'radio',
'title' => false,
'list' => 'dynamic_gets',
'store' => NULL,
'tab_name' => 'Custom Script',
'db' => [
'type' => 'TINYINT(1)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'view_selection' => [
'name' => 'view_selection',
'label' =>
'COM_COMPONENTBUILDER_DYNAMIC_GET_VIEW_SELECTION_LABEL',
'type' => 'textarea',
'title' => false,
'list' => 'dynamic_gets',
'store' => NULL,
'tab_name' => 'Main',
'db' => [
'type' => 'TEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'add_php_before_getitems' => [
'name' => 'add_php_before_getitems',
'label' =>
'COM_COMPONENTBUILDER_DYNAMIC_GET_ADD_PHP_BEFORE_GETITEMS_LABEL',
'type' => 'radio',
'title' => false,
'list' => 'dynamic_gets',
'store' => NULL,
'tab_name' => 'Custom Script',
'db' => [
'type' => 'TINYINT(1)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'add_php_before_getitem' => [
'name' => 'add_php_before_getitem',
'label' =>
'COM_COMPONENTBUILDER_DYNAMIC_GET_ADD_PHP_BEFORE_GETITEM_LABEL',
'type' => 'radio',
'title' => false,
'list' => 'dynamic_gets',
'store' => NULL,
'tab_name' => 'Custom Script',
'db' => [
'type' => 'TINYINT(1)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'add_php_after_getitem' => [
'name' => 'add_php_after_getitem',
'label' =>
'COM_COMPONENTBUILDER_DYNAMIC_GET_ADD_PHP_AFTER_GETITEM_LABEL',
'type' => 'radio',
'title' => false,
'list' => 'dynamic_gets',
'store' => NULL,
'tab_name' => 'Custom Script',
'db' => [
'type' => 'TINYINT(1)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'db_table_main' => [
'name' => 'db_table_main',
'label' =>
'COM_COMPONENTBUILDER_DYNAMIC_GET_DB_TABLE_MAIN_LABEL',
'type' => 'dbtables',
'title' => false,
'list' => 'dynamic_gets',
'store' => NULL,
'tab_name' => 'Main',
'db' => [
'type' => 'VARCHAR(255)',
'default' => '',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'php_custom_get' => [
'name' => 'php_custom_get',
'label' =>
'COM_COMPONENTBUILDER_DYNAMIC_GET_PHP_CUSTOM_GET_LABEL',
'type' => 'editor',
'title' => false,
'list' => 'dynamic_gets',
'store' => 'base64',
'tab_name' => 'Main',
'db' => [
'type' => 'MEDIUMTEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'plugin_events' => [
'name' => 'plugin_events',
'label' =>
'COM_COMPONENTBUILDER_DYNAMIC_GET_PLUGIN_EVENTS_LABEL',
'type' => 'list',
'title' => false,
'list' => 'dynamic_gets',
'store' => 'json',
'tab_name' => 'Main',
'db' => [
'type' => 'VARCHAR(255)',
'default' => '',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'db_selection' => [
'name' => 'db_selection',
'label' =>
'COM_COMPONENTBUILDER_DYNAMIC_GET_DB_SELECTION_LABEL',
'type' => 'textarea',
'title' => false,
'list' => 'dynamic_gets',
'store' => NULL,
'tab_name' => 'Main',
'db' => [
'type' => 'TEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'view_table_main' => [
'name' => 'view_table_main',
'label' =>
'COM_COMPONENTBUILDER_DYNAMIC_GET_VIEW_TABLE_MAIN_LABEL',
'type' => 'adminviews',
'title' => false,
'list' => 'dynamic_gets',
'store' => NULL,
'tab_name' => 'Main',
'db' => [
'type' => 'INT(11)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'add_php_getlistquery' => [
'name' => 'add_php_getlistquery',
'label' =>
'COM_COMPONENTBUILDER_DYNAMIC_GET_ADD_PHP_GETLISTQUERY_LABEL',
'type' => 'radio',
'title' => false,
'list' => 'dynamic_gets',
'store' => NULL,
'tab_name' => 'Custom Script',
'db' => [
'type' => 'TINYINT(1)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'join_db_table' => [
'name' => 'join_db_table',
'label' =>
'COM_COMPONENTBUILDER_DYNAMIC_GET_JOIN_DB_TABLE_LABEL',
'type' => 'subform',
'title' => false,
'list' => 'dynamic_gets',
'store' => 'json',
'tab_name' => 'Joint',
'db' => [
'type' => 'TEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'select_all' => [
'name' => 'select_all',
'label' =>
'COM_COMPONENTBUILDER_DYNAMIC_GET_SELECT_ALL_LABEL',
'type' => 'radio',
'title' => false,
'list' => 'dynamic_gets',
'store' => NULL,
'tab_name' => 'Main',
'db' => [
'type' => 'TINYINT(1)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'php_before_getitem' => [
'name' => 'php_before_getitem',
'label' =>
'COM_COMPONENTBUILDER_DYNAMIC_GET_PHP_BEFORE_GETITEM_LABEL',
'type' => 'editor',
'title' => false,
'list' => 'dynamic_gets',
'store' => 'base64',
'tab_name' => 'Custom Script',
'db' => [
'type' => 'MEDIUMTEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'getcustom' => [
'name' => 'getcustom',
'label' =>
'COM_COMPONENTBUILDER_DYNAMIC_GET_GETCUSTOM_LABEL',
'type' => 'text',
'title' => false,
'list' => 'dynamic_gets',
'store' => NULL,
'tab_name' => 'Main',
'db' => [
'type' => 'VARCHAR(255)',
'default' => '',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'php_after_getitem' => [
'name' => 'php_after_getitem',
'label' =>
'COM_COMPONENTBUILDER_DYNAMIC_GET_PHP_AFTER_GETITEM_LABEL',
'type' => 'editor',
'title' => false,
'list' => 'dynamic_gets',
'store' => 'base64',
'tab_name' => 'Custom Script',
'db' => [
'type' => 'MEDIUMTEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'pagination' => [
'name' => 'pagination',
'label' =>
'COM_COMPONENTBUILDER_DYNAMIC_GET_PAGINATION_LABEL',
'type' => 'radio',
'title' => false,
'list' => 'dynamic_gets',
'store' => NULL,
'tab_name' => 'Main',
'db' => [
'type' => 'TINYINT(1)',
'default' => '1',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'php_getlistquery' => [
'name' => 'php_getlistquery',
'label' =>
'COM_COMPONENTBUILDER_DYNAMIC_GET_PHP_GETLISTQUERY_LABEL',
'type' => 'editor',
'title' => false,
'list' => 'dynamic_gets',
'store' => 'base64',
'tab_name' => 'Custom Script',
'db' => [
'type' => 'MEDIUMTEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'php_before_getitems' => [
'name' => 'php_before_getitems',
'label' =>
'COM_COMPONENTBUILDER_DYNAMIC_GET_PHP_BEFORE_GETITEMS_LABEL',
'type' => 'editor',
'title' => false,
'list' => 'dynamic_gets',
'store' => 'base64',
'tab_name' => 'Custom Script',
'db' => [
'type' => 'MEDIUMTEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'filter' => [
'name' => 'filter',
'label' =>
'COM_COMPONENTBUILDER_DYNAMIC_GET_FILTER_LABEL',
'type' => 'subform',
'title' => false,
'list' => 'dynamic_gets',
'store' => 'json',
'tab_name' => 'Tweak',
'db' => [
'type' => 'TEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'php_after_getitems' => [
'name' => 'php_after_getitems',
'label' =>
'COM_COMPONENTBUILDER_DYNAMIC_GET_PHP_AFTER_GETITEMS_LABEL',
'type' => 'editor',
'title' => false,
'list' => 'dynamic_gets',
'store' => 'base64',
'tab_name' => 'Custom Script',
'db' => [
'type' => 'MEDIUMTEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'where' => [
'name' => 'where',
'label' =>
'COM_COMPONENTBUILDER_DYNAMIC_GET_WHERE_LABEL',
'type' => 'subform',
'title' => false,
'list' => 'dynamic_gets',
'store' => 'json',
'tab_name' => 'Tweak',
'db' => [
'type' => 'TEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'order' => [
'name' => 'order',
'label' =>
'COM_COMPONENTBUILDER_DYNAMIC_GET_ORDER_LABEL',
'type' => 'subform',
'title' => false,
'list' => 'dynamic_gets',
'store' => 'json',
'tab_name' => 'Tweak',
'db' => [
'type' => 'TEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'addcalculation' => [
'name' => 'addcalculation',
'label' =>
'COM_COMPONENTBUILDER_DYNAMIC_GET_ADDCALCULATION_LABEL',
'type' => 'radio',
'title' => false,
'list' => 'dynamic_gets',
'store' => NULL,
'tab_name' => 'Abacus',
'db' => [
'type' => 'TINYINT(1)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'group' => [
'name' => 'group',
'label' =>
'COM_COMPONENTBUILDER_DYNAMIC_GET_GROUP_LABEL',
'type' => 'subform',
'title' => false,
'list' => 'dynamic_gets',
'store' => 'json',
'tab_name' => 'Tweak',
'db' => [
'type' => 'TEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'global' => [
'name' => 'global',
'label' =>
'COM_COMPONENTBUILDER_DYNAMIC_GET_GLOBAL_LABEL',
'type' => 'subform',
'title' => false,
'list' => 'dynamic_gets',
'store' => 'json',
'tab_name' => 'Tweak',
'db' => [
'type' => 'TEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'guid' => [
'name' => 'guid',
'label' =>
'COM_COMPONENTBUILDER_DYNAMIC_GET_GUID_LABEL',
'type' => 'text',
'title' => false,
'list' => 'dynamic_gets',
'store' => NULL,
'tab_name' => 'publishing',
'db' => [
'type' => 'VARCHAR(36)',
'default' => '',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'join_view_table' => [
'name' => 'join_view_table',
'label' =>
'COM_COMPONENTBUILDER_DYNAMIC_GET_JOIN_VIEW_TABLE_LABEL',
'type' => 'subform',
'title' => false,
'list' => 'dynamic_gets',
'store' => 'json',
'tab_name' => 'Joint',
'db' => [
'type' => 'TEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'access' => [
'name' => 'access',
'label' => 'Access',
'type' => 'accesslevel',
'title' => false,
'store' => NULL,
'tab_name' => NULL,
'db' => [
'type' => 'INT(10) unsigned',
'default' => '0',
'key' => true,
'null_switch' => 'NULL',
],
],
],
'custom_code' => [
'component' => [
'name' => 'component',
'label' =>
'COM_COMPONENTBUILDER_CUSTOM_CODE_COMPONENT_LABEL',
'type' => 'joomlacomponent',
'title' => true,
'list' => 'custom_codes',
'store' => NULL,
'tab_name' => 'Details',
'db' => [
'type' => 'INT(11)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'path' => [
'name' => 'path',
'label' =>
'COM_COMPONENTBUILDER_CUSTOM_CODE_PATH_LABEL',
'type' => 'text',
'title' => false,
'list' => 'custom_codes',
'store' => NULL,
'tab_name' => 'Details',
'db' => [
'type' => 'TEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'target' => [
'name' => 'target',
'label' =>
'COM_COMPONENTBUILDER_CUSTOM_CODE_TARGET_LABEL',
'type' => 'radio',
'title' => false,
'list' => 'custom_codes',
'store' => NULL,
'tab_name' => 'Details',
'db' => [
'type' => 'TINYINT(1)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'type' => [
'name' => 'type',
'label' =>
'COM_COMPONENTBUILDER_CUSTOM_CODE_TYPE_LABEL',
'type' => 'radio',
'title' => false,
'list' => 'custom_codes',
'store' => NULL,
'tab_name' => 'Details',
'db' => [
'type' => 'TINYINT(1)',
'default' => '0',
'null_switch' => 'NULL',
'unique_key' => false,
'key' => true,
],
],
'comment_type' => [
'name' => 'comment_type',
'label' =>
'COM_COMPONENTBUILDER_CUSTOM_CODE_COMMENT_TYPE_LABEL',
'type' => 'radio',
'title' => false,
'list' => 'custom_codes',
'store' => NULL,
'tab_name' => 'Details',
'db' => [
'type' => 'TINYINT(1)',
'default' => '1',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'joomla_version' => [
'name' => 'joomla_version',
'label' =>
'COM_COMPONENTBUILDER_CUSTOM_CODE_JOOMLA_VERSION_LABEL',
'type' => 'number',
'title' => false,
'list' => 'custom_codes',
'store' => NULL,
'tab_name' => 'Details',
'db' => [
'type' => 'INT(11)',
'default' => '3',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'function_name' => [
'name' => 'function_name',
'label' =>
'COM_COMPONENTBUILDER_CUSTOM_CODE_FUNCTION_NAME_LABEL',
'type' => 'text',
'title' => false,
'list' => 'custom_codes',
'store' => NULL,
'tab_name' => 'Details',
'db' => [
'type' => 'VARCHAR(255)',
'default' => '',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'system_name' => [
'name' => 'system_name',
'label' =>
'COM_COMPONENTBUILDER_CUSTOM_CODE_SYSTEM_NAME_LABEL',
'type' => 'text',
'title' => false,
'list' => 'custom_codes',
'store' => NULL,
'tab_name' => 'Details',
'db' => [
'type' => 'VARCHAR(255)',
'default' => '',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'code' => [
'name' => 'code',
'label' =>
'COM_COMPONENTBUILDER_CUSTOM_CODE_CODE_LABEL',
'type' => 'editor',
'title' => false,
'list' => 'custom_codes',
'store' => 'base64',
'tab_name' => 'Details',
'db' => [
'type' => 'MEDIUMTEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'hashendtarget' => [
'name' => 'hashendtarget',
'label' =>
'COM_COMPONENTBUILDER_CUSTOM_CODE_HASHENDTARGET_LABEL',
'type' => 'text',
'title' => false,
'list' => 'custom_codes',
'store' => NULL,
'tab_name' => 'Details',
'db' => [
'type' => 'VARCHAR(64)',
'default' => '',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'to_line' => [
'name' => 'to_line',
'label' =>
'COM_COMPONENTBUILDER_CUSTOM_CODE_TO_LINE_LABEL',
'type' => 'text',
'title' => false,
'list' => 'custom_codes',
'store' => NULL,
'tab_name' => 'Details',
'db' => [
'type' => 'VARCHAR(100)',
'default' => '',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'from_line' => [
'name' => 'from_line',
'label' =>
'COM_COMPONENTBUILDER_CUSTOM_CODE_FROM_LINE_LABEL',
'type' => 'text',
'title' => false,
'list' => 'custom_codes',
'store' => NULL,
'tab_name' => 'Details',
'db' => [
'type' => 'VARCHAR(100)',
'default' => '',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'hashtarget' => [
'name' => 'hashtarget',
'label' =>
'COM_COMPONENTBUILDER_CUSTOM_CODE_HASHTARGET_LABEL',
'type' => 'text',
'title' => false,
'list' => 'custom_codes',
'store' => NULL,
'tab_name' => 'Details',
'db' => [
'type' => 'VARCHAR(64)',
'default' => '',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'access' => [
'name' => 'access',
'label' => 'Access',
'type' => 'accesslevel',
'title' => false,
'store' => NULL,
'tab_name' => NULL,
'db' => [
'type' => 'INT(10) unsigned',
'default' => '0',
'key' => true,
'null_switch' => 'NULL',
],
],
],
'class_property' => [
'name' => [
'name' => 'name',
'label' =>
'COM_COMPONENTBUILDER_CLASS_PROPERTY_NAME_LABEL',
'type' => 'text',
'title' => true,
'list' => 'class_properties',
'store' => NULL,
'tab_name' => 'Details',
'db' => [
'type' => 'VARCHAR(255)',
'default' => '',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'visibility' => [
'name' => 'visibility',
'label' =>
'COM_COMPONENTBUILDER_CLASS_PROPERTY_VISIBILITY_LABEL',
'type' => 'list',
'title' => false,
'list' => 'class_properties',
'store' => NULL,
'tab_name' => 'Details',
'db' => [
'type' => 'VARCHAR(255)',
'default' => '',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'extension_type' => [
'name' => 'extension_type',
'label' =>
'COM_COMPONENTBUILDER_CLASS_PROPERTY_EXTENSION_TYPE_LABEL',
'type' => 'list',
'title' => false,
'list' => 'class_properties',
'store' => NULL,
'tab_name' => 'Details',
'db' => [
'type' => 'VARCHAR(64)',
'default' => '',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'guid' => [
'name' => 'guid',
'label' =>
'COM_COMPONENTBUILDER_CLASS_PROPERTY_GUID_LABEL',
'type' => 'text',
'title' => false,
'list' => 'class_properties',
'store' => NULL,
'tab_name' => 'publishing',
'db' => [
'type' => 'VARCHAR(36)',
'default' => '',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'comment' => [
'name' => 'comment',
'label' =>
'COM_COMPONENTBUILDER_CLASS_PROPERTY_COMMENT_LABEL',
'type' => 'textarea',
'title' => false,
'list' => 'class_properties',
'store' => 'base64',
'tab_name' => 'Details',
'db' => [
'type' => 'TEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'joomla_plugin_group' => [
'name' => 'joomla_plugin_group',
'label' =>
'COM_COMPONENTBUILDER_CLASS_PROPERTY_JOOMLA_PLUGIN_GROUP_LABEL',
'type' => 'joomlaplugingroups',
'title' => false,
'list' => 'class_properties',
'store' => NULL,
'tab_name' => 'Details',
'db' => [
'type' => 'INT(11)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'default' => [
'name' => 'default',
'label' =>
'COM_COMPONENTBUILDER_CLASS_PROPERTY_DEFAULT_LABEL',
'type' => 'textarea',
'title' => false,
'list' => 'class_properties',
'store' => 'base64',
'tab_name' => 'Details',
'db' => [
'type' => 'TEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'access' => [
'name' => 'access',
'label' => 'Access',
'type' => 'accesslevel',
'title' => false,
'store' => NULL,
'tab_name' => NULL,
'db' => [
'type' => 'INT(10) unsigned',
'default' => '0',
'key' => true,
'null_switch' => 'NULL',
],
],
],
'class_method' => [
'name' => [
'name' => 'name',
'label' =>
'COM_COMPONENTBUILDER_CLASS_METHOD_NAME_LABEL',
'type' => 'text',
'title' => true,
'list' => 'class_methods',
'store' => NULL,
'tab_name' => 'Details',
'db' => [
'type' => 'VARCHAR(255)',
'default' => '',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'visibility' => [
'name' => 'visibility',
'label' =>
'COM_COMPONENTBUILDER_CLASS_METHOD_VISIBILITY_LABEL',
'type' => 'list',
'title' => false,
'list' => 'class_methods',
'store' => NULL,
'tab_name' => 'Details',
'db' => [
'type' => 'VARCHAR(255)',
'default' => '',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'extension_type' => [
'name' => 'extension_type',
'label' =>
'COM_COMPONENTBUILDER_CLASS_METHOD_EXTENSION_TYPE_LABEL',
'type' => 'list',
'title' => false,
'list' => 'class_methods',
'store' => NULL,
'tab_name' => 'Details',
'db' => [
'type' => 'VARCHAR(64)',
'default' => '',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'guid' => [
'name' => 'guid',
'label' =>
'COM_COMPONENTBUILDER_CLASS_METHOD_GUID_LABEL',
'type' => 'text',
'title' => false,
'list' => 'class_methods',
'store' => NULL,
'tab_name' => 'publishing',
'db' => [
'type' => 'VARCHAR(36)',
'default' => '',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'code' => [
'name' => 'code',
'label' =>
'COM_COMPONENTBUILDER_CLASS_METHOD_CODE_LABEL',
'type' => 'editor',
'title' => false,
'list' => 'class_methods',
'store' => 'base64',
'tab_name' => 'Details',
'db' => [
'type' => 'MEDIUMTEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'comment' => [
'name' => 'comment',
'label' =>
'COM_COMPONENTBUILDER_CLASS_METHOD_COMMENT_LABEL',
'type' => 'textarea',
'title' => false,
'list' => 'class_methods',
'store' => 'base64',
'tab_name' => 'Details',
'db' => [
'type' => 'TEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'joomla_plugin_group' => [
'name' => 'joomla_plugin_group',
'label' =>
'COM_COMPONENTBUILDER_CLASS_METHOD_JOOMLA_PLUGIN_GROUP_LABEL',
'type' => 'joomlaplugingroups',
'title' => false,
'list' => 'class_methods',
'store' => NULL,
'tab_name' => 'Details',
'db' => [
'type' => 'INT(11)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'arguments' => [
'name' => 'arguments',
'label' =>
'COM_COMPONENTBUILDER_CLASS_METHOD_ARGUMENTS_LABEL',
'type' => 'text',
'title' => false,
'list' => 'class_methods',
'store' => 'base64',
'tab_name' => 'Details',
'db' => [
'type' => 'TEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'access' => [
'name' => 'access',
'label' => 'Access',
'type' => 'accesslevel',
'title' => false,
'store' => NULL,
'tab_name' => NULL,
'db' => [
'type' => 'INT(10) unsigned',
'default' => '0',
'key' => true,
'null_switch' => 'NULL',
],
],
],
'placeholder' => [
'target' => [
'name' => 'target',
'label' =>
'COM_COMPONENTBUILDER_PLACEHOLDER_TARGET_LABEL',
'type' => 'text',
'title' => true,
'list' => 'placeholders',
'store' => NULL,
'tab_name' => 'Details',
'db' => [
'type' => 'VARCHAR(255)',
'default' => '',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'value' => [
'name' => 'value',
'label' =>
'COM_COMPONENTBUILDER_PLACEHOLDER_VALUE_LABEL',
'type' => 'textarea',
'title' => false,
'list' => 'placeholders',
'store' => 'base64',
'tab_name' => 'Details',
'db' => [
'type' => 'TEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'access' => [
'name' => 'access',
'label' => 'Access',
'type' => 'accesslevel',
'title' => false,
'store' => NULL,
'tab_name' => NULL,
'db' => [
'type' => 'INT(10) unsigned',
'default' => '0',
'key' => true,
'null_switch' => 'NULL',
],
],
],
'library' => [
'name' => [
'name' => 'name',
'label' =>
'COM_COMPONENTBUILDER_LIBRARY_NAME_LABEL',
'type' => 'text',
'title' => true,
'list' => 'libraries',
'store' => NULL,
'tab_name' => 'Behaviour',
'db' => [
'type' => 'VARCHAR(255)',
'default' => '',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'target' => [
'name' => 'target',
'label' =>
'COM_COMPONENTBUILDER_LIBRARY_TARGET_LABEL',
'type' => 'radio',
'title' => false,
'list' => 'libraries',
'store' => NULL,
'tab_name' => 'Behaviour',
'db' => [
'type' => 'TINYINT(1)',
'default' => '1',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'how' => [
'name' => 'how',
'label' =>
'COM_COMPONENTBUILDER_LIBRARY_HOW_LABEL',
'type' => 'filebehaviour',
'title' => false,
'list' => 'libraries',
'store' => NULL,
'tab_name' => 'Behaviour',
'db' => [
'type' => 'TINYINT(1)',
'default' => '1',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'type' => [
'name' => 'type',
'label' =>
'COM_COMPONENTBUILDER_LIBRARY_TYPE_LABEL',
'type' => 'radio',
'title' => false,
'list' => 'libraries',
'store' => NULL,
'tab_name' => 'Behaviour',
'db' => [
'type' => 'TINYINT(1)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'description' => [
'name' => 'description',
'label' =>
'COM_COMPONENTBUILDER_LIBRARY_DESCRIPTION_LABEL',
'type' => 'text',
'title' => false,
'list' => 'libraries',
'store' => NULL,
'tab_name' => 'Behaviour',
'db' => [
'type' => 'VARCHAR(255)',
'default' => '',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'libraries' => [
'name' => 'libraries',
'label' =>
'COM_COMPONENTBUILDER_LIBRARY_LIBRARIES_LABEL',
'type' => 'librariesx',
'title' => false,
'list' => 'libraries',
'store' => 'json',
'tab_name' => 'Behaviour',
'db' => [
'type' => 'TEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'php_setdocument' => [
'name' => 'php_setdocument',
'label' =>
'COM_COMPONENTBUILDER_LIBRARY_PHP_SETDOCUMENT_LABEL',
'type' => 'textarea',
'title' => false,
'list' => 'libraries',
'store' => 'base64',
'tab_name' => 'Behaviour',
'db' => [
'type' => 'MEDIUMTEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'addconditions' => [
'name' => 'addconditions',
'label' =>
'COM_COMPONENTBUILDER_LIBRARY_ADDCONDITIONS_LABEL',
'type' => 'subform',
'title' => false,
'list' => 'libraries',
'store' => 'json',
'tab_name' => 'Behaviour',
'db' => [
'type' => 'MEDIUMTEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'guid' => [
'name' => 'guid',
'label' =>
'COM_COMPONENTBUILDER_LIBRARY_GUID_LABEL',
'type' => 'text',
'title' => false,
'list' => 'libraries',
'store' => NULL,
'tab_name' => 'publishing',
'db' => [
'type' => 'VARCHAR(36)',
'default' => '',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'access' => [
'name' => 'access',
'label' => 'Access',
'type' => 'accesslevel',
'title' => false,
'store' => NULL,
'tab_name' => NULL,
'db' => [
'type' => 'INT(10) unsigned',
'default' => '0',
'key' => true,
'null_switch' => 'NULL',
],
],
],
'snippet' => [
'name' => [
'name' => 'name',
'label' =>
'COM_COMPONENTBUILDER_SNIPPET_NAME_LABEL',
'type' => 'text',
'title' => true,
'list' => 'snippets',
'store' => NULL,
'tab_name' => 'Details',
'db' => [
'type' => 'VARCHAR(255)',
'default' => '',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'url' => [
'name' => 'url',
'label' =>
'COM_COMPONENTBUILDER_SNIPPET_URL_LABEL',
'type' => 'url',
'title' => false,
'list' => 'snippets',
'store' => NULL,
'tab_name' => 'Details',
'db' => [
'type' => 'VARCHAR(255)',
'default' => '',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'type' => [
'name' => 'type',
'label' =>
'COM_COMPONENTBUILDER_SNIPPET_TYPE_LABEL',
'type' => 'snippettype',
'title' => false,
'list' => 'snippets',
'store' => NULL,
'tab_name' => 'Details',
'db' => [
'type' => 'INT(11)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'heading' => [
'name' => 'heading',
'label' =>
'COM_COMPONENTBUILDER_SNIPPET_HEADING_LABEL',
'type' => 'text',
'title' => false,
'list' => 'snippets',
'store' => NULL,
'tab_name' => 'Details',
'db' => [
'type' => 'VARCHAR(255)',
'default' => '',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'library' => [
'name' => 'library',
'label' =>
'COM_COMPONENTBUILDER_SNIPPET_LIBRARY_LABEL',
'type' => 'library',
'title' => false,
'list' => 'snippets',
'store' => NULL,
'tab_name' => 'Details',
'db' => [
'type' => 'INT(11)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'guid' => [
'name' => 'guid',
'label' =>
'COM_COMPONENTBUILDER_SNIPPET_GUID_LABEL',
'type' => 'text',
'title' => false,
'list' => 'snippets',
'store' => NULL,
'tab_name' => 'publishing',
'db' => [
'type' => 'VARCHAR(36)',
'default' => '',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'contributor_email' => [
'name' => 'contributor_email',
'label' =>
'COM_COMPONENTBUILDER_SNIPPET_CONTRIBUTOR_EMAIL_LABEL',
'type' => 'text',
'title' => false,
'list' => 'snippets',
'store' => NULL,
'tab_name' => 'Contributor',
'db' => [
'type' => 'VARCHAR(255)',
'default' => '',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'contributor_name' => [
'name' => 'contributor_name',
'label' =>
'COM_COMPONENTBUILDER_SNIPPET_CONTRIBUTOR_NAME_LABEL',
'type' => 'text',
'title' => false,
'list' => 'snippets',
'store' => NULL,
'tab_name' => 'Contributor',
'db' => [
'type' => 'VARCHAR(255)',
'default' => '',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'contributor_website' => [
'name' => 'contributor_website',
'label' =>
'COM_COMPONENTBUILDER_SNIPPET_CONTRIBUTOR_WEBSITE_LABEL',
'type' => 'text',
'title' => false,
'list' => 'snippets',
'store' => NULL,
'tab_name' => 'Contributor',
'db' => [
'type' => 'VARCHAR(255)',
'default' => '',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'contributor_company' => [
'name' => 'contributor_company',
'label' =>
'COM_COMPONENTBUILDER_SNIPPET_CONTRIBUTOR_COMPANY_LABEL',
'type' => 'text',
'title' => false,
'list' => 'snippets',
'store' => NULL,
'tab_name' => 'Contributor',
'db' => [
'type' => 'VARCHAR(255)',
'default' => '',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'snippet' => [
'name' => 'snippet',
'label' =>
'COM_COMPONENTBUILDER_SNIPPET_SNIPPET_LABEL',
'type' => 'textarea',
'title' => false,
'list' => 'snippets',
'store' => 'base64',
'tab_name' => 'Details',
'db' => [
'type' => 'TEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'usage' => [
'name' => 'usage',
'label' =>
'COM_COMPONENTBUILDER_SNIPPET_USAGE_LABEL',
'type' => 'textarea',
'title' => false,
'list' => 'snippets',
'store' => NULL,
'tab_name' => 'Details',
'db' => [
'type' => 'TEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'description' => [
'name' => 'description',
'label' =>
'COM_COMPONENTBUILDER_SNIPPET_DESCRIPTION_LABEL',
'type' => 'textarea',
'title' => false,
'list' => 'snippets',
'store' => NULL,
'tab_name' => 'Details',
'db' => [
'type' => 'TEXT',
'default' => 'EMPTY',
'null_switch' => 'NULL',
'unique_key' => false,
'key' => false,
],
],
'access' => [
'name' => 'access',
'label' => 'Access',
'type' => 'accesslevel',
'title' => false,
'store' => NULL,
'tab_name' => NULL,
'db' => [
'type' => 'INT(10) unsigned',
'default' => '0',
'key' => true,
'null_switch' => 'NULL',
],
],
],
'validation_rule' => [
'name' => [
'name' => 'name',
'label' =>
'COM_COMPONENTBUILDER_VALIDATION_RULE_NAME_LABEL',
'type' => 'text',
'title' => true,
'list' => 'validation_rules',
'store' => NULL,
'tab_name' => 'Extends FormRule',
'db' => [
'type' => 'VARCHAR(255)',
'default' => '',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'short_description' => [
'name' => 'short_description',
'label' =>
'COM_COMPONENTBUILDER_VALIDATION_RULE_SHORT_DESCRIPTION_LABEL',
'type' => 'text',
'title' => false,
'list' => 'validation_rules',
'store' => NULL,
'tab_name' => 'Extends FormRule',
'db' => [
'type' => 'VARCHAR(255)',
'default' => '',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'inherit' => [
'name' => 'inherit',
'label' =>
'COM_COMPONENTBUILDER_VALIDATION_RULE_INHERIT_LABEL',
'type' => 'existingvalidationrules',
'title' => false,
'list' => 'validation_rules',
'store' => NULL,
'tab_name' => 'Extends FormRule',
'db' => [
'type' => 'CHAR(64)',
'default' => '',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'php' => [
'name' => 'php',
'label' =>
'COM_COMPONENTBUILDER_VALIDATION_RULE_PHP_LABEL',
'type' => 'textarea',
'title' => false,
'list' => 'validation_rules',
'store' => 'base64',
'tab_name' => 'Extends FormRule',
'db' => [
'type' => 'MEDIUMTEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'access' => [
'name' => 'access',
'label' => 'Access',
'type' => 'accesslevel',
'title' => false,
'store' => NULL,
'tab_name' => NULL,
'db' => [
'type' => 'INT(10) unsigned',
'default' => '0',
'key' => true,
'null_switch' => 'NULL',
],
],
],
'field' => [
'name' => [
'name' => 'name',
'label' =>
'COM_COMPONENTBUILDER_FIELD_NAME_LABEL',
'type' => 'text',
'title' => true,
'list' => 'fields',
'store' => NULL,
'tab_name' => 'Set Properties',
'db' => [
'type' => 'VARCHAR(255)',
'default' => '',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'fieldtype' => [
'name' => 'fieldtype',
'label' =>
'COM_COMPONENTBUILDER_FIELD_FIELDTYPE_LABEL',
'type' => 'fieldtypes',
'title' => false,
'list' => 'fields',
'store' => NULL,
'tab_name' => 'Set Properties',
'db' => [
'type' => 'INT(11)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'datatype' => [
'name' => 'datatype',
'label' =>
'COM_COMPONENTBUILDER_FIELD_DATATYPE_LABEL',
'type' => 'list',
'title' => false,
'list' => 'fields',
'store' => NULL,
'tab_name' => 'Database',
'db' => [
'type' => 'CHAR(64)',
'default' => '',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'indexes' => [
'name' => 'indexes',
'label' =>
'COM_COMPONENTBUILDER_FIELD_INDEXES_LABEL',
'type' => 'list',
'title' => false,
'list' => 'fields',
'store' => NULL,
'tab_name' => 'Database',
'db' => [
'type' => 'CHAR(64)',
'default' => '',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'null_switch' => [
'name' => 'null_switch',
'label' =>
'COM_COMPONENTBUILDER_FIELD_NULL_SWITCH_LABEL',
'type' => 'radio',
'title' => false,
'list' => 'fields',
'store' => NULL,
'tab_name' => 'Database',
'db' => [
'type' => 'CHAR(64)',
'default' => '',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'store' => [
'name' => 'store',
'label' =>
'COM_COMPONENTBUILDER_FIELD_STORE_LABEL',
'type' => 'list',
'title' => false,
'list' => 'fields',
'store' => NULL,
'tab_name' => 'Database',
'db' => [
'type' => 'INT(11)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'catid' => [
'name' => 'catid',
'label' =>
'COM_COMPONENTBUILDER_FIELD_CATID_LABEL',
'type' => 'category',
'title' => false,
'list' => 'fields',
'store' => NULL,
'tab_name' => 'Set Properties',
'db' => [
'type' => 'INT(11)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'on_get_model_field' => [
'name' => 'on_get_model_field',
'label' =>
'COM_COMPONENTBUILDER_FIELD_ON_GET_MODEL_FIELD_LABEL',
'type' => 'textarea',
'title' => false,
'list' => 'fields',
'store' => 'base64',
'tab_name' => 'Database',
'db' => [
'type' => 'TEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'on_save_model_field' => [
'name' => 'on_save_model_field',
'label' =>
'COM_COMPONENTBUILDER_FIELD_ON_SAVE_MODEL_FIELD_LABEL',
'type' => 'textarea',
'title' => false,
'list' => 'fields',
'store' => 'base64',
'tab_name' => 'Database',
'db' => [
'type' => 'TEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'initiator_on_get_model' => [
'name' => 'initiator_on_get_model',
'label' =>
'COM_COMPONENTBUILDER_FIELD_INITIATOR_ON_GET_MODEL_LABEL',
'type' => 'textarea',
'title' => false,
'list' => 'fields',
'store' => 'base64',
'tab_name' => 'Database',
'db' => [
'type' => 'TEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'xml' => [
'name' => 'xml',
'label' => '',
'type' => 'hidden',
'title' => false,
'list' => 'fields',
'store' => 'json',
'tab_name' => 'Type Info',
'db' => [
'type' => 'TEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'datalenght' => [
'name' => 'datalenght',
'label' =>
'COM_COMPONENTBUILDER_FIELD_DATALENGHT_LABEL',
'type' => 'list',
'title' => false,
'list' => 'fields',
'store' => NULL,
'tab_name' => 'Database',
'db' => [
'type' => 'CHAR(64)',
'default' => '',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'javascript_view_footer' => [
'name' => 'javascript_view_footer',
'label' =>
'COM_COMPONENTBUILDER_FIELD_JAVASCRIPT_VIEW_FOOTER_LABEL',
'type' => 'editor',
'title' => false,
'list' => 'fields',
'store' => 'base64',
'tab_name' => 'Scripts',
'db' => [
'type' => 'TEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'css_views' => [
'name' => 'css_views',
'label' =>
'COM_COMPONENTBUILDER_FIELD_CSS_VIEWS_LABEL',
'type' => 'editor',
'title' => false,
'list' => 'fields',
'store' => 'base64',
'tab_name' => 'Scripts',
'db' => [
'type' => 'TEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'css_view' => [
'name' => 'css_view',
'label' =>
'COM_COMPONENTBUILDER_FIELD_CSS_VIEW_LABEL',
'type' => 'editor',
'title' => false,
'list' => 'fields',
'store' => 'base64',
'tab_name' => 'Scripts',
'db' => [
'type' => 'TEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'datadefault_other' => [
'name' => 'datadefault_other',
'label' =>
'COM_COMPONENTBUILDER_FIELD_DATADEFAULT_OTHER_LABEL',
'type' => 'text',
'title' => false,
'list' => 'fields',
'store' => NULL,
'tab_name' => 'Database',
'db' => [
'type' => 'CHAR(64)',
'default' => '',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'datadefault' => [
'name' => 'datadefault',
'label' =>
'COM_COMPONENTBUILDER_FIELD_DATADEFAULT_LABEL',
'type' => 'list',
'title' => false,
'list' => 'fields',
'store' => NULL,
'tab_name' => 'Database',
'db' => [
'type' => 'CHAR(64)',
'default' => '',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'datalenght_other' => [
'name' => 'datalenght_other',
'label' =>
'COM_COMPONENTBUILDER_FIELD_DATALENGHT_OTHER_LABEL',
'type' => 'text',
'title' => false,
'list' => 'fields',
'store' => NULL,
'tab_name' => 'Database',
'db' => [
'type' => 'CHAR(64)',
'default' => '',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'javascript_views_footer' => [
'name' => 'javascript_views_footer',
'label' =>
'COM_COMPONENTBUILDER_FIELD_JAVASCRIPT_VIEWS_FOOTER_LABEL',
'type' => 'editor',
'title' => false,
'list' => 'fields',
'store' => 'base64',
'tab_name' => 'Scripts',
'db' => [
'type' => 'TEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'add_css_view' => [
'name' => 'add_css_view',
'label' =>
'COM_COMPONENTBUILDER_FIELD_ADD_CSS_VIEW_LABEL',
'type' => 'radio',
'title' => false,
'list' => 'fields',
'store' => NULL,
'tab_name' => 'Scripts',
'db' => [
'type' => 'TINYINT(1)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'add_css_views' => [
'name' => 'add_css_views',
'label' =>
'COM_COMPONENTBUILDER_FIELD_ADD_CSS_VIEWS_LABEL',
'type' => 'radio',
'title' => false,
'list' => 'fields',
'store' => NULL,
'tab_name' => 'Scripts',
'db' => [
'type' => 'TINYINT(1)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'add_javascript_view_footer' => [
'name' => 'add_javascript_view_footer',
'label' =>
'COM_COMPONENTBUILDER_FIELD_ADD_JAVASCRIPT_VIEW_FOOTER_LABEL',
'type' => 'radio',
'title' => false,
'list' => 'fields',
'store' => NULL,
'tab_name' => 'Scripts',
'db' => [
'type' => 'TINYINT(1)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'add_javascript_views_footer' => [
'name' => 'add_javascript_views_footer',
'label' =>
'COM_COMPONENTBUILDER_FIELD_ADD_JAVASCRIPT_VIEWS_FOOTER_LABEL',
'type' => 'radio',
'title' => false,
'list' => 'fields',
'store' => NULL,
'tab_name' => 'Scripts',
'db' => [
'type' => 'TINYINT(1)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'initiator_on_save_model' => [
'name' => 'initiator_on_save_model',
'label' =>
'COM_COMPONENTBUILDER_FIELD_INITIATOR_ON_SAVE_MODEL_LABEL',
'type' => 'textarea',
'title' => false,
'list' => 'fields',
'store' => 'base64',
'tab_name' => 'Database',
'db' => [
'type' => 'TEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'guid' => [
'name' => 'guid',
'label' =>
'COM_COMPONENTBUILDER_FIELD_GUID_LABEL',
'type' => 'text',
'title' => false,
'list' => 'fields',
'store' => NULL,
'tab_name' => 'publishing',
'db' => [
'type' => 'VARCHAR(36)',
'default' => '',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'access' => [
'name' => 'access',
'label' => 'Access',
'type' => 'accesslevel',
'title' => false,
'store' => NULL,
'tab_name' => NULL,
'db' => [
'type' => 'INT(10) unsigned',
'default' => '0',
'key' => true,
'null_switch' => 'NULL',
],
],
],
'fieldtype' => [
'name' => [
'name' => 'name',
'label' =>
'COM_COMPONENTBUILDER_FIELDTYPE_NAME_LABEL',
'type' => 'text',
'title' => true,
'list' => 'fieldtypes',
'store' => NULL,
'tab_name' => 'Details',
'db' => [
'type' => 'VARCHAR(255)',
'default' => '',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'store' => [
'name' => 'store',
'label' =>
'COM_COMPONENTBUILDER_FIELDTYPE_STORE_LABEL',
'type' => 'list',
'title' => false,
'list' => 'fieldtypes',
'store' => NULL,
'tab_name' => 'Database (defaults)',
'db' => [
'type' => 'INT(11)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'null_switch' => [
'name' => 'null_switch',
'label' =>
'COM_COMPONENTBUILDER_FIELDTYPE_NULL_SWITCH_LABEL',
'type' => 'radio',
'title' => false,
'list' => 'fieldtypes',
'store' => NULL,
'tab_name' => 'Database (defaults)',
'db' => [
'type' => 'CHAR(64)',
'default' => '',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'indexes' => [
'name' => 'indexes',
'label' =>
'COM_COMPONENTBUILDER_FIELDTYPE_INDEXES_LABEL',
'type' => 'list',
'title' => false,
'list' => 'fieldtypes',
'store' => NULL,
'tab_name' => 'Database (defaults)',
'db' => [
'type' => 'CHAR(64)',
'default' => '',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'datadefault_other' => [
'name' => 'datadefault_other',
'label' =>
'COM_COMPONENTBUILDER_FIELDTYPE_DATADEFAULT_OTHER_LABEL',
'type' => 'text',
'title' => false,
'list' => 'fieldtypes',
'store' => NULL,
'tab_name' => 'Database (defaults)',
'db' => [
'type' => 'CHAR(64)',
'default' => '',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'datadefault' => [
'name' => 'datadefault',
'label' =>
'COM_COMPONENTBUILDER_FIELDTYPE_DATADEFAULT_LABEL',
'type' => 'list',
'title' => false,
'list' => 'fieldtypes',
'store' => NULL,
'tab_name' => 'Database (defaults)',
'db' => [
'type' => 'CHAR(64)',
'default' => '',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'short_description' => [
'name' => 'short_description',
'label' =>
'COM_COMPONENTBUILDER_FIELDTYPE_SHORT_DESCRIPTION_LABEL',
'type' => 'text',
'title' => false,
'list' => 'fieldtypes',
'store' => NULL,
'tab_name' => 'Details',
'db' => [
'type' => 'VARCHAR(255)',
'default' => '',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'datatype' => [
'name' => 'datatype',
'label' =>
'COM_COMPONENTBUILDER_FIELDTYPE_DATATYPE_LABEL',
'type' => 'list',
'title' => false,
'list' => 'fieldtypes',
'store' => NULL,
'tab_name' => 'Database (defaults)',
'db' => [
'type' => 'CHAR(64)',
'default' => '',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'has_defaults' => [
'name' => 'has_defaults',
'label' =>
'COM_COMPONENTBUILDER_FIELDTYPE_HAS_DEFAULTS_LABEL',
'type' => 'radio',
'title' => false,
'list' => 'fieldtypes',
'store' => NULL,
'tab_name' => 'Database (defaults)',
'db' => [
'type' => 'TINYINT(1)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'properties' => [
'name' => 'properties',
'label' =>
'COM_COMPONENTBUILDER_FIELDTYPE_PROPERTIES_LABEL',
'type' => 'subform',
'title' => false,
'list' => 'fieldtypes',
'store' => 'json',
'tab_name' => 'Details',
'db' => [
'type' => 'TEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'description' => [
'name' => 'description',
'label' =>
'COM_COMPONENTBUILDER_FIELDTYPE_DESCRIPTION_LABEL',
'type' => 'textarea',
'title' => false,
'list' => 'fieldtypes',
'store' => NULL,
'tab_name' => 'Details',
'db' => [
'type' => 'TEXT',
'default' => 'EMPTY',
'null_switch' => 'NULL',
'unique_key' => false,
'key' => false,
],
],
'datalenght' => [
'name' => 'datalenght',
'label' =>
'COM_COMPONENTBUILDER_FIELDTYPE_DATALENGHT_LABEL',
'type' => 'list',
'title' => false,
'list' => 'fieldtypes',
'store' => NULL,
'tab_name' => 'Database (defaults)',
'db' => [
'type' => 'CHAR(64)',
'default' => '',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'datalenght_other' => [
'name' => 'datalenght_other',
'label' =>
'COM_COMPONENTBUILDER_FIELDTYPE_DATALENGHT_OTHER_LABEL',
'type' => 'text',
'title' => false,
'list' => 'fieldtypes',
'store' => NULL,
'tab_name' => 'Database (defaults)',
'db' => [
'type' => 'CHAR(64)',
'default' => '',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'guid' => [
'name' => 'guid',
'label' =>
'COM_COMPONENTBUILDER_FIELDTYPE_GUID_LABEL',
'type' => 'text',
'title' => false,
'list' => 'fieldtypes',
'store' => NULL,
'tab_name' => 'publishing',
'db' => [
'type' => 'VARCHAR(36)',
'default' => '',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'catid' => [
'name' => 'catid',
'label' =>
'COM_COMPONENTBUILDER_FIELDTYPE_CATID_LABEL',
'type' => 'category',
'title' => false,
'list' => 'fieldtypes',
'store' => NULL,
'tab_name' => 'Details',
'db' => [
'type' => 'INT(11)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'access' => [
'name' => 'access',
'label' => 'Access',
'type' => 'accesslevel',
'title' => false,
'store' => NULL,
'tab_name' => NULL,
'db' => [
'type' => 'INT(10) unsigned',
'default' => '0',
'key' => true,
'null_switch' => 'NULL',
],
],
],
'language_translation' => [
'source' => [
'name' => 'source',
'label' =>
'COM_COMPONENTBUILDER_LANGUAGE_TRANSLATION_SOURCE_LABEL',
'type' => 'textarea',
'title' => true,
'list' => 'language_translations',
'store' => NULL,
'tab_name' => 'Details',
'db' => [
'type' => 'MEDIUMTEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'plugins' => [
'name' => 'plugins',
'label' =>
'COM_COMPONENTBUILDER_LANGUAGE_TRANSLATION_PLUGINS_LABEL',
'type' => 'joomlaplugins',
'title' => false,
'list' => 'language_translations',
'store' => 'json',
'tab_name' => 'Details',
'db' => [
'type' => 'TEXT',
'default' => 'EMPTY',
'null_switch' => 'NULL',
'unique_key' => false,
'key' => false,
],
],
'modules' => [
'name' => 'modules',
'label' =>
'COM_COMPONENTBUILDER_LANGUAGE_TRANSLATION_MODULES_LABEL',
'type' => 'joomlamodules',
'title' => false,
'list' => 'language_translations',
'store' => 'json',
'tab_name' => 'Details',
'db' => [
'type' => 'TEXT',
'default' => 'EMPTY',
'null_switch' => 'NULL',
'unique_key' => false,
'key' => false,
],
],
'components' => [
'name' => 'components',
'label' =>
'COM_COMPONENTBUILDER_LANGUAGE_TRANSLATION_COMPONENTS_LABEL',
'type' => 'joomlacomponents',
'title' => false,
'list' => 'language_translations',
'store' => 'json',
'tab_name' => 'Details',
'db' => [
'type' => 'TEXT',
'default' => 'EMPTY',
'null_switch' => 'NULL',
'unique_key' => false,
'key' => false,
],
],
'translation' => [
'name' => 'translation',
'label' =>
'COM_COMPONENTBUILDER_LANGUAGE_TRANSLATION_TRANSLATION_LABEL',
'type' => 'subform',
'title' => false,
'list' => 'language_translations',
'store' => 'json',
'tab_name' => 'Details',
'db' => [
'type' => 'TEXT',
'default' => 'EMPTY',
'null_switch' => 'NULL',
'unique_key' => false,
'key' => false,
],
],
'access' => [
'name' => 'access',
'label' => 'Access',
'type' => 'accesslevel',
'title' => false,
'store' => NULL,
'tab_name' => NULL,
'db' => [
'type' => 'INT(10) unsigned',
'default' => '0',
'key' => true,
'null_switch' => 'NULL',
],
],
],
'language' => [
'name' => [
'name' => 'name',
'label' =>
'COM_COMPONENTBUILDER_LANGUAGE_NAME_LABEL',
'type' => 'text',
'title' => true,
'list' => 'languages',
'store' => NULL,
'tab_name' => 'Details',
'db' => [
'type' => 'VARCHAR(255)',
'default' => '',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'langtag' => [
'name' => 'langtag',
'label' =>
'COM_COMPONENTBUILDER_LANGUAGE_LANGTAG_LABEL',
'type' => 'text',
'title' => false,
'list' => 'languages',
'store' => NULL,
'tab_name' => 'Details',
'db' => [
'type' => 'VARCHAR(64)',
'default' => '',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'access' => [
'name' => 'access',
'label' => 'Access',
'type' => 'accesslevel',
'title' => false,
'store' => NULL,
'tab_name' => NULL,
'db' => [
'type' => 'INT(10) unsigned',
'default' => '0',
'key' => true,
'null_switch' => 'NULL',
],
],
],
'server' => [
'name' => [
'name' => 'name',
'label' =>
'COM_COMPONENTBUILDER_SERVER_NAME_LABEL',
'type' => 'text',
'title' => true,
'list' => 'servers',
'store' => NULL,
'tab_name' => 'Details',
'db' => [
'type' => 'VARCHAR(255)',
'default' => '',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'protocol' => [
'name' => 'protocol',
'label' =>
'COM_COMPONENTBUILDER_SERVER_PROTOCOL_LABEL',
'type' => 'list',
'title' => false,
'list' => 'servers',
'store' => NULL,
'tab_name' => 'Details',
'db' => [
'type' => 'TINYINT(1)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'signature' => [
'name' => 'signature',
'label' =>
'COM_COMPONENTBUILDER_SERVER_SIGNATURE_LABEL',
'type' => 'text',
'title' => false,
'list' => 'servers',
'store' => 'basic_encryption',
'tab_name' => 'Details',
'db' => [
'type' => 'TEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'private_key' => [
'name' => 'private_key',
'label' =>
'COM_COMPONENTBUILDER_SERVER_PRIVATE_KEY_LABEL',
'type' => 'textarea',
'title' => false,
'list' => 'servers',
'store' => 'basic_encryption',
'tab_name' => 'Details',
'db' => [
'type' => 'TEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'secret' => [
'name' => 'secret',
'label' =>
'COM_COMPONENTBUILDER_SERVER_SECRET_LABEL',
'type' => 'password',
'title' => false,
'list' => 'servers',
'store' => 'basic_encryption',
'tab_name' => 'Details',
'db' => [
'type' => 'TEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'password' => [
'name' => 'password',
'label' =>
'COM_COMPONENTBUILDER_SERVER_PASSWORD_LABEL',
'type' => 'password',
'title' => false,
'list' => 'servers',
'store' => 'basic_encryption',
'tab_name' => 'Details',
'db' => [
'type' => 'TEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'private' => [
'name' => 'private',
'label' =>
'COM_COMPONENTBUILDER_SERVER_PRIVATE_LABEL',
'type' => 'text',
'title' => false,
'list' => 'servers',
'store' => 'basic_encryption',
'tab_name' => 'Details',
'db' => [
'type' => 'TEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'authentication' => [
'name' => 'authentication',
'label' =>
'COM_COMPONENTBUILDER_SERVER_AUTHENTICATION_LABEL',
'type' => 'list',
'title' => false,
'list' => 'servers',
'store' => NULL,
'tab_name' => 'Details',
'db' => [
'type' => 'TINYINT(1)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'path' => [
'name' => 'path',
'label' =>
'COM_COMPONENTBUILDER_SERVER_PATH_LABEL',
'type' => 'text',
'title' => false,
'list' => 'servers',
'store' => 'basic_encryption',
'tab_name' => 'Details',
'db' => [
'type' => 'TEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'port' => [
'name' => 'port',
'label' =>
'COM_COMPONENTBUILDER_SERVER_PORT_LABEL',
'type' => 'text',
'title' => false,
'list' => 'servers',
'store' => 'basic_encryption',
'tab_name' => 'Details',
'db' => [
'type' => 'TEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'host' => [
'name' => 'host',
'label' =>
'COM_COMPONENTBUILDER_SERVER_HOST_LABEL',
'type' => 'text',
'title' => false,
'list' => 'servers',
'store' => 'basic_encryption',
'tab_name' => 'Details',
'db' => [
'type' => 'TEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'username' => [
'name' => 'username',
'label' =>
'COM_COMPONENTBUILDER_SERVER_USERNAME_LABEL',
'type' => 'text',
'title' => false,
'list' => 'servers',
'store' => 'basic_encryption',
'tab_name' => 'Details',
'db' => [
'type' => 'TEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'access' => [
'name' => 'access',
'label' => 'Access',
'type' => 'accesslevel',
'title' => false,
'store' => NULL,
'tab_name' => NULL,
'db' => [
'type' => 'INT(10) unsigned',
'default' => '0',
'key' => true,
'null_switch' => 'NULL',
],
],
],
'repository' => [
'system_name' => [
'name' => 'system_name',
'label' =>
'COM_COMPONENTBUILDER_REPOSITORY_SYSTEM_NAME_LABEL',
'type' => 'text',
'title' => true,
'list' => 'repositories',
'store' => NULL,
'tab_name' => 'Details',
'db' => [
'type' => 'VARCHAR(255)',
'default' => '',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'organisation' => [
'name' => 'organisation',
'label' =>
'COM_COMPONENTBUILDER_REPOSITORY_ORGANISATION_LABEL',
'type' => 'text',
'title' => false,
'list' => 'repositories',
'store' => NULL,
'tab_name' => 'Details',
'db' => [
'type' => 'VARCHAR(255)',
'default' => '',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'repository' => [
'name' => 'repository',
'label' =>
'COM_COMPONENTBUILDER_REPOSITORY_REPOSITORY_LABEL',
'type' => 'text',
'title' => false,
'list' => 'repositories',
'store' => NULL,
'tab_name' => 'Details',
'db' => [
'type' => 'VARCHAR(255)',
'default' => '',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'target' => [
'name' => 'target',
'label' =>
'COM_COMPONENTBUILDER_REPOSITORY_TARGET_LABEL',
'type' => 'list',
'title' => false,
'list' => 'repositories',
'store' => NULL,
'tab_name' => 'Details',
'db' => [
'type' => 'TINYINT(7)',
'default' => '1',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'type' => [
'name' => 'type',
'label' =>
'COM_COMPONENTBUILDER_REPOSITORY_TYPE_LABEL',
'type' => 'list',
'title' => false,
'list' => 'repositories',
'store' => NULL,
'tab_name' => 'Details',
'db' => [
'type' => 'TINYINT(1)',
'default' => '1',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'base' => [
'name' => 'base',
'label' =>
'COM_COMPONENTBUILDER_REPOSITORY_BASE_LABEL',
'type' => 'url',
'title' => false,
'list' => 'repositories',
'store' => NULL,
'tab_name' => 'Details',
'db' => [
'type' => 'VARCHAR(255)',
'default' => '',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'guid' => [
'name' => 'guid',
'label' =>
'COM_COMPONENTBUILDER_REPOSITORY_GUID_LABEL',
'type' => 'text',
'title' => false,
'list' => 'repositories',
'store' => NULL,
'tab_name' => 'publishing',
'db' => [
'type' => 'VARCHAR(36)',
'default' => '',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'addplaceholders' => [
'name' => 'addplaceholders',
'label' =>
'COM_COMPONENTBUILDER_REPOSITORY_ADDPLACEHOLDERS_LABEL',
'type' => 'subform',
'title' => false,
'list' => 'repositories',
'store' => 'json',
'tab_name' => 'Placeholders',
'db' => [
'type' => 'TEXT',
'default' => 'EMPTY',
'null_switch' => 'NULL',
'unique_key' => false,
'key' => false,
],
],
'access_repo' => [
'name' => 'access_repo',
'label' =>
'COM_COMPONENTBUILDER_REPOSITORY_ACCESS_REPO_LABEL',
'type' => 'radio',
'title' => false,
'list' => 'repositories',
'store' => NULL,
'tab_name' => 'Details',
'db' => [
'type' => 'TINYINT(1)',
'default' => '0',
'null_switch' => 'NULL',
'unique_key' => false,
'key' => true,
],
],
'write_branch' => [
'name' => 'write_branch',
'label' =>
'COM_COMPONENTBUILDER_REPOSITORY_WRITE_BRANCH_LABEL',
'type' => 'text',
'title' => false,
'list' => 'repositories',
'store' => NULL,
'tab_name' => 'Details',
'db' => [
'type' => 'VARCHAR(255)',
'default' => '',
'null_switch' => 'NULL',
'unique_key' => false,
'key' => true,
],
],
'read_branch' => [
'name' => 'read_branch',
'label' =>
'COM_COMPONENTBUILDER_REPOSITORY_READ_BRANCH_LABEL',
'type' => 'text',
'title' => false,
'list' => 'repositories',
'store' => NULL,
'tab_name' => 'Details',
'db' => [
'type' => 'VARCHAR(255)',
'default' => '',
'null_switch' => 'NULL',
'unique_key' => false,
'key' => true,
],
],
'token' => [
'name' => 'token',
'label' =>
'COM_COMPONENTBUILDER_REPOSITORY_TOKEN_LABEL',
'type' => 'password',
'title' => false,
'list' => 'repositories',
'store' => NULL,
'tab_name' => 'Details',
'db' => [
'type' => 'VARCHAR(255)',
'default' => '',
'null_switch' => 'NULL',
'unique_key' => false,
'key' => true,
],
],
'username' => [
'name' => 'username',
'label' =>
'COM_COMPONENTBUILDER_REPOSITORY_USERNAME_LABEL',
'type' => 'text',
'title' => false,
'list' => 'repositories',
'store' => NULL,
'tab_name' => 'Details',
'db' => [
'type' => 'VARCHAR(255)',
'default' => '',
'null_switch' => 'NULL',
'unique_key' => false,
'key' => true,
],
],
'access' => [
'name' => 'access',
'label' => 'Access',
'type' => 'accesslevel',
'title' => false,
'store' => NULL,
'tab_name' => NULL,
'db' => [
'type' => 'INT(10) unsigned',
'default' => '0',
'key' => true,
'null_switch' => 'NULL',
],
],
],
'help_document' => [
'title' => [
'name' => 'title',
'label' =>
'COM_COMPONENTBUILDER_HELP_DOCUMENT_TITLE_LABEL',
'type' => 'text',
'title' => true,
'list' => 'help_documents',
'store' => NULL,
'tab_name' => 'Details',
'db' => [
'type' => 'CHAR(64)',
'default' => '',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'type' => [
'name' => 'type',
'label' =>
'COM_COMPONENTBUILDER_HELP_DOCUMENT_TYPE_LABEL',
'type' => 'list',
'title' => false,
'list' => 'help_documents',
'store' => NULL,
'tab_name' => 'Details',
'db' => [
'type' => 'TINYINT(1)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'groups' => [
'name' => 'groups',
'label' =>
'COM_COMPONENTBUILDER_HELP_DOCUMENT_GROUPS_LABEL',
'type' => 'usergrouplist',
'title' => false,
'list' => 'help_documents',
'store' => 'json',
'tab_name' => 'Details',
'db' => [
'type' => 'TEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'location' => [
'name' => 'location',
'label' =>
'COM_COMPONENTBUILDER_HELP_DOCUMENT_LOCATION_LABEL',
'type' => 'radio',
'title' => false,
'list' => 'help_documents',
'store' => NULL,
'tab_name' => 'Details',
'db' => [
'type' => 'TINYINT(1)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'admin_view' => [
'name' => 'admin_view',
'label' =>
'COM_COMPONENTBUILDER_HELP_DOCUMENT_ADMIN_VIEW_LABEL',
'type' => 'adminviewfolderlist',
'title' => false,
'list' => 'help_documents',
'store' => NULL,
'tab_name' => 'Details',
'db' => [
'type' => 'CHAR(255)',
'default' => '',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'site_view' => [
'name' => 'site_view',
'label' =>
'COM_COMPONENTBUILDER_HELP_DOCUMENT_SITE_VIEW_LABEL',
'type' => 'siteviewfolderlist',
'title' => false,
'list' => 'help_documents',
'store' => NULL,
'tab_name' => 'Details',
'db' => [
'type' => 'CHAR(255)',
'default' => '',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'alias' => [
'name' => 'alias',
'label' =>
'COM_COMPONENTBUILDER_HELP_DOCUMENT_ALIAS_LABEL',
'type' => 'text',
'title' => false,
'list' => 'help_documents',
'store' => NULL,
'tab_name' => 'Details',
'db' => [
'type' => 'CHAR(64)',
'default' => '',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'content' => [
'name' => 'content',
'label' =>
'COM_COMPONENTBUILDER_HELP_DOCUMENT_CONTENT_LABEL',
'type' => 'editor',
'title' => false,
'list' => 'help_documents',
'store' => NULL,
'tab_name' => 'Details',
'db' => [
'type' => 'TEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'article' => [
'name' => 'article',
'label' =>
'COM_COMPONENTBUILDER_HELP_DOCUMENT_ARTICLE_LABEL',
'type' => 'articles',
'title' => false,
'list' => 'help_documents',
'store' => NULL,
'tab_name' => 'Details',
'db' => [
'type' => 'TINYINT(1)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'url' => [
'name' => 'url',
'label' =>
'COM_COMPONENTBUILDER_HELP_DOCUMENT_URL_LABEL',
'type' => 'url',
'title' => false,
'list' => 'help_documents',
'store' => NULL,
'tab_name' => 'Details',
'db' => [
'type' => 'VARCHAR(255)',
'default' => '',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'target' => [
'name' => 'target',
'label' =>
'COM_COMPONENTBUILDER_HELP_DOCUMENT_TARGET_LABEL',
'type' => 'radio',
'title' => false,
'list' => 'help_documents',
'store' => NULL,
'tab_name' => 'Details',
'db' => [
'type' => 'TINYINT(1)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
],
'admin_fields' => [
'admin_view' => [
'name' => 'admin_view',
'label' =>
'COM_COMPONENTBUILDER_ADMIN_FIELDS_ADMIN_VIEW_LABEL',
'type' => 'adminviewsreadonly',
'title' => true,
'list' => 'admins_fields',
'store' => NULL,
'tab_name' => 'Fields',
'db' => [
'type' => 'INT(11)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'addfields' => [
'name' => 'addfields',
'label' =>
'COM_COMPONENTBUILDER_ADMIN_FIELDS_ADDFIELDS_LABEL',
'type' => 'subform',
'title' => false,
'list' => 'admins_fields',
'store' => 'json',
'tab_name' => 'Fields',
'db' => [
'type' => 'MEDIUMTEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'access' => [
'name' => 'access',
'label' => 'Access',
'type' => 'accesslevel',
'title' => false,
'store' => NULL,
'tab_name' => NULL,
'db' => [
'type' => 'INT(10) unsigned',
'default' => '0',
'key' => true,
'null_switch' => 'NULL',
],
],
],
'admin_fields_conditions' => [
'admin_view' => [
'name' => 'admin_view',
'label' =>
'COM_COMPONENTBUILDER_ADMIN_FIELDS_CONDITIONS_ADMIN_VIEW_LABEL',
'type' => 'adminviewsreadonly',
'title' => true,
'list' => 'admins_fields_conditions',
'store' => NULL,
'tab_name' => 'Conditions',
'db' => [
'type' => 'INT(11)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'addconditions' => [
'name' => 'addconditions',
'label' =>
'COM_COMPONENTBUILDER_ADMIN_FIELDS_CONDITIONS_ADDCONDITIONS_LABEL',
'type' => 'subform',
'title' => false,
'list' => 'admins_fields_conditions',
'store' => 'json',
'tab_name' => 'Conditions',
'db' => [
'type' => 'MEDIUMTEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'access' => [
'name' => 'access',
'label' => 'Access',
'type' => 'accesslevel',
'title' => false,
'store' => NULL,
'tab_name' => NULL,
'db' => [
'type' => 'INT(10) unsigned',
'default' => '0',
'key' => true,
'null_switch' => 'NULL',
],
],
],
'admin_fields_relations' => [
'admin_view' => [
'name' => 'admin_view',
'label' =>
'COM_COMPONENTBUILDER_ADMIN_FIELDS_RELATIONS_ADMIN_VIEW_LABEL',
'type' => 'adminviewsreadonly',
'title' => true,
'list' => 'admins_fields_relations',
'store' => NULL,
'tab_name' => 'Relations',
'db' => [
'type' => 'INT(11)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'addrelations' => [
'name' => 'addrelations',
'label' =>
'COM_COMPONENTBUILDER_ADMIN_FIELDS_RELATIONS_ADDRELATIONS_LABEL',
'type' => 'subform',
'title' => false,
'list' => 'admins_fields_relations',
'store' => 'json',
'tab_name' => 'Relations',
'db' => [
'type' => 'MEDIUMTEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'access' => [
'name' => 'access',
'label' => 'Access',
'type' => 'accesslevel',
'title' => false,
'store' => NULL,
'tab_name' => NULL,
'db' => [
'type' => 'INT(10) unsigned',
'default' => '0',
'key' => true,
'null_switch' => 'NULL',
],
],
],
'admin_custom_tabs' => [
'admin_view' => [
'name' => 'admin_view',
'label' =>
'COM_COMPONENTBUILDER_ADMIN_CUSTOM_TABS_ADMIN_VIEW_LABEL',
'type' => 'adminviewsreadonly',
'title' => true,
'list' => 'admins_custom_tabs',
'store' => NULL,
'tab_name' => 'Tabs',
'db' => [
'type' => 'INT(11)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'tabs' => [
'name' => 'tabs',
'label' =>
'COM_COMPONENTBUILDER_ADMIN_CUSTOM_TABS_TABS_LABEL',
'type' => 'subform',
'title' => false,
'list' => 'admins_custom_tabs',
'store' => 'json',
'tab_name' => 'Tabs',
'db' => [
'type' => 'TEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'access' => [
'name' => 'access',
'label' => 'Access',
'type' => 'accesslevel',
'title' => false,
'store' => NULL,
'tab_name' => NULL,
'db' => [
'type' => 'INT(10) unsigned',
'default' => '0',
'key' => true,
'null_switch' => 'NULL',
],
],
],
'component_admin_views' => [
'joomla_component' => [
'name' => 'joomla_component',
'label' =>
'COM_COMPONENTBUILDER_COMPONENT_ADMIN_VIEWS_JOOMLA_COMPONENT_LABEL',
'type' => 'joomlacomponents',
'title' => true,
'list' => 'components_admin_views',
'store' => NULL,
'tab_name' => 'Views',
'db' => [
'type' => 'INT(11)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'addadmin_views' => [
'name' => 'addadmin_views',
'label' =>
'COM_COMPONENTBUILDER_COMPONENT_ADMIN_VIEWS_ADDADMIN_VIEWS_LABEL',
'type' => 'subform',
'title' => false,
'list' => 'components_admin_views',
'store' => 'json',
'tab_name' => 'Views',
'db' => [
'type' => 'TEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'access' => [
'name' => 'access',
'label' => 'Access',
'type' => 'accesslevel',
'title' => false,
'store' => NULL,
'tab_name' => NULL,
'db' => [
'type' => 'INT(10) unsigned',
'default' => '0',
'key' => true,
'null_switch' => 'NULL',
],
],
],
'component_site_views' => [
'joomla_component' => [
'name' => 'joomla_component',
'label' =>
'COM_COMPONENTBUILDER_COMPONENT_SITE_VIEWS_JOOMLA_COMPONENT_LABEL',
'type' => 'joomlacomponents',
'title' => true,
'list' => 'components_site_views',
'store' => NULL,
'tab_name' => 'Views',
'db' => [
'type' => 'INT(11)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'addsite_views' => [
'name' => 'addsite_views',
'label' =>
'COM_COMPONENTBUILDER_COMPONENT_SITE_VIEWS_ADDSITE_VIEWS_LABEL',
'type' => 'subform',
'title' => false,
'list' => 'components_site_views',
'store' => 'json',
'tab_name' => 'Views',
'db' => [
'type' => 'TEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'access' => [
'name' => 'access',
'label' => 'Access',
'type' => 'accesslevel',
'title' => false,
'store' => NULL,
'tab_name' => NULL,
'db' => [
'type' => 'INT(10) unsigned',
'default' => '0',
'key' => true,
'null_switch' => 'NULL',
],
],
],
'component_custom_admin_views' => [
'joomla_component' => [
'name' => 'joomla_component',
'label' =>
'COM_COMPONENTBUILDER_COMPONENT_CUSTOM_ADMIN_VIEWS_JOOMLA_COMPONENT_LABEL',
'type' => 'joomlacomponents',
'title' => true,
'list' => 'components_custom_admin_views',
'store' => NULL,
'tab_name' => 'Views',
'db' => [
'type' => 'INT(11)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'addcustom_admin_views' => [
'name' => 'addcustom_admin_views',
'label' =>
'COM_COMPONENTBUILDER_COMPONENT_CUSTOM_ADMIN_VIEWS_ADDCUSTOM_ADMIN_VIEWS_LABEL',
'type' => 'subform',
'title' => false,
'list' => 'components_custom_admin_views',
'store' => 'json',
'tab_name' => 'Views',
'db' => [
'type' => 'TEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'access' => [
'name' => 'access',
'label' => 'Access',
'type' => 'accesslevel',
'title' => false,
'store' => NULL,
'tab_name' => NULL,
'db' => [
'type' => 'INT(10) unsigned',
'default' => '0',
'key' => true,
'null_switch' => 'NULL',
],
],
],
'component_updates' => [
'joomla_component' => [
'name' => 'joomla_component',
'label' =>
'COM_COMPONENTBUILDER_COMPONENT_UPDATES_JOOMLA_COMPONENT_LABEL',
'type' => 'joomlacomponents',
'title' => true,
'list' => 'components_updates',
'store' => NULL,
'tab_name' => 'Updates',
'db' => [
'type' => 'INT(11)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'version_update' => [
'name' => 'version_update',
'label' =>
'COM_COMPONENTBUILDER_COMPONENT_UPDATES_VERSION_UPDATE_LABEL',
'type' => 'subform',
'title' => false,
'list' => 'components_updates',
'store' => 'json',
'tab_name' => 'Updates',
'db' => [
'type' => 'MEDIUMTEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'access' => [
'name' => 'access',
'label' => 'Access',
'type' => 'accesslevel',
'title' => false,
'store' => NULL,
'tab_name' => NULL,
'db' => [
'type' => 'INT(10) unsigned',
'default' => '0',
'key' => true,
'null_switch' => 'NULL',
],
],
],
'component_mysql_tweaks' => [
'joomla_component' => [
'name' => 'joomla_component',
'label' =>
'COM_COMPONENTBUILDER_COMPONENT_MYSQL_TWEAKS_JOOMLA_COMPONENT_LABEL',
'type' => 'joomlacomponents',
'title' => true,
'list' => 'components_mysql_tweaks',
'store' => NULL,
'tab_name' => 'Mysql Tweaks',
'db' => [
'type' => 'INT(11)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'sql_tweak' => [
'name' => 'sql_tweak',
'label' =>
'COM_COMPONENTBUILDER_COMPONENT_MYSQL_TWEAKS_SQL_TWEAK_LABEL',
'type' => 'subform',
'title' => false,
'list' => 'components_mysql_tweaks',
'store' => 'json',
'tab_name' => 'Mysql Tweaks',
'db' => [
'type' => 'TEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'access' => [
'name' => 'access',
'label' => 'Access',
'type' => 'accesslevel',
'title' => false,
'store' => NULL,
'tab_name' => NULL,
'db' => [
'type' => 'INT(10) unsigned',
'default' => '0',
'key' => true,
'null_switch' => 'NULL',
],
],
],
'component_custom_admin_menus' => [
'joomla_component' => [
'name' => 'joomla_component',
'label' =>
'COM_COMPONENTBUILDER_COMPONENT_CUSTOM_ADMIN_MENUS_JOOMLA_COMPONENT_LABEL',
'type' => 'joomlacomponents',
'title' => true,
'list' => 'components_custom_admin_menus',
'store' => NULL,
'tab_name' => 'Menus',
'db' => [
'type' => 'INT(11)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'addcustommenus' => [
'name' => 'addcustommenus',
'label' =>
'COM_COMPONENTBUILDER_COMPONENT_CUSTOM_ADMIN_MENUS_ADDCUSTOMMENUS_LABEL',
'type' => 'subform',
'title' => false,
'list' => 'components_custom_admin_menus',
'store' => 'json',
'tab_name' => 'Menus',
'db' => [
'type' => 'TEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'access' => [
'name' => 'access',
'label' => 'Access',
'type' => 'accesslevel',
'title' => false,
'store' => NULL,
'tab_name' => NULL,
'db' => [
'type' => 'INT(10) unsigned',
'default' => '0',
'key' => true,
'null_switch' => 'NULL',
],
],
],
'component_router' => [
'joomla_component' => [
'name' => 'joomla_component',
'label' =>
'COM_COMPONENTBUILDER_COMPONENT_ROUTER_JOOMLA_COMPONENT_LABEL',
'type' => 'joomlacomponents',
'title' => true,
'list' => 'components_routers',
'store' => NULL,
'tab_name' => 'Settings',
'db' => [
'type' => 'INT(11)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'mode_constructor_before_parent' => [
'name' => 'mode_constructor_before_parent',
'label' =>
'COM_COMPONENTBUILDER_COMPONENT_ROUTER_MODE_CONSTRUCTOR_BEFORE_PARENT_LABEL',
'type' => 'radio',
'title' => false,
'list' => 'components_routers',
'store' => NULL,
'tab_name' => 'Settings',
'db' => [
'type' => 'TINYINT(1)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'mode_constructor_after_parent' => [
'name' => 'mode_constructor_after_parent',
'label' =>
'COM_COMPONENTBUILDER_COMPONENT_ROUTER_MODE_CONSTRUCTOR_AFTER_PARENT_LABEL',
'type' => 'radio',
'title' => false,
'list' => 'components_routers',
'store' => NULL,
'tab_name' => 'Settings',
'db' => [
'type' => 'TINYINT(1)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'mode_methods' => [
'name' => 'mode_methods',
'label' =>
'COM_COMPONENTBUILDER_COMPONENT_ROUTER_MODE_METHODS_LABEL',
'type' => 'radio',
'title' => false,
'list' => 'components_routers',
'store' => NULL,
'tab_name' => 'Settings',
'db' => [
'type' => 'TINYINT(1)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'methods_code' => [
'name' => 'methods_code',
'label' =>
'COM_COMPONENTBUILDER_COMPONENT_ROUTER_METHODS_CODE_LABEL',
'type' => 'editor',
'title' => false,
'list' => 'components_routers',
'store' => 'base64',
'tab_name' => 'Settings',
'db' => [
'type' => 'MEDIUMTEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'constructor_after_parent_code' => [
'name' => 'constructor_after_parent_code',
'label' =>
'COM_COMPONENTBUILDER_COMPONENT_ROUTER_CONSTRUCTOR_AFTER_PARENT_CODE_LABEL',
'type' => 'editor',
'title' => false,
'list' => 'components_routers',
'store' => 'base64',
'tab_name' => 'Settings',
'db' => [
'type' => 'MEDIUMTEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'constructor_before_parent_manual' => [
'name' => 'constructor_before_parent_manual',
'label' =>
'COM_COMPONENTBUILDER_COMPONENT_ROUTER_CONSTRUCTOR_BEFORE_PARENT_MANUAL_LABEL',
'type' => 'subform',
'title' => false,
'list' => 'components_routers',
'store' => 'json',
'tab_name' => 'Settings',
'db' => [
'type' => 'TEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'constructor_before_parent_code' => [
'name' => 'constructor_before_parent_code',
'label' =>
'COM_COMPONENTBUILDER_COMPONENT_ROUTER_CONSTRUCTOR_BEFORE_PARENT_CODE_LABEL',
'type' => 'editor',
'title' => false,
'list' => 'components_routers',
'store' => 'base64',
'tab_name' => 'Settings',
'db' => [
'type' => 'MEDIUMTEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'access' => [
'name' => 'access',
'label' => 'Access',
'type' => 'accesslevel',
'title' => false,
'store' => NULL,
'tab_name' => NULL,
'db' => [
'type' => 'INT(10) unsigned',
'default' => '0',
'key' => true,
'null_switch' => 'NULL',
],
],
],
'component_config' => [
'joomla_component' => [
'name' => 'joomla_component',
'label' =>
'COM_COMPONENTBUILDER_COMPONENT_CONFIG_JOOMLA_COMPONENT_LABEL',
'type' => 'joomlacomponents',
'title' => true,
'list' => 'components_config',
'store' => NULL,
'tab_name' => 'Options',
'db' => [
'type' => 'INT(11)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'addconfig' => [
'name' => 'addconfig',
'label' =>
'COM_COMPONENTBUILDER_COMPONENT_CONFIG_ADDCONFIG_LABEL',
'type' => 'subform',
'title' => false,
'list' => 'components_config',
'store' => 'json',
'tab_name' => 'Options',
'db' => [
'type' => 'TEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'access' => [
'name' => 'access',
'label' => 'Access',
'type' => 'accesslevel',
'title' => false,
'store' => NULL,
'tab_name' => NULL,
'db' => [
'type' => 'INT(10) unsigned',
'default' => '0',
'key' => true,
'null_switch' => 'NULL',
],
],
],
'component_dashboard' => [
'joomla_component' => [
'name' => 'joomla_component',
'label' =>
'COM_COMPONENTBUILDER_COMPONENT_DASHBOARD_JOOMLA_COMPONENT_LABEL',
'type' => 'joomlacomponents',
'title' => true,
'list' => 'components_dashboard',
'store' => NULL,
'tab_name' => 'Dashboard',
'db' => [
'type' => 'INT(11)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'dashboard_tab' => [
'name' => 'dashboard_tab',
'label' =>
'COM_COMPONENTBUILDER_COMPONENT_DASHBOARD_DASHBOARD_TAB_LABEL',
'type' => 'subform',
'title' => false,
'list' => 'components_dashboard',
'store' => 'json',
'tab_name' => 'Dashboard',
'db' => [
'type' => 'TEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'php_dashboard_methods' => [
'name' => 'php_dashboard_methods',
'label' =>
'COM_COMPONENTBUILDER_COMPONENT_DASHBOARD_PHP_DASHBOARD_METHODS_LABEL',
'type' => 'textarea',
'title' => false,
'list' => 'components_dashboard',
'store' => 'base64',
'tab_name' => 'Dashboard',
'db' => [
'type' => 'MEDIUMTEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'access' => [
'name' => 'access',
'label' => 'Access',
'type' => 'accesslevel',
'title' => false,
'store' => NULL,
'tab_name' => NULL,
'db' => [
'type' => 'INT(10) unsigned',
'default' => '0',
'key' => true,
'null_switch' => 'NULL',
],
],
],
'component_files_folders' => [
'joomla_component' => [
'name' => 'joomla_component',
'label' =>
'COM_COMPONENTBUILDER_COMPONENT_FILES_FOLDERS_JOOMLA_COMPONENT_LABEL',
'type' => 'joomlacomponents',
'title' => true,
'list' => 'components_files_folders',
'store' => NULL,
'tab_name' => 'Basic',
'db' => [
'type' => 'INT(11)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'addfoldersfullpath' => [
'name' => 'addfoldersfullpath',
'label' =>
'COM_COMPONENTBUILDER_COMPONENT_FILES_FOLDERS_ADDFOLDERSFULLPATH_LABEL',
'type' => 'subform',
'title' => false,
'list' => 'components_files_folders',
'store' => 'json',
'tab_name' => 'Advance',
'db' => [
'type' => 'TEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'addfilesfullpath' => [
'name' => 'addfilesfullpath',
'label' =>
'COM_COMPONENTBUILDER_COMPONENT_FILES_FOLDERS_ADDFILESFULLPATH_LABEL',
'type' => 'subform',
'title' => false,
'list' => 'components_files_folders',
'store' => 'json',
'tab_name' => 'Advance',
'db' => [
'type' => 'TEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'addfolders' => [
'name' => 'addfolders',
'label' =>
'COM_COMPONENTBUILDER_COMPONENT_FILES_FOLDERS_ADDFOLDERS_LABEL',
'type' => 'subform',
'title' => false,
'list' => 'components_files_folders',
'store' => 'json',
'tab_name' => 'Basic',
'db' => [
'type' => 'TEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'addfiles' => [
'name' => 'addfiles',
'label' =>
'COM_COMPONENTBUILDER_COMPONENT_FILES_FOLDERS_ADDFILES_LABEL',
'type' => 'subform',
'title' => false,
'list' => 'components_files_folders',
'store' => 'json',
'tab_name' => 'Basic',
'db' => [
'type' => 'TEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'access' => [
'name' => 'access',
'label' => 'Access',
'type' => 'accesslevel',
'title' => false,
'store' => NULL,
'tab_name' => NULL,
'db' => [
'type' => 'INT(10) unsigned',
'default' => '0',
'key' => true,
'null_switch' => 'NULL',
],
],
],
'component_placeholders' => [
'joomla_component' => [
'name' => 'joomla_component',
'label' =>
'COM_COMPONENTBUILDER_COMPONENT_PLACEHOLDERS_JOOMLA_COMPONENT_LABEL',
'type' => 'joomlacomponents',
'title' => true,
'list' => 'components_placeholders',
'store' => NULL,
'tab_name' => 'Details',
'db' => [
'type' => 'INT(11)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'addplaceholders' => [
'name' => 'addplaceholders',
'label' =>
'COM_COMPONENTBUILDER_COMPONENT_PLACEHOLDERS_ADDPLACEHOLDERS_LABEL',
'type' => 'subform',
'title' => false,
'list' => 'components_placeholders',
'store' => 'json',
'tab_name' => 'Details',
'db' => [
'type' => 'TEXT',
'default' => 'EMPTY',
'null_switch' => 'NULL',
'unique_key' => false,
'key' => false,
],
],
'access' => [
'name' => 'access',
'label' => 'Access',
'type' => 'accesslevel',
'title' => false,
'store' => NULL,
'tab_name' => NULL,
'db' => [
'type' => 'INT(10) unsigned',
'default' => '0',
'key' => true,
'null_switch' => 'NULL',
],
],
],
'component_plugins' => [
'joomla_component' => [
'name' => 'joomla_component',
'label' =>
'COM_COMPONENTBUILDER_COMPONENT_PLUGINS_JOOMLA_COMPONENT_LABEL',
'type' => 'joomlacomponents',
'title' => true,
'list' => 'components_plugins',
'store' => NULL,
'tab_name' => 'Plugins',
'db' => [
'type' => 'INT(11)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'addjoomla_plugins' => [
'name' => 'addjoomla_plugins',
'label' =>
'COM_COMPONENTBUILDER_COMPONENT_PLUGINS_ADDJOOMLA_PLUGINS_LABEL',
'type' => 'subform',
'title' => false,
'list' => 'components_plugins',
'store' => 'json',
'tab_name' => 'Plugins',
'db' => [
'type' => 'TEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'access' => [
'name' => 'access',
'label' => 'Access',
'type' => 'accesslevel',
'title' => false,
'store' => NULL,
'tab_name' => NULL,
'db' => [
'type' => 'INT(10) unsigned',
'default' => '0',
'key' => true,
'null_switch' => 'NULL',
],
],
],
'component_modules' => [
'joomla_component' => [
'name' => 'joomla_component',
'label' =>
'COM_COMPONENTBUILDER_COMPONENT_MODULES_JOOMLA_COMPONENT_LABEL',
'type' => 'joomlacomponents',
'title' => true,
'list' => 'components_modules',
'store' => NULL,
'tab_name' => 'Modules',
'db' => [
'type' => 'INT(11)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'addjoomla_modules' => [
'name' => 'addjoomla_modules',
'label' =>
'COM_COMPONENTBUILDER_COMPONENT_MODULES_ADDJOOMLA_MODULES_LABEL',
'type' => 'subform',
'title' => false,
'list' => 'components_modules',
'store' => 'json',
'tab_name' => 'Modules',
'db' => [
'type' => 'TEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'access' => [
'name' => 'access',
'label' => 'Access',
'type' => 'accesslevel',
'title' => false,
'store' => NULL,
'tab_name' => NULL,
'db' => [
'type' => 'INT(10) unsigned',
'default' => '0',
'key' => true,
'null_switch' => 'NULL',
],
],
],
'snippet_type' => [
'name' => [
'name' => 'name',
'label' =>
'COM_COMPONENTBUILDER_SNIPPET_TYPE_NAME_LABEL',
'type' => 'text',
'title' => true,
'list' => 'snippet_types',
'store' => NULL,
'tab_name' => 'Details',
'db' => [
'type' => 'VARCHAR(255)',
'default' => '',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'description' => [
'name' => 'description',
'label' =>
'COM_COMPONENTBUILDER_SNIPPET_TYPE_DESCRIPTION_LABEL',
'type' => 'text',
'title' => false,
'list' => 'snippet_types',
'store' => NULL,
'tab_name' => 'Details',
'db' => [
'type' => 'VARCHAR(255)',
'default' => '',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'access' => [
'name' => 'access',
'label' => 'Access',
'type' => 'accesslevel',
'title' => false,
'store' => NULL,
'tab_name' => NULL,
'db' => [
'type' => 'INT(10) unsigned',
'default' => '0',
'key' => true,
'null_switch' => 'NULL',
],
],
],
'library_config' => [
'library' => [
'name' => 'library',
'label' =>
'COM_COMPONENTBUILDER_LIBRARY_CONFIG_LIBRARY_LABEL',
'type' => 'libraryreadonly',
'title' => true,
'list' => 'libraries_config',
'store' => NULL,
'tab_name' => 'Tweaks',
'db' => [
'type' => 'INT(11)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'addconfig' => [
'name' => 'addconfig',
'label' =>
'COM_COMPONENTBUILDER_LIBRARY_CONFIG_ADDCONFIG_LABEL',
'type' => 'subform',
'title' => false,
'list' => 'libraries_config',
'store' => 'json',
'tab_name' => 'Tweaks',
'db' => [
'type' => 'TEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'access' => [
'name' => 'access',
'label' => 'Access',
'type' => 'accesslevel',
'title' => false,
'store' => NULL,
'tab_name' => NULL,
'db' => [
'type' => 'INT(10) unsigned',
'default' => '0',
'key' => true,
'null_switch' => 'NULL',
],
],
],
'library_files_folders_urls' => [
'library' => [
'name' => 'library',
'label' =>
'COM_COMPONENTBUILDER_LIBRARY_FILES_FOLDERS_URLS_LIBRARY_LABEL',
'type' => 'libraryreadonly',
'title' => true,
'list' => 'libraries_files_folders_urls',
'store' => NULL,
'tab_name' => 'Basic',
'db' => [
'type' => 'INT(11)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'addfoldersfullpath' => [
'name' => 'addfoldersfullpath',
'label' =>
'COM_COMPONENTBUILDER_LIBRARY_FILES_FOLDERS_URLS_ADDFOLDERSFULLPATH_LABEL',
'type' => 'subform',
'title' => false,
'list' => 'libraries_files_folders_urls',
'store' => 'json',
'tab_name' => 'Advance',
'db' => [
'type' => 'TEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'addfilesfullpath' => [
'name' => 'addfilesfullpath',
'label' =>
'COM_COMPONENTBUILDER_LIBRARY_FILES_FOLDERS_URLS_ADDFILESFULLPATH_LABEL',
'type' => 'subform',
'title' => false,
'list' => 'libraries_files_folders_urls',
'store' => 'json',
'tab_name' => 'Advance',
'db' => [
'type' => 'TEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'addfolders' => [
'name' => 'addfolders',
'label' =>
'COM_COMPONENTBUILDER_LIBRARY_FILES_FOLDERS_URLS_ADDFOLDERS_LABEL',
'type' => 'subform',
'title' => false,
'list' => 'libraries_files_folders_urls',
'store' => 'json',
'tab_name' => 'Basic',
'db' => [
'type' => 'TEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'addfiles' => [
'name' => 'addfiles',
'label' =>
'COM_COMPONENTBUILDER_LIBRARY_FILES_FOLDERS_URLS_ADDFILES_LABEL',
'type' => 'subform',
'title' => false,
'list' => 'libraries_files_folders_urls',
'store' => 'json',
'tab_name' => 'Basic',
'db' => [
'type' => 'TEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'addurls' => [
'name' => 'addurls',
'label' =>
'COM_COMPONENTBUILDER_LIBRARY_FILES_FOLDERS_URLS_ADDURLS_LABEL',
'type' => 'subform',
'title' => false,
'list' => 'libraries_files_folders_urls',
'store' => 'json',
'tab_name' => 'Basic',
'db' => [
'type' => 'TEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'access' => [
'name' => 'access',
'label' => 'Access',
'type' => 'accesslevel',
'title' => false,
'store' => NULL,
'tab_name' => NULL,
'db' => [
'type' => 'INT(10) unsigned',
'default' => '0',
'key' => true,
'null_switch' => 'NULL',
],
],
],
'class_extends' => [
'name' => [
'name' => 'name',
'label' =>
'COM_COMPONENTBUILDER_CLASS_EXTENDS_NAME_LABEL',
'type' => 'text',
'title' => true,
'list' => 'class_extendings',
'store' => NULL,
'tab_name' => 'Details',
'db' => [
'type' => 'VARCHAR(255)',
'default' => '',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'extension_type' => [
'name' => 'extension_type',
'label' =>
'COM_COMPONENTBUILDER_CLASS_EXTENDS_EXTENSION_TYPE_LABEL',
'type' => 'list',
'title' => false,
'list' => 'class_extendings',
'store' => NULL,
'tab_name' => 'Details',
'db' => [
'type' => 'VARCHAR(64)',
'default' => '',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'head' => [
'name' => 'head',
'label' =>
'COM_COMPONENTBUILDER_CLASS_EXTENDS_HEAD_LABEL',
'type' => 'editor',
'title' => false,
'list' => 'class_extendings',
'store' => 'base64',
'tab_name' => 'Details',
'db' => [
'type' => 'TEXT',
'default' => 'EMPTY',
'null_switch' => 'NULL',
'unique_key' => false,
'key' => false,
],
],
'comment' => [
'name' => 'comment',
'label' =>
'COM_COMPONENTBUILDER_CLASS_EXTENDS_COMMENT_LABEL',
'type' => 'textarea',
'title' => false,
'list' => 'class_extendings',
'store' => 'base64',
'tab_name' => 'Details',
'db' => [
'type' => 'TEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'access' => [
'name' => 'access',
'label' => 'Access',
'type' => 'accesslevel',
'title' => false,
'store' => NULL,
'tab_name' => NULL,
'db' => [
'type' => 'INT(10) unsigned',
'default' => '0',
'key' => true,
'null_switch' => 'NULL',
],
],
],
'joomla_module_updates' => [
'joomla_module' => [
'name' => 'joomla_module',
'label' =>
'COM_COMPONENTBUILDER_JOOMLA_MODULE_UPDATES_JOOMLA_MODULE_LABEL',
'type' => 'joomlamodules',
'title' => true,
'list' => 'joomla_modules_updates',
'store' => NULL,
'tab_name' => 'Updates',
'db' => [
'type' => 'INT(11)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'version_update' => [
'name' => 'version_update',
'label' =>
'COM_COMPONENTBUILDER_JOOMLA_MODULE_UPDATES_VERSION_UPDATE_LABEL',
'type' => 'subform',
'title' => false,
'list' => 'joomla_modules_updates',
'store' => 'json',
'tab_name' => 'Updates',
'db' => [
'type' => 'MEDIUMTEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'access' => [
'name' => 'access',
'label' => 'Access',
'type' => 'accesslevel',
'title' => false,
'store' => NULL,
'tab_name' => NULL,
'db' => [
'type' => 'INT(10) unsigned',
'default' => '0',
'key' => true,
'null_switch' => 'NULL',
],
],
],
'joomla_module_files_folders_urls' => [
'joomla_module' => [
'name' => 'joomla_module',
'label' =>
'COM_COMPONENTBUILDER_JOOMLA_MODULE_FILES_FOLDERS_URLS_JOOMLA_MODULE_LABEL',
'type' => 'joomlamodules',
'title' => true,
'list' => 'joomla_modules_files_folders_urls',
'store' => NULL,
'tab_name' => 'Basic',
'db' => [
'type' => 'INT(11)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'addfoldersfullpath' => [
'name' => 'addfoldersfullpath',
'label' =>
'COM_COMPONENTBUILDER_JOOMLA_MODULE_FILES_FOLDERS_URLS_ADDFOLDERSFULLPATH_LABEL',
'type' => 'subform',
'title' => false,
'list' => 'joomla_modules_files_folders_urls',
'store' => 'json',
'tab_name' => 'Advance',
'db' => [
'type' => 'TEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'addfilesfullpath' => [
'name' => 'addfilesfullpath',
'label' =>
'COM_COMPONENTBUILDER_JOOMLA_MODULE_FILES_FOLDERS_URLS_ADDFILESFULLPATH_LABEL',
'type' => 'subform',
'title' => false,
'list' => 'joomla_modules_files_folders_urls',
'store' => 'json',
'tab_name' => 'Advance',
'db' => [
'type' => 'TEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'addfolders' => [
'name' => 'addfolders',
'label' =>
'COM_COMPONENTBUILDER_JOOMLA_MODULE_FILES_FOLDERS_URLS_ADDFOLDERS_LABEL',
'type' => 'subform',
'title' => false,
'list' => 'joomla_modules_files_folders_urls',
'store' => 'json',
'tab_name' => 'Basic',
'db' => [
'type' => 'TEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'addfiles' => [
'name' => 'addfiles',
'label' =>
'COM_COMPONENTBUILDER_JOOMLA_MODULE_FILES_FOLDERS_URLS_ADDFILES_LABEL',
'type' => 'subform',
'title' => false,
'list' => 'joomla_modules_files_folders_urls',
'store' => 'json',
'tab_name' => 'Basic',
'db' => [
'type' => 'TEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'addurls' => [
'name' => 'addurls',
'label' =>
'COM_COMPONENTBUILDER_JOOMLA_MODULE_FILES_FOLDERS_URLS_ADDURLS_LABEL',
'type' => 'subform',
'title' => false,
'list' => 'joomla_modules_files_folders_urls',
'store' => 'json',
'tab_name' => 'Basic',
'db' => [
'type' => 'TEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'access' => [
'name' => 'access',
'label' => 'Access',
'type' => 'accesslevel',
'title' => false,
'store' => NULL,
'tab_name' => NULL,
'db' => [
'type' => 'INT(10) unsigned',
'default' => '0',
'key' => true,
'null_switch' => 'NULL',
],
],
],
'joomla_plugin_group' => [
'name' => [
'name' => 'name',
'label' =>
'COM_COMPONENTBUILDER_JOOMLA_PLUGIN_GROUP_NAME_LABEL',
'type' => 'text',
'title' => true,
'list' => 'joomla_plugin_groups',
'store' => NULL,
'tab_name' => 'Details',
'db' => [
'type' => 'VARCHAR(255)',
'default' => '',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'class_extends' => [
'name' => 'class_extends',
'label' =>
'COM_COMPONENTBUILDER_JOOMLA_PLUGIN_GROUP_CLASS_EXTENDS_LABEL',
'type' => 'classextends',
'title' => false,
'list' => 'joomla_plugin_groups',
'store' => NULL,
'tab_name' => 'Details',
'db' => [
'type' => 'INT(11)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'access' => [
'name' => 'access',
'label' => 'Access',
'type' => 'accesslevel',
'title' => false,
'store' => NULL,
'tab_name' => NULL,
'db' => [
'type' => 'INT(10) unsigned',
'default' => '0',
'key' => true,
'null_switch' => 'NULL',
],
],
],
'joomla_plugin_updates' => [
'joomla_plugin' => [
'name' => 'joomla_plugin',
'label' =>
'COM_COMPONENTBUILDER_JOOMLA_PLUGIN_UPDATES_JOOMLA_PLUGIN_LABEL',
'type' => 'joomlaplugins',
'title' => true,
'list' => 'joomla_plugins_updates',
'store' => NULL,
'tab_name' => 'Updates',
'db' => [
'type' => 'INT(11)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'version_update' => [
'name' => 'version_update',
'label' =>
'COM_COMPONENTBUILDER_JOOMLA_PLUGIN_UPDATES_VERSION_UPDATE_LABEL',
'type' => 'subform',
'title' => false,
'list' => 'joomla_plugins_updates',
'store' => 'json',
'tab_name' => 'Updates',
'db' => [
'type' => 'MEDIUMTEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'access' => [
'name' => 'access',
'label' => 'Access',
'type' => 'accesslevel',
'title' => false,
'store' => NULL,
'tab_name' => NULL,
'db' => [
'type' => 'INT(10) unsigned',
'default' => '0',
'key' => true,
'null_switch' => 'NULL',
],
],
],
'joomla_plugin_files_folders_urls' => [
'joomla_plugin' => [
'name' => 'joomla_plugin',
'label' =>
'COM_COMPONENTBUILDER_JOOMLA_PLUGIN_FILES_FOLDERS_URLS_JOOMLA_PLUGIN_LABEL',
'type' => 'joomlaplugins',
'title' => true,
'list' => 'joomla_plugins_files_folders_urls',
'store' => NULL,
'tab_name' => 'Basic',
'db' => [
'type' => 'INT(11)',
'default' => '0',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => true,
],
],
'addfoldersfullpath' => [
'name' => 'addfoldersfullpath',
'label' =>
'COM_COMPONENTBUILDER_JOOMLA_PLUGIN_FILES_FOLDERS_URLS_ADDFOLDERSFULLPATH_LABEL',
'type' => 'subform',
'title' => false,
'list' => 'joomla_plugins_files_folders_urls',
'store' => 'json',
'tab_name' => 'Advance',
'db' => [
'type' => 'TEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'addfilesfullpath' => [
'name' => 'addfilesfullpath',
'label' =>
'COM_COMPONENTBUILDER_JOOMLA_PLUGIN_FILES_FOLDERS_URLS_ADDFILESFULLPATH_LABEL',
'type' => 'subform',
'title' => false,
'list' => 'joomla_plugins_files_folders_urls',
'store' => 'json',
'tab_name' => 'Advance',
'db' => [
'type' => 'TEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'addfolders' => [
'name' => 'addfolders',
'label' =>
'COM_COMPONENTBUILDER_JOOMLA_PLUGIN_FILES_FOLDERS_URLS_ADDFOLDERS_LABEL',
'type' => 'subform',
'title' => false,
'list' => 'joomla_plugins_files_folders_urls',
'store' => 'json',
'tab_name' => 'Basic',
'db' => [
'type' => 'TEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'addfiles' => [
'name' => 'addfiles',
'label' =>
'COM_COMPONENTBUILDER_JOOMLA_PLUGIN_FILES_FOLDERS_URLS_ADDFILES_LABEL',
'type' => 'subform',
'title' => false,
'list' => 'joomla_plugins_files_folders_urls',
'store' => 'json',
'tab_name' => 'Basic',
'db' => [
'type' => 'TEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'addurls' => [
'name' => 'addurls',
'label' =>
'COM_COMPONENTBUILDER_JOOMLA_PLUGIN_FILES_FOLDERS_URLS_ADDURLS_LABEL',
'type' => 'subform',
'title' => false,
'list' => 'joomla_plugins_files_folders_urls',
'store' => 'json',
'tab_name' => 'Basic',
'db' => [
'type' => 'TEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'unique_key' => false,
'key' => false,
],
],
'access' => [
'name' => 'access',
'label' => 'Access',
'type' => 'accesslevel',
'title' => false,
'store' => NULL,
'tab_name' => NULL,
'db' => [
'type' => 'INT(10) unsigned',
'default' => '0',
'key' => true,
'null_switch' => 'NULL',
],
],
],
];
}
src/Componentbuilder/Table/Schema.php000064400000002145151162054240013606
0ustar00<?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\Table;
use VDM\Joomla\Componentbuilder\Table;
use VDM\Joomla\Interfaces\SchemaInterface;
use VDM\Joomla\Abstraction\Schema as ExtendingSchema;
/**
* Componentbuilder Tables Schema
*
* @since 3.2.1
*/
final class Schema extends ExtendingSchema implements SchemaInterface
{
/**
* Constructor.
*
* @param Table $table The Table Class.
*
* @since 3.2.1
*/
public function __construct(?Table $table = null)
{
$table ??= new Table;
parent::__construct($table);
}
/**
* Get the targeted component code
*
* @return string
* @since 3.2.1
*/
protected function getCode(): string
{
return 'componentbuilder';
}
}
src/Componentbuilder/Table/SchemaChecker.php000064400000003035151162054240015072
0ustar00<?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\Table;
use VDM\Joomla\Componentbuilder\Table;
use VDM\Joomla\Componentbuilder\Table\Schema;
use VDM\Joomla\Interfaces\SchemaCheckerInterface;
use VDM\Joomla\Abstraction\SchemaChecker as ExtendingSchemaChecker;
/**
* Componentbuilder Tables Schema Checker
*
* @since 3.2.2
*/
final class SchemaChecker extends ExtendingSchemaChecker implements
SchemaCheckerInterface
{
/**
* Get the targeted component code
*
* @return string
* @since 3.2.2
*/
protected function getCode(): string
{
return 'componentbuilder';
}
/**
* Get the targeted component power path
*
* @return string
* @since 3.2.2
*/
protected function getPowerPath(): string
{
return 'helpers/powerloader.php';
}
/**
* Get the fully qualified name of the schema class.
*
* @return string
* @since 3.2.2
*/
protected function getSchemaClass(): string
{
return Schema::class;
}
/**
* Get the fully qualified name of the table class.
*
* @return string
* @since 3.2.2
*/
protected function getTableClass(): string
{
return Table::class;
}
}
src/Componentbuilder/Table/index.html000064400000000054151162054240013667
0ustar00<html><body
bgcolor="#FFFFFF"></body></html>src/Componentbuilder/Utilities/Constantpaths.php000064400000005554151162054240016172
0ustar00<?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\Utilities;
/**
* Utilities Constant Paths
*
* @since 3.2.0
*/
class Constantpaths
{
/**
* The array of constant paths
*
* JPATH_SITE is meant to represent the root path of the JSite
application,
* just as JPATH_ADMINISTRATOR is mean to represent the root path of the
JAdministrator application.
*
* JPATH_BASE is the root path for the current requested
application.... so if you are in the administrator application:
*
* JPATH_BASE == JPATH_ADMINISTRATOR
*
* If you are in the site application:
*
* JPATH_BASE == JPATH_SITE
*
* If you are in the installation application:
*
* JPATH_BASE == JPATH_INSTALLATION.
*
* JPATH_ROOT is the root path for the Joomla install and does not
depend upon any application.
*
* @var array
* @since 3.2.0
*/
protected array $paths = [
// The path to the administrator folder.
'JPATH_ADMINISTRATOR' => JPATH_ADMINISTRATOR,
// The path to the installed Joomla! site, or JPATH_ROOT/administrator if
executed from the backend.
'JPATH_BASE' => JPATH_BASE,
// The path to the cache folder.
'JPATH_CACHE' => JPATH_CACHE,
// The path to the administration folder of the current component being
executed.
'JPATH_COMPONENT_ADMINISTRATOR' =>
JPATH_COMPONENT_ADMINISTRATOR,
// The path to the site folder of the current component being executed.
'JPATH_COMPONENT_SITE' => JPATH_COMPONENT_SITE,
// The path to the current component being executed.
'JPATH_COMPONENT' => JPATH_COMPONENT,
// The path to folder containing the configuration.php file.
'JPATH_CONFIGURATION' => JPATH_CONFIGURATION,
// The path to the installation folder.
'JPATH_INSTALLATION' => JPATH_INSTALLATION,
// The path to the libraries folder.
'JPATH_LIBRARIES' => JPATH_LIBRARIES,
// The path to the plugins folder.
'JPATH_PLUGINS' => JPATH_PLUGINS,
// The path to the installed Joomla! site.
'JPATH_ROOT' => JPATH_ROOT,
// The path to the installed Joomla! site.
'JPATH_SITE' => JPATH_SITE,
// The path to the templates folder.
'JPATH_THEMES' => JPATH_THEMES
];
/**
* get array of constant paths or just one constant path
*
* @param string|null $path The path to get
*
* @return array|string|null
* @since 3.2.0
*/
public function get(?string $path = null)
{
if (is_null($path))
{
return $this->paths;
}
return $this->paths[$path] ?? null;
}
}
src/Componentbuilder/Utilities/Exception/NoUserIdFoundException.php000064400000001125151162054240021630
0ustar00<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September, 2020
* @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\Utilities\Exception;
/**
* No User Id Found Exception
*
* @since 5.0.2
*/
class NoUserIdFoundException extends \InvalidArgumentException
{
}
src/Componentbuilder/Utilities/Exception/index.html000064400000000054151162054250016552
0ustar00<html><body
bgcolor="#FFFFFF"></body></html>src/Componentbuilder/Utilities/FilterHelper.php000064400000050245151162054250015724
0ustar00<?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\Utilities;
use Joomla\CMS\Factory;
use Joomla\CMS\Language\Text;
use VDM\Joomla\Utilities\ArrayHelper;
use VDM\Joomla\Utilities\JsonHelper;
use VDM\Joomla\Utilities\GetHelper;
/**
* Filter Helper
*
* @since 3.2.0
*/
abstract class FilterHelper
{
/**
* get extensions grouped list xml
*
* @return string The XML string of Extentions
* @since 3.2.0
*/
public static function extensions(): string
{
// the extension types
$extensions = array(
'joomla_component' =>
'COM_COMPONENTBUILDER_COMPONENT',
'joomla_module' =>
'COM_COMPONENTBUILDER_MODULE',
'joomla_plugin' => 'COM_COMPONENTBUILDER_PLUGIN'
);
// get the extension values
foreach ($extensions as $extension => $label)
{
${$extension} = self::names($extension);
}
$xml = new \DOMDocument();
$xml->formatOutput = true;
$root = $xml->createElement('field');
$root->setAttributeNode(new \DOMAttr('name',
'extension'));
$root->setAttributeNode(new \DOMAttr('type',
'groupedlist'));
$root->setAttributeNode(new \DOMAttr('onchange',
'this.form.submit();'));
$root
->appendChild($xml->createElement('option', '-
' . Text::_('COM_COMPONENTBUILDER_SELECT_EXTENSION') .
' -'))
->setAttributeNode(new \DOMAttr('value', ''));
foreach ($extensions as $extension => $label)
{
$extension_node = $xml->createElement('group');
$extension_node->setAttributeNode(new \DOMAttr('label',
$label));
if (!ArrayHelper::check(${$extension}))
{
$extension_node
->appendChild($xml->createElement('option', '-
' . Text::_('COM_COMPONENTBUILDER_NONE') . ' -'))
->setAttributeNode(new \DOMAttr('disabled',
'true'));
}
else
{
foreach (${$extension} as $id => $element)
{
$extension_node
->appendChild($xml->createElement('option',
$element))
->setAttributeNode(new \DOMAttr('value', $extension .
'__' . $id));
}
}
$root->appendChild($extension_node);
}
$xml->appendChild($root);
return $xml->saveXML();
}
/**
* Get by type the ids and system names
*
* @param string $type The table name to get system names for
* @param string|null $limiter The to limit by limiter table
*
* @return array|null The array of system name and IDs
* @since 3.2.0
*/
public static function names(string $type, ?string $limiter = null):
?array
{
$db = Factory::getDbo();
$query = $db->getQuery(true);
$query
->select($db->quoteName(array('id',
'system_name')))
->from($db->quoteName('#__componentbuilder_' . $type))
->where($db->quoteName('published') . ' >=
1')
->order($db->quoteName('modified') . ' desc')
->order($db->quoteName('created') . ' desc');
// check if we have a limiter for admin views
if ($type === 'admin_view' && $limiter)
{
// first get all views
$admin_view_ids = array();
// if this is a plugin or a module, then no views
if (strpos($limiter, 'joomla_component') !== false)
{
$component = (int) str_replace('joomla_component__',
'', $limiter);
// get the views of this component
if ($add_views = GetHelper::var('component_admin_views',
(int) $component, 'joomla_component',
'addadmin_views'))
{
if (JsonHelper::check($add_views))
{
$add_views = json_decode($add_views, true);
if (ArrayHelper::check($add_views))
{
foreach($add_views as $add_view)
{
if (isset($add_view['adminview']))
{
$admin_view_ids[(int) $add_view['adminview']] = (int)
$add_view['adminview'];
}
}
}
}
}
}
// now check if we still have admin views
if (ArrayHelper::check($admin_view_ids))
{
$query->where($db->quoteName('id') . ' IN ('
. implode(',', $admin_view_ids) . ')');
}
else
{
return null;
}
}
$db->setQuery($query);
$db->execute();
if ($db->getNumRows())
{
return $db->loadAssocList('id', 'system_name');
}
return null;
}
/**
* get any area linked IDs
*
* @param int $id The target ID
* @param string $method The target method
*
* @return array|null The result ids
* @since 3.2.0
**/
public static function linked(int $id, string $method): ?array
{
// check if method exist
if (method_exists(__CLASS__, $method))
{
return self::{$method}($id);
}
return null;
}
/**
* get the substrings of the namespace until the last "\" or
"."
*
* @return array|null The result substrings
* @since 3.2.0
**/
public static function namespaces(): ?array
{
$db = Factory::getDbo();
$query = $db->getQuery(true);
$query
->select(
'DISTINCT REPLACE(SUBSTRING('
. $db->quoteName('namespace')
. ', 1, LENGTH('
. $db->quoteName('namespace')
. ') - LEAST('
. 'IF(LOCATE('
. $db->quote('\\')
. ', ' . $db->quoteName('namespace')
. ') > 0, LOCATE('
. $db->quote('\\')
. ', REVERSE('
. $db->quoteName('namespace')
. ')), 0), '
. 'IF(LOCATE('
. $db->quote('.')
. ', ' . $db->quoteName('namespace')
. ') > 0, LOCATE('
. $db->quote('.')
. ', REVERSE('
. $db->quoteName('namespace')
. ')), 0))), ".", "\\\") AS
trimmed_namespace'
)
->from($db->quoteName('#__componentbuilder_power'))
->where($db->quoteName('published') . ' = 1')
->order('LENGTH(trimmed_namespace) ASC, trimmed_namespace
ASC');
$db->setQuery($query);
$db->execute();
if ($db->getNumRows())
{
return $db->loadAssocList('trimmed_namespace',
'trimmed_namespace');
}
return null;
}
/**
* get get IDs of powers matching namespaces
*
* @param string $namespace The target namespace
*
* @return array|null The result ids
* @since 3.2.0
**/
public static function namegroup(string $namespace): ?array
{
$db = Factory::getDbo();
$query = $db->getQuery(true);
$query
->select($db->quoteName(array('id')))
->from($db->quoteName('#__componentbuilder_power'))
->where($db->quoteName('published') . ' =
1');
// we get only those that match the owner and repo (smaller set)
$paths = explode('\\', $namespace);
foreach ($paths as $path)
{
$query->where($db->quoteName('namespace') . '
REGEXP ' . $db->quote($path));
}
$db->setQuery($query);
$db->execute();
if ($db->getNumRows())
{
return $db->loadColumn();
}
return null;
}
/**
* get translation extension ids
*
* @param int $extension The target ID
* @param string $type The target method
*
* @return array|null The result ids
* @since 3.2.0
**/
public static function translation(int $extension, string $type): ?array
{
// only allow these columns (extension types)
$columns = array(
'joomla_component' => 'components',
'joomla_module' => 'modules',
'joomla_plugin' => 'plugins'
);
// check if the column name is correct
if (isset($columns[$type]))
{
$column = $columns[$type];
$db = Factory::getDbo();
$query = $db->getQuery(true);
$query
->select($db->quoteName(array('id', $column)))
->from($db->quoteName('#__componentbuilder_language_translation'))
->where($db->quoteName($column) . ' != ' .
$db->quote(''));
$db->setQuery($query);
$db->execute();
if ($db->getNumRows())
{
$results = $db->loadAssocList();
$matches = [];
foreach ($results as $k => $v)
{
$value = json_decode($v[$column], true);
if (in_array($extension, $value))
{
$matches[$v['id']] = $v['id'];
}
}
// Checks that we found matches
if (ArrayHelper::check($matches))
{
return array_values($matches);
}
}
}
return null;
}
/**
* get translation ids
*
* @param int $id The target ID
*
* @return array|null The result ids
* @since 3.2.0
**/
public static function translations($language, $translated = true):
?array
{
$db = Factory::getDbo();
$query = $db->getQuery(true);
$query
->select($db->quoteName('id'))
->from($db->quoteName('#__componentbuilder_language_translation'));
// Build the where condition
if ($translated === true) // Translated
{
if ($language === 'all')
{
if (($languages = self::languages()) !== null)
{
$wheres = [];
foreach ($languages as $k => $v)
{
$wheres[] = $db->quoteName('translation') . ' LIKE
' . $db->quote('%' . $k . '%');
}
$query->where($wheres);
}
}
else
{
$query->where($db->quoteName('translation') . '
LIKE ' . $db->quote('%' . $language . '%'));
}
}
else // Not translated
{
if ($language === 'none')
{
$query->where(
array(
$db->quoteName('translation') . ' = ' .
$db->quote(''),
$db->quoteName('translation') . ' = ' .
$db->quote('[]'),
$db->quoteName('translation') . ' = ' .
$db->quote('{}')
), 'OR'
);
}
else
{
$query->where($db->quoteName('translation') . '
NOT LIKE ' . $db->quote('%' . $language .
'%'));
}
}
$db->setQuery($query);
$db->execute();
if ($db->getNumRows())
{
return array_unique($db->loadColumn());
}
return null;
}
/**
* get available languages
*
* @return array|null The result ids
* @since 3.2.0
**/
public static function languages(): ?array
{
$db = Factory::getDbo();
$query = $db->getQuery(true);
$query
->select($db->quoteName(array('langtag',
'name')))
->from($db->quoteName('#__componentbuilder_language'))
->where($db->quoteName('published') . ' = 1')
->order($db->quoteName('name') . ' desc');
$db->setQuery($query);
$db->execute();
if ($db->getNumRows())
{
return $db->loadAssocList('langtag', 'name');
}
return null;
}
/**
* get get IDs of powers link to this path
*
* @param string $path The target PATH
*
* @return array|null The result ids
* @since 3.2.0
**/
public static function paths(string $path): ?array
{
// get all this power ids
$ids = [];
$db = Factory::getDbo();
$query = $db->getQuery(true);
$query
->select($db->quoteName(array('id',
'approved_paths')))
->from($db->quoteName('#__componentbuilder_power'))
->where($db->quoteName('published') . ' =
1');
// we get only those that match the owner and repo (smaller set)
if (($pos = strpos($path, '/')) !== false)
{
$owner = substr($path, 0, $pos);
$repo = substr($path, $pos + 1);
$query
->where($db->quoteName('approved_paths') . '
REGEXP ' . $db->quote($owner))
->where($db->quoteName('approved_paths') . '
REGEXP ' . $db->quote($repo));
}
$db->setQuery($query);
$db->execute();
if ($db->getNumRows())
{
$result = $db->loadAssocList('id',
'approved_paths');
foreach ($result as $id => $paths)
{
if (JsonHelper::check($paths))
{
$paths = json_decode($paths, true);
if (ArrayHelper::check($paths) && in_array($path, $paths,
true))
{
$ids[$id] = $id;
}
}
}
if (ArrayHelper::check($ids))
{
return $ids;
}
}
return null;
}
/**
* get available repositories of target area
*
* @param int $target The target area
*
* @return array|null The result ids
* @since 3.2.0
**/
public static function repositories(int $target): ?array
{
$db = Factory::getDbo();
$query = $db->getQuery(true);
$query
->select($db->quoteName(array('repository',
'organisation')))
->from($db->quoteName('#__componentbuilder_repository'))
->where($db->quoteName('published') . ' >=
1')
->where($db->quoteName('target') . ' = ' .
$target)
->order($db->quoteName('ordering') . '
desc');
$db->setQuery($query);
$db->execute();
if ($db->getNumRows())
{
$items = $db->loadObjectList();
$options = [];
foreach($items as $item)
{
$path = $item->organisation . '/' . $item->repository;
$options[$path] = $path;
}
return $options;
}
return null;
}
/**
* Get a component admin views IDs
*
* @param int $id The target ID
*
* @return array|null The result ids
* @since 3.2.0
*/
private static function joomla_component_admin_views(int $id): ?array
{
// get all this components views
$admin_view_ids = [];
// get the views of this component
if ($add_views = GetHelper::var('component_admin_views', (int)
$id, 'joomla_component', 'addadmin_views'))
{
if (JsonHelper::check($add_views))
{
$add_views = json_decode($add_views, true);
if (ArrayHelper::check($add_views))
{
foreach($add_views as $add_view)
{
if (isset($add_view['adminview']))
{
$admin_view_ids[(int) $add_view['adminview']] = (int)
$add_view['adminview'];
}
}
}
}
}
// check that we have fields
if (ArrayHelper::check($admin_view_ids))
{
return array_values($admin_view_ids);
}
return null;
}
/**
* get a component custom admin views IDs
*
* @param int $id The target ID
*
* @return array|null The result ids
* @since 3.2.0
*/
private static function joomla_component_custom_admin_views($id): ?array
{
// get all this components views
$admin_view_ids = [];
// get the views of this component
if ($add_views = GetHelper::var('component_custom_admin_views',
(int) $id, 'joomla_component',
'addcustom_admin_views'))
{
if (JsonHelper::check($add_views))
{
$add_views = json_decode($add_views, true);
if (ArrayHelper::check($add_views))
{
foreach($add_views as $add_view)
{
if (isset($add_view['customadminview']))
{
$admin_view_ids[(int) $add_view['customadminview']] =
(int) $add_view['customadminview'];
}
}
}
}
}
// check that we have fields
if (ArrayHelper::check($admin_view_ids))
{
return array_values($admin_view_ids);
}
return null;
}
/**
* get a component site views IDs
*
* @param int $id The target ID
*
* @return array|null The result ids
* @since 3.2.0
*/
private static function joomla_component_site_views($id): ?array
{
// get all this components views
$admin_view_ids = [];
// get the views of this component
if ($add_views = GetHelper::var('component_site_views', (int)
$id, 'joomla_component', 'addsite_views'))
{
if (JsonHelper::check($add_views))
{
$add_views = json_decode($add_views, true);
if (ArrayHelper::check($add_views))
{
foreach($add_views as $add_view)
{
if (isset($add_view['siteview']))
{
$admin_view_ids[(int) $add_view['siteview']] = (int)
$add_view['siteview'];
}
}
}
}
}
// check that we have fields
if (ArrayHelper::check($admin_view_ids))
{
return array_values($admin_view_ids);
}
return null;
}
/**
* get a component fields IDs
*
* @param int $id The target ID
*
* @return array|null The result ids
* @since 3.2.0
*/
private static function joomla_component($id): ?array
{
// we start the field array
$field_ids = [];
// first get all views
$admin_view_ids = [];
// get the views of this component
if ($add_views = GetHelper::var('component_admin_views', (int)
$id, 'joomla_component', 'addadmin_views'))
{
if (JsonHelper::check($add_views))
{
$add_views = json_decode($add_views, true);
if (ArrayHelper::check($add_views))
{
foreach($add_views as $add_view)
{
if (isset($add_view['adminview']))
{
$admin_view_ids[(int) $add_view['adminview']] = (int)
$add_view['adminview'];
}
}
}
}
}
// check that we have views
if (ArrayHelper::check($admin_view_ids))
{
foreach ($admin_view_ids as $admin_view)
{
// get all the fields linked to the admin view
if ($add_fields = GetHelper::var('admin_fields', (int)
$admin_view, 'admin_view', 'addfields'))
{
if (JsonHelper::check($add_fields))
{
$add_fields = json_decode($add_fields, true);
if (ArrayHelper::check($add_fields))
{
foreach($add_fields as $add_field)
{
if (isset($add_field['field']))
{
$field_ids[(int) $add_field['field']] = (int)
$add_field['field'];
}
}
}
}
}
}
}
// get config values
if ($add_config = GetHelper::var('component_config', (int) $id,
'joomla_component', 'addconfig'))
{
if (JsonHelper::check($add_config))
{
$add_config = json_decode($add_config, true);
if (ArrayHelper::check($add_config))
{
foreach($add_config as $add_conf)
{
if (isset($add_conf['field']))
{
$field_ids[(int) $add_conf['field']] = (int)
$add_conf['field'];
}
}
}
}
}
// check that we have fields
if (ArrayHelper::check($field_ids))
{
return array_values($field_ids);
}
return null;
}
/**
* get a module fields IDs
*
* @param int $id The target ID
*
* @return array|null The result ids
* @since 3.2.0
*/
private static function joomla_module($id): ?array
{
// we start the field array
$field_ids = [];
if ($fields = GetHelper::var('joomla_module', (int) $id,
'id', 'fields'))
{
if (JsonHelper::check($fields))
{
$fields = json_decode($fields, true);
if (ArrayHelper::check($fields))
{
foreach($fields as $form)
{
if (isset($form['fields']) &&
ArrayHelper::check($form['fields']))
{
foreach ($form['fields'] as $field)
{
if (isset($field['field']))
{
$field_ids[(int) $field['field']] = (int)
$field['field'];
}
}
}
}
}
}
}
// check that we have fields
if (ArrayHelper::check($field_ids))
{
return array_values($field_ids);
}
return null;
}
/**
* get a plugin fields IDs
*
* @param int $id The target ID
*
* @return array|null The result ids
* @since 3.2.0
*/
private static function joomla_plugin($id): ?array
{
// we start the field array
$field_ids = [];
if ($fields = GetHelper::var('joomla_plugin', (int) $id,
'id', 'fields'))
{
if (JsonHelper::check($fields))
{
$fields = json_decode($fields, true);
if (ArrayHelper::check($fields))
{
foreach($fields as $form)
{
if (isset($form['fields']) &&
ArrayHelper::check($form['fields']))
{
foreach ($form['fields'] as $field)
{
if (isset($field['field']))
{
$field_ids[(int) $field['field']] = (int)
$field['field'];
}
}
}
}
}
}
}
// check that we have fields
if (ArrayHelper::check($field_ids))
{
return array_values($field_ids);
}
return null;
}
/**
* get an admin view fields IDs
*
* @param int $id The target ID
*
* @return array|null The result ids
* @since 3.2.0
*/
private static function admin_view($id): ?array
{
// we start the field array
$field_ids = [];
// get all the fields linked to the admin view
if ($add_fields = GetHelper::var('admin_fields', (int) $id,
'admin_view', 'addfields'))
{
if (JsonHelper::check($add_fields))
{
$add_fields = json_decode($add_fields, true);
if (ArrayHelper::check($add_fields))
{
foreach($add_fields as $add_field)
{
if (isset($add_field['field']))
{
$field_ids[(int) $add_field['field']] = (int)
$add_field['field'];
}
}
}
}
}
// check that we have fields
if (ArrayHelper::check($field_ids))
{
return array_values($field_ids);
}
return null;
}
}
src/Componentbuilder/Utilities/RepoHelper.php000064400000004756151162054250015412
0ustar00<?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\Utilities;
use Joomla\CMS\Factory;
use VDM\Joomla\Utilities\JsonHelper;
use VDM\Joomla\Utilities\ArrayHelper;
/**
* Repositories Helper
*
* @since 3.2.2
*/
abstract class RepoHelper
{
/**
* get available repositories of target area
*
* @param int $target The target area
*
* @return array|null The result set
* @since 3.2.0
**/
public static function get(int $target): ?array
{
$db = Factory::getDbo();
$query = $db->getQuery(true);
$query->select($db->quoteName(array(
'type',
'base',
'organisation',
'repository',
'read_branch',
'write_branch',
'token',
'username',
'target',
'access_repo',
'addplaceholders',
'guid'
)))
->from($db->quoteName('#__componentbuilder_repository'))
->where($db->quoteName('published') . ' >=
1')
->where($db->quoteName('target') . ' = ' .
$target)
->order($db->quoteName('ordering') . '
desc');
$db->setQuery($query);
$db->execute();
if ($db->getNumRows())
{
$items = $db->loadObjectList();
$options = [];
foreach($items as $item)
{
if ($item->access_repo != 1)
{
unset($item->username);
unset($item->token);
}
unset($item->access_repo);
$item->placeholders =
self::setPlaceholders($item->addplaceholders ?? '');
unset($item->addplaceholders);
$path = $item->organisation . '/' . $item->repository;
$options[$path] = $item;
}
return $options;
}
return null;
}
/**
* set the placeholders for this repo
*
* @param string $placeholders The repo placeholders
*
* @return array The result set
* @since 5.0.3
**/
protected static function setPlaceholders(string $placeholders): array
{
$bucket = [];
if (JsonHelper::check($placeholders))
{
$placeholders = json_decode((string) $placeholders, true);
if (ArrayHelper::check($placeholders))
{
foreach ($placeholders as $row)
{
$bucket[$row['target']] = $row['value'];
}
}
}
return $bucket;
}
}
src/Componentbuilder/Utilities/UserHelper.php000064400000032665151162054250015423
0ustar00<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September, 2020
* @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\Utilities;
use Joomla\CMS\Factory;
use Joomla\CMS\Form\Form;
use Joomla\CMS\Language\Text;
use Joomla\CMS\User\User;
use Joomla\CMS\User\UserHelper as JoomlaUserHelper;
use Joomla\CMS\MVC\Model\BaseDatabaseModel;
use VDM\Joomla\Utilities\Component\Helper as Component;
use VDM\Joomla\Utilities\ArrayHelper;
use VDM\Joomla\Utilities\StringHelper;
use VDM\Joomla\Componentbuilder\Utilities\Exception\NoUserIdFoundException;
/**
* Create & Update User [Save]
*
* @since 5.0.2
*/
abstract class UserHelper
{
/**
* Save user details by either creating a new user or updating an existing
user.
*
* @param array $credentials User credentials including
'name', 'username', 'email',
'password', and 'password2'.
* @param int $autologin Flag to determine whether to auto-login
the user after registration.
* @param array $params Parameters for user activation, password
sending, and user registration allowance.
* @param int $mode Mode of registration: 1 = Site
Registration, 0 = Admin Registration, 2 = Custom Helper Method.
*
* @return int User ID on success.
*
* @throws \InvalidArgumentException If required credentials are
missing.
* @throws \RuntimeException If the user update or creation
fails.
* @throws NoUserIdFoundException If the user is not found.
*
* @since 5.0.3
*/
public static function save(array $credentials, int $autologin = 0,
array $params = ['useractivation' => 0,
'sendpassword' => 1], int $mode = 1): int
{
// can not continue without an email
if (empty($credentials['email']))
{
throw new
\InvalidArgumentException(Text::_('COM_COMPONENTBUILDER_CAN_NOT_SAVE_USER_WITHOUT_EMAIL_VALUE'));
}
// Ensure the 'username' key exists in the credentials array,
set to an empty string if not provided.
$username = $credentials['username'] ??
$credentials['email'];
// If the user's ID is set and valid, handle the update logic.
if (!empty($credentials['id']) &&
$credentials['id'] > 0)
{
$userId = $credentials['id'];
$email = $credentials['email'];
// Fetch existing user by email and username.
$existingEmailUserId = static::getUserIdByEmail($email);
$existingUsernameId = static::getUserIdByUsername($username);
// Validate that we aren't attempting to update other users or
reuse another user's email/username.
if (
($existingEmailUserId && $existingEmailUserId != $userId) ||
($existingUsernameId && $existingUsernameId != $userId) ||
($existingEmailUserId && $existingUsernameId &&
$existingEmailUserId != $existingUsernameId)
) {
throw new NoUserIdFoundException(
Text::sprintf(
'User ID mismatch detected when trying to save %s (%s)
credentials.',
$username,
$email
)
);
}
// Update the existing user.
return static::update($credentials);
}
// Create a new user if no existing user is found.
return static::create($credentials, $autologin, $params, $mode);
}
/**
* Create a user and update the given table.
*
* @param array $credentials User credentials including
'name', 'username', 'email',
'password', and 'password2'.
* @param int $autologin Flag to determine whether to auto-login
the user after registration.
* @param array $params Parameters for user activation, password
sending, and user registration allowance.
* @param int $mode Mode of registration: 1 = Site
Registration, 0 = Admin Registration, 2 = Custom Helper Method.
*
* @return int User ID on success.
*
* @throws \RuntimeException If user creation fails.
* @throws NoUserIdFoundException If the user is not found.
*
* @since 5.0.3
*/
public static function create(array $credentials, int $autologin = 0,
array $params = ['useractivation' => 0,
'sendpassword' => 1], int $mode = 1): int
{
$lang = Factory::getLanguage();
$lang->load('com_users', JPATH_SITE, 'en-GB',
true);
// Handle custom registration mode
if ($mode === 2 && method_exists(ComponentbuilderHelper::class,
'registerUser'))
{
$params['autologin'] = $autologin;
$userId = ComponentbuilderHelper::registerUser($credentials, $params);
if (is_numeric($userId))
{
return $userId;
}
throw new
NoUserIdFoundException(Text::_('COM_COMPONENTBUILDER_USER_CREATION_FAILED'));
}
// Check if we have params/config
if (ArrayHelper::check($params))
{
// Make changes to user config
foreach ($params as $param => $set)
{
// If you know of a better path, let me know
$params[$param] = Component::setParams($param, $set,
'com_users');
}
}
// Fallback to Site Registrations if mode is set to 2 but the method
doesn't exist
$mode = $mode === 2 ? 1 : $mode;
// Load the appropriate user model
$model = static::getModelByMode($mode);
// Set default values for missing credentials
$credentials['username'] = $credentials['username']
?? $credentials['email'];
// Prepare user data
$data = static::prepareUserData($credentials, $mode);
// Set form path (bug fix for Joomla)
static::setFormPathForUserClass($mode);
// Handle user creation
$userId = $mode === 1 ? $model->register($data) :
static::adminRegister($model, $data);
// Check if we have params
if (ArrayHelper::check($params))
{
// Change user params/config back
foreach ($params as $param => $set)
{
// If you know of a better path, let me know
Component::setParams($param, $set, 'com_users');
}
}
if (!$userId)
{
$current_user = Factory::getApplication()->getIdentity();
// only allow those with access to Users to ignore errors
if ($current_user->authorise('core.manage',
'com_users'))
{
$userId =
static::getUserIdByUsername($credentials['username']);
}
}
if (is_numeric($userId) && $userId > 0)
{
// Handle post-registration processes
return static::handlePostRegistration($userId, $autologin,
$credentials);
}
$error_messages = '';
if (method_exists($model, 'getError'))
{
$errors = $model->getError();
if (!empty($errors))
{
if (is_array($errors))
{
$error_messages = '<br>' .
implode('<br>', $errors);
}
elseif (is_string($errors))
{
$error_messages = '<br>' . $errors;
}
}
}
throw new NoUserIdFoundException(
Text::sprintf('COM_COMPONENTBUILDER_USER_S_S_CREATION_FAILEDS',
(string) $credentials['username'],
(string) $credentials['email'],
$error_messages
)
);
}
/**
* Update user details.
*
* @param array $userDetails Array containing user details to be
updated.
*
* @return int Updated user ID on success.
*
* @throws \RuntimeException If user update fails.
*
* @since 5.0.3
*/
public static function update(array $userDetails): int
{
$lang = Factory::getLanguage();
$lang->load('com_users', JPATH_ADMINISTRATOR,
'en-GB', true);
$model = Component::getModel('User', 'Administrator',
'com_users');
// Set default values for missing credentials
$userDetails['username'] = $userDetails['username']
?? $userDetails['email'];
// Prepare user data for update
$data = [
'id' => $userDetails['id'],
'username' => $userDetails['username'],
'name' => $userDetails['name'],
'email' => $userDetails['email'],
'password' => $userDetails['password'] ?? null,
'password2' => $userDetails['password2'] ??
null,
'block' => 0
];
// set groups if found
if (isset($userDetails['groups']) &&
ArrayHelper::check($userDetails['groups']))
{
$data['groups'] = $userDetails['groups'];
}
// Update the user
if ($model->save($data))
{
return $userDetails['id'];
}
$error_messages = '';
if (method_exists($model, 'getError'))
{
$errors = $model->getError();
if (!empty($errors))
{
if (is_array($errors))
{
$error_messages = '<br>' .
implode('<br>', $errors);
}
elseif (is_string($errors))
{
$error_messages = '<br>' . $errors;
}
}
}
throw new \RuntimeException(
Text::sprintf('COM_COMPONENTBUILDER_UPDATE_OF_USER_S_S_FAILEDS',
(string) $userDetails['username'],
(string) $userDetails['email'],
(string) $error_messages
)
);
}
/**
* Method to get an instance of a user for the given id.
*
* @param int $id The id
*
* @return User
*
* @since 5.0.3
*/
public static function getUserById(int $id): User
{
return new User($id);
}
/**
* Retrieve the user ID by username.
*
* @param string $username The username to check.
*
* @return int|null The user ID if the user exists, null otherwise.
*
* @since 5.0.3
*/
public static function getUserIdByUsername(string $username): ?int
{
$userId = JoomlaUserHelper::getUserId($username);
return $userId ?: null;
}
/**
* Retrieve the user ID by email.
*
* @param string $email The email address to check.
*
* @return int|null The user ID if the user exists, null otherwise.
*
* @since 5.0.3
*/
public static function getUserIdByEmail(string $email): ?int
{
// Initialise some variables
$db = Factory::getDbo();
$query = $db->getQuery(true)
->select($db->quoteName('id'))
->from($db->quoteName('#__users'))
->where($db->quoteName('email') . ' =
:email')
->bind(':email', $email)
->setLimit(1);
$db->setQuery($query);
$userId = $db->loadResult();
return $userId ?: null;
}
/**
* Load the correct user model based on the registration mode.
*
* @param int $mode The registration mode.
*
* @return BaseDatabaseModel The appropriate user model.
*
* @since 5.0.3
*/
protected static function getModelByMode(int $mode): BaseDatabaseModel
{
if ($mode === 1)
{
return Component::getModel('Registration', 'Site',
'com_users');
}
return Component::getModel('User', 'Administrator',
'com_users');
}
/**
* Prepare user data array for registration or update.
*
* @param array $credentials User credentials.
* @param int $mode The registration mode.
*
* @return array The prepared user data array.
*
* @since 5.0.3
*/
protected static function prepareUserData(array $credentials, int $mode)
{
$data = [
'username' => $credentials['username'],
'name' => $credentials['name'],
'block' => 0
];
if ($mode === 1)
{
$data['email1'] = $credentials['email'];
}
else
{
$data['email'] = $credentials['email'];
$data['registerDate'] = Factory::getDate()->toSql();
}
if ($mode === 1 && empty($credentials['password']))
{
$credentials['password'] = StringHelper::random(10);
$credentials['password2'] =
$credentials['password'];
}
if (!empty($credentials['password']) &&
!empty($credentials['password2']))
{
$data['password1'] = $credentials['password'];
$data['password2'] = $credentials['password2'];
}
if ($mode === 0 && isset($credentials['groups'])
&& ArrayHelper::check($credentials['groups']))
{
$data['groups'] = $credentials['groups'];
}
return $data;
}
/**
* Handle the registration process for admin mode.
*
* @param BaseDatabaseModel $model The user model.
* @param array $data The user data.
*
* @return int The ID of the created user.
*
* @since 5.0.3
*/
private static function adminRegister(BaseDatabaseModel $model, array
$data): int
{
$model->save($data);
return $model->getState('user.id', 0);
}
/**
* Handle post-registration processes like auto-login.
*
* @param int $userId The ID of the created user.
* @param int $autologin Flag to determine whether to auto-login
the user.
* @param array $credentials The user credentials.
*
* @return int The user ID on success.
*
* @since 5.0.3
*/
private static function handlePostRegistration(int $userId, int
$autologin, array $credentials): int
{
// make sure user is it the correct groups
if ($userId > 0 && !empty($credentials['groups']))
{
try
{
JoomlaUserHelper::setUserGroups($userId,
$credentials['groups']);
}
catch (\Exception $e)
{
// we might need say something
}
}
if ($autologin && !empty($credentials['password']))
{
try
{
Factory::getApplication()->login($credentials);
}
catch (\Exception $e)
{
// we might need to redirect here?
}
}
return $userId;
}
/**
* Address bug on \Joomla\CMS\MVC\Model\FormBehaviorTrait Line 76
* The use of JPATH_COMPONENT cause it to load the
* active component forms and fields, which breaks the registration
model.
*
* @param int $mode
*
* @since 5.0.3
*/
private static function setFormPathForUserClass(int $mode): void
{
if ($mode == 1) // 1 = use of the Registration Model
{
// Get the form.
Form::addFormPath(JPATH_ROOT .
'/components/com_users/forms');
}
}
}
src/Componentbuilder/Utilities/index.html000064400000000054151162054250014614
0ustar00<html><body
bgcolor="#FFFFFF"></body></html>src/Componentbuilder/index.html000064400000000054151162054250012641
0ustar00<html><body
bgcolor="#FFFFFF"></body></html>