Moves multiple class methods to their own power classes. Moves many compiler config values to its own config class. Updated the Expantion method to use the new config class.
This commit is contained in:
@ -0,0 +1,144 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 30th April, 2015
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||
* @copyright Copyright (C) 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\Componentbuilder\Compiler\Factory as Compiler;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Config;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Placefix;
|
||||
|
||||
|
||||
/**
|
||||
* Get a Components Global Placeholders
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class Placeholder
|
||||
{
|
||||
/**
|
||||
* Placeholders
|
||||
*
|
||||
* @var arraya
|
||||
* @since 3.2.0
|
||||
**/
|
||||
protected $placeholders = null;
|
||||
|
||||
/**
|
||||
* Compiler Config
|
||||
*
|
||||
* @var Config
|
||||
* @since 3.2.0
|
||||
**/
|
||||
protected $config;
|
||||
|
||||
/**
|
||||
* Database object to query local DB
|
||||
*
|
||||
* @var \JDatabaseDriver
|
||||
* @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, ?\JDatabaseDriver $db = null)
|
||||
{
|
||||
$this->config = $config ?: Compiler::_('Config');
|
||||
$this->db = $db ?: Factory::getDbo();
|
||||
}
|
||||
|
||||
/**
|
||||
* get all System Placeholders
|
||||
*
|
||||
* @return array The global placeholders
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function get()
|
||||
{
|
||||
// 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 = array();
|
||||
// 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($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')];
|
||||
|
||||
// get the current components overrides
|
||||
if (($_placeholders = GetHelper::var(
|
||||
'component_placeholders', $config->component_id,
|
||||
'joomla_component', 'addplaceholders'
|
||||
)) !== false
|
||||
&& JsonHelper::check($_placeholders))
|
||||
{
|
||||
$_placeholders = json_decode($_placeholders, true);
|
||||
if (ArrayHelper::check($_placeholders))
|
||||
{
|
||||
foreach ($_placeholders as $row)
|
||||
{
|
||||
$bucket[$row['target']] = $row['value'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->placeholders = $bucket;
|
||||
|
||||
return $bucket;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -12,167 +12,492 @@
|
||||
namespace VDM\Joomla\Componentbuilder\Compiler;
|
||||
|
||||
|
||||
use Joomla\Registry\Registry;
|
||||
use Joomla\Registry\Registry;
|
||||
use Joomla\CMS\Factory;
|
||||
use Joomla\Input\Input;
|
||||
use VDM\Joomla\Utilities\Component\Helper;
|
||||
use VDM\Joomla\Utilities\GetHelper;
|
||||
use VDM\Joomla\Utilities\StringHelper;
|
||||
use VDM\Joomla\Utilities\String\ClassfunctionHelper;
|
||||
|
||||
|
||||
/**
|
||||
* Compiler Configurations Registry
|
||||
* Compiler Configurations
|
||||
*
|
||||
* @since 3.1.6
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class Config extends Registry implements \JsonSerializable, \ArrayAccess, \IteratorAggregate, \Countable
|
||||
{
|
||||
/**
|
||||
* Hold a JInput object for easier access to the input variables.
|
||||
*
|
||||
* @var Input
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected $input;
|
||||
|
||||
/**
|
||||
* The Params
|
||||
*
|
||||
* @var Registry
|
||||
* @since 3.1.6
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected Registry $params;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param array $config The data to bind to the new Config object.
|
||||
* @param Registry $params The component parameters
|
||||
* @param Input|null $input Input
|
||||
* @param Registry|null $params The component parameters
|
||||
*
|
||||
* @since 3.1.6
|
||||
* @throws \Exception
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function __construct(array $config, ?Registry $params = null)
|
||||
public function __construct(?Input $input = null, ?Registry $params = null)
|
||||
{
|
||||
// Set the params
|
||||
$this->input = $input ?: Factory::getApplication()->input;
|
||||
$this->params = $params ?: Helper::getParams('com_componentbuilder');
|
||||
|
||||
// Instantiate the internal data object.
|
||||
$this->data = new \stdClass;
|
||||
// use underscore as the separator
|
||||
$this->separator = '_';
|
||||
|
||||
// Load the config to the data object
|
||||
$this->bindData($this->data, $this->modelConfig($config));
|
||||
// Instantiate the internal data object.
|
||||
$this->data = new \stdClass();
|
||||
}
|
||||
|
||||
/**
|
||||
* model the configuration data array
|
||||
* setting any config value
|
||||
*
|
||||
* @param array $config The data to bind to the new Config object.
|
||||
* @param String $key The value's key/path name
|
||||
* @param mixed $value Optional default value, returned if the internal value is null.
|
||||
*
|
||||
* @return array
|
||||
* @since 3.1.6
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected function modelConfig(array $config): array
|
||||
public function __set($key, $value)
|
||||
{
|
||||
// we do not yet have this set as an option
|
||||
$config['remove_line_breaks']
|
||||
= 2; // 2 is global (use the components value)
|
||||
$this->set($key, $value);
|
||||
}
|
||||
|
||||
// set the minfy switch of the JavaScript
|
||||
$config['minify'] = (isset($config['minify']) && $config['minify'] != 2)
|
||||
? $config['minify'] : $this->params->get('minify', 0);
|
||||
/**
|
||||
* 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)
|
||||
{
|
||||
// function name with no underscores
|
||||
$method = 'get' . ucfirst(ClassfunctionHelper::safe(str_replace('_', '', $key)));
|
||||
|
||||
// set the global language
|
||||
$config['lang_tag'] = $this->params->get('language', 'en-GB');
|
||||
if (($value = $this->get($key, '__N0T_S3T_')) !== '__N0T_S3T_')
|
||||
{
|
||||
return $value;
|
||||
}
|
||||
elseif (method_exists($this, $method))
|
||||
{
|
||||
$value = $this->{$method}();
|
||||
|
||||
// check if we have Tidy enabled
|
||||
$config['tidy'] = extension_loaded('Tidy');
|
||||
$this->set($key, $value);
|
||||
|
||||
// set the field type builder
|
||||
$config['field_builder_type'] = $this->params->get(
|
||||
'compiler_field_builder_type', 2
|
||||
return $value;
|
||||
}
|
||||
|
||||
throw new \InvalidArgumentException(sprintf('Argument %s could not be found as function [%s], or path.', $key, $method));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a registry 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(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}();
|
||||
|
||||
$this->set($path, $value);
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
return $default;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 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($this->component_code_name);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 posted Joomla version name
|
||||
*
|
||||
* @return string Joomla version code name
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected function getJoomlaversionname(): string
|
||||
{
|
||||
return StringHelper::safe($this->joomla_version);
|
||||
}
|
||||
|
||||
/**
|
||||
* get indentation value
|
||||
*
|
||||
* @return string Indentation value
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected function getIndentationvalue(): string
|
||||
{
|
||||
return "\t"; // TODO add to GUI as an Global Option?
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 active value
|
||||
$add = ($value == 0) ? false : (
|
||||
($value == 1) ? true : (
|
||||
((int) GetHelper::var('joomla_component', $this->component_id, 'id', 'debug_linenr' ) == 1) ? true : false
|
||||
)
|
||||
);
|
||||
|
||||
// load the compiler path
|
||||
$config['compiler_path'] = $this->params->get(
|
||||
return $add;
|
||||
}
|
||||
|
||||
/**
|
||||
* get posted minify switch
|
||||
*
|
||||
* @return int Minify switch number
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected function getMinify(): int
|
||||
{
|
||||
$minify = $this->input->post->get('minify', 2, 'INT');
|
||||
|
||||
// if value is 2 use global value
|
||||
$minify = ($minify != 2) ? $minify : $this->params->get('minify', 0);
|
||||
|
||||
return $minify;
|
||||
}
|
||||
|
||||
/**
|
||||
* get posted remove line breaks switch
|
||||
*
|
||||
* @return bool Remove line breaks switch number
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected function getRemovelinebreaks(): bool
|
||||
{
|
||||
$value = 2; // 2 is global (use the components value) TODO: get from post
|
||||
|
||||
// get active value
|
||||
$remove = ($value == 0) ? false : (
|
||||
($value == 1) ? true : (
|
||||
((int) GetHelper::var('joomla_component', $this->component_id, 'id', 'remove_line_breaks' ) == 1) ? true : false
|
||||
)
|
||||
);
|
||||
|
||||
return $remove;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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');
|
||||
}
|
||||
|
||||
/**
|
||||
* 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' => 'JText:' . ':script(',
|
||||
't' => 'Text:' . ':_(', // namespace and J version will be found
|
||||
'ts' => 'Text:' . ':sprintf(', // namespace and J version will be found
|
||||
'jt' => 'JustTEXT:' . ':_('
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 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'
|
||||
);
|
||||
}
|
||||
|
||||
// load the jcb powers path
|
||||
$config['jcb_powers_path'] = $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 getJcbpowerspath(): string
|
||||
{
|
||||
// get jcb powers path
|
||||
return $this->params->get('jcb_powers_path', 'libraries/jcb_powers');
|
||||
}
|
||||
|
||||
// set the component ID
|
||||
$config['component_id'] = (int)$config['component'];
|
||||
// TODO set up stream correctly
|
||||
unset($config['component']);
|
||||
/**
|
||||
* 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
|
||||
);
|
||||
|
||||
// set this components code name
|
||||
if ($name_code = GetHelper::var(
|
||||
'joomla_component', $config['component_id'], 'id', 'name_code'
|
||||
)) {
|
||||
// set lang prefix
|
||||
$config['lang_prefix'] = 'COM_' . StringHelper::safe(
|
||||
$name_code, 'U'
|
||||
);
|
||||
// get component value
|
||||
$add = (($add_assets_table_fix = (int) GetHelper::var(
|
||||
'joomla_component', $this->component_id, 'id',
|
||||
'assets_table_fix'
|
||||
)) == 3) ? $global : $add_assets_table_fix;
|
||||
|
||||
// set component code name
|
||||
$config['component_code_name'] = StringHelper::safe(
|
||||
$name_code
|
||||
);
|
||||
return $add;
|
||||
}
|
||||
|
||||
// set component context
|
||||
$config['component_context'] = $config['component_code_name'] . '.'
|
||||
. $config['component_id'];
|
||||
/**
|
||||
* 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');
|
||||
|
||||
// set the component name length
|
||||
$config['component_code_name_length'] = strlen(
|
||||
$config['component_code_name']
|
||||
);
|
||||
// get active value
|
||||
$add = ($value == 0) ? false : (
|
||||
($value == 1) ? true : (
|
||||
((int) GetHelper::var('joomla_component', $this->component_id, 'id', 'add_placeholders' ) == 1) ? true : false
|
||||
)
|
||||
);
|
||||
|
||||
// add assets table fix
|
||||
$global = (int)$this->params->get(
|
||||
'assets_table_fix', 1
|
||||
);
|
||||
$config['add_assets_table_fix'] = (($add_assets_table_fix
|
||||
= (int)GetHelper::var(
|
||||
'joomla_component', $config['component_id'], 'id',
|
||||
'assets_table_fix'
|
||||
)) == 3) ? $global : $add_assets_table_fix;
|
||||
return $add;
|
||||
}
|
||||
|
||||
// set if language strings line breaks should be removed
|
||||
$global = ((int)GetHelper::var(
|
||||
'joomla_component', $config['component_id'], 'id',
|
||||
'remove_line_breaks'
|
||||
) == 1) ? true : false;
|
||||
$config['remove_line_breaks'] = ((int)$config['remove_line_breaks']
|
||||
== 0)
|
||||
? false
|
||||
: (((int)$config['remove_line_breaks'] == 1) ? true
|
||||
: $global);
|
||||
/**
|
||||
* 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');
|
||||
|
||||
// set if placeholders should be added to customcode
|
||||
$global = ((int)GetHelper::var(
|
||||
'joomla_component', $config['component_id'], 'id',
|
||||
'add_placeholders'
|
||||
) == 1) ? true : false;
|
||||
$config['add_placeholders'] = ((int)$config['placeholders'] == 0)
|
||||
? false
|
||||
: (((int)$config['placeholders'] == 1) ? true : $global);
|
||||
// TODO set up stream correctly
|
||||
unset($config['placeholders']);
|
||||
// get active value
|
||||
$add = ($value == 0) ? false : (
|
||||
($value == 1) ? true : (
|
||||
((int) GetHelper::var('joomla_component', $this->component_id, 'id', 'add_powers' ) == 1) ? true : false
|
||||
)
|
||||
);
|
||||
|
||||
// set if line numbers should be added to comments
|
||||
$global = ((int)GetHelper::var(
|
||||
'joomla_component', $config['component_id'], 'id',
|
||||
'debug_linenr'
|
||||
) == 1) ? true : false;
|
||||
$config['debug_line_nr'] = ((int)$config['debuglinenr'] == 0) ? false
|
||||
: (((int)$config['debuglinenr'] == 1) ? true : $global);
|
||||
return $add;
|
||||
}
|
||||
|
||||
// set if powers should be added to component (default is true)
|
||||
$global = ((int)GetHelper::var(
|
||||
'joomla_component', $config['component_id'], 'id',
|
||||
'add_powers'
|
||||
) == 1) ? true : false;
|
||||
$config['add_power'] = (isset($config['powers']) && (int)$config['powers'] == 0)
|
||||
? false : ((isset($config['powers']) && (int)$config['powers'] == 1) ? true : $global);
|
||||
// TODO set up stream correctly
|
||||
unset($config['powers']);
|
||||
}
|
||||
|
||||
return $config;
|
||||
}
|
||||
/**
|
||||
* 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';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,635 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 30th April, 2015
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||
* @copyright Copyright (C) 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\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\Extractor;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Customcode\External;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Placefix;
|
||||
|
||||
|
||||
/**
|
||||
* Compiler Custom Code
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class Customcode
|
||||
{
|
||||
/**
|
||||
* 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;
|
||||
|
||||
/**
|
||||
* Compiler Custom Code External
|
||||
*
|
||||
* @var External
|
||||
* @since 3.2.0
|
||||
**/
|
||||
protected External $external;
|
||||
|
||||
/**
|
||||
* Database object to query local DB
|
||||
*
|
||||
* @var \JDatabaseDriver
|
||||
* @since 3.2.0
|
||||
**/
|
||||
protected $db;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param Config|null $config The compiler config object.
|
||||
* @param Placeholder|null $placeholder The compiler placeholder object.
|
||||
* @param Extract|null $extractor The compiler language extractor object.
|
||||
* @param External|null $external The compiler external custom code object.
|
||||
* @param \JDatabaseDriver $db The Database Driver object.
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function __construct(?Config $config = null, ?Placeholder $placeholder = null,
|
||||
?Extractor $extractor = null, ?External $external = null, ?\JDatabaseDriver $db = null)
|
||||
{
|
||||
$this->config = $config ?: Compiler::_('Config');
|
||||
$this->placeholder = $placeholder ?: Compiler::_('Placeholder');
|
||||
$this->extractor = $extractor ?: Compiler::_('Language.Extractor');
|
||||
$this->external = $external ?: Compiler::_('Customcode.External');
|
||||
$this->db = $db ?: Factory::getDbo();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the **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 add(string $string, int $debug = 0): string
|
||||
{
|
||||
if (StringHelper::check($string))
|
||||
{
|
||||
$string = $this->extractor->engine(
|
||||
$this->set(
|
||||
$this->external->set($string, $debug), $debug
|
||||
)
|
||||
);
|
||||
}
|
||||
// if debug
|
||||
if ($debug)
|
||||
{
|
||||
jexit();
|
||||
}
|
||||
|
||||
return $string;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
* @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 = array();
|
||||
$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(
|
||||
$key, '+'
|
||||
) === false)
|
||||
{
|
||||
$getFuncName = trim($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(
|
||||
$key, '+'
|
||||
) !== false)
|
||||
{
|
||||
$array = explode('+', $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'] = array();
|
||||
}
|
||||
// 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 placholdres (this allow the use of [] + and , in the values)
|
||||
$this->data[$id]['args'][$key]
|
||||
= array_map(
|
||||
function ($_key) {
|
||||
return $this->placeholder->update(
|
||||
$_key,
|
||||
$this->keys
|
||||
);
|
||||
}, (array) explode(',', $array[1])
|
||||
);
|
||||
}
|
||||
elseif (StringHelper::check(
|
||||
$array[1]
|
||||
))
|
||||
{
|
||||
$this->data[$id]['args'][$key]
|
||||
= array();
|
||||
// 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->load($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 load(?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))
|
||||
{
|
||||
$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->order(
|
||||
$this->db->quoteName('a.from_line') . ' ASC'
|
||||
); // <--- insure we always add code from top of file
|
||||
// reset custom code
|
||||
$this->active = array();
|
||||
}
|
||||
$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($customCode['code']);
|
||||
// always insure that the external code is loaded
|
||||
$customCode['code'] = $this->external->set(
|
||||
$customCode['code']
|
||||
);
|
||||
// set the lang only if needed
|
||||
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(
|
||||
"__", $customCode['hashtarget']
|
||||
);
|
||||
// is this a replace code, set end has array
|
||||
if ($customCode['type'] == 1
|
||||
&& strpos(
|
||||
$customCode['hashendtarget'], '__'
|
||||
) !== false)
|
||||
{
|
||||
$customCode['hashendtarget'] = explode(
|
||||
"__", $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;
|
||||
}
|
||||
$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)
|
||||
{
|
||||
$code = array();
|
||||
// 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'], $this->placeholder->active
|
||||
) . $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($item['code'], Placefix::b() . 'view') !== false
|
||||
|| stripos($item['code'], Placefix::b() . 'sview') !== false
|
||||
|| stripos($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'], $this->placeholder->active
|
||||
) . $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;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,406 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 30th April, 2015
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||
* @copyright Copyright (C) 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;
|
||||
|
||||
|
||||
/**
|
||||
* Compiler External Custom Code
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class External
|
||||
{
|
||||
/**
|
||||
* 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
|
||||
*
|
||||
* @var \JDatabaseDriver
|
||||
* @since 3.2.0
|
||||
**/
|
||||
protected \JDatabaseDriver $db;
|
||||
|
||||
/**
|
||||
* User object
|
||||
*
|
||||
* @var User
|
||||
* @since 3.2.0
|
||||
**/
|
||||
protected User $user;
|
||||
|
||||
/**
|
||||
* Database object to query local DB
|
||||
*
|
||||
* @var CMSApplication
|
||||
* @since 3.2.0
|
||||
**/
|
||||
protected CMSApplication $app;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param Placeholder|null $placeholder The compiler placeholder object.
|
||||
* @param \JDatabaseDriver|null $db The Database Driver object.
|
||||
* @param User|null $user The User object.
|
||||
* @param CMSApplication|null $app The CMS Application object.
|
||||
*
|
||||
* @throws \Exception
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function __construct(?Placeholder $placeholder = null,
|
||||
?\JDatabaseDriver $db = null, ?User $user = null, ?CMSApplication $app = null)
|
||||
{
|
||||
$this->placeholder = $placeholder ?: Compiler::_('Placeholder');
|
||||
$this->db = $db ?: Factory::getDbo();
|
||||
$this->user = $user ?: Factory::getUser();
|
||||
$this->app = $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 = array();
|
||||
$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($target, '>{')) !== false)
|
||||
{
|
||||
// the length
|
||||
$target_len = strlen($target);
|
||||
// where to cut
|
||||
$cutting = $target_len - $pos;
|
||||
// get the sequence
|
||||
$sequence = substr($target, "-$cutting");
|
||||
// remove from the URL
|
||||
$target_url = str_replace($sequence, '', $target);
|
||||
// set the cut key for this target if not set
|
||||
$this->cutter[trim($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
|
||||
if (isset($this->code[$target_key]))
|
||||
{
|
||||
// update the placeholder with the external code string
|
||||
$bucket[$key] = $this->code[$target_key];
|
||||
}
|
||||
else
|
||||
{
|
||||
// remove the placeholder
|
||||
$bucket[$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 '';
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,256 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 30th April, 2015
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||
* @copyright Copyright (C) 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;
|
||||
|
||||
|
||||
/**
|
||||
* Compiler Gui Custom Code
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class Gui
|
||||
{
|
||||
/**
|
||||
* Compiler Config
|
||||
*
|
||||
* @var Config
|
||||
* @since 3.2.0
|
||||
**/
|
||||
protected Config $config;
|
||||
|
||||
/**
|
||||
* Compiler Placeholder Reverse
|
||||
*
|
||||
* @var Reverse
|
||||
* @since 3.2.0
|
||||
**/
|
||||
protected Reverse $reverse;
|
||||
|
||||
/**
|
||||
* Database object to query local DB
|
||||
*
|
||||
* @var \JDatabaseDriver
|
||||
* @since 3.2.0
|
||||
**/
|
||||
protected \JDatabaseDriver $db;
|
||||
|
||||
/**
|
||||
* Database object to query local DB
|
||||
*
|
||||
* @var CMSApplication
|
||||
* @since 3.2.0
|
||||
**/
|
||||
protected CMSApplication $app;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param Config|null $config The compiler config object.
|
||||
* @param Reverse|null $reverse The compiler placeholder reverse object.
|
||||
* @param \JDatabaseDriver|null $db The Database Driver object.
|
||||
* @param CMSApplication|null $app The CMS Application object.
|
||||
*
|
||||
* @throws \Exception
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function __construct(?Config $config = null, ?Reverse $reverse = null,
|
||||
?\JDatabaseDriver $db = null, ?CMSApplication $app = null)
|
||||
{
|
||||
$this->config = $config ?: Compiler::_('Config');
|
||||
$this->reverse = $reverse ?: Compiler::_('Placeholder.Reverse');
|
||||
$this->db = $db ?: Factory::getDbo();
|
||||
$this->app = $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($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_conent = FileHelper::getContent($file);
|
||||
|
||||
$guiCode = array();
|
||||
// we add a new search for the GUI CODE Blocks
|
||||
$guiCode[] = GetHelper::allBetween(
|
||||
$file_conent, '/***[JCB' . 'GUI<>', '/***[/JCBGUI' . '$$$$]***/'
|
||||
);
|
||||
$guiCode[] = GetHelper::allBetween(
|
||||
$file_conent, '<!--[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, '', $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
|
||||
);
|
||||
// update the GUI/Tables/Database
|
||||
$object = new \stdClass();
|
||||
$object->id = $id;
|
||||
$object->{$field} = base64_encode(
|
||||
$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
|
||||
if (strpos($code, '$$$$') !== false)
|
||||
{
|
||||
// we do not add GUI wrapper placeholder to code
|
||||
// that already has any customcode placeholders
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -9,41 +9,29 @@
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace VDM\Joomla\Componentbuilder\Extension;
|
||||
namespace VDM\Joomla\Componentbuilder\Compiler\Extension\JoomlaThree;
|
||||
|
||||
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\InstallInterface;
|
||||
use VDM\Joomla\Utilities\ArrayHelper;
|
||||
use VDM\Joomla\Utilities\StringHelper;
|
||||
use VDM\Joomla\Componentbuilder\Line;
|
||||
use VDM\Joomla\Componentbuilder\Tab;
|
||||
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.1.5
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class InstallScript
|
||||
class InstallScript implements GetScriptInterface
|
||||
{
|
||||
/**
|
||||
* The Line numbering Methods
|
||||
*
|
||||
* @since 3.1.5
|
||||
*/
|
||||
use Line;
|
||||
|
||||
/**
|
||||
* The Tab Adding Method
|
||||
*
|
||||
* @since 3.1.5
|
||||
*/
|
||||
use Tab;
|
||||
|
||||
/**
|
||||
* The extension
|
||||
*
|
||||
* @var object
|
||||
* @since 3.1.5
|
||||
* @var InstallInterface|Object
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected object $extension;
|
||||
|
||||
@ -51,7 +39,7 @@ class InstallScript
|
||||
* The methods
|
||||
*
|
||||
* @var array
|
||||
* @since 3.1.5
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected array $methods = ['php_script', 'php_preflight', 'php_postflight', 'php_method'];
|
||||
|
||||
@ -59,7 +47,7 @@ class InstallScript
|
||||
* The types
|
||||
*
|
||||
* @var array
|
||||
* @since 3.1.5
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected array $types = ['construct', 'install', 'update', 'uninstall', 'discover_install'];
|
||||
|
||||
@ -67,7 +55,7 @@ class InstallScript
|
||||
* The construct bucket
|
||||
*
|
||||
* @var array
|
||||
* @since 3.1.5
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected array $construct = [];
|
||||
|
||||
@ -75,7 +63,7 @@ class InstallScript
|
||||
* The install bucket
|
||||
*
|
||||
* @var array
|
||||
* @since 3.1.5
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected array $install = [];
|
||||
|
||||
@ -83,7 +71,7 @@ class InstallScript
|
||||
* The update bucket
|
||||
*
|
||||
* @var array
|
||||
* @since 3.1.5
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected array $update = [];
|
||||
|
||||
@ -91,7 +79,7 @@ class InstallScript
|
||||
* The uninstall bucket
|
||||
*
|
||||
* @var array
|
||||
* @since 3.1.5
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected array $uninstall = [];
|
||||
|
||||
@ -99,7 +87,7 @@ class InstallScript
|
||||
* The preflight switch
|
||||
*
|
||||
* @var bool
|
||||
* @since 3.1.5
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected bool $preflightActive = false;
|
||||
|
||||
@ -107,7 +95,7 @@ class InstallScript
|
||||
* The preflight bucket
|
||||
*
|
||||
* @var array
|
||||
* @since 3.1.5
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected array $preflightBucket = ['install' => [], 'uninstall' => [], 'discover_install' => [], 'update' => []];
|
||||
|
||||
@ -115,7 +103,7 @@ class InstallScript
|
||||
* The postflight switch
|
||||
*
|
||||
* @var bool
|
||||
* @since 3.1.5
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected bool $postflightActive = false;
|
||||
|
||||
@ -123,15 +111,19 @@ class InstallScript
|
||||
* The postflight bucket
|
||||
*
|
||||
* @var array
|
||||
* @since 3.1.5
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected array $postflightBucket = ['install' => [], 'uninstall' => [], 'discover_install' => [], 'update' => []];
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* @since 3.1.5
|
||||
* get install script
|
||||
*
|
||||
* @param Object $extension The extension object
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function __construct(object $extension)
|
||||
public function get(object $extension): string
|
||||
{
|
||||
// loop over methods and types
|
||||
foreach ($this->methods as $method)
|
||||
@ -163,16 +155,7 @@ class InstallScript
|
||||
}
|
||||
|
||||
$this->extension = $extension;
|
||||
}
|
||||
|
||||
/**
|
||||
* get install script
|
||||
*
|
||||
* @return string
|
||||
* @since 3.1.5
|
||||
*/
|
||||
public function get(): string
|
||||
{
|
||||
// return the class
|
||||
return $this->build();
|
||||
}
|
||||
@ -181,7 +164,7 @@ class InstallScript
|
||||
* build the install class
|
||||
*
|
||||
* @return string
|
||||
* @since 3.1.5
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected function build(): string
|
||||
{
|
||||
@ -216,12 +199,13 @@ class InstallScript
|
||||
* get install script head
|
||||
*
|
||||
* @return string
|
||||
* @since 3.1.5
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected function head(): string
|
||||
{
|
||||
// get the extension
|
||||
$extension = $this->extension;
|
||||
|
||||
// start build
|
||||
$script = PHP_EOL . '/**';
|
||||
$script .= PHP_EOL . ' * ' . $extension->official_name
|
||||
@ -239,7 +223,7 @@ class InstallScript
|
||||
* get constructor
|
||||
*
|
||||
* @return string
|
||||
* @since 3.1.5
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected function construct(): string
|
||||
{
|
||||
@ -250,18 +234,18 @@ class InstallScript
|
||||
}
|
||||
|
||||
// the __construct script
|
||||
$script = PHP_EOL . PHP_EOL . $this->_t(1) . '/**';
|
||||
$script .= PHP_EOL . $this->_t(1) . ' * Constructor';
|
||||
$script .= PHP_EOL . $this->_t(1) . ' *';
|
||||
$script .= PHP_EOL . $this->_t(1)
|
||||
$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 . $this->_t(1) . ' */';
|
||||
$script .= PHP_EOL . $this->_t(1)
|
||||
$script .= PHP_EOL . Indent::_(1) . ' */';
|
||||
$script .= PHP_EOL . Indent::_(1)
|
||||
. 'public function __construct($adapter)';
|
||||
$script .= PHP_EOL . $this->_t(1) . '{';
|
||||
$script .= PHP_EOL . Indent::_(1) . '{';
|
||||
$script .= PHP_EOL . implode(PHP_EOL . PHP_EOL, $this->construct);
|
||||
// close the function
|
||||
$script .= PHP_EOL . $this->_t(1) . '}';
|
||||
$script .= PHP_EOL . Indent::_(1) . '}';
|
||||
|
||||
return $script;
|
||||
}
|
||||
@ -272,7 +256,7 @@ class InstallScript
|
||||
* @param string $name the method being called
|
||||
*
|
||||
* @return string
|
||||
* @since 3.1.5
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected function main(string $name): string
|
||||
{
|
||||
@ -282,26 +266,26 @@ class InstallScript
|
||||
return '';
|
||||
}
|
||||
// load the install method
|
||||
$script = PHP_EOL . PHP_EOL . $this->_t(1) . '/**';
|
||||
$script .= PHP_EOL . $this->_t(1) . " * Called on $name";
|
||||
$script .= PHP_EOL . $this->_t(1) . ' *';
|
||||
$script .= PHP_EOL . $this->_t(1)
|
||||
$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 . $this->_t(1) . ' *';
|
||||
$script .= PHP_EOL . $this->_t(1)
|
||||
$script .= PHP_EOL . Indent::_(1) . ' *';
|
||||
$script .= PHP_EOL . Indent::_(1)
|
||||
. ' * @return boolean True on success';
|
||||
$script .= PHP_EOL . $this->_t(1) . ' */';
|
||||
$script .= PHP_EOL . $this->_t(1) . 'public function '
|
||||
$script .= PHP_EOL . Indent::_(1) . ' */';
|
||||
$script .= PHP_EOL . Indent::_(1) . 'public function '
|
||||
. $name . '($adapter)';
|
||||
$script .= PHP_EOL . $this->_t(1) . '{';
|
||||
$script .= PHP_EOL . Indent::_(1) . '{';
|
||||
$script .= PHP_EOL . implode(PHP_EOL . PHP_EOL, $this->{$name});
|
||||
// return true
|
||||
if ('uninstall' !== $name)
|
||||
{
|
||||
$script .= PHP_EOL . $this->_t(2) . 'return true;';
|
||||
$script .= PHP_EOL . Indent::_(2) . 'return true;';
|
||||
}
|
||||
// close the function
|
||||
$script .= PHP_EOL . $this->_t(1) . '}';
|
||||
$script .= PHP_EOL . Indent::_(1) . '}';
|
||||
|
||||
return $script;
|
||||
}
|
||||
@ -312,7 +296,7 @@ class InstallScript
|
||||
* @param string $name the method being called
|
||||
*
|
||||
* @return string
|
||||
* @since 3.1.5
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected function flight(string $name): string
|
||||
{
|
||||
@ -323,42 +307,40 @@ class InstallScript
|
||||
}
|
||||
|
||||
// the pre/post function types
|
||||
$script = PHP_EOL . PHP_EOL . $this->_t(1) . '/**';
|
||||
$script .= PHP_EOL . $this->_t(1)
|
||||
$script = PHP_EOL . PHP_EOL . Indent::_(1) . '/**';
|
||||
$script .= PHP_EOL . Indent::_(1)
|
||||
. ' * Called before any type of action';
|
||||
$script .= PHP_EOL . $this->_t(1) . ' *';
|
||||
$script .= PHP_EOL . $this->_t(1)
|
||||
$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 . $this->_t(1)
|
||||
$script .= PHP_EOL . Indent::_(1)
|
||||
. ' * @param Joomla\CMS\Installer\InstallerAdapter $adapter The object responsible for running this script';
|
||||
$script .= PHP_EOL . $this->_t(1) . ' *';
|
||||
$script .= PHP_EOL . $this->_t(1)
|
||||
$script .= PHP_EOL . Indent::_(1) . ' *';
|
||||
$script .= PHP_EOL . Indent::_(1)
|
||||
. ' * @return boolean True on success';
|
||||
$script .= PHP_EOL . $this->_t(1) . ' */';
|
||||
$script .= PHP_EOL . $this->_t(1) . 'public function '
|
||||
$script .= PHP_EOL . Indent::_(1) . ' */';
|
||||
$script .= PHP_EOL . Indent::_(1) . 'public function '
|
||||
. $name . '($route, $adapter)';
|
||||
$script .= PHP_EOL . $this->_t(1) . '{';
|
||||
$script .= PHP_EOL . $this->_t(2) . '//' . $this->setLine(
|
||||
__LINE__
|
||||
) . ' get application';
|
||||
$script .= PHP_EOL . $this->_t(2)
|
||||
$script .= PHP_EOL . Indent::_(1) . '{';
|
||||
$script .= PHP_EOL . Indent::_(2) . '//' . Line::_(__Line__, __Class__)
|
||||
. ' get application';
|
||||
$script .= PHP_EOL . Indent::_(2)
|
||||
. '$app = JFactory::getApplication();' . PHP_EOL;
|
||||
|
||||
// add the default version check (TODO) must make this dynamic
|
||||
if ('preflight' === $name)
|
||||
{
|
||||
$script .= PHP_EOL . $this->_t(2) . '//' . $this->setLine(
|
||||
__LINE__
|
||||
) . ' the default for both install and update';
|
||||
$script .= PHP_EOL . $this->_t(2)
|
||||
$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 . $this->_t(2)
|
||||
$script .= PHP_EOL . Indent::_(2)
|
||||
. "if (!\$jversion->isCompatible('3.8.0'))";
|
||||
$script .= PHP_EOL . $this->_t(2) . '{';
|
||||
$script .= PHP_EOL . $this->_t(3)
|
||||
$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 . $this->_t(3) . 'return false;';
|
||||
$script .= PHP_EOL . $this->_t(2) . '}' . PHP_EOL;
|
||||
$script .= PHP_EOL . Indent::_(3) . 'return false;';
|
||||
$script .= PHP_EOL . Indent::_(2) . '}' . PHP_EOL;
|
||||
}
|
||||
|
||||
// now add the scripts
|
||||
@ -367,22 +349,23 @@ class InstallScript
|
||||
if (ArrayHelper::check($_script))
|
||||
{
|
||||
// set the if and script
|
||||
$script .= PHP_EOL . $this->_t(2) . "if ('" . $route
|
||||
$script .= PHP_EOL . Indent::_(2) . "if ('" . $route
|
||||
. "' === \$route)";
|
||||
$script .= PHP_EOL . $this->_t(2) . '{';
|
||||
$script .= PHP_EOL . Indent::_(2) . '{';
|
||||
$script .= PHP_EOL . implode(
|
||||
PHP_EOL . PHP_EOL, $_script
|
||||
);
|
||||
$script .= PHP_EOL . $this->_t(2) . '}' . PHP_EOL;
|
||||
$script .= PHP_EOL . Indent::_(2) . '}' . PHP_EOL;
|
||||
}
|
||||
}
|
||||
|
||||
// return true
|
||||
$script .= PHP_EOL . $this->_t(2) . 'return true;';
|
||||
$script .= PHP_EOL . Indent::_(2) . 'return true;';
|
||||
// close the function
|
||||
$script .= PHP_EOL . $this->_t(1) . '}';
|
||||
$script .= PHP_EOL . Indent::_(1) . '}';
|
||||
|
||||
return $script;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
@ -0,0 +1,111 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 30th April, 2015
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||
* @copyright Copyright (C) 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;
|
||||
|
||||
|
||||
/**
|
||||
* Compiler Factory
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
abstract class Factory
|
||||
{
|
||||
/**
|
||||
* Global Compiler Container
|
||||
*
|
||||
* @var Container
|
||||
* @since 3.2.0
|
||||
**/
|
||||
protected static $container = null;
|
||||
|
||||
/**
|
||||
* Current Joomla Version Being Build
|
||||
*
|
||||
* @var int
|
||||
* @since 3.2.0
|
||||
**/
|
||||
protected static $JoomlaVersion;
|
||||
|
||||
/**
|
||||
* Get any class from the compiler container
|
||||
*
|
||||
* @param string $key The container class key
|
||||
*
|
||||
* @return Mixed
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public static function _($key)
|
||||
{
|
||||
return self::getContainer()->get($key);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a the global compiler container
|
||||
*
|
||||
* @return Container
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public static function getContainer(): Container
|
||||
{
|
||||
if (!self::$container)
|
||||
{
|
||||
self::$container = self::createContainer();
|
||||
}
|
||||
|
||||
return self::$container;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a container object
|
||||
*
|
||||
* @return Container
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected static function createContainer(): Container
|
||||
{
|
||||
$container = (new Container())
|
||||
->registerServiceProvider(new \VDM\Joomla\Componentbuilder\Compiler\Service\Config())
|
||||
->registerServiceProvider(new \VDM\Joomla\Componentbuilder\Compiler\Service\Event())
|
||||
->registerServiceProvider(new \VDM\Joomla\Componentbuilder\Compiler\Service\Language())
|
||||
->registerServiceProvider(new \VDM\Joomla\Componentbuilder\Compiler\Service\Placeholder())
|
||||
->registerServiceProvider(new \VDM\Joomla\Componentbuilder\Compiler\Service\Customcode())
|
||||
->registerServiceProvider(new \VDM\Joomla\Componentbuilder\Compiler\Service\Power())
|
||||
->registerServiceProvider(new \VDM\Joomla\Componentbuilder\Compiler\Service\Component())
|
||||
->registerServiceProvider(new \VDM\Joomla\Componentbuilder\Compiler\Service\Extension());
|
||||
|
||||
return $container;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,33 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 30th April, 2015
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||
* @copyright Copyright (C) 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 mix $data The values to pass to the event/plugin
|
||||
*
|
||||
* @return void
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function trigger(string $event, $data);
|
||||
}
|
||||
|
@ -9,35 +9,24 @@
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace VDM\Joomla\Componentbuilder;
|
||||
|
||||
|
||||
use VDM\Joomla\Componentbuilder\Factory\Compiler\Config;
|
||||
namespace VDM\Joomla\Componentbuilder\Compiler\Interfaces;
|
||||
|
||||
|
||||
/**
|
||||
* Add line comment
|
||||
* The functions a get script should have
|
||||
*
|
||||
* @since 3.1.5
|
||||
* @since 3.2.0
|
||||
*/
|
||||
trait Line
|
||||
interface GetScriptInterface
|
||||
{
|
||||
/**
|
||||
* Set the line number in comments
|
||||
* get code to use
|
||||
*
|
||||
* @param int $nr The line number
|
||||
* @param Object $code The code object
|
||||
*
|
||||
* @return string
|
||||
* @since 3.1.5
|
||||
* @since 3.2.0
|
||||
*/
|
||||
private function setLine(int $nr): string
|
||||
{
|
||||
if (Config::get('debug_line_nr', false))
|
||||
{
|
||||
return ' [' . get_called_class() . ' ' . $nr . ']';
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
public function get(object $extension): string;
|
||||
}
|
||||
|
@ -0,0 +1,44 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 30th April, 2015
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||
* @copyright Copyright (C) 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 properties an extension should have to be passed to the InstallScript class
|
||||
*/
|
||||
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;
|
||||
}
|
||||
|
@ -0,0 +1 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
@ -0,0 +1,98 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 30th April, 2015
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||
* @copyright Copyright (C) 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\Utilities\Component\Helper;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\EventInterface;
|
||||
|
||||
|
||||
/**
|
||||
* Compiler Events
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
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 and event
|
||||
*
|
||||
* @param string $event The event to trigger
|
||||
* @param mix $data The values to pass to the event/plugin
|
||||
*
|
||||
* @return void
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function trigger($event, $data)
|
||||
{
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
@ -0,0 +1,201 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 30th April, 2015
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||
* @copyright Copyright (C) 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;
|
||||
|
||||
|
||||
/**
|
||||
* Compiler Language Content
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class Language
|
||||
{
|
||||
/**
|
||||
* 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
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* We need to remove all text breaks from all language strings
|
||||
*
|
||||
* @param string $string The language string
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected function fix(string $string): string
|
||||
{
|
||||
if ($this->config->remove_line_breaks)
|
||||
{
|
||||
return trim(str_replace(array(PHP_EOL, "\r", "\n"), '', $string));
|
||||
}
|
||||
|
||||
return trim($string);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,254 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 30th April, 2015
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||
* @copyright Copyright (C) 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\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;
|
||||
|
||||
|
||||
/**
|
||||
* Compiler Language Extractor
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
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 = [];
|
||||
|
||||
/**
|
||||
* 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;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param Config|null $config The compiler config object.
|
||||
* @param Language|null $language The compiler Language object.
|
||||
* @param Placeholder|null $placeholder The compiler placeholder object.
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function __construct(?Config $config = null, ?Language $language = null, ?Placeholder $placeholder = null)
|
||||
{
|
||||
$this->config = $config ?: Compiler::_('Config');
|
||||
$this->language = $language ?: Compiler::_('Language');
|
||||
$this->placeholder = $placeholder ?: Compiler::_('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, function ($get) use ($content) {
|
||||
if (strpos($content, $get) !== false)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
);
|
||||
// check if we should continue
|
||||
if (ArrayHelper::check($lang_string_targets))
|
||||
{
|
||||
// insure string is not broken
|
||||
$content = $this->placeholder->update($content, $this->placeholder->active);
|
||||
// reset some buckets
|
||||
$lang_holders = array();
|
||||
$lang_check = array();
|
||||
$lang_only = array();
|
||||
$js_text = array();
|
||||
$sc_text = array();
|
||||
// first get the Joomla .JText._()
|
||||
if (in_array('Joomla' . '.JText._(', $lang_string_targets))
|
||||
{
|
||||
$js_text[] = GetHelper::allBetween(
|
||||
$content, "Joomla" . ".JText._('", "'"
|
||||
);
|
||||
$js_text[] = GetHelper::allBetween(
|
||||
$content, 'Joomla' . '.JText._("', '"'
|
||||
);
|
||||
// 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))
|
||||
{
|
||||
$sc_text[] = GetHelper::allBetween(
|
||||
$content, "JText:" . ":script('", "'"
|
||||
);
|
||||
$sc_text[] = GetHelper::allBetween(
|
||||
$content, 'JText:' . ':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 === '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;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
@ -0,0 +1,262 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 30th April, 2015
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||
* @copyright Copyright (C) 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\Utilities\GetHelper;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Factory as Compiler;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Config;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Placefix;
|
||||
|
||||
|
||||
/**
|
||||
* Compiler Placeholder
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class Placeholder
|
||||
{
|
||||
/**
|
||||
* 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 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->active[Placefix::_($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)
|
||||
{
|
||||
$key = Placefix::_($key);
|
||||
|
||||
$this->active = array_filter(
|
||||
$this->active,
|
||||
function(string $k) use($key){
|
||||
return 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))
|
||||
{
|
||||
// This is an error, (TODO) actualy we need to add a kind of log here to know that this happened
|
||||
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 ($placeholder as $key => $val)
|
||||
{
|
||||
if (strpos($data, $key) !== false)
|
||||
{
|
||||
$replace = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
// only replace if the data has these placeholder values
|
||||
if ($replace === true)
|
||||
{
|
||||
|
||||
return str_replace(
|
||||
array_keys($placeholder), array_values($placeholder), $data
|
||||
);
|
||||
}
|
||||
}
|
||||
elseif (3 == $action) // <-- remove placeholders not in data string
|
||||
{
|
||||
$replace = $placeholder;
|
||||
foreach ($replace as $key => $val)
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 on success
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function keys(int $type, ?int $id = null)
|
||||
{
|
||||
switch ($type)
|
||||
{
|
||||
case 3:
|
||||
return [ 'start' => "", 'end' => ""];
|
||||
break;
|
||||
case 11:
|
||||
//***[REPLACED$$$$]***//**1**/
|
||||
if ($this->config->get('add_placeholders', false) === true)
|
||||
{
|
||||
return [
|
||||
'start' => '/***[REPLACED$$$$]***//**' . $id . '**/',
|
||||
'end' => '/***[/REPLACED$$$$]***/'
|
||||
];
|
||||
}
|
||||
else
|
||||
{
|
||||
return [ 'start' => "", 'end' => ""];
|
||||
}
|
||||
break;
|
||||
case 12:
|
||||
//***[INSERTED$$$$]***//**1**/
|
||||
if ($this->config->get('add_placeholders', false) === true)
|
||||
{
|
||||
return [
|
||||
'start' => '/***[INSERTED$$$$]***//**' . $id . '**/',
|
||||
'end' => '/***[/INSERTED$$$$]***/'
|
||||
];
|
||||
}
|
||||
else
|
||||
{
|
||||
return [ 'start' => "", 'end' => ""];
|
||||
}
|
||||
break;
|
||||
case 21:
|
||||
//<!--[REPLACED$$$$]--><!--1-->
|
||||
if ($this->config->get('add_placeholders', false) === true)
|
||||
{
|
||||
return [
|
||||
'start' => '<!--[REPLACED$$$$]--><!--' . $id . '-->',
|
||||
'end' => '<!--[/REPLACED$$$$]-->'
|
||||
];
|
||||
}
|
||||
else
|
||||
{
|
||||
return [ 'start' => "", 'end' => ""];
|
||||
}
|
||||
break;
|
||||
case 22:
|
||||
//<!--[INSERTED$$$$]--><!--1-->
|
||||
if ($this->config->get('add_placeholders', false) === true)
|
||||
{
|
||||
return [
|
||||
'start' => '<!--[INSERTED$$$$]--><!--' . $id . '-->',
|
||||
'end' => '<!--[/INSERTED$$$$]-->'
|
||||
];
|
||||
}
|
||||
else
|
||||
{
|
||||
return [ 'start' => "", 'end' => ""];
|
||||
}
|
||||
break;
|
||||
case 33:
|
||||
return ['start' => Placefix::h(), 'end' => Placefix::h()];
|
||||
break;
|
||||
case 66:
|
||||
return ['start' => Placefix::b(), 'end' => Placefix::d()];
|
||||
break;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,243 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 30th April, 2015
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||
* @copyright Copyright (C) 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;
|
||||
|
||||
|
||||
/**
|
||||
* 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;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param Config|null $config The compiler config object.
|
||||
* @param Placeholder|null $placeholder The compiler placeholder object.
|
||||
* @param Language|null $language The compiler language object.
|
||||
* @param Extract|null $extractor The compiler language extractor object.
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function __construct(
|
||||
?Config $config = null, ?Placeholder $placeholder = null,
|
||||
?Language $language = null, ?Extractor $extractor = null)
|
||||
{
|
||||
$this->config = $config ?: Compiler::_('Config');
|
||||
$this->placeholder = $placeholder ?: Compiler::_('Placeholder');
|
||||
$this->language = $language ?: Compiler::_('Language');
|
||||
$this->extractor = $extractor ?: Compiler::_('Language.Extractor');
|
||||
}
|
||||
|
||||
/**
|
||||
* 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|null $id The custom code id
|
||||
* @param string $field The field name
|
||||
* @param string $table The table name
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function engine(string $string, array &$placeholders,
|
||||
string $target, ?int $id = null, $field = 'code', $table = 'custom_code'): string
|
||||
{
|
||||
// get local code if set
|
||||
if ($id > 0 && $code = base64_decode(
|
||||
GetHelper::var($table, $id, 'id', $field)
|
||||
))
|
||||
{
|
||||
$string = $this->setReverse(
|
||||
$string, $code, $target
|
||||
);
|
||||
}
|
||||
|
||||
return $this->placeholder->update($string, $placeholders, 2);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 setReverse(string $updateString, string $string, string $target): string
|
||||
{
|
||||
// get targets to search for
|
||||
$lang_string_targets = array_filter(
|
||||
$this->config->lang_string_targets, function ($get) use ($string) {
|
||||
if (strpos($string, $get) !== false)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
);
|
||||
// check if we should continue
|
||||
if (ArrayHelper::check($lang_string_targets))
|
||||
{
|
||||
// start lang holder
|
||||
$lang_holders = array();
|
||||
// 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->replace(
|
||||
$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;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
@ -0,0 +1,517 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 30th April, 2015
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||
* @copyright Copyright (C) 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\Factory as Compiler;
|
||||
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;
|
||||
|
||||
|
||||
/**
|
||||
* Compiler Power
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class Power
|
||||
{
|
||||
/**
|
||||
* All loaded powers
|
||||
*
|
||||
* @var array
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public array $active = [];
|
||||
|
||||
/**
|
||||
* The state of all loaded powers
|
||||
*
|
||||
* @var array
|
||||
* @since 3.2.0
|
||||
**/
|
||||
protected array $state = [];
|
||||
|
||||
/**
|
||||
* 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 Customcode in Gui
|
||||
*
|
||||
* @var Gui
|
||||
* @since 3.2.0
|
||||
**/
|
||||
protected Gui $gui;
|
||||
|
||||
/**
|
||||
* Database object to query local DB
|
||||
*
|
||||
* @var \JDatabaseDriver
|
||||
* @since 3.2.0
|
||||
**/
|
||||
protected \JDatabaseDriver $db;
|
||||
|
||||
/**
|
||||
* Database object to query local DB
|
||||
*
|
||||
* @var CMSApplication
|
||||
* @since 3.2.0
|
||||
**/
|
||||
protected CMSApplication $app;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param Config|null $config The compiler config object.
|
||||
* @param Placeholder|null $placeholder The compiler placeholder object.
|
||||
* @param Customcode|null $customcode The compiler customcode object.
|
||||
* @param Gui|null $gui The compiler customcode gui object.
|
||||
* @param \JDatabaseDriver|null $db The Database Driver object.
|
||||
* @param CMSApplication|null $app The CMS Application object.
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function __construct(?Config $config = null, ?Placeholder $placeholder = null,
|
||||
?Customcode $customcode = null, ?Gui $gui = null,
|
||||
?\JDatabaseDriver $db = null, ?CMSApplication $app = null)
|
||||
{
|
||||
$this->config = $config ?: Compiler::_('Config');
|
||||
$this->placeholder = $placeholder ?: Compiler::_('Placeholder');
|
||||
$this->customcode = $customcode ?: Compiler::_('Customcode');
|
||||
$this->gui = $gui ?: Compiler::_('Customcode.Gui');
|
||||
$this->db = $db ?: Factory::getDbo();
|
||||
$this->app = $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 mixed
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function get(string $guid, int $build = 0)
|
||||
{
|
||||
if (($this->config->get('add_power', true) || $build == 1) && $this->set($guid))
|
||||
{
|
||||
return $this->active[$guid];
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a power
|
||||
*
|
||||
* @param string $guid The global unique id of the power
|
||||
*
|
||||
* @return bool
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected function set(string $guid): bool
|
||||
{
|
||||
// check if we have been here before
|
||||
if (isset($this->state[$guid]))
|
||||
{
|
||||
return $this->state[$guid];
|
||||
}
|
||||
elseif (GuidHelper::valid($guid))
|
||||
{
|
||||
// Create a new query object.
|
||||
$query = $this->db->getQuery(true);
|
||||
|
||||
$query->select('a.*');
|
||||
// from these tables
|
||||
$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())
|
||||
{
|
||||
// make sure that in recursion we
|
||||
// don't try to load this power again
|
||||
$this->state[$guid] = true;
|
||||
// get the power data
|
||||
$this->active[$guid] = $this->db->loadObject();
|
||||
// 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 usr if needed
|
||||
$fix_url
|
||||
= '"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;
|
||||
// now set the name
|
||||
$this->active[$guid]->name = $this->placeholder->update(
|
||||
$this->customcode->add($this->active[$guid]->name),
|
||||
$this->placeholder->active
|
||||
);
|
||||
// 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 namespace
|
||||
$this->active[$guid]->namespace = $this->placeholder->update(
|
||||
$this->active[$guid]->namespace, $this->placeholder->active
|
||||
);
|
||||
// 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($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,
|
||||
$fix_url),
|
||||
'Error'
|
||||
);
|
||||
$this->state[$guid] = false;
|
||||
unset($this->active[$guid]);
|
||||
// reset back to starting value
|
||||
$this->config->lang_target = $tmp_lang_target;
|
||||
// we break out here
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
// 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 = NamespaceHelper::safe(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($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,
|
||||
$fix_url),
|
||||
'Error'
|
||||
);
|
||||
$this->state[$guid] = false;
|
||||
unset($this->active[$guid]);
|
||||
// reset back to starting value
|
||||
$this->config->lang_target = $tmp_lang_target;
|
||||
// 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 = 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($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"',
|
||||
$fix_url),
|
||||
'Error'
|
||||
);
|
||||
$this->state[$guid] = false;
|
||||
unset($this->active[$guid]);
|
||||
// reset back to starting value
|
||||
$this->config->lang_target = $tmp_lang_target;
|
||||
// we break out here
|
||||
return false;
|
||||
}
|
||||
// make sure the arrays are namespace safe
|
||||
$path_array = array_map(function ($val) {
|
||||
return NamespaceHelper::safe($val);
|
||||
}, $path_array);
|
||||
$namespace_array = array_map(function ($val) {
|
||||
return NamespaceHelper::safe($val);
|
||||
}, $namespace_array);
|
||||
// set the actual class namespace
|
||||
$this->active[$guid]->_namespace = implode('\\', $namespace_array);
|
||||
// prefix values
|
||||
$this->active[$guid]->_namespace_prefix = $path_array;
|
||||
// get the parent folder (the first value in array)
|
||||
$prefix_folder = implode('.', $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(function ($val) {
|
||||
return NamespaceHelper::safe($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;
|
||||
}
|
||||
// load use ids
|
||||
$use = array();
|
||||
$as = array();
|
||||
// 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($this->active[$guid]->use_selection, true) : null;
|
||||
if ($this->active[$guid]->use_selection)
|
||||
{
|
||||
$use = array_values(array_map(function ($u) use(&$as) {
|
||||
// track the AS options
|
||||
if (empty($u['as']))
|
||||
{
|
||||
$as[$u['use']] = 'default';
|
||||
}
|
||||
else
|
||||
{
|
||||
$as[$u['use']] = (string) $u['as'];
|
||||
}
|
||||
// return the guid
|
||||
return $u['use'];
|
||||
}, $this->active[$guid]->use_selection));
|
||||
}
|
||||
// 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($this->active[$guid]->load_selection, true) : null;
|
||||
if ($this->active[$guid]->load_selection)
|
||||
{
|
||||
// load use ids
|
||||
array_map(function ($l) {
|
||||
// just load it directly and be done with it
|
||||
return $this->set($l['load']);
|
||||
}, $this->active[$guid]->load_selection);
|
||||
}
|
||||
// see if we have implements
|
||||
$this->active[$guid]->implement_names = array();
|
||||
// does this implement
|
||||
$this->active[$guid]->implements = (isset($this->active[$guid]->implements)
|
||||
&& JsonHelper::check(
|
||||
$this->active[$guid]->implements
|
||||
)) ? json_decode($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))
|
||||
{
|
||||
$this->active[$guid]->implement_names[] = $this->placeholder->update(
|
||||
$this->customcode->add($this->active[$guid]->implements_custom),
|
||||
$this->placeholder->active
|
||||
);
|
||||
// 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// does this extend something
|
||||
$this->active[$guid]->extends_name = null;
|
||||
// we first check for custom extending options
|
||||
if ($this->active[$guid]->extends == -1
|
||||
&& StringHelper::check($this->active[$guid]->extends_custom))
|
||||
{
|
||||
$this->active[$guid]->extends_name = $this->placeholder->update(
|
||||
$this->customcode->add($this->active[$guid]->extends_custom),
|
||||
$this->placeholder->active
|
||||
);
|
||||
// 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;
|
||||
}
|
||||
}
|
||||
// set GUI mapper
|
||||
$guiMapper = array('table' => 'power', 'id' => (int) $this->active[$guid]->id, 'type' => 'php');
|
||||
// add the header script
|
||||
if ($this->active[$guid]->add_head == 1)
|
||||
{
|
||||
// set GUI mapper field
|
||||
$guiMapper['field'] = 'head';
|
||||
// base64 Decode code
|
||||
$this->active[$guid]->head = $this->gui->set(
|
||||
$this->placeholder->update(
|
||||
$this->customcode->add(
|
||||
base64_decode(
|
||||
$this->active[$guid]->head
|
||||
)
|
||||
), $this->placeholder->active
|
||||
),
|
||||
$guiMapper
|
||||
) . PHP_EOL;
|
||||
}
|
||||
// now add all the extra use statements
|
||||
if (ArrayHelper::check($use))
|
||||
{
|
||||
foreach (array_unique($use) as $u)
|
||||
{
|
||||
if ($this->set($u))
|
||||
{
|
||||
$add_use = $this->get($u, 1)->namespace;
|
||||
// check if it is already added manually, you know how some people are
|
||||
if (strpos($this->active[$guid]->head, $add_use) === false)
|
||||
{
|
||||
// check if it has an AS option
|
||||
if (isset($as[$u]) && StringHelper::check($as[$u]) && $as[$u] !== 'default')
|
||||
{
|
||||
$this->active[$guid]->head .= 'use ' . $add_use . ' as ' . $as[$u] . ';' . PHP_EOL;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->active[$guid]->head .= 'use ' . $add_use . ';' . PHP_EOL;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// now set the description
|
||||
$this->active[$guid]->description = (StringHelper::check($this->active[$guid]->description)) ? $this->placeholder->update(
|
||||
$this->customcode->add($this->active[$guid]->description),
|
||||
$this->placeholder->active
|
||||
) : '';
|
||||
// add the main code if set
|
||||
if (StringHelper::check($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->add(
|
||||
base64_decode(
|
||||
$this->active[$guid]->main_class_code
|
||||
)
|
||||
), $this->placeholder->active
|
||||
),
|
||||
$guiMapper
|
||||
);
|
||||
}
|
||||
// reset back to starting value
|
||||
$this->config->lang_target = $tmp_lang_target;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
// we failed to get the power,
|
||||
// so we raise an error message
|
||||
// only if guid is valid
|
||||
if (GuidHelper::valid($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;
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,56 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 30th April, 2015
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||
* @copyright Copyright (C) 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\Placeholder as ComponentPlaceholder;
|
||||
|
||||
|
||||
/**
|
||||
* Component Service Provider
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class Component 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(ComponentPlaceholder::class, 'Component.Placeholder')
|
||||
->share('Component.Placeholder', [$this, 'getComponentPlaceholder'], true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Component Placeholders
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return ComponentPlaceholder
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function getComponentPlaceholder(Container $container): ComponentPlaceholder
|
||||
{
|
||||
return new ComponentPlaceholder(
|
||||
$container->get('Config')
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,54 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 30th April, 2015
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||
* @copyright Copyright (C) 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 as CompilerConfig;
|
||||
|
||||
|
||||
/**
|
||||
* Compiler Config Service Provider
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class Config 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(CompilerConfig::class, 'Config')
|
||||
->share('Config', [$this, 'getConfig'], true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Compiler Configurations
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return CompilerConfig
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function getConfig(Container $container): CompilerConfig
|
||||
{
|
||||
return new CompilerConfig();
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,99 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 30th April, 2015
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||
* @copyright Copyright (C) 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\Customcode\External;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Customcode\Gui;
|
||||
|
||||
|
||||
/**
|
||||
* 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);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Compiler Customcode
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return CompilerCustomcode
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function getCustomcode(Container $container): CompilerCustomcode
|
||||
{
|
||||
return new CompilerCustomcode(
|
||||
$container->get('Config'),
|
||||
$container->get('Placeholder'),
|
||||
$container->get('Language.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')
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,55 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 30th April, 2015
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||
* @copyright Copyright (C) 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\EventInterface;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\JoomlaThree\Event as J3Event;
|
||||
|
||||
|
||||
/**
|
||||
* Event Service Provider
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class Event 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(J3Event::class, 'J3.Event')
|
||||
->share('J3.Event', [$this, 'getJ3Event'], true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Joomla 3 Event
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return EventInterface
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function getJ3Event(Container $container): EventInterface
|
||||
{
|
||||
return new J3Event();
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,55 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 30th April, 2015
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||
* @copyright Copyright (C) 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;
|
||||
|
||||
|
||||
/**
|
||||
* Extension Script Service Provider
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class Extension 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(J3InstallScript::class, 'J3.Extension.InstallScript')
|
||||
->share('J3.Extension.InstallScript', [$this, 'getJ3ExtensionInstallScript'], true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Joomla 3 Extension Install Script
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return GetScriptInterface
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function getJ3ExtensionInstallScript(Container $container): GetScriptInterface
|
||||
{
|
||||
return new J3InstallScript();
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,78 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 30th April, 2015
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||
* @copyright Copyright (C) 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\Extractor;
|
||||
|
||||
|
||||
/**
|
||||
* 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, 'getLanguage'], true);
|
||||
|
||||
$container->alias(Extractor::class, 'Language.Extractor')
|
||||
->share('Language.Extractor', [$this, 'getLanguageExtractor'], true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Compiler Language
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return CompilerLanguage
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function getLanguage(Container $container): CompilerLanguage
|
||||
{
|
||||
return new CompilerLanguage(
|
||||
$container->get('Config')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Compiler Language Extractor
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return Extractor
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function getLanguageExtractor(Container $container): Extractor
|
||||
{
|
||||
return new Extractor(
|
||||
$container->get('Config'),
|
||||
$container->get('Language'),
|
||||
$container->get('Placeholder')
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,78 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 30th April, 2015
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||
* @copyright Copyright (C) 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 Worker
|
||||
* @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')
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,59 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 30th April, 2015
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||
* @copyright Copyright (C) 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 CompilerPower;
|
||||
|
||||
|
||||
/**
|
||||
* 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(CompilerPower::class, 'Power')
|
||||
->share('Power', [$this, 'getPower'], true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Compiler Power
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return CompilerPower
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function getPower(Container $container): CompilerPower
|
||||
{
|
||||
return new CompilerPower(
|
||||
$container->get('Config'),
|
||||
$container->get('Placeholder'),
|
||||
$container->get('Customcode'),
|
||||
$container->get('Customcode.Gui')
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
@ -0,0 +1,90 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 30th April, 2015
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||
* @copyright Copyright (C) 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 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;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,79 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 30th April, 2015
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||
* @copyright Copyright (C) 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;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,106 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 30th April, 2015
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||
* @copyright Copyright (C) 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 $hhh = '#' . '#' . '#';
|
||||
|
||||
/**
|
||||
* The open prefix
|
||||
*
|
||||
* @var string
|
||||
* @since 3.2.0
|
||||
**/
|
||||
private static $bbb = '[' . '[' . '[';
|
||||
|
||||
/**
|
||||
* The close suffix
|
||||
*
|
||||
* @var string
|
||||
* @since 3.2.0
|
||||
**/
|
||||
private static $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;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
@ -1,257 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 30th April, 2015
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace VDM\Joomla\Componentbuilder\Factory\Compiler;
|
||||
|
||||
|
||||
use Joomla\CMS\Factory;
|
||||
use Joomla\Registry\Registry;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Config as CompilerConfig;
|
||||
use VDM\Joomla\Utilities\ArrayHelper;
|
||||
|
||||
|
||||
/**
|
||||
* Factory to load the compiler config
|
||||
*/
|
||||
abstract class Config
|
||||
{
|
||||
/**
|
||||
* Global Config object
|
||||
*
|
||||
* @var CompilerConfig
|
||||
* @since 3.1.6
|
||||
**/
|
||||
protected static $CompilerConfig = null;
|
||||
|
||||
/**
|
||||
* Get a value.
|
||||
*
|
||||
* @param string $path Registry path (e.g. version)
|
||||
* @param mixed $default Optional default value, returned if the internal value is null.
|
||||
*
|
||||
* @return mixed Value of entry or null
|
||||
*
|
||||
* @since 3.1.6
|
||||
*/
|
||||
public static function get(string $path, $default = null)
|
||||
{
|
||||
// check that if we already have config registry set
|
||||
if (!self::$CompilerConfig)
|
||||
{
|
||||
// create config registry
|
||||
self::$CompilerConfig = self::create();
|
||||
}
|
||||
|
||||
// return the value or default if none is found
|
||||
return self::$CompilerConfig->get($path, $default);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a registry path exists.
|
||||
*
|
||||
* @param string $path Registry path (e.g. guid.main.0.path)
|
||||
*
|
||||
* @return boolean
|
||||
*
|
||||
* @since 3.1.6
|
||||
*/
|
||||
public static function exists($path)
|
||||
{
|
||||
// check that if we already have config registry set
|
||||
if (!self::$CompilerConfig)
|
||||
{
|
||||
// create config registry
|
||||
self::$CompilerConfig = self::create();
|
||||
}
|
||||
|
||||
// check if exists
|
||||
return self::$CompilerConfig->exists($path);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to extract a sub-registry from path
|
||||
*
|
||||
* @param string $path Registry path (e.g. guid.main)
|
||||
*
|
||||
* @return Registry Registry object (empty if no data is present)
|
||||
*
|
||||
* @since 3.1.6
|
||||
*/
|
||||
public function extract($path)
|
||||
{
|
||||
if (!self::exists($path))
|
||||
{
|
||||
// create config registry
|
||||
return new Registry();
|
||||
}
|
||||
|
||||
return self::$CompilerConfig->extract($path);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets this object represented as an ArrayIterator.
|
||||
*
|
||||
* This allows the data properties to be accessed via a foreach statement.
|
||||
*
|
||||
* @return \ArrayIterator This object represented as an ArrayIterator.
|
||||
*
|
||||
* @see IteratorAggregate::getIterator()
|
||||
* @since 3.1.6
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public static function getIterator()
|
||||
{
|
||||
// check that if we already have config registry set
|
||||
if (!self::$CompilerConfig)
|
||||
{
|
||||
// create config registry
|
||||
self::$CompilerConfig = self::create();
|
||||
}
|
||||
|
||||
return self::$CompilerConfig->getIterator();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a registry value.
|
||||
*
|
||||
* @param string $path Registry Path (e.g. guid.main.0.url)
|
||||
* @param mixed $value Value of entry
|
||||
* @param string $separator The key separator
|
||||
*
|
||||
* @return mixed The value of the that has been set.
|
||||
*
|
||||
* @since 3.1.6
|
||||
*/
|
||||
public static function set($path, $value, $separator = null)
|
||||
{
|
||||
// check that if we already have config registry set
|
||||
if (!self::$CompilerConfig)
|
||||
{
|
||||
// create config registry
|
||||
self::$CompilerConfig = self::create();
|
||||
}
|
||||
|
||||
self::$CompilerConfig->set($path, $value, $separator);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a registry value
|
||||
*
|
||||
* @param string $path Registry Path (e.g. guid.main.0.url)
|
||||
*
|
||||
* @return mixed The value of the removed node or null if not set
|
||||
*
|
||||
* @since 3.1.6
|
||||
*/
|
||||
public static function remove($path)
|
||||
{
|
||||
// check that if we already have config registry set
|
||||
if (!self::$CompilerConfig)
|
||||
{
|
||||
// create config registry
|
||||
self::$CompilerConfig = self::create();
|
||||
}
|
||||
|
||||
// remove the actual value
|
||||
return self::$CompilerConfig->remove($path);
|
||||
}
|
||||
|
||||
/**
|
||||
* Transforms a namespace to an array
|
||||
*
|
||||
* @return array An associative array holding the namespace data
|
||||
*
|
||||
* @since 3.1.6
|
||||
*/
|
||||
public static function toArray()
|
||||
{
|
||||
// check that if we already have config registry set
|
||||
if (!self::$CompilerConfig)
|
||||
{
|
||||
// create config registry
|
||||
self::$CompilerConfig = self::create();
|
||||
}
|
||||
|
||||
return self::$CompilerConfig->toArray();
|
||||
}
|
||||
|
||||
/**
|
||||
* Transforms a namespace to an object
|
||||
*
|
||||
* @return object An an object holding the namespace data
|
||||
*
|
||||
* @since 3.1.6
|
||||
*/
|
||||
public static function toObject()
|
||||
{
|
||||
// check that if we already have config registry set
|
||||
if (!self::$CompilerConfig)
|
||||
{
|
||||
// create config registry
|
||||
self::$CompilerConfig = self::create();
|
||||
}
|
||||
|
||||
return self::$CompilerConfig->toObject();
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize a CompilerConfig object if id does not exist.
|
||||
*
|
||||
* Returns the global {@link CompilerConfig} object, only creating it if it doesn't already exist.
|
||||
*
|
||||
* @param array $config The data to bind to the new Config object.
|
||||
*
|
||||
*
|
||||
* @return CompilerConfig object
|
||||
*
|
||||
* @see Session
|
||||
* @since 3.1.6
|
||||
**/
|
||||
public static function init($config = null): CompilerConfig
|
||||
{
|
||||
if (!self::$CompilerConfig)
|
||||
{
|
||||
self::$CompilerConfig = self::create($config);
|
||||
}
|
||||
|
||||
return self::$CompilerConfig;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a CompilerConfig object
|
||||
*
|
||||
* @param array $config The data to bind to the new Config object.
|
||||
*
|
||||
* @return CompilerConfig object
|
||||
* @since 3.1.6
|
||||
* @throws \Exception
|
||||
**/
|
||||
protected static function create($config = null): CompilerConfig
|
||||
{
|
||||
// get the session
|
||||
$session = Factory::getSession();
|
||||
|
||||
// check if we have config
|
||||
if (ArrayHelper::check($config))
|
||||
{
|
||||
// save for later should we call this out of scope
|
||||
$session->set('Componentbuilder.Compiler.Config', $config);
|
||||
}
|
||||
// if not found try loading it from the session
|
||||
elseif (($config = $session->get('Componentbuilder.Compiler.Config', false)) === false)
|
||||
{
|
||||
throw new \Exception('Compiler configuration not found.');
|
||||
}
|
||||
|
||||
return new CompilerConfig($config);
|
||||
}
|
||||
}
|
||||
|
@ -1,58 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 30th April, 2015
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace VDM\Joomla\Componentbuilder;
|
||||
|
||||
|
||||
/**
|
||||
* Adds Tabs
|
||||
*
|
||||
* @since 3.1.5
|
||||
*/
|
||||
trait Tab
|
||||
{
|
||||
/**
|
||||
* Tab/spacer bucket (to speed-up the build)
|
||||
*
|
||||
* @var array
|
||||
* @since 3.1.5
|
||||
*/
|
||||
protected $tabSpacerBucket = array();
|
||||
|
||||
/**
|
||||
* Set tab/spacer
|
||||
*
|
||||
* @var string
|
||||
* @since 3.1.5
|
||||
*/
|
||||
protected $tabSpacer = "\t";
|
||||
|
||||
/**
|
||||
* Set the tab/space
|
||||
*
|
||||
* @param int $nr The number of tag/space
|
||||
*
|
||||
* @return string
|
||||
* @since 3.1.5
|
||||
*/
|
||||
public function _t(int $nr) : string
|
||||
{
|
||||
// check if we already have the string
|
||||
if (!isset($this->tabSpacerBucket[$nr]))
|
||||
{
|
||||
// get the string
|
||||
$this->tabSpacerBucket[$nr] = str_repeat($this->tabSpacer, (int) $nr);
|
||||
}
|
||||
// return stored string
|
||||
return $this->tabSpacerBucket[$nr];
|
||||
}
|
||||
}
|
||||
|
1
libraries/jcb_powers/VDM.Joomla/src/index.html
Normal file
1
libraries/jcb_powers/VDM.Joomla/src/index.html
Normal file
@ -0,0 +1 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
Reference in New Issue
Block a user