Converts compiler to move component get methods to the powers area.

This commit is contained in:
2023-01-15 10:42:19 +02:00
parent e8abe8e3cf
commit f44f385159
12 changed files with 1446 additions and 1346 deletions

View File

@ -32,7 +32,7 @@ abstract class BaseConfig extends JoomlaRegistry
* @var Input
* @since 3.2.0
*/
protected $input;
protected Input $input;
/**
* The Params
@ -66,12 +66,12 @@ abstract class BaseConfig extends JoomlaRegistry
/**
* setting any config value
*
* @param String $key The value's key/path name
* @param string $key The value's key/path name
* @param mixed $value Optional default value, returned if the internal value is null.
*
* @since 3.2.0
*/
public function __set($key, $value)
public function __set(string $key, $value)
{
$this->set($key, $value);
}
@ -79,12 +79,12 @@ abstract class BaseConfig extends JoomlaRegistry
/**
* getting any valid value
*
* @param String $key The value's key/path name
* @param string $key The value's key/path name
*
* @since 3.2.0
* @throws \InvalidArgumentException If $key is not a valid function name.
*/
public function __get($key)
public function __get(string $key)
{
// check if it has been set
if (($value = $this->get($key, '__N0T_S3T_Y3T_')) !== '__N0T_S3T_Y3T_')
@ -98,7 +98,7 @@ abstract class BaseConfig extends JoomlaRegistry
/**
* Get a config value.
*
* @param string $path Registry path (e.g. joomla.content.showauthor)
* @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
@ -117,7 +117,7 @@ abstract class BaseConfig extends JoomlaRegistry
}
elseif (method_exists($this, $method))
{
$value = $this->{$method}();
$value = $this->{$method}($default);
$this->set($path, $value);

View File

@ -12,6 +12,8 @@
namespace VDM\Joomla\Componentbuilder\Compiler;
use Joomla\Registry\Registry as JoomlaRegistry;
use Joomla\CMS\Factory as JoomlaFactory;
use VDM\Joomla\Utilities\GetHelper;
use VDM\Joomla\Utilities\StringHelper;
use VDM\Joomla\Componentbuilder\Abstraction\BaseConfig;
@ -20,10 +22,85 @@ use VDM\Joomla\Componentbuilder\Abstraction\BaseConfig;
/**
* Compiler Configurations
*
* All these functions are accessed via the direct name without the get:
* example: $this->component_code_name calls: $this->getComponentcodename()
*
* All values once called are cached, yet can be updated directly:
* example: $this->component_code_name = 'new_code_name'; // be warned!
*
* @since 3.2.0
*/
class Config extends BaseConfig
{
/**
* The Global Joomla Configuration
*
* @var JoomlaRegistry
* @since 3.2.0
*/
protected JoomlaRegistry $config;
/**
* Constructor
*
* @param Input|null $input Input
* @param Registry|null $params The component parameters
* @param Registry|null $config The Joomla configuration
*
* @throws \Exception
* @since 3.2.0
*/
public function __construct(?Input $input = null, ?JoomlaRegistry $params = null, ?JoomlaRegistry $config = null)
{
parent::__construct($input, $params);
$this->config = $config ?: JoomlaFactory::getConfig();
}
/**
* get add contributors switch
*
* @return bool Add contributors switch
* @since 3.2.0
*/
protected function getAddcontributors(): bool
{
return false; // default is false
}
/**
* get Add Ajax Switch
*
* @return bool Add Ajax Switch
* @since 3.2.0
*/
protected function getAddajax(): bool
{
return false; // default is false
}
/**
* get Add Site Ajax Switch
*
* @return bool Add Site Ajax Switch
* @since 3.2.0
*/
protected function getAddsiteajax(): bool
{
return false; // default is false
}
/**
* get add eximport
*
* @return bool add eximport switch
* @since 3.2.0
*/
protected function getAddeximport(): bool
{
return false; // default is false
}
/**
* get posted component id
*
@ -35,6 +112,17 @@ class Config extends BaseConfig
return $this->input->post->get('component_id', 0, 'INT');
}
/**
* get component version
*
* @return string Component version
* @since 3.2.0
*/
protected function getComponentversion(): string
{
return '1.0.0';
}
/**
* get components code name
*
@ -84,6 +172,20 @@ class Config extends BaseConfig
return $this->input->post->get('joomla_version', 3, 'INT');
}
/**
* get Joomla versions
*
* @return array Joomla versions
* @since 3.2.0
*/
protected function getJoomlaversions(): array
{
return [
3 => ['folder_key' => 3, 'xml_version' => 3.9], // only joomla 3
3.10 => ['folder_key' => 3, 'xml_version' => 4.0] // legacy joomla 4
];
}
/**
* get posted Joomla version name
*
@ -95,6 +197,17 @@ class Config extends BaseConfig
return StringHelper::safe($this->joomla_version);
}
/**
* set joomla fields
*
* @return bool set joomla fields
* @since 3.2.0
*/
protected function getSetjoomlafields(): bool
{
return false;
}
/**
* get indentation value
*
@ -138,15 +251,12 @@ class Config extends BaseConfig
{
// 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
)
);
return $add;
// get global value
if ($value > 1)
{
return (int) GetHelper::var('joomla_component', $this->component_id, 'id', 'debug_linenr');
}
return $value;
}
/**
@ -157,12 +267,11 @@ class Config extends BaseConfig
*/
protected function getMinify(): int
{
// get posted value
$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;
return ($minify != 2) ? $minify : $this->params->get('minify', 0);
}
/**
@ -173,16 +282,14 @@ class Config extends BaseConfig
*/
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 posted value
$value = $this->input->post->get('remove_line_breaks', 2, 'INT');
// get global
if ($value > 1)
{
return (bool) GetHelper::var('joomla_component', $this->component_id, 'id', 'remove_line_breaks');
}
return (bool) $value;
}
/**
@ -197,6 +304,30 @@ class Config extends BaseConfig
return \extension_loaded('Tidy');
}
/**
* add tidy warning
*
* @return bool Set tidy warning
* @since 3.2.0
*/
protected function getSettidywarning(): bool
{
// add warning once
return true;
}
/**
* get history tag switch
*
* @return bool get history tag switch
* @since 3.2.0
*/
protected function getSettaghistory(): bool
{
// add warning once
return true;
}
/**
* get language tag
*
@ -206,7 +337,7 @@ class Config extends BaseConfig
protected function getLangtag(): string
{
// get the global language
return $this->params->get('language', 'en-GB');
return $this->params->get('language', 'en-GB');
}
/**
@ -275,11 +406,36 @@ class Config extends BaseConfig
protected function getFieldbuildertype(): int
{
// get the field type builder
return $this->params->get(
return $this->params->get(
'compiler_field_builder_type', 2
);
}
/**
* get default fields
*
* @return array The default fields
* @since 3.2.0
*/
protected function getDefaultfields(): array
{
// get the field type builder
return ['created', 'created_by', 'modified', 'modified_by', 'published',
'ordering', 'access', 'version', 'hits', 'id'];
}
/**
* get temporary path
*
* @return string The temporary path
* @since 3.2.0
*/
protected function getTmppath(): string
{
// get the temporary path
return $this->config->get('tmp_path');
}
/**
* get compiler path
*
@ -289,7 +445,7 @@ class Config extends BaseConfig
protected function getCompilerpath(): string
{
// get the compiler path
return $this->params->get(
return $this->params->get(
'compiler_folder_path',
JPATH_COMPONENT_ADMINISTRATOR . '/compiler'
);
@ -304,7 +460,19 @@ class Config extends BaseConfig
protected function getJcbpowerspath(): string
{
// get jcb powers path
return $this->params->get('jcb_powers_path', 'libraries/jcb_powers');
return $this->params->get('jcb_powers_path', 'libraries/jcb_powers');
}
/**
* get bom path
*
* @return string The bom path
* @since 3.2.0
*/
protected function getBompath(): string
{
// get default bom path
return $this->compiler_path . '/default.txt';
}
/**
@ -321,12 +489,50 @@ class Config extends BaseConfig
);
// get component value
$add = (($add_assets_table_fix = (int) GetHelper::var(
return (($add_assets_table_fix = (int) GetHelper::var(
'joomla_component', $this->component_id, 'id',
'assets_table_fix'
)) == 3) ? $global : $add_assets_table_fix;
}
return $add;
/**
* get switch to add assets table name fix
*
* @return bool Switch number to add assets table name fix
* @since 3.2.0
*/
protected function getAddassetstablenamefix(): bool
{
// get global is false
return false;
}
/**
* get access worse case size
*
* @return int access worse case size
* @since 3.2.0
*/
protected function getAccessworsecase(): int
{
// we start at zero
return 0;
}
/**
* get mysql table keys
*
* @return array
* @since 3.2.0
*/
protected function getMysqltablekeys(): array
{
return [
'engine' => ['default' => 'MyISAM'],
'charset' => ['default' => 'utf8'],
'collate' => ['default' => 'utf8_general_ci'],
'row_format' => ['default' => '']
];
}
/**
@ -339,15 +545,12 @@ class Config extends BaseConfig
{
// get posted value
$value = $this->input->post->get('add_placeholders', 2, 'INT');
// get active value
$add = ($value == 0) ? false : (
($value == 1) ? true : (
((int) GetHelper::var('joomla_component', $this->component_id, 'id', 'add_placeholders' ) == 1) ? true : false
)
);
return $add;
// get global value
if ($value > 1)
{
return (bool) GetHelper::var('joomla_component', $this->component_id, 'id', 'add_placeholders');
}
return (bool) $value;
}
/**
@ -360,15 +563,12 @@ class Config extends BaseConfig
{
// get posted value
$value = $this->input->post->get('powers', 2, 'INT');
// get active value
$add = ($value == 0) ? false : (
($value == 1) ? true : (
((int) GetHelper::var('joomla_component', $this->component_id, 'id', 'add_powers' ) == 1) ? true : false
)
);
return $add;
// get global value
if ($value > 1)
{
return (bool) GetHelper::var('joomla_component', $this->component_id, 'id', 'add_powers');
}
return (bool) $value;
}
/**
@ -384,6 +584,17 @@ class Config extends BaseConfig
return 'admin';
}
/**
* get encryption types
*
* @return array encryption types
* @since 3.2.0
*/
protected function getCryptiontypes(): array
{
return ['basic', 'medium', 'whmcs', 'expert'];
}
/**
* get basic encryption switch
*
@ -438,6 +649,50 @@ class Config extends BaseConfig
{
return true;
}
/**
* The Uikit switch
*
* @return int Switch to control the adding uikit
* @since 3.2.0
*/
protected function getUikit(): int
{
return 0; // default its not added
}
/**
* The google chart switch
*
* @return bool Switch to control the adding googlechart
* @since 3.2.0
*/
protected function getGooglechart(): bool
{
return false; // default its not added
}
/**
* The footable switch
*
* @return bool Switch to control the adding footable
* @since 3.2.0
*/
protected function getFootable(): bool
{
return false; // default its not added
}
/**
* The footable version
*
* @return int Switch to control the adding footable
* @since 3.2.0
*/
protected function getFootableversion(): int
{
return 2; // default is version 2
}
}