Adds some PHP 8 ready changes to compiler classes. Adds Server and Crypt classes.

This commit is contained in:
Llewellyn van der Merwe 2023-01-01 04:11:34 +02:00
parent e614f2ec23
commit e771e7d243
Signed by: Llewellyn
GPG Key ID: A9201372263741E7
71 changed files with 2697 additions and 872 deletions

View File

@ -140,13 +140,13 @@ TODO
+ *Author*: [Llewellyn van der Merwe](mailto:joomla@vdm.io) + *Author*: [Llewellyn van der Merwe](mailto:joomla@vdm.io)
+ *Name*: [Component Builder](https://git.vdm.dev/joomla/Component-Builder) + *Name*: [Component Builder](https://git.vdm.dev/joomla/Component-Builder)
+ *First Build*: 30th April, 2015 + *First Build*: 30th April, 2015
+ *Last Build*: 29th December, 2023 + *Last Build*: 1st January, 2023
+ *Version*: 3.1.13 + *Version*: 3.1.13
+ *Copyright*: Copyright (C) 2015 Vast Development Method. All rights reserved. + *Copyright*: Copyright (C) 2015 Vast Development Method. All rights reserved.
+ *License*: GNU General Public License version 2 or later; see LICENSE.txt + *License*: GNU General Public License version 2 or later; see LICENSE.txt
+ *Line count*: **341727** + *Line count*: **342047**
+ *Field count*: **2009** + *Field count*: **2009**
+ *File count*: **2222** + *File count*: **2225**
+ *Folder count*: **391** + *Folder count*: **391**
> This **component** was build with a [Joomla](https://extensions.joomla.org/extension/component-builder/) [Automated Component Builder](https://www.joomlacomponentbuilder.com). > This **component** was build with a [Joomla](https://extensions.joomla.org/extension/component-builder/) [Automated Component Builder](https://www.joomlacomponentbuilder.com).

View File

@ -140,13 +140,13 @@ TODO
+ *Author*: [Llewellyn van der Merwe](mailto:joomla@vdm.io) + *Author*: [Llewellyn van der Merwe](mailto:joomla@vdm.io)
+ *Name*: [Component Builder](https://git.vdm.dev/joomla/Component-Builder) + *Name*: [Component Builder](https://git.vdm.dev/joomla/Component-Builder)
+ *First Build*: 30th April, 2015 + *First Build*: 30th April, 2015
+ *Last Build*: 29th December, 2023 + *Last Build*: 1st January, 2023
+ *Version*: 3.1.13 + *Version*: 3.1.13
+ *Copyright*: Copyright (C) 2015 Vast Development Method. All rights reserved. + *Copyright*: Copyright (C) 2015 Vast Development Method. All rights reserved.
+ *License*: GNU General Public License version 2 or later; see LICENSE.txt + *License*: GNU General Public License version 2 or later; see LICENSE.txt
+ *Line count*: **341727** + *Line count*: **342047**
+ *Field count*: **2009** + *Field count*: **2009**
+ *File count*: **2222** + *File count*: **2225**
+ *Folder count*: **391** + *Folder count*: **391**
> This **component** was build with a [Joomla](https://extensions.joomla.org/extension/component-builder/) [Automated Component Builder](https://www.joomlacomponentbuilder.com). > This **component** was build with a [Joomla](https://extensions.joomla.org/extension/component-builder/) [Automated Component Builder](https://www.joomlacomponentbuilder.com).

View File

@ -19,6 +19,7 @@ use VDM\Joomla\Utilities\StringHelper;
use VDM\Joomla\Utilities\ArrayHelper; use VDM\Joomla\Utilities\ArrayHelper;
use VDM\Joomla\Utilities\ObjectHelper; use VDM\Joomla\Utilities\ObjectHelper;
use VDM\Joomla\Utilities\FileHelper; use VDM\Joomla\Utilities\FileHelper;
use VDM\Joomla\Utilities\GetHelper;
use VDM\Joomla\Utilities\MathHelper; use VDM\Joomla\Utilities\MathHelper;
use VDM\Joomla\Componentbuilder\Compiler\Factory as CFactory; use VDM\Joomla\Componentbuilder\Compiler\Factory as CFactory;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Placefix; use VDM\Joomla\Componentbuilder\Compiler\Utilities\Placefix;
@ -34,7 +35,6 @@ ComponentbuilderHelper::autoLoader();
class Compiler extends Infusion class Compiler extends Infusion
{ {
/** /**
* The Temp path * The Temp path
* *
@ -106,19 +106,17 @@ class Compiler extends Infusion
// clear form component xml // clear form component xml
$xmlPath = $this->componentPath . '/' $xmlPath = $this->componentPath . '/'
. CFactory::_('Content')->get('component') . '.xml'; . CFactory::_('Content')->get('component') . '.xml';
$componentXML = ComponentbuilderHelper::getFileContents( $componentXML = FileHelper::getContent($xmlPath);
$xmlPath $textToSite = GetHelper::between(
);
$textToSite = ComponentbuilderHelper::getBetween(
$componentXML, '<files folder="site">', '</files>' $componentXML, '<files folder="site">', '</files>'
); );
$textToSiteLang = ComponentbuilderHelper::getBetween( $textToSiteLang = GetHelper::between(
$componentXML, '<languages folder="site">', '</languages>' $componentXML, '<languages folder="site">', '</languages>'
); );
$componentXML = str_replace( $componentXML = str_replace(
array('<files folder="site">' . $textToSite . "</files>", array('<files folder="site">' . $textToSite . "</files>",
'<languages folder="site">' . $textToSiteLang '<languages folder="site">' . $textToSiteLang
. "</languages>"), array('', ''), $componentXML . "</languages>"), array('', ''), (string) $componentXML
); );
$this->writeFile($xmlPath, $componentXML); $this->writeFile($xmlPath, $componentXML);
} }
@ -383,7 +381,7 @@ class Compiler extends Infusion
&& ArrayHelper::check($this->newFiles['dynamic'])) && ArrayHelper::check($this->newFiles['dynamic']))
{ {
// get the bom file // get the bom file
$bom = ComponentbuilderHelper::getFileContents($this->bomPath); $bom = FileHelper::getContent($this->bomPath);
// first we do the static files // first we do the static files
foreach ($this->newFiles['static'] as $static) foreach ($this->newFiles['static'] as $static)
{ {
@ -640,7 +638,7 @@ class Compiler extends Infusion
$php = "<?php\n"; $php = "<?php\n";
} }
// get content of the file // get content of the file
$string = ComponentbuilderHelper::getFileContents($path); $string = FileHelper::getContent($path);
// Trigger Event: jcb_ce_onGetFileContents // Trigger Event: jcb_ce_onGetFileContents
CFactory::_('Event')->trigger( CFactory::_('Event')->trigger(
'jcb_ce_onGetFileContents', 'jcb_ce_onGetFileContents',
@ -648,10 +646,10 @@ class Compiler extends Infusion
&$view) &$view)
); );
// see if we should add a BOM // see if we should add a BOM
if (strpos($string, Placefix::_h('BOM')) !== false) if (strpos((string) $string, (string) Placefix::_h('BOM')) !== false)
{ {
list($wast, $code) = explode( list($wast, $code) = explode(
Placefix::_h('BOM'), $string Placefix::_h('BOM'), (string) $string
); );
$string = $php . $bom . $code; $string = $php . $bom . $code;
} }
@ -678,7 +676,7 @@ class Compiler extends Infusion
// add answer back to file // add answer back to file
$this->writeFile($path, $answer); $this->writeFile($path, $answer);
// count the file lines // count the file lines
$this->lineCount = $this->lineCount + substr_count($answer, PHP_EOL); $this->lineCount = $this->lineCount + substr_count((string) $answer, PHP_EOL);
} }
/** /**
@ -884,7 +882,7 @@ class Compiler extends Infusion
$this->buildReadMeData(); $this->buildReadMeData();
} }
// get the file // get the file
$string = ComponentbuilderHelper::getFileContents($path); $string = FileHelper::getContent($path);
// update the file // update the file
$answer = CFactory::_('Placeholder')->update($string, CFactory::_('Content')->active); $answer = CFactory::_('Placeholder')->update($string, CFactory::_('Content')->active);
// add to zip array // add to zip array
@ -1506,7 +1504,7 @@ class Compiler extends Infusion
$_commentType = " -->"; $_commentType = " -->";
} }
// escape the code // escape the code
$code = explode(PHP_EOL, $target['code']); $code = explode(PHP_EOL, (string) $target['code']);
$code = PHP_EOL . $commentType . implode( $code = PHP_EOL . $commentType . implode(
$_commentType . PHP_EOL . $commentType, $code $_commentType . PHP_EOL . $commentType, $code
) . $_commentType . PHP_EOL; ) . $_commentType . PHP_EOL;
@ -1540,10 +1538,10 @@ class Compiler extends Infusion
// move to the position where we should add the data // move to the position where we should add the data
fseek($fpFile, $position); fseek($fpFile, $position);
// Add the data // Add the data
fwrite($fpFile, $data); fwrite($fpFile, (string) $data);
// truncate file at the end of the data that was added // truncate file at the end of the data that was added
$remove = MathHelper::bc( $remove = MathHelper::bc(
'add', $position, mb_strlen($data, '8bit') 'add', $position, mb_strlen((string) $data, '8bit')
); );
ftruncate($fpFile, $remove); ftruncate($fpFile, $remove);
// check if this was a replacement of data // check if this was a replacement of data

File diff suppressed because it is too large Load Diff

View File

@ -406,11 +406,11 @@ class Structure extends Get
. CFactory::_('Config')->joomla_version; . CFactory::_('Config')->joomla_version;
$this->componentBackupName = 'com_' $this->componentBackupName = 'com_'
. $this->componentData->sales_name . '_v' . str_replace( . $this->componentData->sales_name . '_v' . str_replace(
'.', '_', $this->componentData->component_version '.', '_', (string) $this->componentData->component_version
) . '__J' . CFactory::_('Config')->joomla_version; ) . '__J' . CFactory::_('Config')->joomla_version;
$this->componentFolderName = 'com_' $this->componentFolderName = 'com_'
. $this->componentData->name_code . '_v' . str_replace( . $this->componentData->name_code . '_v' . str_replace(
'.', '_', $this->componentData->component_version '.', '_', (string) $this->componentData->component_version
) . '__J' . CFactory::_('Config')->joomla_version; ) . '__J' . CFactory::_('Config')->joomla_version;
// set component folder path // set component folder path
$this->componentPath = CFactory::_('Config')->get('compiler_path', JPATH_COMPONENT_ADMINISTRATOR . '/compiler') . '/' $this->componentPath = CFactory::_('Config')->get('compiler_path', JPATH_COMPONENT_ADMINISTRATOR . '/compiler') . '/'
@ -761,7 +761,7 @@ class Structure extends Get
&& StringHelper::check($css)) && StringHelper::check($css))
{ {
// make sure this script does not have PHP // make sure this script does not have PHP
if (strpos($css, '<?php') === false) if (strpos((string) $css, '<?php') === false)
{ {
// make sure the field is added // make sure the field is added
$module->add_scripts_field = true; $module->add_scripts_field = true;
@ -796,7 +796,7 @@ class Structure extends Get
&& StringHelper::check($javascript)) && StringHelper::check($javascript))
{ {
// make sure this script does not have PHP // make sure this script does not have PHP
if (strpos($javascript, '<?php') === false) if (strpos((string) $javascript, '<?php') === false)
{ {
// make sure the field is added // make sure the field is added
$module->add_scripts_field = true; $module->add_scripts_field = true;
@ -924,9 +924,9 @@ class Structure extends Get
// check if we have an double fields naming set // check if we have an double fields naming set
$field_name_inner = ''; $field_name_inner = '';
$field_name_outer = $field_name; $field_name_outer = $field_name;
if (strpos($field_name, '.') !== false) if (strpos((string) $field_name, '.') !== false)
{ {
$field_names = explode('.', $field_name); $field_names = explode('.', (string) $field_name);
if (count((array) $field_names) == 2) if (count((array) $field_names) == 2)
{ {
$field_name_outer = $field_names[0]; $field_name_outer = $field_names[0];
@ -1124,7 +1124,7 @@ class Structure extends Get
)) ))
{ {
// set file name // set file name
$fileName = basename($url['url']); $fileName = basename((string) $url['url']);
// get the file contents // get the file contents
$data = FileHelper::getContent( $data = FileHelper::getContent(
$url['url'] $url['url']
@ -1333,9 +1333,9 @@ class Structure extends Get
// check if we have an double fields naming set // check if we have an double fields naming set
$field_name_inner = ''; $field_name_inner = '';
$field_name_outer = $field_name; $field_name_outer = $field_name;
if (strpos($field_name, '.') !== false) if (strpos((string) $field_name, '.') !== false)
{ {
$field_names = explode('.', $field_name); $field_names = explode('.', (string) $field_name);
if (count((array) $field_names) == 2) if (count((array) $field_names) == 2)
{ {
$field_name_outer = $field_names[0]; $field_name_outer = $field_names[0];
@ -1361,16 +1361,16 @@ class Structure extends Get
if (!isset($plugin->add_rule_path[$file . $field_name . $fieldset])) if (!isset($plugin->add_rule_path[$file . $field_name . $fieldset]))
{ {
$plugin->add_rule_path[$file . $field_name . $fieldset] = $plugin->add_rule_path[$file . $field_name . $fieldset] =
'/plugins/' . strtolower($plugin->group '/plugins/' . strtolower((string) $plugin->group
) . '/' . strtolower($plugin->code_name) ) . '/' . strtolower((string) $plugin->code_name)
. '/rules'; . '/rules';
} }
if (!isset($plugin->add_field_path[$file . $field_name . $fieldset])) if (!isset($plugin->add_field_path[$file . $field_name . $fieldset]))
{ {
$plugin->add_field_path[$file . $field_name . $fieldset] = $plugin->add_field_path[$file . $field_name . $fieldset] =
'/plugins/' . strtolower($plugin->group '/plugins/' . strtolower((string) $plugin->group
) . '/' . strtolower($plugin->code_name) ) . '/' . strtolower((string) $plugin->code_name)
. '/fields'; . '/fields';
} }
} }
@ -1515,7 +1515,7 @@ class Structure extends Get
)) ))
{ {
// set file name // set file name
$fileName = basename($url['url']); $fileName = basename((string) $url['url']);
// get the file contents // get the file contents
$data = FileHelper::getContent( $data = FileHelper::getContent(
$url['url'] $url['url']
@ -1636,7 +1636,7 @@ class Structure extends Get
$libFolder = strtolower( $libFolder = strtolower(
preg_replace( preg_replace(
'/\s+/', '-', '/\s+/', '-',
StringHelper::safe( (string) StringHelper::safe(
$library->name, 'filename', ' ', false $library->name, 'filename', ' ', false
) )
) )
@ -1660,7 +1660,7 @@ class Structure extends Get
// add local folder // add local folder
$addLocalFolder = true; $addLocalFolder = true;
// set file name // set file name
$fileName = basename($url['url']); $fileName = basename((string) $url['url']);
// get the file contents // get the file contents
$data = FileHelper::getContent( $data = FileHelper::getContent(
$url['url'] $url['url']
@ -1742,10 +1742,10 @@ class Structure extends Get
&& StringHelper::check( && StringHelper::check(
$this->componentData->dashboard $this->componentData->dashboard
) )
&& strpos($this->componentData->dashboard, '_') !== false) && strpos((string) $this->componentData->dashboard, '_') !== false)
{ {
// set the default view // set the default view
$getter = explode('_', $this->componentData->dashboard); $getter = explode('_', (string) $this->componentData->dashboard);
if (count((array) $getter) == 2 && is_numeric($getter[1])) if (count((array) $getter) == 2 && is_numeric($getter[1]))
{ {
// the pointers // the pointers
@ -2061,7 +2061,7 @@ class Structure extends Get
$this->notNew[] = 'LICENSE.txt'; $this->notNew[] = 'LICENSE.txt';
// do license check // do license check
$LICENSE = false; $LICENSE = false;
$licenseChecker = strtolower($this->componentData->license); $licenseChecker = strtolower((string) $this->componentData->license);
if (strpos($licenseChecker, 'gnu') !== false if (strpos($licenseChecker, 'gnu') !== false
&& strpos( && strpos(
$licenseChecker, '2' $licenseChecker, '2'
@ -2097,7 +2097,7 @@ class Structure extends Get
} }
else else
{ {
$new = str_replace($details->rename, $codeName, $item); $new = str_replace($details->rename, $codeName, (string) $item);
} }
} }
else else
@ -2120,20 +2120,20 @@ class Structure extends Get
{ {
// set destination path // set destination path
$zipPath = str_replace( $zipPath = str_replace(
$details->_target['type'] . '/', '', $details->path $details->_target['type'] . '/', '', (string) $details->path
); );
$path = str_replace( $path = str_replace(
$details->_target['type'] . '/', $details->_target['type'] . '/',
$this->dynamicPaths[$details->_target['key']] . '/', $this->dynamicPaths[$details->_target['key']] . '/',
$details->path (string) $details->path
); );
} }
else else
{ {
// set destination path // set destination path
$zipPath = str_replace('c0mp0n3nt/', '', $details->path); $zipPath = str_replace('c0mp0n3nt/', '', (string) $details->path);
$path = str_replace( $path = str_replace(
'c0mp0n3nt/', $this->componentPath . '/', $details->path 'c0mp0n3nt/', $this->componentPath . '/', (string) $details->path
); );
} }
// set the template folder path // set the template folder path
@ -2141,9 +2141,9 @@ class Structure extends Get
? (($details->custom !== 'full') ? $this->templatePathCustom ? (($details->custom !== 'full') ? $this->templatePathCustom
. '/' : '') : $this->templatePath . '/'; . '/' : '') : $this->templatePath . '/';
// set the final paths // set the final paths
$currentFullPath = (preg_match('/^[a-z]:/i', $item)) ? $item $currentFullPath = (preg_match('/^[a-z]:/i', (string) $item)) ? $item
: $templatePath . '/' . $item; : $templatePath . '/' . $item;
$currentFullPath = str_replace('//', '/', $currentFullPath); $currentFullPath = str_replace('//', '/', (string) $currentFullPath);
$packageFullPath = str_replace('//', '/', $path . '/' . $new); $packageFullPath = str_replace('//', '/', $path . '/' . $new);
$zipFullPath = str_replace( $zipFullPath = str_replace(
'//', '/', $zipPath . '/' . $new '//', '/', $zipPath . '/' . $new
@ -2545,7 +2545,7 @@ class Structure extends Get
'trim', 'trim',
explode( explode(
',', ',',
GetHelper::between( (string) GetHelper::between(
$multi_field['settings']->xml, 'fields="', '"' $multi_field['settings']->xml, 'fields="', '"'
) )
) )
@ -2578,7 +2578,7 @@ class Structure extends Get
&& StringHelper::check($view['settings']->created)) && StringHelper::check($view['settings']->created))
{ {
// first set the main date // first set the main date
$date = strtotime($view['settings']->created); $date = strtotime((string) $view['settings']->created);
} }
else else
{ {
@ -2604,7 +2604,7 @@ class Structure extends Get
&& StringHelper::check($view['settings']->modified) && StringHelper::check($view['settings']->modified)
&& '0000-00-00 00:00:00' !== $view['settings']->modified) && '0000-00-00 00:00:00' !== $view['settings']->modified)
{ {
$date = strtotime($view['settings']->modified); $date = strtotime((string) $view['settings']->modified);
} }
else else
{ {
@ -2637,7 +2637,7 @@ class Structure extends Get
!== $field['settings']->modified) !== $field['settings']->modified)
{ {
$anotherDate = strtotime( $anotherDate = strtotime(
$field['settings']->modified (string) $field['settings']->modified
); );
if ($anotherDate > $date) if ($anotherDate > $date)
{ {
@ -2662,7 +2662,7 @@ class Structure extends Get
!== $view['settings']->main_get->modified) !== $view['settings']->main_get->modified)
{ {
$anotherDate = strtotime( $anotherDate = strtotime(
$view['settings']->main_get->modified (string) $view['settings']->main_get->modified
); );
if ($anotherDate > $date) if ($anotherDate > $date)
{ {
@ -2685,7 +2685,7 @@ class Structure extends Get
!== $view['settings']->main_get->modified) !== $view['settings']->main_get->modified)
{ {
$anotherDate = strtotime( $anotherDate = strtotime(
$view['settings']->main_get->modified (string) $view['settings']->main_get->modified
); );
if ($anotherDate > $date) if ($anotherDate > $date)
{ {
@ -2745,20 +2745,20 @@ class Structure extends Get
{ {
// set destination path // set destination path
$path = ''; $path = '';
if (strpos($details->path, 'VIEW') !== false) if (strpos((string) $details->path, 'VIEW') !== false)
{ {
$path = str_replace('VIEW', $name, $details->path); $path = str_replace('VIEW', $name, (string) $details->path);
} }
else else
{ {
$path = $details->path; $path = $details->path;
} }
// make sure we have component to replace // make sure we have component to replace
if (strpos($path, 'c0mp0n3nt') !== false) if (strpos((string) $path, 'c0mp0n3nt') !== false)
{ {
$zipPath = str_replace('c0mp0n3nt/', '', $path); $zipPath = str_replace('c0mp0n3nt/', '', (string) $path);
$path = str_replace( $path = str_replace(
'c0mp0n3nt/', $this->componentPath . '/', $path 'c0mp0n3nt/', $this->componentPath . '/', (string) $path
); );
} }
else else
@ -2786,7 +2786,7 @@ class Structure extends Get
if ($fileName) if ($fileName)
{ {
$new = str_replace( $new = str_replace(
$details->rename, $fileName, $item $details->rename, $fileName, (string) $item
); );
$name = $name . '_' . $fileName; $name = $name . '_' . $fileName;
} }
@ -2797,7 +2797,7 @@ class Structure extends Get
else else
{ {
$new = str_replace( $new = str_replace(
$details->rename, $name, $item $details->rename, $name, (string) $item
); );
} }
} }
@ -2849,7 +2849,7 @@ class Structure extends Get
if (File::exists($custom_settings)) if (File::exists($custom_settings))
{ {
$version_data = json_decode( $version_data = json_decode(
FileHelper::getContent( (string) FileHelper::getContent(
$custom_settings $custom_settings
) )
); );
@ -2857,7 +2857,7 @@ class Structure extends Get
else else
{ {
$version_data = json_decode( $version_data = json_decode(
FileHelper::getContent( (string) FileHelper::getContent(
$this->templatePath . '/settings.json' $this->templatePath . '/settings.json'
) )
); );
@ -2938,7 +2938,7 @@ class Structure extends Get
if (isset($custom['path']) if (isset($custom['path'])
&& StringHelper::check($custom['path'])) && StringHelper::check($custom['path']))
{ {
$custom['path'] = trim($custom['path'], '/'); $custom['path'] = trim((string) $custom['path'], '/');
} }
// by default custom path is true // by default custom path is true
$customPath = 'custom'; $customPath = 'custom';
@ -2961,14 +2961,14 @@ class Structure extends Get
$customPath = 'full'; $customPath = 'full';
} }
// make sure we use the correct name // make sure we use the correct name
$pathArray = (array) explode('/', $custom['path']); $pathArray = (array) explode('/', (string) $custom['path']);
$firstFolder = array_values($pathArray)[0]; $firstFolder = array_values($pathArray)[0];
$lastFolder = end($pathArray); $lastFolder = end($pathArray);
// only rename folder if last has folder name // only rename folder if last has folder name
if (isset($custom['rename']) && $custom['rename'] == 1) if (isset($custom['rename']) && $custom['rename'] == 1)
{ {
$custom['path'] = str_replace( $custom['path'] = str_replace(
'/' . $lastFolder, '', $custom['path'] '/' . $lastFolder, '', (string) $custom['path']
); );
$rename = 'new'; $rename = 'new';
$newname = $lastFolder; $newname = $lastFolder;
@ -2976,7 +2976,7 @@ class Structure extends Get
elseif ('full' === $customPath) elseif ('full' === $customPath)
{ {
// make sure we use the correct name // make sure we use the correct name
$folderArray = (array) explode('/', $custom['folder']); $folderArray = (array) explode('/', (string) $custom['folder']);
$lastFolder = end($folderArray); $lastFolder = end($folderArray);
$rename = 'new'; $rename = 'new';
$newname = $lastFolder; $newname = $lastFolder;
@ -2993,12 +2993,12 @@ class Structure extends Get
) . '_f' . $pointer_tracker; ) . '_f' . $pointer_tracker;
$pointer_tracker++; $pointer_tracker++;
// fix custom path // fix custom path
$custom['path'] = ltrim($custom['path'], '/'); $custom['path'] = ltrim((string) $custom['path'], '/');
// set new folder to object // set new folder to object
$version_data->move->static->{$key_pointer} = new stdClass(); $version_data->move->static->{$key_pointer} = new stdClass();
$version_data->move->static->{$key_pointer}->naam $version_data->move->static->{$key_pointer}->naam
= str_replace( = str_replace(
'//', '/', $custom['folder'] '//', '/', (string) $custom['folder']
); );
$version_data->move->static->{$key_pointer}->path $version_data->move->static->{$key_pointer}->path
= $_target_type = $_target_type
@ -3084,14 +3084,14 @@ class Structure extends Get
// set new file to object // set new file to object
$version_data->move->static->{$key_pointer} = new stdClass(); $version_data->move->static->{$key_pointer} = new stdClass();
$version_data->move->static->{$key_pointer}->naam = str_replace( $version_data->move->static->{$key_pointer}->naam = str_replace(
'//', '/', $custom['file'] '//', '/', (string) $custom['file']
); );
// update the dynamic component name placholders in file names // update the dynamic component name placholders in file names
$custom['path'] = CFactory::_('Placeholder')->update_( $custom['path'] = CFactory::_('Placeholder')->update_(
$custom['path'] $custom['path']
); );
// get the path info // get the path info
$pathInfo = pathinfo($custom['path']); $pathInfo = pathinfo((string) $custom['path']);
if (isset($pathInfo['extension']) && $pathInfo['extension']) if (isset($pathInfo['extension']) && $pathInfo['extension'])
{ {
$pathInfo['dirname'] = trim($pathInfo['dirname'], '/'); $pathInfo['dirname'] = trim($pathInfo['dirname'], '/');
@ -3106,9 +3106,9 @@ class Structure extends Get
elseif ('full' === $customPath) elseif ('full' === $customPath)
{ {
// fix custom path // fix custom path
$custom['path'] = ltrim($custom['path'], '/'); $custom['path'] = ltrim((string) $custom['path'], '/');
// get file array // get file array
$fileArray = (array) explode('/', $custom['file']); $fileArray = (array) explode('/', (string) $custom['file']);
// set the info // set the info
$version_data->move->static->{$key_pointer}->path $version_data->move->static->{$key_pointer}->path
= $_target_type = $_target_type
@ -3121,7 +3121,7 @@ class Structure extends Get
else else
{ {
// fix custom path // fix custom path
$custom['path'] = ltrim($custom['path'], '/'); $custom['path'] = ltrim((string) $custom['path'], '/');
// set the info // set the info
$version_data->move->static->{$key_pointer}->path $version_data->move->static->{$key_pointer}->path
= $_target_type = $_target_type

View File

@ -1956,9 +1956,9 @@ class Fields extends Structure
$optionSet = ''; $optionSet = '';
if (strtolower($typeName) === 'groupedlist' if (strtolower($typeName) === 'groupedlist'
&& strpos( && strpos(
$value, ',' (string) $value, ','
) !== false ) !== false
&& strpos($value, '@@') !== false) && strpos((string) $value, '@@') !== false)
{ {
// reset the group temp arrays // reset the group temp arrays
$groups_ = array(); $groups_ = array();
@ -1966,7 +1966,7 @@ class Fields extends Structure
'option' => array()); 'option' => array());
$order_ = array(); $order_ = array();
// mulitpal options // mulitpal options
$options = explode(',', $value); $options = explode(',', (string) $value);
foreach ($options as $option) foreach ($options as $option)
{ {
if (strpos($option, '@@') !== false) if (strpos($option, '@@') !== false)
@ -2106,10 +2106,10 @@ class Fields extends Structure
} }
} }
} }
elseif (strpos($value, ',') !== false) elseif (strpos((string) $value, ',') !== false)
{ {
// mulitpal options // mulitpal options
$options = explode(',', $value); $options = explode(',', (string) $value);
foreach ($options as $option) foreach ($options as $option)
{ {
if (strpos($option, '|') !== false) if (strpos($option, '|') !== false)
@ -2156,10 +2156,10 @@ class Fields extends Structure
else else
{ {
// one option // one option
if (strpos($value, '|') !== false) if (strpos((string) $value, '|') !== false)
{ {
// has other value then text // has other value then text
list($v, $t) = explode('|', $value); list($v, $t) = explode('|', (string) $value);
$langValue = $langView . '_' $langValue = $langView . '_'
. FieldHelper::safe( . FieldHelper::safe(
$t, true $t, true
@ -2283,11 +2283,11 @@ class Fields extends Structure
$field .= PHP_EOL . Indent::_(4) $field .= PHP_EOL . Indent::_(4)
. '<fieldset hidden="true" name="' . '<fieldset hidden="true" name="'
. $fieldAttributes['name'] . '_modal" repeat="true">'; . $fieldAttributes['name'] . '_modal" repeat="true">';
if (strpos($fieldAttributes['fields'], ',') !== false) if (strpos((string) $fieldAttributes['fields'], ',') !== false)
{ {
// mulitpal fields // mulitpal fields
$fieldsSets = (array) explode( $fieldsSets = (array) explode(
',', $fieldAttributes['fields'] ',', (string) $fieldAttributes['fields']
); );
} }
elseif (is_numeric($fieldAttributes['fields'])) elseif (is_numeric($fieldAttributes['fields']))
@ -2449,11 +2449,11 @@ class Fields extends Structure
$field .= PHP_EOL . Indent::_(3) . $taber $field .= PHP_EOL . Indent::_(3) . $taber
. '<form hidden="true" name="list_' . '<form hidden="true" name="list_'
. $fieldAttributes['name'] . '_modal" repeat="true">'; . $fieldAttributes['name'] . '_modal" repeat="true">';
if (strpos($fieldAttributes['fields'], ',') !== false) if (strpos((string) $fieldAttributes['fields'], ',') !== false)
{ {
// mulitpal fields // mulitpal fields
$fieldsSets = (array) explode( $fieldsSets = (array) explode(
',', $fieldAttributes['fields'] ',', (string) $fieldAttributes['fields']
); );
} }
elseif (is_numeric($fieldAttributes['fields'])) elseif (is_numeric($fieldAttributes['fields']))
@ -2640,9 +2640,9 @@ class Fields extends Structure
$optionSet = ''; $optionSet = '';
if (strtolower($typeName) === 'groupedlist' if (strtolower($typeName) === 'groupedlist'
&& strpos( && strpos(
$value, ',' (string) $value, ','
) !== false ) !== false
&& strpos($value, '@@') !== false) && strpos((string) $value, '@@') !== false)
{ {
// reset the group temp arrays // reset the group temp arrays
$groups_ = array(); $groups_ = array();
@ -2650,7 +2650,7 @@ class Fields extends Structure
'option' => array()); 'option' => array());
$order_ = array(); $order_ = array();
// mulitpal options // mulitpal options
$options = explode(',', $value); $options = explode(',', (string) $value);
foreach ($options as $option) foreach ($options as $option)
{ {
if (strpos($option, '@@') !== false) if (strpos($option, '@@') !== false)
@ -2790,10 +2790,10 @@ class Fields extends Structure
} }
} }
} }
elseif (strpos($value, ',') !== false) elseif (strpos((string) $value, ',') !== false)
{ {
// mulitpal options // mulitpal options
$options = explode(',', $value); $options = explode(',', (string) $value);
foreach ($options as $option) foreach ($options as $option)
{ {
if (strpos($option, '|') !== false) if (strpos($option, '|') !== false)
@ -2840,10 +2840,10 @@ class Fields extends Structure
else else
{ {
// one option // one option
if (strpos($value, '|') !== false) if (strpos((string) $value, '|') !== false)
{ {
// has other value then text // has other value then text
list($v, $t) = explode('|', $value); list($v, $t) = explode('|', (string) $value);
$langValue = $langView . '_' $langValue = $langView . '_'
. FieldHelper::safe( . FieldHelper::safe(
$t, true $t, true
@ -2972,9 +2972,9 @@ class Fields extends Structure
); );
if (strtolower($typeName) === 'groupedlist' if (strtolower($typeName) === 'groupedlist'
&& strpos( && strpos(
$value, ',' (string) $value, ','
) !== false ) !== false
&& strpos($value, '@@') !== false) && strpos((string) $value, '@@') !== false)
{ {
// reset the group temp arrays // reset the group temp arrays
$groups_ = array(); $groups_ = array();
@ -2982,7 +2982,7 @@ class Fields extends Structure
'option' => array()); 'option' => array());
$order_ = array(); $order_ = array();
// mulitpal options // mulitpal options
$options = explode(',', $value); $options = explode(',', (string) $value);
foreach ($options as $option) foreach ($options as $option)
{ {
if (strpos($option, '@@') !== false) if (strpos($option, '@@') !== false)
@ -3125,10 +3125,10 @@ class Fields extends Structure
} }
} }
} }
elseif (strpos($value, ',') !== false) elseif (strpos((string) $value, ',') !== false)
{ {
// mulitpal options // mulitpal options
$options = explode(',', $value); $options = explode(',', (string) $value);
foreach ($options as $option) foreach ($options as $option)
{ {
$optionXML = $field->fieldXML->addChild('option'); $optionXML = $field->fieldXML->addChild('option');
@ -3170,10 +3170,10 @@ class Fields extends Structure
{ {
// one option // one option
$optionXML = $field->fieldXML->addChild('option'); $optionXML = $field->fieldXML->addChild('option');
if (strpos($value, '|') !== false) if (strpos((string) $value, '|') !== false)
{ {
// has other value then text // has other value then text
list($v, $t) = explode('|', $value); list($v, $t) = explode('|', (string) $value);
$langValue = $langView . '_' $langValue = $langView . '_'
. FieldHelper::safe( . FieldHelper::safe(
$t, true $t, true
@ -3279,11 +3279,11 @@ class Fields extends Structure
); );
$fieldSetXML->addAttribute('repeat', 'true'); $fieldSetXML->addAttribute('repeat', 'true');
if (strpos($fieldAttributes['fields'], ',') !== false) if (strpos((string) $fieldAttributes['fields'], ',') !== false)
{ {
// mulitpal fields // mulitpal fields
$fieldsSets = (array) explode( $fieldsSets = (array) explode(
',', $fieldAttributes['fields'] ',', (string) $fieldAttributes['fields']
); );
} }
elseif (is_numeric($fieldAttributes['fields'])) elseif (is_numeric($fieldAttributes['fields']))
@ -3462,11 +3462,11 @@ class Fields extends Structure
$form, $attributes $form, $attributes
); );
if (strpos($fieldAttributes['fields'], ',') !== false) if (strpos((string) $fieldAttributes['fields'], ',') !== false)
{ {
// multiple fields // multiple fields
$fieldsSets = (array) explode( $fieldsSets = (array) explode(
',', $fieldAttributes['fields'] ',', (string) $fieldAttributes['fields']
); );
} }
elseif (is_numeric($fieldAttributes['fields'])) elseif (is_numeric($fieldAttributes['fields']))
@ -3657,9 +3657,9 @@ class Fields extends Structure
); );
if (strtolower($typeName) === 'groupedlist' if (strtolower($typeName) === 'groupedlist'
&& strpos( && strpos(
$value, ',' (string) $value, ','
) !== false ) !== false
&& strpos($value, '@@') !== false) && strpos((string) $value, '@@') !== false)
{ {
// reset the group temp arrays // reset the group temp arrays
$groups_ = array(); $groups_ = array();
@ -3667,7 +3667,7 @@ class Fields extends Structure
'option' => array()); 'option' => array());
$order_ = array(); $order_ = array();
// mulitpal options // mulitpal options
$options = explode(',', $value); $options = explode(',', (string) $value);
foreach ($options as $option) foreach ($options as $option)
{ {
if (strpos($option, '@@') !== false) if (strpos($option, '@@') !== false)
@ -3810,10 +3810,10 @@ class Fields extends Structure
} }
} }
} }
elseif (strpos($value, ',') !== false) elseif (strpos((string) $value, ',') !== false)
{ {
// municipal options // municipal options
$options = explode(',', $value); $options = explode(',', (string) $value);
foreach ($options as $option) foreach ($options as $option)
{ {
$optionXML = $field->fieldXML->addChild('option'); $optionXML = $field->fieldXML->addChild('option');
@ -3855,10 +3855,10 @@ class Fields extends Structure
{ {
// one option // one option
$optionXML = $field->fieldXML->addChild('option'); $optionXML = $field->fieldXML->addChild('option');
if (strpos($value, '|') !== false) if (strpos((string) $value, '|') !== false)
{ {
// has other value then text // has other value then text
list($v, $t) = explode('|', $value); list($v, $t) = explode('|', (string) $value);
$langValue = $langView . '_' $langValue = $langView . '_'
. FieldHelper::safe( . FieldHelper::safe(
$t, true $t, true
@ -4053,7 +4053,7 @@ class Fields extends Structure
foreach ($this->siteFields[$view][$field] as $codeString => $array) foreach ($this->siteFields[$view][$field] as $codeString => $array)
{ {
// get the code array // get the code array
$codeArray = explode('___', $codeString); $codeArray = explode('___', (string) $codeString);
// set the code // set the code
$code = trim($codeArray[0]); $code = trim($codeArray[0]);
// set the decoding methods // set the decoding methods
@ -4189,18 +4189,18 @@ class Fields extends Structure
); );
} }
// catch all PHP here // catch all PHP here
elseif (strpos($property['name'], 'type_php') !== false elseif (strpos((string) $property['name'], 'type_php') !== false
&& $setCustom) && $setCustom)
{ {
// set the line number // set the line number
$phpLine = (int) preg_replace( $phpLine = (int) preg_replace(
'/[^0-9]/', '', $property['name'] '/[^0-9]/', '', (string) $property['name']
); );
// set the type key // set the type key
$phpKey = (string) trim( $phpKey = (string) trim(
str_replace( str_replace(
'type_', '', 'type_', '',
preg_replace('/[0-9]+/', '', $property['name']) preg_replace('/[0-9]+/', '', (string) $property['name'])
), '_' ), '_'
); );
// load the php for the custom field file // load the php for the custom field file
@ -4619,7 +4619,7 @@ class Fields extends Structure
&& !is_numeric($number_check)) && !is_numeric($number_check))
{ {
$number_check = str_replace( $number_check = str_replace(
',', '.', $field['settings']->datadefault_other ',', '.', (string) $field['settings']->datadefault_other
); );
} }
// check if we have a valid number value // check if we have a valid number value
@ -4962,14 +4962,14 @@ class Fields extends Structure
. $otherView; . $otherView;
} }
// check the context (does our target match) // check the context (does our target match)
if (strpos($_extension, '.') !== false) if (strpos((string) $_extension, '.') !== false)
{ {
$target_view = trim(explode('.', $_extension)[1]); $target_view = trim(explode('.', (string) $_extension)[1]);
// from my understanding the target extension view and the otherView must align // from my understanding the target extension view and the otherView must align
// so I will here check that it does, and if not raise an error message to fix this // so I will here check that it does, and if not raise an error message to fix this
if ($target_view !== $otherView) if ($target_view !== $otherView)
{ {
$target_extension = trim(explode('.', $_extension)[0]); $target_extension = trim(explode('.', (string) $_extension)[0]);
$correction = $target_extension . '.' . $otherView; $correction = $target_extension . '.' . $otherView;
$this->app->enqueueMessage( $this->app->enqueueMessage(
JText::sprintf( JText::sprintf(
@ -5242,7 +5242,7 @@ class Fields extends Structure
$filter_type_code = StringHelper::safe( $filter_type_code = StringHelper::safe(
$nameListCode . 'filter' . $name $nameListCode . 'filter' . $name
); );
$filter_type_code = preg_replace('/_+/', '', $filter_type_code); $filter_type_code = preg_replace('/_+/', '', (string) $filter_type_code);
$filter_function_name = StringHelper::safe( $filter_function_name = StringHelper::safe(
$name, 'F' $name, 'F'
); );
@ -5338,10 +5338,10 @@ class Fields extends Structure
// set J prefix // set J prefix
$jprefix = 'J'; $jprefix = 'J';
// check if this field has a dot in field type name // check if this field has a dot in field type name
if (strpos($data['type'], '.') !== false) if (strpos((string) $data['type'], '.') !== false)
{ {
// so we have name spacing in custom field type name // so we have name spacing in custom field type name
$dotTypeArray = explode('.', $data['type']); $dotTypeArray = explode('.', (string) $data['type']);
// set the J prefix // set the J prefix
if (count((array) $dotTypeArray) > 1) if (count((array) $dotTypeArray) > 1)
{ {
@ -5527,7 +5527,7 @@ class Fields extends Structure
); );
} }
// check the the JFormHelper::loadFieldClass(..) was set // check the the JFormHelper::loadFieldClass(..) was set
elseif (strpos(CFactory::_('Content')->get_('customfield_' . $data['type'], 'JFORM_TYPE_HEADER'), elseif (strpos((string) CFactory::_('Content')->get_('customfield_' . $data['type'], 'JFORM_TYPE_HEADER'),
'JFormHelper::loadFieldClass(') === false) 'JFormHelper::loadFieldClass(') === false)
{ {
CFactory::_('Content')->add_('customfield_' . $data['type'], 'JFORM_TYPE_HEADER', CFactory::_('Content')->add_('customfield_' . $data['type'], 'JFORM_TYPE_HEADER',
@ -5873,7 +5873,7 @@ class Fields extends Structure
$field_filter_sets[] = Indent::_(3) . 'type="' $field_filter_sets[] = Indent::_(3) . 'type="'
. $filter['type'] . '"'; . $filter['type'] . '"';
// set css classname of this field // set css classname of this field
$filter['class'] = ucfirst($filter['type']); $filter['class'] = ucfirst((string) $filter['type']);
} }
else else
{ {
@ -5881,7 +5881,7 @@ class Fields extends Structure
$field_filter_sets[] = Indent::_(3) . 'type="' $field_filter_sets[] = Indent::_(3) . 'type="'
. $filter['filter_type'] . '"'; . $filter['filter_type'] . '"';
// set css classname of this field // set css classname of this field
$filter['class'] = ucfirst($filter['filter_type']); $filter['class'] = ucfirst((string) $filter['filter_type']);
} }
$field_filter_sets[] = Indent::_(3) . 'name="' $field_filter_sets[] = Indent::_(3) . 'name="'
. $filter['code'] . '"'; . $filter['code'] . '"';
@ -6124,17 +6124,17 @@ class Fields extends Structure
$fieldData['component'] = $local_component; $fieldData['component'] = $local_component;
} }
// check that the component has the com_ value in it // check that the component has the com_ value in it
if (strpos($fieldData['component'], 'com_') === false if (strpos((string) $fieldData['component'], 'com_') === false
|| strpos( || strpos(
$fieldData['component'], '=' (string) $fieldData['component'], '='
) !== false) ) !== false)
{ {
$fieldData['component'] = "com_" . $fieldData['component']; $fieldData['component'] = "com_" . $fieldData['component'];
} }
// make sure the component is update if # # # or [ [ [ component placeholder is used // make sure the component is update if # # # or [ [ [ component placeholder is used
if (strpos($fieldData['component'], Placefix::h()) !== false if (strpos((string) $fieldData['component'], (string) Placefix::h()) !== false
|| strpos( || strpos(
$fieldData['component'], Placefix::b() (string) $fieldData['component'], (string) Placefix::b()
) !== false) // should not be needed... but ) !== false) // should not be needed... but
{ {
$fieldData['component'] = CFactory::_('Placeholder')->update_( $fieldData['component'] = CFactory::_('Placeholder')->update_(

File diff suppressed because it is too large Load Diff

View File

@ -103,7 +103,7 @@ class Infusion extends Interpretation
// COMPANYNAME // COMPANYNAME
CFactory::_('Content')->set('COMPANYNAME', trim( CFactory::_('Content')->set('COMPANYNAME', trim(
JFilterOutput::cleanText($this->componentData->companyname) (string) JFilterOutput::cleanText($this->componentData->companyname)
)); ));
// CREATIONDATE // CREATIONDATE
@ -121,31 +121,31 @@ class Infusion extends Interpretation
// AUTHOR // AUTHOR
CFactory::_('Content')->set('AUTHOR', trim( CFactory::_('Content')->set('AUTHOR', trim(
JFilterOutput::cleanText($this->componentData->author) (string) JFilterOutput::cleanText($this->componentData->author)
)); ));
// AUTHOREMAIL // AUTHOREMAIL
CFactory::_('Content')->set('AUTHOREMAIL', trim($this->componentData->email)); CFactory::_('Content')->set('AUTHOREMAIL', trim((string) $this->componentData->email));
// AUTHORWEBSITE // AUTHORWEBSITE
CFactory::_('Content')->set('AUTHORWEBSITE', trim($this->componentData->website)); CFactory::_('Content')->set('AUTHORWEBSITE', trim((string) $this->componentData->website));
// COPYRIGHT // COPYRIGHT
CFactory::_('Content')->set('COPYRIGHT', trim($this->componentData->copyright)); CFactory::_('Content')->set('COPYRIGHT', trim((string) $this->componentData->copyright));
// LICENSE // LICENSE
CFactory::_('Content')->set('LICENSE', trim($this->componentData->license)); CFactory::_('Content')->set('LICENSE', trim((string) $this->componentData->license));
// VERSION // VERSION
CFactory::_('Content')->set('VERSION', trim($this->componentData->component_version)); CFactory::_('Content')->set('VERSION', trim((string) $this->componentData->component_version));
// set the actual global version // set the actual global version
CFactory::_('Content')->set('ACTUALVERSION', CFactory::_('Content')->get('VERSION')); CFactory::_('Content')->set('ACTUALVERSION', CFactory::_('Content')->get('VERSION'));
// do some Tweaks to the version based on selected options // do some Tweaks to the version based on selected options
if (strpos(CFactory::_('Content')->get('VERSION'), '.') !== false) if (strpos((string) CFactory::_('Content')->get('VERSION'), '.') !== false)
{ {
$versionArray = explode( $versionArray = explode(
'.', CFactory::_('Content')->get('VERSION') '.', (string) CFactory::_('Content')->get('VERSION')
); );
} }
// load only first two values // load only first two values
@ -177,13 +177,13 @@ class Infusion extends Interpretation
// SHORT_DISCRIPTION // SHORT_DISCRIPTION
CFactory::_('Content')->set('SHORT_DESCRIPTION', trim( CFactory::_('Content')->set('SHORT_DESCRIPTION', trim(
JFilterOutput::cleanText( (string) JFilterOutput::cleanText(
$this->componentData->short_description $this->componentData->short_description
) )
)); ));
// DESCRIPTION // DESCRIPTION
CFactory::_('Content')->set('DESCRIPTION', trim($this->componentData->description)); CFactory::_('Content')->set('DESCRIPTION', trim((string) $this->componentData->description));
// COMP_IMAGE_TYPE // COMP_IMAGE_TYPE
CFactory::_('Content')->set('COMP_IMAGE_TYPE', $this->setComponentImageType($this->componentData->image)); CFactory::_('Content')->set('COMP_IMAGE_TYPE', $this->setComponentImageType($this->componentData->image));
@ -419,7 +419,7 @@ class Infusion extends Interpretation
)) ))
{ {
CFactory::_('Content')->set_($nameSingleCode, 'DOCUMENT_CUSTOM_PHP', str_replace( CFactory::_('Content')->set_($nameSingleCode, 'DOCUMENT_CUSTOM_PHP', str_replace(
'$document->', '$this->document->', $phpDocument '$document->', '$this->document->', (string) $phpDocument
)); ));
// clear some memory // clear some memory
unset($phpDocument); unset($phpDocument);
@ -835,7 +835,7 @@ class Infusion extends Interpretation
{ {
// only minfy if no php is added to the footer script // only minfy if no php is added to the footer script
if (CFactory::_('Config')->get('minify', 0) if (CFactory::_('Config')->get('minify', 0)
&& strpos($footerScript, '<?php') === false) && strpos((string) $footerScript, '<?php') === false)
{ {
// minfy the script // minfy the script
$minifier = new JS; $minifier = new JS;
@ -1425,7 +1425,7 @@ class Infusion extends Interpretation
$target = array('admin' => 'a_rule_zi'); $target = array('admin' => 'a_rule_zi');
$this->buildDynamique($target, 'rule', $rule); $this->buildDynamique($target, 'rule', $rule);
// set the JFormRule Name // set the JFormRule Name
CFactory::_('Content')->set_('a_rule_zi_' . $rule, 'Name', ucfirst($rule)); CFactory::_('Content')->set_('a_rule_zi_' . $rule, 'Name', ucfirst((string) $rule));
// set the JFormRule PHP // set the JFormRule PHP
CFactory::_('Content')->set_('a_rule_zi_' . $rule, 'VALIDATION_RULE_METHODS', PHP_EOL . $_php); CFactory::_('Content')->set_('a_rule_zi_' . $rule, 'VALIDATION_RULE_METHODS', PHP_EOL . $_php);
} }
@ -2118,13 +2118,13 @@ class Infusion extends Interpretation
foreach ($this->languages['components'] as $tag => $areas) foreach ($this->languages['components'] as $tag => $areas)
{ {
// trim the tag // trim the tag
$tag = trim($tag); $tag = trim((string) $tag);
foreach ($areas as $area => $languageStrings) foreach ($areas as $area => $languageStrings)
{ {
// set naming convention // set naming convention
$p = 'admin'; $p = 'admin';
$t = ''; $t = '';
if (strpos($area, 'site') !== false) if (strpos((string) $area, 'site') !== false)
{ {
if (CFactory::_('Config')->remove_site_folder if (CFactory::_('Config')->remove_site_folder
&& CFactory::_('Config')->remove_site_edit_folder) && CFactory::_('Config')->remove_site_edit_folder)
@ -2133,7 +2133,7 @@ class Infusion extends Interpretation
} }
$p = 'site'; $p = 'site';
} }
if (strpos($area, 'sys') !== false) if (strpos((string) $area, 'sys') !== false)
{ {
$t = '.sys'; $t = '.sys';
} }

View File

@ -26,6 +26,11 @@
// No direct access to this file // No direct access to this file
defined('_JEXEC') or die('Restricted access'); defined('_JEXEC') or die('Restricted access');
use VDM\Joomla\Utilities\StringHelper;
use VDM\Joomla\Utilities\JsonHelper;
use VDM\Joomla\Utilities\GetHelper;
use VDM\Joomla\Utilities\ArrayHelper;
/** /**
* Mapping class * Mapping class
*/ */
@ -102,7 +107,7 @@ class Mapping
// set the app to insure messages can be set // set the app to insure messages can be set
$this->app = JFactory::getApplication(); $this->app = JFactory::getApplication();
// check that we have data // check that we have data
if (ComponentbuilderHelper::checkArray($data)) if (ArrayHelper::check($data))
{ {
// make sure we have an id // make sure we have an id
if (isset($data['id']) && $data['id'] > 0) if (isset($data['id']) && $data['id'] > 0)
@ -117,15 +122,15 @@ class Mapping
{ {
case 'base64': case 'base64':
// set needed value // set needed value
$this->$key = base64_decode($value); $this->$key = base64_decode((string) $value);
break; break;
case 'json': case 'json':
// set needed value // set needed value
$this->$key = json_decode($value, true); $this->$key = json_decode((string) $value, true);
break; break;
case 'safeString': case 'safeString':
// set needed value // set needed value
$this->$key = ComponentbuilderHelper::safeString($value); $this->$key = StringHelper::check($value);
break; break;
default : default :
$this->$key = $value; $this->$key = $value;
@ -134,10 +139,10 @@ class Mapping
} }
} }
// get linked admin views // get linked admin views
$addadmin_views = ComponentbuilderHelper::getVar('component_admin_views', $data['id'], 'joomla_component', 'addadmin_views'); $addadmin_views = GetHelper::var('component_admin_views', $data['id'], 'joomla_component', 'addadmin_views');
if (ComponentbuilderHelper::checkJson($addadmin_views)) if (JsonHelper::check($addadmin_views))
{ {
$this->addadmin_views = json_decode($addadmin_views, true); $this->addadmin_views = json_decode((string)$addadmin_views, true);
} }
// set the map of the views needed // set the map of the views needed
if ($this->setMap()) if ($this->setMap())
@ -173,7 +178,7 @@ class Mapping
{ {
// start parsing the sql dump data // start parsing the sql dump data
$queries = JDatabaseDriver::splitSql($this->buildcompsql); $queries = JDatabaseDriver::splitSql($this->buildcompsql);
if (ComponentbuilderHelper::checkArray($queries)) if (ArrayHelper::check($queries))
{ {
foreach ($queries as $query) foreach ($queries as $query)
{ {
@ -208,7 +213,7 @@ class Mapping
} }
} }
// check if the mapping was done // check if the mapping was done
if (ComponentbuilderHelper::checkArray($this->map)) if (ArrayHelper::check($this->map))
{ {
return true; return true;
} }
@ -224,12 +229,12 @@ class Mapping
if (strpos($query, '`#__') !== false) if (strpos($query, '`#__') !== false)
{ {
// get table name // get table name
$tableName = ComponentbuilderHelper::getBetween($query, '`#__', "`"); $tableName = GetHelper::between($query, '`#__', "`");
} }
elseif (strpos($query, "'#__") !== false) elseif (strpos($query, "'#__") !== false)
{ {
// get table name // get table name
$tableName = ComponentbuilderHelper::getBetween($query, "'#__", "'"); $tableName = GetHelper::between($query, "'#__", "'");
} }
// if it still was not found // if it still was not found
if (!isset($tableName) || !ComponentbuilderHelper::checkString($tableName)) if (!isset($tableName) || !ComponentbuilderHelper::checkString($tableName))
@ -267,12 +272,12 @@ class Mapping
if (0 === strpos($row, '`')) if (0 === strpos($row, '`'))
{ {
// get field name // get field name
$name = ComponentbuilderHelper::getBetween($row, '`', '`'); $name = GetHelper::between($row, '`', '`');
} }
if (0 === strpos($row, "'")) if (0 === strpos($row, "'"))
{ {
// get field name // get field name
$name = ComponentbuilderHelper::getBetween($row, "'", "'"); $name = GetHelper::between($row, "'", "'");
} }
// check if the name was found // check if the name was found
if (ComponentbuilderHelper::checkString($name)) if (ComponentbuilderHelper::checkString($name))
@ -289,7 +294,7 @@ class Mapping
{ {
$field['row'] = $row; $field['row'] = $row;
$field['name'] = $name; $field['name'] = $name;
$field['label'] = ComponentbuilderHelper::safeString($name, 'W'); $field['label'] = StringHelper::check($name, 'W');
$field['fieldType'] = $fieldType; $field['fieldType'] = $fieldType;
$field['size'] = $this->getSize($row, $field); $field['size'] = $this->getSize($row, $field);
$field['sizeOther'] = ''; $field['sizeOther'] = '';
@ -319,7 +324,7 @@ class Mapping
} }
} }
} }
if (ComponentbuilderHelper::checkArray($fields)) if (ArrayHelper::check($fields))
{ {
return $fields; return $fields;
} }
@ -352,7 +357,7 @@ class Mapping
{ {
if (in_array($field['dataType'], $this->dataSize)) if (in_array($field['dataType'], $this->dataSize))
{ {
return ComponentbuilderHelper::getBetween($row, $field['dataType'].'(', ')'); return GetHelper::between($row, $field['dataType'].'(', ')');
} }
return ''; return '';
} }
@ -365,12 +370,12 @@ class Mapping
// get default value // get default value
if (strpos($row, 'DEFAULT "') !== false) // to sure it this is correct... if (strpos($row, 'DEFAULT "') !== false) // to sure it this is correct...
{ {
return ComponentbuilderHelper::getBetween($row, 'DEFAULT "', '"'); return GetHelper::between($row, 'DEFAULT "', '"');
} }
// get default value // get default value
if (strpos($row, "DEFAULT '") !== false) if (strpos($row, "DEFAULT '") !== false)
{ {
return ComponentbuilderHelper::getBetween($row, "DEFAULT '", "'"); return GetHelper::between($row, "DEFAULT '", "'");
} }
return ''; return '';
} }

View File

@ -26,6 +26,10 @@
// No direct access to this file // No direct access to this file
defined('_JEXEC') or die('Restricted access'); defined('_JEXEC') or die('Restricted access');
use VDM\Joomla\Componentbuilder\Compiler\Factory as CFactory;
use VDM\Joomla\Utilities\StringHelper;
use VDM\Joomla\Utilities\GetHelper;
/** /**
* Builder class * Builder class
*/ */
@ -102,7 +106,7 @@ class Builder extends Mapping
{ {
// set the view object // set the view object
$object = new stdClass(); $object = new stdClass();
$object->system_name = ComponentbuilderHelper::safeString($name, 'W') . ' (dynamic build)'; $object->system_name = StringHelper::check($name, 'W') . ' (dynamic build)';
$object->name_single = $name; $object->name_single = $name;
$object->name_list = $name. 's'; $object->name_list = $name. 's';
$object->short_description = $name. ' view (dynamic build)'; $object->short_description = $name. ' view (dynamic build)';
@ -264,7 +268,7 @@ class Builder extends Mapping
protected function getFieldType($fieldName) protected function getFieldType($fieldName)
{ {
// load the field settings // load the field settings
return ComponentbuilderHelper::getVar('fieldtype', $fieldName, 'name', 'id'); return GetHelper::var('fieldtype', $fieldName, 'name', 'id');
} }
/** /**

View File

@ -26,6 +26,9 @@
// No direct access to this file // No direct access to this file
defined('_JEXEC') or die('Restricted access'); defined('_JEXEC') or die('Restricted access');
use VDM\Joomla\Utilities\GetHelper;
use VDM\Joomla\Utilities\ArrayHelper;
/** /**
* Extrusion class * Extrusion class
*/ */
@ -58,10 +61,10 @@ class Extrusion extends Builder
protected function setAdminViews(&$component_id) protected function setAdminViews(&$component_id)
{ {
// check if views were set // check if views were set
if (ComponentbuilderHelper::checkArray($this->views)) if (ArrayHelper::check($this->views))
{ {
$count = 0; $count = 0;
if (ComponentbuilderHelper::checkArray($this->addadmin_views)) if (ArrayHelper::check($this->addadmin_views))
{ {
$count = (int) count((array)$this->addadmin_views) + 3; $count = (int) count((array)$this->addadmin_views) + 3;
} }
@ -84,7 +87,7 @@ class Extrusion extends Builder
$this->addadmin_views['addadmin_views'.$pointer]['order'] = $pointer + 1; $this->addadmin_views['addadmin_views'.$pointer]['order'] = $pointer + 1;
} }
} }
if (isset($this->addadmin_views) && ComponentbuilderHelper::checkArray($this->addadmin_views)) if (isset($this->addadmin_views) && ArrayHelper::check($this->addadmin_views))
{ {
// set the field object // set the field object
$object = new stdClass(); $object = new stdClass();
@ -94,7 +97,7 @@ class Extrusion extends Builder
$object->created_by = $this->user->id; $object->created_by = $this->user->id;
$object->published = 1; $object->published = 1;
// check if it is already set // check if it is already set
if ($item_id = ComponentbuilderHelper::getVar('component_admin_views', $component_id, 'joomla_component', 'id')) if ($item_id = GetHelper::var('component_admin_views', $component_id, 'joomla_component', 'id'))
{ {
// set ID // set ID
$object->id = (int) $item_id; $object->id = (int) $item_id;

File diff suppressed because one or more lines are too long

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<extension type="component" version="4" method="upgrade"> <extension type="component" version="4" method="upgrade">
<name>COM_COMPONENTBUILDER</name> <name>COM_COMPONENTBUILDER</name>
<creationDate>29th December, 2023</creationDate> <creationDate>1st January, 2023</creationDate>
<author>Llewellyn van der Merwe</author> <author>Llewellyn van der Merwe</author>
<authorEmail>joomla@vdm.io</authorEmail> <authorEmail>joomla@vdm.io</authorEmail>
<authorUrl>https://dev.vdm.io</authorUrl> <authorUrl>https://dev.vdm.io</authorUrl>

View File

@ -0,0 +1,233 @@
<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace VDM\Joomla\Componentbuilder\Abstraction;
use VDM\Joomla\Utilities\StringHelper;
use VDM\Joomla\Utilities\ArrayHelper;
use VDM\Joomla\Componentbuilder\Table;
/**
* Our base Model
*
* @since 3.2.0
*/
abstract class Model
{
/**
* Last ID
*
* @var array
* @since 3.2.0
*/
protected array $last;
/**
* Search Table
*
* @var Table
* @since 3.2.0
*/
protected Table $table;
/**
* Constructor
*
* @param Table $table The search table object.
*
* @since 3.2.0
*/
public function __construct(Table $table)
{
$this->table = $table;
}
/**
* Model the value
* Example: $this->value(value, 'value_key', 'table_name');
*
* @param mixed $value The value to model
* @param string $field The field key
* @param string|null $table The table
*
* @return mixed
* @since 3.2.0
*/
abstract public function value($value, string $field, ?string $table = null);
/**
* Model the values of an item
* Example: $this->item('table_name', Object);
*
* @param object $item The item object
* @param string|null $table The table
*
* @return object|null
* @since 3.2.0
*/
public function item(object $item, ?string $table = null): ?object
{
// set the table name
if (empty($table))
{
$table = $this->getTable();
}
// field counter
$field_number = 0;
// check if this is a valid table
if (($fields = $this->getTableFields($table)) !== null)
{
foreach ($fields as $field)
{
// model a value if it exists
if(isset($item->{$field}))
{
$item->{$field} = $this->value($item->{$field}, $field, $table);
if ($this->validate($item->{$field}))
{
$field_number++;
}
else
{
unset($item->{$field});
}
}
}
}
// all items must have more than one field or its empty (1 = id)
if ($field_number > 1)
{
return $item;
}
return null;
}
/**
* Model the values of multiple items
* Example: $this->items(Array, 'table_name');
*
* @param array|null $items The array of item objects
* @param string|null $table The table
*
* @return array|null
* @since 3.2.0
*/
public function items(?array $items = null, ?string $table = null): ?array
{
// check if this is a valid table
if (ArrayHelper::check($items))
{
// set the table name
if (empty($table))
{
$table = $this->getTable();
}
foreach ($items as $id => &$item)
{
// model the item
if (($item = $this->item($item, $table)) !== null)
{
// add the last ID
$this->last[$table] = $item->id;
}
else
{
unset($items[$id]);
}
}
if (ArrayHelper::check($items))
{
return $items;
}
}
return null;
}
/**
* Get last modeled ID
* Example: $this->last('table_name');
*
* @param string|null $table The table
*
* @return int|null
* @since 3.2.0
*/
public function last(?string $table = null): ?int
{
// set the table name
if (empty($table))
{
$table = $this->getTable();
}
// check if this is a valid table
if ($table && isset($this->last[$table]))
{
return $this->last[$table];
}
return null;
}
/**
* Validate the values (basic, override in child class)
*
* @param mixed $value The field value
* @param string|null $field The field key
* @param string|null $table The table
*
* @return bool
* @since 3.2.0
*/
protected function validate(&$value, ?string $field = null, ?string $table = null): bool
{
// check values
if (StringHelper::check($value) || ArrayHelper::check($value, true))
{
return true;
}
// remove empty values
return false;
}
/**
* Get the current active table's fields
*
* @param string $table The table
*
* @return array
* @since 3.2.0
*/
protected function getTableFields(string $table): ?array
{
return $this->table->fields($table);
}
/**
* Get the current active table
*
* @return string
* @since 3.2.0
*/
abstract protected function getTable(): string;
}

View File

@ -204,7 +204,7 @@ class Gui implements GuiInterface
if (is_array($query) && count($query) >= 3) if (is_array($query) && count($query) >= 3)
{ {
// cleanup the newlines around the code // cleanup the newlines around the code
$code = trim(str_replace($first_line, '', $code), PHP_EOL) $code = trim(str_replace($first_line, '', (string) $code), PHP_EOL)
. PHP_EOL; . PHP_EOL;
// set the ID // set the ID
$id = (int) $query[2]; $id = (int) $query[2];
@ -243,14 +243,9 @@ class Gui implements GuiInterface
protected function check(string &$code): bool protected function check(string &$code): bool
{ {
// check for customcode placeholders // check for customcode placeholders
if (strpos($code, '$$$$') !== false) // we do not add GUI wrapper placeholder to code
{ // that already has any customcode placeholders
// we do not add GUI wrapper placeholder to code return strpos($code, '$$$$') === false;
// that already has any customcode placeholders
return false;
}
return true;
} }
} }

View File

@ -56,7 +56,7 @@ class Hash
public function set(string $script): string public function set(string $script): string
{ {
// check if we should hash a string // check if we should hash a string
if (\strpos($script, 'HASH' . 'STRING((((') !== false) if (strpos($script, 'HASH' . 'STRING((((') !== false)
{ {
// get the strings // get the strings
$values = GetHelper::allBetween( $values = GetHelper::allBetween(
@ -67,14 +67,14 @@ class Hash
foreach ($values as $value) foreach ($values as $value)
{ {
$locker['HASH' . 'STRING((((' . $value . '))))'] $locker['HASH' . 'STRING((((' . $value . '))))']
= \md5($value); = md5((string) $value);
} }
// update the script // update the script
return $this->placeholder->update($script, $locker); return $this->placeholder->update($script, $locker);
} }
// check if we should hash a file // check if we should hash a file
if (\strpos($script, 'HASH' . 'FILE((((') !== false) if (strpos($script, 'HASH' . 'FILE((((') !== false)
{ {
// get the strings // get the strings
$values = GetHelper::allBetween( $values = GetHelper::allBetween(
@ -89,7 +89,7 @@ class Hash
{ {
// now we hash the file content // now we hash the file content
$locker['HASH' . 'FILE((((' . $path . '))))'] $locker['HASH' . 'FILE((((' . $path . '))))']
= \md5($value); = md5((string) $value);
} }
else else
{ {

View File

@ -69,8 +69,8 @@ class LockBase implements LockBaseInterface
$locker['LOCK'.'BASE64((((' . $value . '))))'] $locker['LOCK'.'BASE64((((' . $value . '))))']
= "base64_decode( preg_replace('/\s+/', ''," . = "base64_decode( preg_replace('/\s+/', ''," .
PHP_EOL . Indent::_(2) . "'" . PHP_EOL . Indent::_(2) . "'" .
\wordwrap( wordwrap(
\base64_encode($value), 64, PHP_EOL . Indent::_(2), true base64_encode((string) $value), 64, PHP_EOL . Indent::_(2), true
) . ) .
"'))"; "'))";
} }

View File

@ -144,7 +144,7 @@ class InstallScript implements GetScriptInterface
else else
{ {
// get the flight key // get the flight key
$flight = str_replace('php_', '', $method); $flight = str_replace('php_', '', (string) $method);
// load the script to our bucket // load the script to our bucket
$this->{$flight . 'Bucket'}[$type][] = $extension->{$method . '_' . $type}; $this->{$flight . 'Bucket'}[$type][] = $extension->{$method . '_' . $type};
// show that the method is active // show that the method is active

View File

@ -102,8 +102,8 @@ class Customcode
= true; = true;
} }
if (strpos($field->javascript_view_footer, "token") !== false if (strpos((string) $field->javascript_view_footer, "token") !== false
|| strpos($field->javascript_view_footer, "task=ajax") !== false) || strpos((string) $field->javascript_view_footer, "task=ajax") !== false)
{ {
if (!isset($this->dispenser->hub['token'])) if (!isset($this->dispenser->hub['token']))
{ {
@ -182,8 +182,8 @@ class Customcode
{ {
$field->javascript_views_footer_decoded = true; $field->javascript_views_footer_decoded = true;
} }
if (strpos($field->javascript_views_footer, "token") !== false if (strpos((string) $field->javascript_views_footer, "token") !== false
|| strpos($field->javascript_views_footer, "task=ajax") !== false) || strpos((string) $field->javascript_views_footer, "task=ajax") !== false)
{ {
if (!isset($this->dispenser->hub['token'])) if (!isset($this->dispenser->hub['token']))
{ {

View File

@ -196,7 +196,7 @@ class Data
$field->type = $field->fieldtype; $field->type = $field->fieldtype;
// load the values form params // load the values form params
$field->xml = $this->customcode->update(json_decode($field->xml)); $field->xml = $this->customcode->update(json_decode((string) $field->xml));
// check if we have validate (validation rule and set it if found) // check if we have validate (validation rule and set it if found)
$this->validation->set($id, $field->xml); $this->validation->set($id, $field->xml);
@ -204,7 +204,7 @@ class Data
// load the type values form type params // load the type values form type params
$field->properties = (isset($field->properties) $field->properties = (isset($field->properties)
&& JsonHelper::check($field->properties)) && JsonHelper::check($field->properties))
? json_decode($field->properties, true) : null; ? json_decode((string) $field->properties, true) : null;
if (ArrayHelper::check($field->properties)) if (ArrayHelper::check($field->properties))
{ {
$field->properties = array_values($field->properties); $field->properties = array_values($field->properties);
@ -243,13 +243,13 @@ class Data
)) ))
{ {
$field->initiator_save_key = md5( $field->initiator_save_key = md5(
$field->initiator_on_save_model (string) $field->initiator_on_save_model
); );
$field->initiator_save = explode( $field->initiator_save = explode(
PHP_EOL, $this->placeholder->update_( PHP_EOL, $this->placeholder->update_(
$this->customcode->update( $this->customcode->update(
base64_decode( base64_decode(
$field->initiator_on_save_model (string) $field->initiator_on_save_model
) )
) )
) )
@ -260,13 +260,13 @@ class Data
)) ))
{ {
$field->initiator_get_key = md5( $field->initiator_get_key = md5(
$field->initiator_on_get_model (string) $field->initiator_on_get_model
); );
$field->initiator_get = explode( $field->initiator_get = explode(
PHP_EOL, $this->placeholder->update_( PHP_EOL, $this->placeholder->update_(
$this->customcode->update( $this->customcode->update(
base64_decode( base64_decode(
$field->initiator_on_get_model (string) $field->initiator_on_get_model
) )
) )
) )
@ -276,14 +276,14 @@ class Data
$field->model_field['save'] = explode( $field->model_field['save'] = explode(
PHP_EOL, $this->placeholder->update_( PHP_EOL, $this->placeholder->update_(
$this->customcode->update( $this->customcode->update(
base64_decode($field->on_save_model_field) base64_decode((string) $field->on_save_model_field)
) )
) )
); );
$field->model_field['get'] = explode( $field->model_field['get'] = explode(
PHP_EOL, $this->placeholder->update_( PHP_EOL, $this->placeholder->update_(
$this->customcode->update( $this->customcode->update(
base64_decode($field->on_get_model_field) base64_decode((string) $field->on_get_model_field)
) )
) )
); );

View File

@ -88,7 +88,7 @@ class CoreValidation implements CoreValidationInterface
} }
// remove the Rule.php from the name // remove the Rule.php from the name
$this->rules = array_map( function ($name) { $this->rules = array_map( function ($name): string {
return str_replace(array('./','Rule.php'), '', $name); return str_replace(array('./','Rule.php'), '', $name);
}, $rules); }, $rules);
} }
@ -99,7 +99,7 @@ class CoreValidation implements CoreValidationInterface
// check if the names should be all lowercase // check if the names should be all lowercase
if ($lowercase) if ($lowercase)
{ {
return array_map( function($item) { return array_map( function($item): string {
return strtolower($item); return strtolower($item);
}, $this->rules); }, $this->rules);
} }

View File

@ -53,7 +53,7 @@ class TypeName
)) ))
{ {
// search for own custom fields // search for own custom fields
if (strpos($field['settings']->type_name, '@') !== false) if (strpos((string) $field['settings']->type_name, '@') !== false)
{ {
// set own custom field // set own custom field
$field['settings']->own_custom = $field['settings']->type_name; $field['settings']->own_custom = $field['settings']->type_name;
@ -66,8 +66,8 @@ class TypeName
); );
// if custom (we must use the xml value) // if custom (we must use the xml value)
if (strtolower($type_name) === 'custom' if (strtolower((string) $type_name) === 'custom'
|| strtolower($type_name) === 'customuser') || strtolower((string) $type_name) === 'customuser')
{ {
$type = TypeHelper::safe( $type = TypeHelper::safe(
GetHelper::between( GetHelper::between(

View File

@ -133,7 +133,7 @@ class Validation
$this->placeholder->update_( $this->placeholder->update_(
$this->customcode->update( $this->customcode->update(
base64_decode( base64_decode(
$php_code (string) $php_code
) )
) )
), ),

View File

@ -166,7 +166,7 @@ class History implements HistoryInterface
// check the note // check the note
if (JsonHelper::check($object->version_note)) if (JsonHelper::check($object->version_note))
{ {
$version_note = json_decode($object->version_note, true); $version_note = json_decode((string) $object->version_note, true);
} }
else else
{ {
@ -183,7 +183,7 @@ class History implements HistoryInterface
)) !== false) )) !== false)
{ {
// last version that was used to build/compile // last version that was used to build/compile
$this->tmp = json_decode($object->version_data); $this->tmp = json_decode((string) $object->version_data);
// remove it from this component // remove it from this component
unset($version_note['component'][$key]); unset($version_note['component'][$key]);
} }

View File

@ -104,13 +104,8 @@ class Extractor
{ {
// get targets to search for // get targets to search for
$lang_string_targets = array_filter( $lang_string_targets = array_filter(
$this->config->lang_string_targets, function ($get) use ($content) { $this->config->lang_string_targets, function ($get) use ($content): bool {
if (strpos($content, $get) !== false) return strpos($content, $get) !== false;
{
return true;
}
return false;
} }
); );
// check if we should continue // check if we should continue

View File

@ -100,12 +100,7 @@ class Placeholder implements PlaceholderInterface
*/ */
public function exist(string $key): bool public function exist(string $key): bool
{ {
if (isset($this->active[$key]) || $this->exist_($key) || $this->exist_h($key)) return isset($this->active[$key]) || $this->exist_($key) || $this->exist_h($key);
{
return true;
}
return false;
} }
/** /**
@ -193,11 +188,7 @@ class Placeholder implements PlaceholderInterface
*/ */
public function exist_(string $key): bool public function exist_(string $key): bool
{ {
if (isset($this->active[Placefix::_($key)])) return isset($this->active[Placefix::_($key)]);
{
return true;
}
return false;
} }
/** /**
@ -274,11 +265,7 @@ class Placeholder implements PlaceholderInterface
*/ */
public function exist_h(string $key): bool public function exist_h(string $key): bool
{ {
if (isset($this->active[Placefix::_h($key)])) return isset($this->active[Placefix::_h($key)]);
{
return true;
}
return false;
} }
/** /**
@ -401,7 +388,7 @@ class Placeholder implements PlaceholderInterface
elseif (2 == $action) // <-- check if data string has placeholders elseif (2 == $action) // <-- check if data string has placeholders
{ {
$replace = false; $replace = false;
foreach ($placeholder as $key => $val) foreach (array_keys($placeholder) as $key)
{ {
if (strpos($data, $key) !== false) if (strpos($data, $key) !== false)
{ {
@ -410,7 +397,7 @@ class Placeholder implements PlaceholderInterface
} }
} }
// only replace if the data has these placeholder values // only replace if the data has these placeholder values
if ($replace === true) if ($replace)
{ {
return str_replace( return str_replace(
array_keys($placeholder), array_values($placeholder), $data array_keys($placeholder), array_values($placeholder), $data
@ -420,7 +407,7 @@ class Placeholder implements PlaceholderInterface
elseif (3 == $action) // <-- remove placeholders not in data string elseif (3 == $action) // <-- remove placeholders not in data string
{ {
$replace = $placeholder; $replace = $placeholder;
foreach ($replace as $key => $val) foreach (array_keys($replace) as $key)
{ {
if (strpos($data, $key) === false) if (strpos($data, $key) === false)
{ {

View File

@ -99,7 +99,7 @@ class Reverse
{ {
// get local code if set // get local code if set
if ($id > 0 && $code = base64_decode( if ($id > 0 && $code = base64_decode(
GetHelper::var($table, $id, 'id', $field) (string) GetHelper::var($table, $id, 'id', $field)
)) ))
{ {
$string = $this->setReverse( $string = $this->setReverse(
@ -124,13 +124,9 @@ class Reverse
{ {
// get targets to search for // get targets to search for
$lang_string_targets = array_filter( $lang_string_targets = array_filter(
$this->config->lang_string_targets, function ($get) use ($string) { $this->config->lang_string_targets,
if (strpos($string, $get) !== false) function ($get) use ($string) : bool {
{ return strpos($string, $get) !== false;
return true;
}
return false;
} }
); );
// check if we should continue // check if we should continue

View File

@ -297,7 +297,7 @@ class Power implements PowerInterface
$this->placeholder->update_( $this->placeholder->update_(
$this->customcode->update( $this->customcode->update(
base64_decode( base64_decode(
$this->active[$guid]->licensing_template (string) $this->active[$guid]->licensing_template
) )
) )
), ),
@ -321,7 +321,7 @@ class Power implements PowerInterface
$this->placeholder->update_( $this->placeholder->update_(
$this->customcode->update( $this->customcode->update(
base64_decode( base64_decode(
$this->active[$guid]->head (string) $this->active[$guid]->head
) )
) )
), ),
@ -351,7 +351,7 @@ class Power implements PowerInterface
$this->placeholder->update_( $this->placeholder->update_(
$this->customcode->update( $this->customcode->update(
base64_decode( base64_decode(
$this->active[$guid]->main_class_code (string) $this->active[$guid]->main_class_code
) )
) )
), ),
@ -391,10 +391,10 @@ class Power implements PowerInterface
* *
* @param string $guid The global unique id of the power * @param string $guid The global unique id of the power
* *
* @return void * @return bool
* @since 3.2.0 * @since 3.2.0
*/ */
protected function setNamespace(string $guid) protected function setNamespace(string $guid): bool
{ {
// set namespace // set namespace
$this->active[$guid]->namespace = $this->placeholder->update_( $this->active[$guid]->namespace = $this->placeholder->update_(
@ -407,7 +407,7 @@ class Power implements PowerInterface
// we raise an error message // we raise an error message
$this->app->enqueueMessage( $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', 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, ucfirst((string) $this->active[$guid]->type), $this->active[$guid]->name, $this->active[$guid]->namespace,
'"https://www.php-fig.org/psr/psr-4/" target="_blank"', $this->active[$guid]->type, '"https://www.php-fig.org/psr/psr-4/" target="_blank"', $this->active[$guid]->type,
$this->fixUrl), $this->fixUrl),
'Error' 'Error'
@ -429,7 +429,7 @@ class Power implements PowerInterface
// we raise an error message // we raise an error message
$this->app->enqueueMessage( $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', 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, ucfirst((string) $this->active[$guid]->type), $this->active[$guid]->name, $this->active[$guid]->namespace,
'"https://www.php-fig.org/psr/psr-4/" target="_blank"', $this->active[$guid]->type, '"https://www.php-fig.org/psr/psr-4/" target="_blank"', $this->active[$guid]->type,
$this->fixUrl), $this->fixUrl),
'Error' 'Error'
@ -472,7 +472,7 @@ class Power implements PowerInterface
// we raise an error message // we raise an error message
$this->app->enqueueMessage( $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', 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, ucfirst((string) $this->active[$guid]->type), $this->active[$guid]->name, $this->active[$guid]->type, $this->active[$guid]->class_name, $this->active[$guid]->file_name,
'"https://www.php-fig.org/psr/psr-4/" target="_blank"', '"https://www.php-fig.org/psr/psr-4/" target="_blank"',
$this->fixUrl), $this->fixUrl),
'Error' 'Error'
@ -533,20 +533,13 @@ class Power implements PowerInterface
$this->active[$guid]->use_selection = (isset($this->active[$guid]->use_selection) $this->active[$guid]->use_selection = (isset($this->active[$guid]->use_selection)
&& JsonHelper::check( && JsonHelper::check(
$this->active[$guid]->use_selection $this->active[$guid]->use_selection
)) ? json_decode($this->active[$guid]->use_selection, true) : null; )) ? json_decode((string) $this->active[$guid]->use_selection, true) : null;
if ($this->active[$guid]->use_selection) if ($this->active[$guid]->use_selection)
{ {
$use = array_values(array_map(function ($u) use(&$as) { $use = array_values(array_map(function ($u) use(&$as) {
// track the AS options // track the AS options
if (empty($u['as'])) $as[$u['use']] = empty($u['as']) ? 'default' : (string) $u['as'];
{
$as[$u['use']] = 'default';
}
else
{
$as[$u['use']] = (string) $u['as'];
}
// return the guid // return the guid
return $u['use']; return $u['use'];
}, $this->active[$guid]->use_selection)); }, $this->active[$guid]->use_selection));
@ -567,7 +560,7 @@ class Power implements PowerInterface
$this->active[$guid]->load_selection = (isset($this->active[$guid]->load_selection) $this->active[$guid]->load_selection = (isset($this->active[$guid]->load_selection)
&& JsonHelper::check( && JsonHelper::check(
$this->active[$guid]->load_selection $this->active[$guid]->load_selection
)) ? json_decode($this->active[$guid]->load_selection, true) : null; )) ? json_decode((string) $this->active[$guid]->load_selection, true) : null;
if ($this->active[$guid]->load_selection) if ($this->active[$guid]->load_selection)
{ {
@ -594,7 +587,7 @@ class Power implements PowerInterface
$_composer = (isset($this->active[$guid]->composer) $_composer = (isset($this->active[$guid]->composer)
&& JsonHelper::check( && JsonHelper::check(
$this->active[$guid]->composer $this->active[$guid]->composer
)) ? json_decode($this->active[$guid]->composer, true) : null; )) ? json_decode((string) $this->active[$guid]->composer, true) : null;
unset($this->active[$guid]->composer); unset($this->active[$guid]->composer);
@ -602,46 +595,44 @@ class Power implements PowerInterface
{ {
foreach ($_composer as $composer) foreach ($_composer as $composer)
{ {
if (isset($composer['access_point']) && StringHelper::check($composer['access_point'])) if (isset($composer['access_point']) && StringHelper::check($composer['access_point']) &&
isset($composer['namespace']) && ArrayHelper::check($composer['namespace']))
{ {
if (isset($composer['namespace']) && ArrayHelper::check($composer['namespace'])) foreach ($composer['namespace'] as $_namespace)
{ {
foreach ($composer['namespace'] as $_namespace) // make sure we have a valid namespace
if (isset($_namespace['use']) && StringHelper::check($_namespace['use']) &&
strpos((string) $_namespace['use'], '\\') !== false)
{ {
// make sure we have a valid namespace // add the namespace to this access point
if (isset($_namespace['use']) && StringHelper::check($_namespace['use']) && $as = 'default';
strpos($_namespace['use'], '\\') !== false) if (strpos((string) $_namespace['use'], ' as ') !== false)
{ {
// add the namespace to this access point $namespace_as = explode(' as ', (string) $_namespace['use']);
$as = 'default'; // make sure the AS value is set
if (strpos($_namespace['use'], ' as ') !== false) if (count($namespace_as) == 2)
{ {
$namespace_as = explode(' as ', $_namespace['use']); $as = trim(trim($namespace_as[1], ';'));
// make sure the AS value is set
if (count($namespace_as) == 2)
{
$as = trim(trim($namespace_as[1], ';'));
}
$namespace = $this->getCleanNamespace($namespace_as[0], false);
} }
else $namespace = $this->getCleanNamespace($namespace_as[0], false);
{
// trim possible use or ; added to the namespace
$namespace = $this->getCleanNamespace($_namespace['use'], false);
}
// check if still valid
if (!StringHelper::check($namespace))
{
continue;
}
// add to the header of the class
$this->addToHeader($guid, $this->getUseNamespace($namespace, $as));
// add composer namespaces for autoloader
$this->composer[$namespace] = $composer['access_point'];
} }
else
{
// trim possible use or ; added to the namespace
$namespace = $this->getCleanNamespace($_namespace['use'], false);
}
// check if still valid
if (!StringHelper::check($namespace))
{
continue;
}
// add to the header of the class
$this->addToHeader($guid, $this->getUseNamespace($namespace, $as));
// add composer namespaces for autoloader
$this->composer[$namespace] = $composer['access_point'];
} }
} }
} }
@ -667,7 +658,7 @@ class Power implements PowerInterface
$this->active[$guid]->implements = (isset($this->active[$guid]->implements) $this->active[$guid]->implements = (isset($this->active[$guid]->implements)
&& JsonHelper::check( && JsonHelper::check(
$this->active[$guid]->implements $this->active[$guid]->implements
)) ? json_decode($this->active[$guid]->implements, true) : null; )) ? json_decode((string) $this->active[$guid]->implements, true) : null;
if ($this->active[$guid]->implements) if ($this->active[$guid]->implements)
{ {
@ -820,7 +811,7 @@ class Power implements PowerInterface
{ {
// check if it is already added manually // check if it is already added manually
if (isset($this->active[$guid]->head) && if (isset($this->active[$guid]->head) &&
strpos($this->active[$guid]->head, $string) === false) strpos((string) $this->active[$guid]->head, $string) === false)
{ {
$this->active[$guid]->head .= $string . PHP_EOL; $this->active[$guid]->head .= $string . PHP_EOL;
} }

View File

@ -166,10 +166,10 @@ class Infusion
if (StringHelper::check($power->description)) if (StringHelper::check($power->description))
{ {
// check if this is escaped // check if this is escaped
if (strpos($power->description, '/*') === false) if (strpos((string) $power->description, '/*') === false)
{ {
// make this description escaped // make this description escaped
$power->description = '/**' . PHP_EOL . ' * ' . implode(PHP_EOL . ' * ', explode(PHP_EOL, $power->description)) . PHP_EOL . ' */'; $power->description = '/**' . PHP_EOL . ' * ' . implode(PHP_EOL . ' * ', explode(PHP_EOL, (string) $power->description)) . PHP_EOL . ' */';
} }
$code[] = PHP_EOL . $power->description; $code[] = PHP_EOL . $power->description;
} }

View File

@ -61,7 +61,7 @@ class Registry extends BaseRegistry
// convert all array to [] // convert all array to []
$array = preg_split("/\r\n|\n|\r/", $data); $array = preg_split("/\r\n|\n|\r/", $data);
$array = preg_replace(["/\s*array\s\($/", "/\)(,)?$/", "/\s=>\s$/"], [NULL, ']$1', ' => ['], $array); $array = preg_replace(["/\s*array\s\($/", "/\)(,)?$/", "/\s=>\s$/"], [NULL, ']$1', ' => ['], $array);
$data = join(PHP_EOL, array_filter(["["] + $array)); $data = implode(PHP_EOL, array_filter(["["] + $array));
// add needed indentation to the last ] // add needed indentation to the last ]
$data = preg_replace("/^(\])/m", Indent::_($default) . '$1', $data); $data = preg_replace("/^(\])/m", Indent::_($default) . '$1', $data);
@ -88,7 +88,7 @@ class Registry extends BaseRegistry
// update each found space (group) with one indentation // update each found space (group) with one indentation
foreach (range(1, 11) as $space) foreach (range(1, 11) as $space)
{ {
if (strlen($matches[$space]) > 0) if (strlen((string) $matches[$space]) > 0)
{ {
$indent .= Indent::_(1); $indent .= Indent::_(1);
} }

View File

@ -0,0 +1,72 @@
<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 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\Database\Load;
use VDM\Joomla\Componentbuilder\Database\Insert;
/**
* Database Service Provider
*
* @since 3.2.0
*/
class Database implements ServiceProviderInterface
{
/**
* Registers the service provider with a DI container.
*
* @param Container $container The DI container.
*
* @return void
* @since 3.2.0
*/
public function register(Container $container)
{
$container->alias(Load::class, 'Load')
->share('Load', [$this, 'getLoad'], true);
$container->alias(Insert::class, 'Insert')
->share('Insert', [$this, 'getInsert'], true);
}
/**
* Get the Core Load Database
*
* @param Container $container The DI container.
*
* @return Load
* @since 3.2.0
*/
public function getLoad(Container $container): Load
{
return new Load();
}
/**
* Get the Core Insert Database
*
* @param Container $container The DI container.
*
* @return Insert
* @since 3.2.0
*/
public function getInsert(Container $container): Insert
{
return new Insert();
}
}

View File

@ -0,0 +1,58 @@
<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace VDM\Joomla\Componentbuilder\Compiler\Service;
use Joomla\DI\Container;
use Joomla\DI\ServiceProviderInterface;
use VDM\Joomla\Componentbuilder\Server\Model\Load as ServerLoad;
/**
* Model Service Provider
*
* @since 3.2.0
*/
class Model implements ServiceProviderInterface
{
/**
* Registers the service provider with a DI container.
*
* @param Container $container The DI container.
*
* @return void
* @since 3.2.0
*/
public function register(Container $container)
{
$container->alias(ServerLoad::class, 'Model.Server.Load')
->share('Model.Server.Load', [$this, 'getServerLoad'], true);
}
/**
* Get the Server Model Server Loader class
*
* @param Container $container The DI container.
*
* @return ServerLoad
* @since 3.2.0
*/
public function getServerLoad(Container $container): ServerLoad
{
return new ServerLoad(
$container->get('Crypt'),
$container->get('Table')
);
}
}

View File

@ -51,9 +51,9 @@ abstract class Path
} }
} }
// if just a string // if just a string
elseif (StringHelper::check($values) && strpos($values, '\\') !== false) elseif (StringHelper::check($values) && strpos((string) $values, '\\') !== false)
{ {
$values = str_replace('\\', '/', $values); $values = str_replace('\\', '/', (string) $values);
} }
} }

View File

@ -0,0 +1,153 @@
<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace VDM\Joomla\Componentbuilder;
use VDM\Joomla\Componentbuilder\Crypt\FOF;
use VDM\Joomla\Componentbuilder\Crypt\Password;
/**
* Crypto Class
*
* @since 3.2.0
*/
class Crypt
{
/**
* The Crypt AES FOF class
* replacement class
*
* @var FOF
* @since 3.2.0
*/
protected FOF $fof;
/**
* The Password class
*
* @var Password
* @since 3.2.0
*/
protected Password $password;
/**
* Active encryption options
*
* @var array
* @since 3.2.0
*/
protected array $options = ['basic' => true, 'medium' => true];
/**
* Active passwords
*
* @var array
* @since 3.2.0
*/
protected array $passwords = ['basic' => null, 'medium' => null];
/**
* Constructor
*
* @param FOF $fof The FOF class
* @param Password $password The Password class
*
* @since 3.2.0
*/
public function __construct(FOF $fof, Password $password)
{
$this->fof = $fof;
$this->password = $password;
}
/**
* Encrypt a string as needed
*
* @param string $string The string to encrypt
* @param string $method The encryption method to use
* @param string|null $default The default password
*
* @return string
* @since 3.2.0
**/
public function encrypt(string $string, string $method,
?string $default = null): string
{
if (($password = $this->getPassword($method, $default)) !== null)
{
return $this->fof->encrypt($string, $password);
}
return $string;
}
/**
* Decrypt a string as needed
*
* @param string $string The string to decrypt
* @param string $method The encryption method to use
* @param string|null $default The default password
*
* @return string
* @since 3.2.0
**/
public function decrypt(string $string, string $method,
?string $default = null): string
{
if (($password = $this->getPassword($method, $default)) !== null)
{
return $this->fof->decrypt($string, $password);
}
return $string;
}
/**
* Check if a decryption method exist and is supported
*
* @param string $method The encryption method to find
*
* @return bool true it it exist
* @since 3.2.0
**/
public function exist(string $method): bool
{
return $this->options[$method] ?? false;
}
/**
* Get the password
*
* @param string $method The encryption method to find
* @param string|null $default The default password
*
* @return string|null the password or null
* @since 3.2.0
**/
protected function getPassword(string $method, ?string $default = null): ?string
{
if ($this->exist($method))
{
if (empty($this->passwords[$method]))
{
$this->passwords[$method] = $this->password->get($method, $default);
}
return $this->passwords[$method];
}
return null;
}
}

View File

@ -0,0 +1,204 @@
<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace VDM\Joomla\Componentbuilder\Crypt;
use phpseclib3\Crypt\AES;
use VDM\Joomla\Componentbuilder\Crypt\Random;
use VDM\Joomla\Componentbuilder\Interfaces\Cryptinterface;
/**
* Replacement Class for FOFEncryptAes
*
* @since 3.2.0
*/
class FOF implements Cryptinterface
{
/**
* The Aes class
*
* @var AES
* @since 3.2.0
*/
protected AES $aes;
/**
* The Random class
*
* @var Random
* @since 3.2.0
*/
protected Random $random;
/**
* The block size
*
* @var int
* @since 3.2.0
*/
protected int $size = 128;
/**
* Constructor
*
* @param AES $aes The Aes class
* @param Random $random The Random class
*
* @since 3.2.0
*/
public function __construct(AES $aes, Random $random)
{
$this->aes = $aes;
$this->random = $random;
// we set the length once
$this->aes->setKeyLength($this->size);
}
/**
* Encrypt a string as needed
*
* @param string $string The string to encrypt
* @param string $key The encryption key
*
* @return string
* @since 3.2.0
**/
public function encrypt(string $string, string $key): string
{
// we get the IV length
$iv_length = (int) $this->aes->getBlockLength() >> 3;
// get the IV value
$iv = $this->random::string($iv_length);
// Load the IV
$this->aes->setIV($iv);
// load the key
$this->aes->setKey($this->getExpandedKey($key, $iv_length, $iv));
// encrypt the string, and base 64 encode the result
return base64_encode($iv . $this->aes->encrypt($string));
}
/**
* Decrypt a string as needed
*
* @param string $string The string to decrypt
* @param string $key The decryption key
*
* @return string
* @since 3.2.0
**/
public function decrypt(string $string, string $key): string
{
// we get the IV length
$iv_length = (int) $this->aes->getBlockLength() >> 3;
// remove base 64 encoding
$string = base64_decode($string);
// get the IV
$iv = substr($string, 0, $iv_length);
// remove the IV
$string = substr($string, $iv_length);
// set the key
$this->aes->setKey($this->getExpandedKey($key, $iv_length, $iv));
// set the IV
$this->aes->setIV($iv);
return $this->aes->decrypt($string);
}
/**
* Function taken from FOFEncryptAes
* changed a little but basically the same
* to ensure we get the same passwords (not ideal)
* we should use `$this->aes->setPassword(...)` instead
* but can't for backwards compatibility issues with already encrypted string
*
* @param string $key The key to expand
* @param int $blockSize The size of the block
* @param string $iv The IV used
*
* @return string
* @since 3.2.0
*/
protected function getExpandedKey(string $key, int $blockSize, string $iv): string
{
$pass_length = strlen($key);
if (function_exists('mb_strlen'))
{
$pass_length = mb_strlen($key, 'ASCII');
}
if ($pass_length != $blockSize)
{
$iterations = 1000;
$salt = $this->resizeKey($iv, 16);
$key = hash_pbkdf2('sha256', $key, $salt, $iterations, $blockSize, true);
}
return $key;
}
/**
* Function taken from FOFEncryptAes
* changed a little but basically the same
* to ensure we get the same passwords (not ideal)
* we should use `$this->aes->setPassword(...)` instead
* but can't for backwards compatibility issues with already encrypted string
*
* @param string $key The key to resize
* @param int $size The size of the block
*
* @return string|null
* @since 3.2.0
*/
protected function resizeKey(string $key, int $size): ?string
{
if (empty($key))
{
return null;
}
$key_length = strlen($key);
if (function_exists('mb_strlen'))
{
$key_length = mb_strlen($key, 'ASCII');
}
if ($key_length == $size)
{
return $key;
}
if ($key_length > $size)
{
if (function_exists('mb_substr'))
{
return mb_substr($key, 0, $size, 'ASCII');
}
return substr($key, 0, $size);
}
return $key . str_repeat("\0", ($size - $key_length));
}
}

View File

@ -0,0 +1,26 @@
<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace VDM\Joomla\Componentbuilder\Crypt;
use phpseclib3\Crypt\PublicKeyLoader;
/**
* KeyLoader Class
*
* @since 3.2.0
*/
class KeyLoader extends PublicKeyLoader
{
}

View File

@ -0,0 +1,46 @@
<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace VDM\Joomla\Componentbuilder\Crypt;
use VDM\Joomla\Utilities\Component\Helper;
/**
* Password Class
*
* @since 3.2.0
*/
class Password
{
/**
* Get the type of password
* Example: $this->get('basic', 'default-password');
*
* @param string $type The value of password to get
* @param string|null $default The default password if the type is not found
*
* @return string|null
* @since 3.2.0
*/
public function get(string $type, ?string $default = null): ?string
{
if (($password = Helper::_('getCryptKey', [$type, $default])) !== null)
{
return $password;
}
return $default;
}
}

View File

@ -0,0 +1,26 @@
<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace VDM\Joomla\Componentbuilder\Crypt;
use phpseclib3\Crypt\Random as CryptRandom;
/**
* Random Class
*
* @since 3.2.0
*/
class Random extends CryptRandom
{
}

View File

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

View File

@ -194,14 +194,7 @@ class Insert extends Database implements InsertInterface
// load only what is part of the columns set // load only what is part of the columns set
foreach ($columns as $key) foreach ($columns as $key)
{ {
if (isset($value->{$key})) $row[] = isset($value->{$key}) ? $this->quote($value->{$key}) : '';
{
$row[] = $this->quote($value->{$key});
}
else
{
$row[] = '';
}
} }
// add to query // add to query

View File

@ -0,0 +1,43 @@
<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace VDM\Joomla\Componentbuilder\Interfaces;
/**
* The Crypt Interface
*/
interface Cryptinterface
{
/**
* Encrypt a string as needed
*
* @param string $string The string to encrypt
* @param string $key The encryption key
*
* @return string
* @since 3.2.0
**/
public function encrypt(string $string, string $key): string;
/**
* Decrypt a string as needed
*
* @param string $string The string to decrypt
* @param string $key The decryption key
*
* @return string
* @since 3.2.0
**/
public function decrypt(string $string, string $key): string;
}

View File

@ -0,0 +1,71 @@
<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace VDM\Joomla\Componentbuilder\Interfaces;
/**
* Model Interface
*
* @since 3.2.0
*/
interface ModelInterface
{
/**
* Model the value
* Example: $this->value(value, 'value_key', 'table_name');
*
* @param mixed $value The value to model
* @param string $field The field key
* @param string|null $table The table
*
* @return mixed
* @since 3.2.0
*/
public function value($value, string $field, ?string $table = null);
/**
* Model the values of an item
* Example: $this->item(Object, 'table_name');
*
* @param object $item The item object
* @param string|null $table The table
*
* @return object|null
* @since 3.2.0
*/
public function item(object $item, ?string $table = null): ?object;
/**
* Model the values of multiple items
* Example: $this->items(Array, 'table_name');
*
* @param array|null $items The array of item objects
* @param string|null $table The table
*
* @return array|null
* @since 3.2.0
*/
public function items(?array $items = null, ?string $table = null): ?array;
/**
* Get last modeled ID
* Example: $this->last('table_name');
*
* @param string|null $table The table
*
* @return int|null
* @since 3.2.0
*/
public function last(?string $table = null): ?int;
}

View File

@ -0,0 +1,42 @@
<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace VDM\Joomla\Componentbuilder\Interfaces;
/**
* The Core Server Interface
*/
interface Serverinterface
{
/**
* set the server details
*
* @param object $details The server details
*
* @return self
* @since 3.2.0
**/
public function set(object $details);
/**
* move a file to server with the FTP client
*
* @param string $localPath The full local path to the file
* @param string $fileName The file name
*
* @return bool
* @since 3.2.0
**/
public function move(string $localPath, string $fileName): bool;
}

View File

@ -172,7 +172,7 @@ class Insert
$success = true; $success = true;
foreach ($items as $item) foreach ($items as $item)
{ {
if ($this->item($item, $table) !== true) if (!$this->item($item, $table))
{ {
$success = false; $success = false;
break; break;

View File

@ -117,7 +117,7 @@ abstract class Engine
protected function lineCounter() protected function lineCounter()
{ {
// we count every line we search // we count every line we search
$this->config->line_counter = $this->config->line_counter + 1; $this->config->line_counter += 1;
} }
} }

View File

@ -404,8 +404,8 @@ class Agent
'&match_case=' . (int) $this->config->match_case . '&match_case=' . (int) $this->config->match_case .
'&whole_word=' . (int) $this->config->whole_word . '&whole_word=' . (int) $this->config->whole_word .
'&regex_search=' . (int) $this->config->regex_search . '&regex_search=' . (int) $this->config->regex_search .
'&search_value=' . (string) urlencode($this->config->search_value) . '&search_value=' . (string) urlencode((string) $this->config->search_value) .
'&replace_value=' . (string) urlencode($this->config->replace_value))); '&replace_value=' . (string) urlencode((string) $this->config->replace_value)));
} }
/** /**

View File

@ -167,51 +167,39 @@ class Search implements SearchInterface
// forth layer // forth layer
foreach ($ro as $k => $r) foreach ($ro as $k => $r)
{ {
if (StringHelper::check($r)) if (StringHelper::check($r) && ($_found = $this->string($r)) !== null)
{ {
if (($_found = $this->string($r)) !== null) foreach ($_found as $_n => $_f)
{ {
foreach ($_found as $_n => $_f) $found[$keys . '.' . $key . '.' . $ke . '.' . $k . '.' . $_n] = $_f;
{
$found[$keys . '.' . $key . '.' . $ke . '.' . $k . '.' . $_n] = $_f;
}
} }
} }
} }
} }
elseif (StringHelper::check($ro)) elseif (StringHelper::check($ro) && ($_found = $this->string($ro)) !== null)
{ {
if (($_found = $this->string($ro)) !== null) foreach ($_found as $_n => $_f)
{ {
foreach ($_found as $_n => $_f) $found[$keys. '.' . $key . '.' . $ke . '.' . $_n] = $_f;
{
$found[$keys. '.' . $key . '.' . $ke . '.' . $_n] = $_f;
}
} }
} }
} }
} }
elseif (StringHelper::check($row)) elseif (StringHelper::check($row) && ($_found = $this->string($row)) !== null)
{ {
if (($_found = $this->string($row)) !== null) foreach ($_found as $_n => $_f)
{ {
foreach ($_found as $_n => $_f) $found[$keys. '.' . $key . '.' . $_n] = $_f;
{
$found[$keys. '.' . $key . '.' . $_n] = $_f;
}
} }
} }
} }
} }
elseif (StringHelper::check($rows)) elseif (StringHelper::check($rows) && ($_found = $this->string($rows)) !== null)
{ {
if (($_found = $this->string($rows)) !== null) foreach ($_found as $_n => $_f)
{ {
foreach ($_found as $_n => $_f) $found[$keys. '.' . $_n] = $_f;
{
$found[$keys. '.' . $_n] = $_f;
}
} }
} }
} }
@ -308,7 +296,7 @@ class Search implements SearchInterface
protected function fieldCounter() protected function fieldCounter()
{ {
// we count every field we search // we count every field we search
$this->config->field_counter = $this->config->field_counter + 1; $this->config->field_counter += 1;
} }
} }

View File

@ -83,9 +83,9 @@ class Update
// the possibility of updating sub-forms in sub-forms // the possibility of updating sub-forms in sub-forms
if (ArrayHelper::check($value)) if (ArrayHelper::check($value))
{ {
if (strpos($line, '.') !== false) if (strpos((string) $line, '.') !== false)
{ {
$line = explode('.', $line); $line = explode('.', (string) $line);
} }
// first layer // first layer
foreach ($value as $keys => &$rows) foreach ($value as $keys => &$rows)

View File

@ -173,7 +173,7 @@ class Insert implements InsertInterface
$success = true; $success = true;
foreach ($items as $item) foreach ($items as $item)
{ {
if ($this->item($item, $table) !== true) if (!$this->item($item, $table))
{ {
$success = false; $success = false;
break; break;

View File

@ -75,7 +75,7 @@ class Insert extends Model implements ModelInterface
switch($store) switch($store)
{ {
case 'base64': case 'base64':
$value = base64_encode($value); $value = base64_encode((string) $value);
break; break;
case 'json': case 'json':
$value = json_encode($value, JSON_FORCE_OBJECT); $value = json_encode($value, JSON_FORCE_OBJECT);

View File

@ -77,13 +77,13 @@ class Load extends Model implements ModelInterface
switch($store) switch($store)
{ {
case 'base64': case 'base64':
$value = base64_decode($value); $value = base64_decode((string) $value);
break; break;
case 'json': case 'json':
// check if there is a json string // check if there is a json string
if (JsonHelper::check($value)) if (JsonHelper::check($value))
{ {
$value = json_decode($value, true); $value = json_decode((string) $value, true);
} }
break; break;
} }

View File

@ -0,0 +1,147 @@
<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace VDM\Joomla\Componentbuilder;
use Joomla\CMS\Factory as JoomlaFactory;
use Joomla\CMS\User\User;
use VDM\Joomla\Componentbuilder\Server\Load;
use VDM\Joomla\Componentbuilder\Server\Ftp;
use VDM\Joomla\Componentbuilder\Server\Sftp;
use VDM\Joomla\Utilities\StringHelper;
/**
* Server Class
*
* @since 3.2.0
*/
class Server
{
/**
* The Loader
*
* @var Load
* @since 3.2.0
*/
protected Load $load;
/**
* The Ftp object
*
* @var Ftp
* @since 3.2.0
**/
protected Ftp $ftp;
/**
* The Sftp object
*
* @var Sftp
* @since 3.2.0
**/
protected Sftp $sftp;
/**
* Current User object
*
* @var User
* @since 3.2.0
*/
protected User $user;
/**
* Constructor
*
* @param Load $load The server details loader object.
* @param Ftp $ftp The server ftp object.
* @param Sftp $sftp The server sftp object.
* @param User|null $user The user object.
*
* @since 3.2.0
*/
public function __construct(Load $load, Ftp $ftp, Sftp $sftp, ?User $user = null)
{
$this->load = $load;
$this->ftp = $ftp;
$this->sftp = $sftp;
$this->user = $user ?: JoomlaFactory::getUser();
}
/**
* Move File to Server
*
* @param int $id The server local id to use
* @param string $localPath The local path to the file
* @param string $fileName The actual file name
* @param int|null $protocol The protocol to use (if set)
* @param string $permission The permission validation area
*
* @return bool true on success
* @since 3.2.0
*/
public function move(int $id, string $localPath, string $fileName,
?int $protocol = null, string $permission = 'core.export'): bool
{
// get the server
if ($this->user->authorise($permission, 'com_componentbuilder') &&
(
(
is_numeric($protocol) &&
($protocol == 1 || $protocol == 2)
) || (
($protocol = $this->load->value($id, 'protocol')) !== null &&
($protocol == 1 || $protocol == 2)
)
)
)
{
// use the FTP protocol
if (1 == $protocol)
{
$protocol = 'ftp';
$fields = [
'name',
'signature'
];
}
// use the SFTP protocol
else
{
$protocol = 'sftp';
$fields = [
'name',
'authentication',
'username',
'host',
'password',
'path',
'port',
'private',
'private_key',
'secret'
];
}
// get the details
if (StringHelper::check($protocol) && ($details = $this->load->item($id, $fields)) !== null)
{
// now move the file
return $this->{$protocol}->set($details)->move($localPath, $fileName);
}
}
return false;
}
}

View File

@ -0,0 +1,139 @@
<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace VDM\Joomla\Componentbuilder\Server;
use Joomla\CMS\Client\FtpClient;
use VDM\Joomla\Utilities\StringHelper;
use VDM\Joomla\Utilities\ArrayHelper;
use VDM\Joomla\Componentbuilder\Interfaces\Serverinterface;
/**
* Ftp Class
*
* @since 3.2.0
*/
class Ftp implements Serverinterface
{
/**
* The client object
*
* @var FtpClient
* @since 3.2.0
**/
protected FtpClient $client;
/**
* The server details
*
* @var object
* @since 3.2.0
**/
protected object $details;
/**
* set the server details
*
* @param object $details The server details
*
* @return Ftp
* @since 3.2.0
**/
public function set(object $details): Ftp
{
// set the details
$this->details = $details;
return $this;
}
/**
* move a file to server with the FTP client
*
* @param string $localPath The full local path to the file
* @param string $fileName The file name
*
* @return bool
* @since 3.2.0
**/
public function move(string $localPath, string $fileName): bool
{
if ($this->connected())
{
return $this->client->store($localPath, $fileName);
}
return false;
}
/**
* Make sure we are connected
*
* @return bool
* @since 3.2.0
**/
protected function connected(): bool
{
// check if we have a connection
return ($this->client instanceof FtpClient && $this->client->isConnected()) ||
($this->client = $this->getClient()) !== null;
}
/**
* get the FtpClient object
*
* @return FtpClient|null
* @since 3.2.0
**/
protected function getClient(): ?FtpClient
{
// make sure we have a string and it is not default or empty
if (StringHelper::check($this->details->signature))
{
// turn into variables
parse_str((string) $this->details->signature);
// set options
if (isset($options) && ArrayHelper::check($options))
{
foreach ($options as $o__p0t1on => $vAln3)
{
if ('timeout' === $o__p0t1on)
{
$options[$o__p0t1on] = (int) $vAln3;
}
if ('type' === $o__p0t1on)
{
$options[$o__p0t1on] = (string) $vAln3;
}
}
}
else
{
$options = array();
}
// get ftp object
if (isset($host) && $host != 'HOSTNAME' &&
isset($port) && $port != 'PORT_INT' &&
isset($username) && $username != 'user@name.com' &&
isset($password) && $password != 'password')
{
// this is a singleton
return FtpClient::getInstance($host, $port, $options, $username, $password);
}
}
return null;
}
}

View File

@ -0,0 +1,122 @@
<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace VDM\Joomla\Componentbuilder\Server;
use VDM\Joomla\Componentbuilder\Compiler\Factory;
use VDM\Joomla\Componentbuilder\Database\Load as Database;
use VDM\Joomla\Componentbuilder\Server\Model\Load as Model;
/**
* Server Load Class
*
* @since 3.2.0
*/
class Load
{
/**
* Database Load
*
* @var Database
* @since 3.2.0
*/
protected Database $db;
/**
* Model Class
*
* @var Model
* @since 3.2.0
*/
protected Model $model;
/**
* Constructor
*
* @param Database|null $db The database object.
* @param Model|null $model The core crypt object.
*
* @since 3.2.0
*/
public function __construct(?Database $db = null, ?Model $model = null)
{
$this->db = $db ?: Factory::_('Load');
$this->model = $model ?: Factory::_('Model.Server.Load');
}
/**
* Get a value from a given server
* Example: $this->value(23, 'protocol');
*
* @param int $id The item ID
* @param string $field The table field
*
* @return object|null
* @since 3.2.0
*/
public function value(int $id, string $field): ?object
{
if ($id > 0 && ($value = $this->db->value(
$this->setDatabaseFields([$field]), ['a' => 'server'], ['a.id' => $id]
)) !== null)
{
return $this->model->value($value, $field, 'server');
}
return null;
}
/**
* Get values from a given server
* Example: $this->item(23, ['name', 'of', 'fields']);
*
* @param int $id The item ID
* @param array $fields The table fields
*
* @return object|null
* @since 3.2.0
*/
public function item(int $id, array $fields): ?object
{
if ($id > 0 && ($item = $this->db->item(
$this->setDatabaseFields($fields), ['a' => 'server'], ['a.id' => $id]
)) !== null)
{
return $this->model->item($item, 'server');
}
return null;
}
/**
* Set Fields ready to use in database call
*
* @param array $fields The table
* @param string $key The table key to which the fields belong
*
* @return array
* @since 3.2.0
*/
protected function setDatabaseFields(array $fields, string $key = 'a'): array
{
$bucket = [];
foreach ($fields as $field)
{
$bucket[$key . '.' . $field] = $field;
}
return $bucket;
}
}

View File

@ -0,0 +1,135 @@
<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace VDM\Joomla\Componentbuilder\Server\Model;
use Joomla\Registry\Registry;
use VDM\Joomla\Componentbuilder\Compiler\Factory;
use VDM\Joomla\Componentbuilder\Crypt;
use VDM\Joomla\Componentbuilder\Table;
use VDM\Joomla\Componentbuilder\Interfaces\ModelInterface;
use VDM\Joomla\Componentbuilder\Abstraction\Model;
/**
* Server Model Load Class
*
* @since 3.2.0
*/
class Load extends Model implements ModelInterface
{
/**
* Decryption Class
*
* @var Crypt
* @since 3.2.0
*/
protected Crypt $crypt;
/**
* Constructor
*
* @param Crypt|null $crypt The core crypt object.
* @param Table|null $table The search table object.
*
* @since 3.2.0
*/
public function __construct(?Crypt $crypt = null, ?Table $table = null)
{
parent::__construct($table ?? Factory::_('Table'));
$this->crypt = $crypt ?: Factory::_('Crypt');
}
/**
* Model the value
* Example: $this->value(value, 'value_key', 'table_name');
*
* @param mixed $value The value to model
* @param string $field The field key
* @param string|null $table The table
*
* @return mixed
* @since 3.2.0
*/
public function value($value, string $field, ?string $table = null)
{
// load the table
if (empty($table))
{
$table = $this->getTable();
}
// check if this is a valid table
if (StringHelper::check($value) && ($store = $this->table->get($table, $field, 'store')) !== null)
{
// open the value based on the store method
switch($store)
{
case 'basic_encryption':
$value = $this->crypt->decrypt($value, 'basic');
break;
case 'medium_encryption':
$value = $this->crypt->decrypt($value, 'medium');
break;
case 'base64':
$value = base64_decode((string) $value);
break;
case 'json':
// check if there is a json string
if (JsonHelper::check($value))
{
$registry = new Registry;
$registry->loadString($value);
$value = $registry->toArray();
}
break;
default:
if ($this->crypt->exist($store))
{
$value = $this->crypt->decrypt($value, $store);
}
break;
}
}
return $value;
}
/**
* Validate the values (basic, override in child class)
*
* @param mixed $value The field value
* @param string|null $field The field key
* @param string|null $table The table
*
* @return bool
* @since 3.2.0
*/
protected function validate(&$value, ?string $field = null, ?string $table = null): bool
{
// remove none
return true;
}
/**
* Get the current active table
*
* @return string
* @since 3.2.0
*/
protected function getTable(): string
{
return 'server';
}
}

View File

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

View File

@ -0,0 +1,185 @@
<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace VDM\Joomla\Componentbuilder\Server;
use phpseclib3\Net\SFTP as SftpClient;
use VDM\Joomla\Componentbuilder\Crypt\KeyLoader;
use VDM\Joomla\Utilities\StringHelper;
use VDM\Joomla\Utilities\FileHelper;
use VDM\Joomla\Componentbuilder\Interfaces\Serverinterface;
/**
* Sftp Class
*
* @since 3.2.0
*/
class Sftp implements Serverinterface
{
/**
* The KeyLoader
*
* @var KeyLoader
* @since 3.2.0
*/
protected KeyLoader $key;
/**
* The client object
*
* @var SftpClient
* @since 3.2.0
**/
protected SftpClient $client;
/**
* The server details
*
* @var object
* @since 3.2.0
**/
protected object $details;
/**
* Constructor
*
* @param KeyLoader $key The key loader object.
*
* @since 3.2.0
*/
public function __construct(KeyLoader $key)
{
$this->key = $key;
}
/**
* set the server details
*
* @param object $details The server details
*
* @return Sftp
* @since 3.2.0
**/
public function set(object $details): Sftp
{
// set the details
$this->details = $details;
return $this;
}
/**
* move a file to server with the FTP client
*
* @param string $localPath The full local path to the file
* @param string $fileName The file name
*
* @return bool
* @since 3.2.0
**/
public function move(string $localPath, string $fileName): bool
{
if ($this->connected() &&
($data = FileHelper::getContent($localPath, null)) !== null)
{
// get the remote path
$path = '';
if (isset($this->details->path) &&
StringHelper::check($this->details->path) &&
$this->details->path !== '/')
{
$path = '/' . trim((string) $this->details->path, '/');
}
return $this->client->put($path . '/' . $fileName, $data);
}
return false;
}
/**
* get the SftpClient object
*
* @return SftpClient|null
* @since 3.2.0
**/
protected function getClient(): ?SftpClient
{
// make sure we have a host value set
if (isset($this->details->host) && StringHelper::check($this->details->host) &&
isset($this->details->username) && StringHelper::check($this->details->username))
{
// insure the port is set
$port = (isset($this->details->port) && is_numeric($this->details->port) && $this->details->port > 0)
? (int) $this->details->port : 22;
// open the connection
$sftp = new SftpClient($this->details->host, $port);
// set the passphrase if it exist
$passphrase = $this->details->secret ?? null;
// set the password if it exist
$password = $this->details->password ?? null;
// now login based on authentication type
$key = null;
switch($this->details->authentication)
{
case 1: // password
$key = $this->details->password ?? null;
$password = null;
break;
case 2: // private key file
case 3: // both password and private key file
if (isset($this->details->private) && StringHelper::check($this->details->private) &&
($private_key = FileHelper::getContent($this->details->private, null)) !== null)
{
$key = $this->key::load($private_key, $passphrase);
}
break;
case 4: // private key field
case 5: // both password and private key field
if (isset($this->details->private_key) && StringHelper::check($this->details->private_key))
{
$key = $this->key::load($this->details->private_key, $passphrase);
}
break;
}
// login
if ((!empty($key) && !empty($password) && $sftp->login($this->details->username, $key, $password)) ||
(!empty($key) && $sftp->login($this->details->username, $key)))
{
return $sftp;
}
}
return null;
}
/**
* Make sure we are connected
*
* @return bool
* @since 3.2.0
**/
protected function connected(): bool
{
// check if we have a connection
return ($this->client instanceof SftpClient && ($this->client->isConnected() || $this->client->ping())) ||
($this->client = $this->getClient()) !== null;
}
}

View File

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

View File

@ -20,6 +20,8 @@ use phpseclib3\Crypt\DES;
use VDM\Joomla\Componentbuilder\Crypt as Crypto; use VDM\Joomla\Componentbuilder\Crypt as Crypto;
use VDM\Joomla\Componentbuilder\Crypt\KeyLoader; use VDM\Joomla\Componentbuilder\Crypt\KeyLoader;
use VDM\Joomla\Componentbuilder\Crypt\Random; use VDM\Joomla\Componentbuilder\Crypt\Random;
use VDM\Joomla\Componentbuilder\Crypt\Password;
use VDM\Joomla\Componentbuilder\Crypt\FOF;
/** /**
@ -45,6 +47,12 @@ class Crypt implements ServiceProviderInterface
$container->alias(Random::class, 'Crypt.Random') $container->alias(Random::class, 'Crypt.Random')
->share('Crypt.Random', [$this, 'getRandom'], true); ->share('Crypt.Random', [$this, 'getRandom'], true);
$container->alias(Password::class, 'Crypt.Password')
->share('Crypt.Password', [$this, 'getPassword'], true);
$container->alias(FOF::class, 'Crypt.FOF')
->share('Crypt.FOF', [$this, 'getFOF'], true);
$container->alias(KeyLoader::class, 'Crypt.Key') $container->alias(KeyLoader::class, 'Crypt.Key')
->share('Crypt.Key', [$this, 'getKeyLoader'], true); ->share('Crypt.Key', [$this, 'getKeyLoader'], true);
@ -93,7 +101,23 @@ class Crypt implements ServiceProviderInterface
*/ */
public function getCrypt(Container $container): Crypto public function getCrypt(Container $container): Crypto
{ {
return new Crypto(); return new Crypto(
$container->get('Crypt.FOF'),
$container->get('Crypt.Password')
);
}
/**
* Get the Password class
*
* @param Container $container The DI container.
*
* @return Password
* @since 3.2.0
*/
public function getPassword(Container $container): Password
{
return new Password();
} }
/** /**
@ -109,6 +133,22 @@ class Crypt implements ServiceProviderInterface
return new Random(); return new Random();
} }
/**
* Get the FOF AES Cyper with CBC mode
*
* @param Container $container The DI container.
*
* @return FOF
* @since 3.2.0
*/
public function getFOF(Container $container): FOF
{
return new FOF(
$container->get('Crypt.AES.CBC'),
$container->get('Crypt.Random')
);
}
/** /**
* Get the KeyLoader class * Get the KeyLoader class
* *

View File

@ -0,0 +1,114 @@
<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace VDM\Joomla\Componentbuilder\Service;
use Joomla\DI\Container;
use Joomla\DI\ServiceProviderInterface;
use VDM\Joomla\Componentbuilder\Server as Client;
use VDM\Joomla\Componentbuilder\Server\Load;
use VDM\Joomla\Componentbuilder\Server\Ftp;
use VDM\Joomla\Componentbuilder\Server\Sftp;
/**
* Server Service Provider
*
* @since 3.2.0
*/
class Server implements ServiceProviderInterface
{
/**
* Registers the service provider with a DI container.
*
* @param Container $container The DI container.
*
* @return void
* @since 3.2.0
*/
public function register(Container $container)
{
$container->alias(Client::class, 'Server')
->share('Server', [$this, 'getServer'], true);
$container->alias(Load::class, 'Server.Load')
->share('Server.Load', [$this, 'getServerLoad'], true);
$container->alias(Ftp::class, 'Server.FTP')
->share('Server.FTP', [$this, 'getServerFtp'], true);
$container->alias(Sftp::class, 'Server.SFTP')
->share('Server.SFTP', [$this, 'getServerSftp'], true);
}
/**
* Get the Server Client class
*
* @param Container $container The DI container.
*
* @return Client
* @since 3.2.0
*/
public function getServer(Container $container): Client
{
return new Client(
$container->get('Server.Load'),
$container->get('Server.FTP'),
$container->get('Server.SFTP')
);
}
/**
* Get the Server Load class
*
* @param Container $container The DI container.
*
* @return Load
* @since 3.2.0
*/
public function getServerLoad(Container $container): Load
{
return new Load(
$container->get('Load'),
$container->get('Model.Server.Load')
);
}
/**
* Get the Server Ftp class
*
* @param Container $container The DI container.
*
* @return Ftp
* @since 3.2.0
*/
public function getServerFtp(Container $container): Ftp
{
return new Ftp();
}
/**
* Get the Server Sftp class
*
* @param Container $container The DI container.
*
* @return Sftp
* @since 3.2.0
*/
public function getServerSftp(Container $container): Sftp
{
return new Sftp(
$container->get('Crypt.Key')
);
}
}

View File

@ -85,7 +85,7 @@ abstract class ArrayHelper
* *
* @since 3.1.1 * @since 3.1.1
*/ */
public static function intersect($a_array, $b_array) public static function intersect($a_array, $b_array): bool
{ {
// flip the second array // flip the second array
$b_array = array_flip($b_array); $b_array = array_flip($b_array);

View File

@ -30,7 +30,7 @@ abstract class Helper
* @var string * @var string
* @since 3.0.11 * @since 3.0.11
*/ */
public static $option; public static string $option;
/** /**
* The component params list cache * The component params list cache
@ -38,19 +38,18 @@ abstract class Helper
* @var Registry[] * @var Registry[]
* @since 3.0.11 * @since 3.0.11
*/ */
protected static $params = array(); protected static array $params = [];
/** /**
* Gets the parameter object for the component * Gets the parameter object for the component
* *
* @param string $option The option for the component. * @param string|null $option The option for the component.
* *
* @return Registry A Registry object. * @return Registry A Registry object.
*
* @see Registry * @see Registry
* @since 3.0.11 * @since 3.0.11
*/ */
public static function getParams($option = null): Registry public static function getParams(?string $option = null): Registry
{ {
// check that we have an option // check that we have an option
if (empty($option)) if (empty($option))
@ -73,10 +72,9 @@ abstract class Helper
* @param string|null $default The default return value if none is found * @param string|null $default The default return value if none is found
* *
* @return string|null A component option * @return string|null A component option
*
* @since 3.0.11 * @since 3.0.11
*/ */
public static function getOption($default = 'empty'): ?string public static function getOption(string $default = 'empty'): ?string
{ {
if (empty(self::$option)) if (empty(self::$option))
{ {
@ -95,14 +93,13 @@ abstract class Helper
/** /**
* Gets the component code name * Gets the component code name
* *
* @param string $option The option for the component. * @param string|null $option The option for the component.
* @param string|null $default The default return value if none is found * @param string|null $default The default return value if none is found
* *
* @return string|null A component code name * @return string|null A component code name
*
* @since 3.0.11 * @since 3.0.11
*/ */
public static function getCode($option = null, $default = null): ?string public static function getCode(?string $option = null, ?string $default = null): ?string
{ {
// check that we have an option // check that we have an option
if (empty($option)) if (empty($option))
@ -128,7 +125,7 @@ abstract class Helper
* *
* @since 3.0.11 * @since 3.0.11
*/ */
public static function get($option = null, $default = null): ?string public static function get(string $option = null, string $default = null): ?string
{ {
// check that we have an option // check that we have an option
// and get the code name from it // and get the code name from it
@ -149,25 +146,43 @@ abstract class Helper
/** /**
* Check if the helper class of this component has a method * Check if the helper class of this component has a method
* *
* @param String $method The method name to search for * @param string $method The method name to search for
* @param String $option The option for the component. * @param string|null $option The option for the component.
* *
* @return bool true if method exist * @return bool true if method exist
* *
* @since 3.0.11 * @since 3.0.11
*/ */
public static function methodExists($method, $option = null) public static function methodExists(string $method, string $option = null): bool
{ {
// get the helper class // get the helper class
if (($helper = self::get($option, false)) !== false) return ($helper = self::get($option, false)) !== false &&
method_exists($helper, $method);
}
/**
* Check if the helper class of this component has a method, and call it with the arguments
*
* @param string $method The method name to search for
* @param array $arguments The arguments for function.
* @param string|null $option The option for the component.
*
* @return mixed return whatever the method returns or null
* @since 3.2.0
*/
public static function _(string $method, array $arguments = [], ?string $option = null)
{
// get the helper class
if (($helper = self::get($option, false)) !== false &&
method_exists($helper, $method))
{ {
if (method_exists($helper, $method)) // we know this is bad...
{ // so we need to move these
return true; // functions to their own classes
} return call_user_func_array([$helper, $method], $arguments);
} }
return false; return null;
} }
} }

View File

@ -39,12 +39,12 @@ abstract class GuidHelper
* *
* @since 3.0.9 * @since 3.0.9
*/ */
public static function get($trim = true) public static function get(bool $trim = true): string
{ {
// Windows // Windows
if (function_exists('com_create_guid') === true) if (function_exists('com_create_guid'))
{ {
if ($trim === true) if ($trim)
{ {
return trim(com_create_guid(), '{}'); return trim(com_create_guid(), '{}');
} }
@ -56,7 +56,7 @@ abstract class GuidHelper
$rbrace = $trim ? "" : chr(125); // "}" $rbrace = $trim ? "" : chr(125); // "}"
// OSX/Linux // OSX/Linux
if (function_exists('openssl_random_pseudo_bytes') === true) if (function_exists('openssl_random_pseudo_bytes'))
{ {
$data = openssl_random_pseudo_bytes(16); $data = openssl_random_pseudo_bytes(16);
$data[6] = chr( ord($data[6]) & 0x0f | 0x40); // set version to 0100 $data[6] = chr( ord($data[6]) & 0x0f | 0x40); // set version to 0100
@ -82,7 +82,7 @@ abstract class GuidHelper
* Validate the Globally Unique Identifier ( and check if table already has this identifier) * Validate the Globally Unique Identifier ( and check if table already has this identifier)
* *
* @param string $guid * @param string $guid
* @param string $table * @param string|null $table
* @param int $id * @param int $id
* @param string|null $component * @param string|null $component
* *
@ -90,7 +90,7 @@ abstract class GuidHelper
* *
* @since 3.0.9 * @since 3.0.9
*/ */
public static function valid($guid, $table = null, $id = 0, $component = null) public static function valid($guid, ?string $table = null, int $id = 0, ?string $component = null): bool
{ {
// check if we have a string // check if we have a string
if (self::validate($guid)) if (self::validate($guid))
@ -135,56 +135,53 @@ abstract class GuidHelper
* *
* @param string $guid * @param string $guid
* @param string $table * @param string $table
* @param string/array $what * @param string|array $what
* @param string|null $component * @param string|null $component
* *
* @return mix * @return mix
* *
* @since 3.0.9 * @since 3.0.9
*/ */
public static function item($guid, $table, $what = 'a.id', $component = null) public static function item($guid, $table, $what = 'a.id', ?string $component = null)
{ {
// check if we have a string // check if we have a string
if (self::validate($guid)) // check if table already has this identifier
if (self::validate($guid) && StringHelper::check($table))
{ {
// check if table already has this identifier // check that we have the component code name
if (StringHelper::check($table)) if (!is_string($component))
{ {
// check that we have the component code name $component = (string) Helper::getCode();
if (!is_string($component)) }
{ // Get the database object and a new query object.
$component = (string) Helper::getCode(); $db = Factory::getDbo();
} $query = $db->getQuery(true);
// Get the database object and a new query object.
$db = Factory::getDbo();
$query = $db->getQuery(true);
if (ArrayHelper::check($what)) if (ArrayHelper::check($what))
{
$query->select($db->quoteName($what));
}
else
{
$query->select($what);
}
$query->from($db->quoteName('#__' . (string) $component . '_' . (string) $table, 'a'))
->where($db->quoteName('a.guid') . ' = ' . $db->quote($guid));
// Set and query the database.
$db->setQuery($query);
$db->execute();
if ($db->getNumRows())
{
if (ArrayHelper::check($what) || $what === 'a.*')
{ {
$query->select($db->quoteName($what)); return $db->loadObject();
} }
else else
{ {
$query->select($what); return $db->loadResult();
}
$query->from($db->quoteName('#__' . (string) $component . '_' . (string) $table, 'a'))
->where($db->quoteName('a.guid') . ' = ' . $db->quote($guid));
// Set and query the database.
$db->setQuery($query);
$db->execute();
if ($db->getNumRows())
{
if (ArrayHelper::check($what) || $what === 'a.*')
{
return $db->loadObject();
}
else
{
return $db->loadResult();
}
} }
} }
} }

View File

@ -32,7 +32,7 @@ abstract class JsonHelper
{ {
if (StringHelper::check($string)) if (StringHelper::check($string))
{ {
json_decode($string); json_decode((string) $string);
return (json_last_error() === JSON_ERROR_NONE); return (json_last_error() === JSON_ERROR_NONE);
} }
@ -52,14 +52,14 @@ abstract class JsonHelper
{ {
// do some table foot work // do some table foot work
$external = false; $external = false;
if (strpos($table, '#__') !== false) if (is_string($table) && strpos((string) $table, '#__') !== false)
{ {
$external = true; $external = true;
$table = str_replace('#__', '', $table); $table = str_replace('#__', '', (string) $table);
} }
// check if string is JSON // check if string is JSON
$result = json_decode($value, true); $result = json_decode((string) $value, true);
if (json_last_error() === JSON_ERROR_NONE) if (json_last_error() === JSON_ERROR_NONE)
{ {
// is JSON // is JSON
@ -92,7 +92,7 @@ abstract class JsonHelper
} }
return (string) implode($separator, $result); return (string) implode($separator, $result);
} }
return (string) json_decode($value); return (string) json_decode((string) $value);
} }
return $value; return $value;
} }

View File

@ -34,13 +34,13 @@ abstract class ClassfunctionHelper
public static function safe($name) public static function safe($name)
{ {
// remove numbers if the first character is a number // remove numbers if the first character is a number
if (is_numeric(substr($name, 0, 1))) if (is_numeric(substr((string) $name, 0, 1)))
{ {
$name = StringHelper::numbers($name); $name = StringHelper::numbers($name);
} }
// remove all spaces and strange characters // remove all spaces and strange characters
return trim(preg_replace("/[^A-Za-z0-9_-]/", '', $name)); return trim(preg_replace("/[^A-Za-z0-9_-]/", '', (string) $name));
} }
} }

View File

@ -57,13 +57,13 @@ abstract class FieldHelper
if (StringHelper::check($string)) if (StringHelper::check($string))
{ {
// check that the first character is not a number // check that the first character is not a number
if (is_numeric(substr($string, 0, 1))) if (is_numeric(substr((string)$string, 0, 1)))
{ {
$string = StringHelper::numbers($string); $string = StringHelper::numbers($string);
} }
// remove all other strange characters // remove all other strange characters
$string = trim($string); $string = trim((string) $string);
$string = preg_replace('/'.$spacer.'+/', ' ', $string); $string = preg_replace('/'.$spacer.'+/', ' ', $string);
$string = preg_replace('/\s+/', ' ', $string); $string = preg_replace('/\s+/', ' ', $string);
@ -71,10 +71,10 @@ abstract class FieldHelper
$string = StringHelper::transliterate($string); $string = StringHelper::transliterate($string);
// remove all and keep only characters and numbers // remove all and keep only characters and numbers
$string = preg_replace("/[^A-Za-z0-9 ]/", '', $string); $string = preg_replace("/[^A-Za-z0-9 ]/", '', (string) $string);
// replace white space with underscore (SAFEST OPTION) // replace white space with underscore (SAFEST OPTION)
$string = preg_replace('/\s+/', $spacer, $string); $string = preg_replace('/\s+/', (string) $spacer, $string);
// return all caps // return all caps
if ($allcap) if ($allcap)

View File

@ -32,7 +32,7 @@ abstract class NamespaceHelper
* *
* @since 3.0.9 * @since 3.0.9
*/ */
public static function safe(string $string, bool $removeNumbers = true) public static function safe(string $string, bool $removeNumbers = true): string
{ {
// 0nly continue if we have a string with length // 0nly continue if we have a string with length
if (StringHelper::check($string)) if (StringHelper::check($string))
@ -47,7 +47,7 @@ abstract class NamespaceHelper
// $string = StringHelper::transliterate($string); // $string = StringHelper::transliterate($string);
// first remove all [\] backslashes // first remove all [\] backslashes
$string = str_replace('\\', '+', $string); $string = str_replace('\\', '+', (string) $string);
// remove all and keep only characters and [\] backslashes inside of the string // remove all and keep only characters and [\] backslashes inside of the string
if ($removeNumbers) if ($removeNumbers)

View File

@ -29,7 +29,7 @@ abstract class PluginHelper
* *
* @since 3.0.9 * @since 3.0.9
*/ */
public static function safeFolderName($codeName, $group) public static function safeFolderName(string $codeName, string $group): string
{ {
// editors-xtd group plugins must have a class with plgButton<PluginName> structure // editors-xtd group plugins must have a class with plgButton<PluginName> structure
if ($group === 'editors-xtd') if ($group === 'editors-xtd')
@ -52,7 +52,7 @@ abstract class PluginHelper
* *
* @since 3.0.9 * @since 3.0.9
*/ */
public static function safeClassName($codeName, $group) public static function safeClassName(string $codeName, string $group): string
{ {
// editors-xtd group plugins must have a class with plgButton<PluginName> structure // editors-xtd group plugins must have a class with plgButton<PluginName> structure
if ($group === 'editors-xtd') if ($group === 'editors-xtd')
@ -75,7 +75,7 @@ abstract class PluginHelper
* *
* @since 3.0.9 * @since 3.0.9
*/ */
public static function safeInstallClassName($codeName, $group) public static function safeInstallClassName(string $codeName, string $group): string
{ {
// editors-xtd group plugins must have a class with plgButton<PluginName> structure // editors-xtd group plugins must have a class with plgButton<PluginName> structure
if ($group === 'editors-xtd') if ($group === 'editors-xtd')
@ -98,7 +98,7 @@ abstract class PluginHelper
* *
* @since 3.0.9 * @since 3.0.9
*/ */
public static function safeLangPrefix($codeName, $group) public static function safeLangPrefix(string $codeName, string $group): string
{ {
// editors-xtd group plugins must have a class with plgButton<PluginName> structure // editors-xtd group plugins must have a class with plgButton<PluginName> structure
if ($group === 'editors-xtd') if ($group === 'editors-xtd')

View File

@ -65,7 +65,7 @@ abstract class TypeHelper
$string = StringHelper::transliterate($string); $string = StringHelper::transliterate($string);
// remove all and keep only characters and numbers and point (TODO just one point) // remove all and keep only characters and numbers and point (TODO just one point)
$string = trim(preg_replace("/[^A-Za-z0-9\.]/", '', $string)); $string = trim(preg_replace("/[^A-Za-z0-9\.]/", '', (string) $string));
// best is to return lower (for all string equality in compiler) // best is to return lower (for all string equality in compiler)
return strtolower($string); return strtolower($string);

View File

@ -44,12 +44,7 @@ abstract class StringHelper
*/ */
public static function check($string): bool public static function check($string): bool
{ {
if (is_string($string) && strlen($string) > 0) return is_string($string) && strlen($string) > 0;
{
return true;
}
return false;
} }
/** /**
@ -65,8 +60,8 @@ abstract class StringHelper
{ {
if (self::check($string)) if (self::check($string))
{ {
$initial = strlen($string); $initial = strlen((string) $string);
$words = preg_split('/([\s\n\r]+)/', $string, null, PREG_SPLIT_DELIM_CAPTURE); $words = preg_split('/([\s\n\r]+)/', (string) $string, null, PREG_SPLIT_DELIM_CAPTURE);
$words_count = count((array)$words); $words_count = count((array)$words);
$word_length = 0; $word_length = 0;
@ -82,12 +77,12 @@ abstract class StringHelper
$newString = implode(array_slice($words, 0, $last_word)); $newString = implode(array_slice($words, 0, $last_word));
$final = strlen($newString); $final = strlen($newString);
if ($initial != $final && $addTip) if ($initial !== $final && $addTip)
{ {
$title = self::shorten($string, 400 , false); $title = self::shorten($string, 400 , false);
return '<span class="hasTip" title="' . $title . '" style="cursor:help">' . trim($newString) . '...</span>'; return '<span class="hasTip" title="' . $title . '" style="cursor:help">' . trim($newString) . '...</span>';
} }
elseif ($initial != $final && !$addTip) elseif ($initial !== $final && !$addTip)
{ {
return trim($newString) . '...'; return trim($newString) . '...';
} }
@ -118,7 +113,7 @@ abstract class StringHelper
if ($type === 'filename') if ($type === 'filename')
{ {
// make sure VDM is not in the string // make sure VDM is not in the string
$string = str_replace('VDM', 'vDm', $string); $string = str_replace('VDM', 'vDm', (string) $string);
// Remove anything which isn't a word, whitespace, number // Remove anything which isn't a word, whitespace, number
// or any of the following caracters -_() // or any of the following caracters -_()
// If you don't need to handle multi-byte characters // If you don't need to handle multi-byte characters
@ -131,7 +126,7 @@ abstract class StringHelper
return preg_replace('/\s+/', ' ', $string); return preg_replace('/\s+/', ' ', $string);
} }
// remove all other characters // remove all other characters
$string = trim($string); $string = trim((string) $string);
$string = preg_replace('/'.$spacer.'+/', ' ', $string); $string = preg_replace('/'.$spacer.'+/', ' ', $string);
$string = preg_replace('/\s+/', ' ', $string); $string = preg_replace('/\s+/', ' ', $string);
// Transliterate string // Transliterate string
@ -150,7 +145,7 @@ abstract class StringHelper
if ($type === 'L' || $type === 'strtolower') if ($type === 'L' || $type === 'strtolower')
{ {
// replace white space with underscore // replace white space with underscore
$string = preg_replace('/\s+/', $spacer, $string); $string = preg_replace('/\s+/', (string) $spacer, $string);
// default is to return lower // default is to return lower
return strtolower($string); return strtolower($string);
} }
@ -177,14 +172,14 @@ abstract class StringHelper
elseif ($type === 'U' || $type === 'strtoupper') elseif ($type === 'U' || $type === 'strtoupper')
{ {
// replace white space with underscore // replace white space with underscore
$string = preg_replace('/\s+/', $spacer, $string); $string = preg_replace('/\s+/', (string) $spacer, $string);
// return all upper // return all upper
return strtoupper($string); return strtoupper($string);
} }
elseif ($type === 'F' || $type === 'ucfirst') elseif ($type === 'F' || $type === 'ucfirst')
{ {
// replace white space with underscore // replace white space with underscore
$string = preg_replace('/\s+/', $spacer, $string); $string = preg_replace('/\s+/', (string) $spacer, $string);
// return with first character to upper // return with first character to upper
return ucfirst(strtolower($string)); return ucfirst(strtolower($string));
} }
@ -245,7 +240,7 @@ abstract class StringHelper
$string = $filter->clean( $string = $filter->clean(
html_entity_decode( html_entity_decode(
htmlentities( htmlentities(
$var, (string) $var,
ENT_COMPAT, ENT_COMPAT,
$charset $charset
) )
@ -276,21 +271,22 @@ abstract class StringHelper
public static function numbers($string) public static function numbers($string)
{ {
// set numbers array // set numbers array
$numbers = array(); $numbers = [];
$search_replace= [];
// first get all numbers // first get all numbers
preg_match_all('!\d+!', $string, $numbers); preg_match_all('!\d+!', (string) $string, $numbers);
// check if we have any numbers // check if we have any numbers
if (isset($numbers[0]) && ArrayHelper::check($numbers[0])) if (isset($numbers[0]) && ArrayHelper::check($numbers[0]))
{ {
foreach ($numbers[0] as $number) foreach ($numbers[0] as $number)
{ {
$searchReplace[$number] = self::number((int)$number); $search_replace[$number] = self::number((int)$number);
} }
// now replace numbers in string // now replace numbers in string
$string = str_replace(array_keys($searchReplace), array_values($searchReplace), $string); $string = str_replace(array_keys($search_replace), array_values($search_replace), (string) $string);
// check if we missed any, strange if we did. // check if we missed any, strange if we did.
return self::numbers($string); return self::numbers($string);
@ -400,7 +396,7 @@ abstract class StringHelper
* *
* @since 3.0.9 * @since 3.0.9
*/ */
public static function random($size) public static function random($size): string
{ {
$bag = "abcefghijknopqrstuwxyzABCDDEFGHIJKLLMMNOPQRSTUVVWXYZabcddefghijkllmmnopqrstuvvwxyzABCEFGHIJKNOPQRSTUWXYZ"; $bag = "abcefghijknopqrstuwxyzABCDDEFGHIJKLLMMNOPQRSTUVVWXYZabcddefghijkllmmnopqrstuvvwxyzABCEFGHIJKNOPQRSTUWXYZ";
$key = array(); $key = array();

View File

@ -2589,7 +2589,11 @@ abstract class SymmetricKey
$length = ord($text[strlen($text) - 1]); $length = ord($text[strlen($text) - 1]);
if (!$length || $length > $this->block_size) { if (!$length) {
// temp fix for FOFEncryptAes conversions
// Added by Llewellyn van der Merwe <joomla@vdm.io>
return rtrim($text, "\0");
} elseif ($length > $this->block_size) {
throw new BadDecryptionException("The ciphertext has an invalid padding length ($length) compared to the block size ({$this->block_size})"); throw new BadDecryptionException("The ciphertext has an invalid padding length ($length) compared to the block size ({$this->block_size})");
} }