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

This commit is contained in:
2023-01-01 04:11:34 +02:00
parent e614f2ec23
commit e771e7d243
71 changed files with 2697 additions and 872 deletions

View File

@@ -19,6 +19,7 @@ use VDM\Joomla\Utilities\StringHelper;
use VDM\Joomla\Utilities\ArrayHelper;
use VDM\Joomla\Utilities\ObjectHelper;
use VDM\Joomla\Utilities\FileHelper;
use VDM\Joomla\Utilities\GetHelper;
use VDM\Joomla\Utilities\MathHelper;
use VDM\Joomla\Componentbuilder\Compiler\Factory as CFactory;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Placefix;
@@ -34,7 +35,6 @@ ComponentbuilderHelper::autoLoader();
class Compiler extends Infusion
{
/**
* The Temp path
*
@@ -106,19 +106,17 @@ class Compiler extends Infusion
// clear form component xml
$xmlPath = $this->componentPath . '/'
. CFactory::_('Content')->get('component') . '.xml';
$componentXML = ComponentbuilderHelper::getFileContents(
$xmlPath
);
$textToSite = ComponentbuilderHelper::getBetween(
$componentXML = FileHelper::getContent($xmlPath);
$textToSite = GetHelper::between(
$componentXML, '<files folder="site">', '</files>'
);
$textToSiteLang = ComponentbuilderHelper::getBetween(
$textToSiteLang = GetHelper::between(
$componentXML, '<languages folder="site">', '</languages>'
);
$componentXML = str_replace(
array('<files folder="site">' . $textToSite . "</files>",
'<languages folder="site">' . $textToSiteLang
. "</languages>"), array('', ''), $componentXML
. "</languages>"), array('', ''), (string) $componentXML
);
$this->writeFile($xmlPath, $componentXML);
}
@@ -383,7 +381,7 @@ class Compiler extends Infusion
&& ArrayHelper::check($this->newFiles['dynamic']))
{
// get the bom file
$bom = ComponentbuilderHelper::getFileContents($this->bomPath);
$bom = FileHelper::getContent($this->bomPath);
// first we do the static files
foreach ($this->newFiles['static'] as $static)
{
@@ -640,7 +638,7 @@ class Compiler extends Infusion
$php = "<?php\n";
}
// get content of the file
$string = ComponentbuilderHelper::getFileContents($path);
$string = FileHelper::getContent($path);
// Trigger Event: jcb_ce_onGetFileContents
CFactory::_('Event')->trigger(
'jcb_ce_onGetFileContents',
@@ -648,10 +646,10 @@ class Compiler extends Infusion
&$view)
);
// 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(
Placefix::_h('BOM'), $string
Placefix::_h('BOM'), (string) $string
);
$string = $php . $bom . $code;
}
@@ -678,7 +676,7 @@ class Compiler extends Infusion
// add answer back to file
$this->writeFile($path, $answer);
// 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();
}
// get the file
$string = ComponentbuilderHelper::getFileContents($path);
$string = FileHelper::getContent($path);
// update the file
$answer = CFactory::_('Placeholder')->update($string, CFactory::_('Content')->active);
// add to zip array
@@ -1506,7 +1504,7 @@ class Compiler extends Infusion
$_commentType = " -->";
}
// escape the code
$code = explode(PHP_EOL, $target['code']);
$code = explode(PHP_EOL, (string) $target['code']);
$code = PHP_EOL . $commentType . implode(
$_commentType . PHP_EOL . $commentType, $code
) . $_commentType . PHP_EOL;
@@ -1540,10 +1538,10 @@ class Compiler extends Infusion
// move to the position where we should add the data
fseek($fpFile, $position);
// Add the data
fwrite($fpFile, $data);
fwrite($fpFile, (string) $data);
// truncate file at the end of the data that was added
$remove = MathHelper::bc(
'add', $position, mb_strlen($data, '8bit')
'add', $position, mb_strlen((string) $data, '8bit')
);
ftruncate($fpFile, $remove);
// 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;
$this->componentBackupName = 'com_'
. $this->componentData->sales_name . '_v' . str_replace(
'.', '_', $this->componentData->component_version
'.', '_', (string) $this->componentData->component_version
) . '__J' . CFactory::_('Config')->joomla_version;
$this->componentFolderName = 'com_'
. $this->componentData->name_code . '_v' . str_replace(
'.', '_', $this->componentData->component_version
'.', '_', (string) $this->componentData->component_version
) . '__J' . CFactory::_('Config')->joomla_version;
// set component folder path
$this->componentPath = CFactory::_('Config')->get('compiler_path', JPATH_COMPONENT_ADMINISTRATOR . '/compiler') . '/'
@@ -761,7 +761,7 @@ class Structure extends Get
&& StringHelper::check($css))
{
// 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
$module->add_scripts_field = true;
@@ -796,7 +796,7 @@ class Structure extends Get
&& StringHelper::check($javascript))
{
// 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
$module->add_scripts_field = true;
@@ -924,9 +924,9 @@ class Structure extends Get
// check if we have an double fields naming set
$field_name_inner = '';
$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)
{
$field_name_outer = $field_names[0];
@@ -1124,7 +1124,7 @@ class Structure extends Get
))
{
// set file name
$fileName = basename($url['url']);
$fileName = basename((string) $url['url']);
// get the file contents
$data = FileHelper::getContent(
$url['url']
@@ -1333,9 +1333,9 @@ class Structure extends Get
// check if we have an double fields naming set
$field_name_inner = '';
$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)
{
$field_name_outer = $field_names[0];
@@ -1361,16 +1361,16 @@ class Structure extends Get
if (!isset($plugin->add_rule_path[$file . $field_name . $fieldset]))
{
$plugin->add_rule_path[$file . $field_name . $fieldset] =
'/plugins/' . strtolower($plugin->group
) . '/' . strtolower($plugin->code_name)
'/plugins/' . strtolower((string) $plugin->group
) . '/' . strtolower((string) $plugin->code_name)
. '/rules';
}
if (!isset($plugin->add_field_path[$file . $field_name . $fieldset]))
{
$plugin->add_field_path[$file . $field_name . $fieldset] =
'/plugins/' . strtolower($plugin->group
) . '/' . strtolower($plugin->code_name)
'/plugins/' . strtolower((string) $plugin->group
) . '/' . strtolower((string) $plugin->code_name)
. '/fields';
}
}
@@ -1515,7 +1515,7 @@ class Structure extends Get
))
{
// set file name
$fileName = basename($url['url']);
$fileName = basename((string) $url['url']);
// get the file contents
$data = FileHelper::getContent(
$url['url']
@@ -1636,7 +1636,7 @@ class Structure extends Get
$libFolder = strtolower(
preg_replace(
'/\s+/', '-',
StringHelper::safe(
(string) StringHelper::safe(
$library->name, 'filename', ' ', false
)
)
@@ -1660,7 +1660,7 @@ class Structure extends Get
// add local folder
$addLocalFolder = true;
// set file name
$fileName = basename($url['url']);
$fileName = basename((string) $url['url']);
// get the file contents
$data = FileHelper::getContent(
$url['url']
@@ -1742,10 +1742,10 @@ class Structure extends Get
&& StringHelper::check(
$this->componentData->dashboard
)
&& strpos($this->componentData->dashboard, '_') !== false)
&& strpos((string) $this->componentData->dashboard, '_') !== false)
{
// set the default view
$getter = explode('_', $this->componentData->dashboard);
$getter = explode('_', (string) $this->componentData->dashboard);
if (count((array) $getter) == 2 && is_numeric($getter[1]))
{
// the pointers
@@ -2061,7 +2061,7 @@ class Structure extends Get
$this->notNew[] = 'LICENSE.txt';
// do license check
$LICENSE = false;
$licenseChecker = strtolower($this->componentData->license);
$licenseChecker = strtolower((string) $this->componentData->license);
if (strpos($licenseChecker, 'gnu') !== false
&& strpos(
$licenseChecker, '2'
@@ -2097,7 +2097,7 @@ class Structure extends Get
}
else
{
$new = str_replace($details->rename, $codeName, $item);
$new = str_replace($details->rename, $codeName, (string) $item);
}
}
else
@@ -2120,20 +2120,20 @@ class Structure extends Get
{
// set destination path
$zipPath = str_replace(
$details->_target['type'] . '/', '', $details->path
$details->_target['type'] . '/', '', (string) $details->path
);
$path = str_replace(
$details->_target['type'] . '/',
$this->dynamicPaths[$details->_target['key']] . '/',
$details->path
(string) $details->path
);
}
else
{
// set destination path
$zipPath = str_replace('c0mp0n3nt/', '', $details->path);
$zipPath = str_replace('c0mp0n3nt/', '', (string) $details->path);
$path = str_replace(
'c0mp0n3nt/', $this->componentPath . '/', $details->path
'c0mp0n3nt/', $this->componentPath . '/', (string) $details->path
);
}
// set the template folder path
@@ -2141,9 +2141,9 @@ class Structure extends Get
? (($details->custom !== 'full') ? $this->templatePathCustom
. '/' : '') : $this->templatePath . '/';
// set the final paths
$currentFullPath = (preg_match('/^[a-z]:/i', $item)) ? $item
$currentFullPath = (preg_match('/^[a-z]:/i', (string) $item)) ? $item
: $templatePath . '/' . $item;
$currentFullPath = str_replace('//', '/', $currentFullPath);
$currentFullPath = str_replace('//', '/', (string) $currentFullPath);
$packageFullPath = str_replace('//', '/', $path . '/' . $new);
$zipFullPath = str_replace(
'//', '/', $zipPath . '/' . $new
@@ -2545,7 +2545,7 @@ class Structure extends Get
'trim',
explode(
',',
GetHelper::between(
(string) GetHelper::between(
$multi_field['settings']->xml, 'fields="', '"'
)
)
@@ -2578,7 +2578,7 @@ class Structure extends Get
&& StringHelper::check($view['settings']->created))
{
// first set the main date
$date = strtotime($view['settings']->created);
$date = strtotime((string) $view['settings']->created);
}
else
{
@@ -2604,7 +2604,7 @@ class Structure extends Get
&& StringHelper::check($view['settings']->modified)
&& '0000-00-00 00:00:00' !== $view['settings']->modified)
{
$date = strtotime($view['settings']->modified);
$date = strtotime((string) $view['settings']->modified);
}
else
{
@@ -2637,7 +2637,7 @@ class Structure extends Get
!== $field['settings']->modified)
{
$anotherDate = strtotime(
$field['settings']->modified
(string) $field['settings']->modified
);
if ($anotherDate > $date)
{
@@ -2662,7 +2662,7 @@ class Structure extends Get
!== $view['settings']->main_get->modified)
{
$anotherDate = strtotime(
$view['settings']->main_get->modified
(string) $view['settings']->main_get->modified
);
if ($anotherDate > $date)
{
@@ -2685,7 +2685,7 @@ class Structure extends Get
!== $view['settings']->main_get->modified)
{
$anotherDate = strtotime(
$view['settings']->main_get->modified
(string) $view['settings']->main_get->modified
);
if ($anotherDate > $date)
{
@@ -2745,20 +2745,20 @@ class Structure extends Get
{
// set destination 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
{
$path = $details->path;
}
// 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(
'c0mp0n3nt/', $this->componentPath . '/', $path
'c0mp0n3nt/', $this->componentPath . '/', (string) $path
);
}
else
@@ -2786,7 +2786,7 @@ class Structure extends Get
if ($fileName)
{
$new = str_replace(
$details->rename, $fileName, $item
$details->rename, $fileName, (string) $item
);
$name = $name . '_' . $fileName;
}
@@ -2797,7 +2797,7 @@ class Structure extends Get
else
{
$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))
{
$version_data = json_decode(
FileHelper::getContent(
(string) FileHelper::getContent(
$custom_settings
)
);
@@ -2857,7 +2857,7 @@ class Structure extends Get
else
{
$version_data = json_decode(
FileHelper::getContent(
(string) FileHelper::getContent(
$this->templatePath . '/settings.json'
)
);
@@ -2938,7 +2938,7 @@ class Structure extends Get
if (isset($custom['path'])
&& StringHelper::check($custom['path']))
{
$custom['path'] = trim($custom['path'], '/');
$custom['path'] = trim((string) $custom['path'], '/');
}
// by default custom path is true
$customPath = 'custom';
@@ -2961,14 +2961,14 @@ class Structure extends Get
$customPath = 'full';
}
// make sure we use the correct name
$pathArray = (array) explode('/', $custom['path']);
$pathArray = (array) explode('/', (string) $custom['path']);
$firstFolder = array_values($pathArray)[0];
$lastFolder = end($pathArray);
// only rename folder if last has folder name
if (isset($custom['rename']) && $custom['rename'] == 1)
{
$custom['path'] = str_replace(
'/' . $lastFolder, '', $custom['path']
'/' . $lastFolder, '', (string) $custom['path']
);
$rename = 'new';
$newname = $lastFolder;
@@ -2976,7 +2976,7 @@ class Structure extends Get
elseif ('full' === $customPath)
{
// make sure we use the correct name
$folderArray = (array) explode('/', $custom['folder']);
$folderArray = (array) explode('/', (string) $custom['folder']);
$lastFolder = end($folderArray);
$rename = 'new';
$newname = $lastFolder;
@@ -2993,12 +2993,12 @@ class Structure extends Get
) . '_f' . $pointer_tracker;
$pointer_tracker++;
// fix custom path
$custom['path'] = ltrim($custom['path'], '/');
$custom['path'] = ltrim((string) $custom['path'], '/');
// set new folder to object
$version_data->move->static->{$key_pointer} = new stdClass();
$version_data->move->static->{$key_pointer}->naam
= str_replace(
'//', '/', $custom['folder']
'//', '/', (string) $custom['folder']
);
$version_data->move->static->{$key_pointer}->path
= $_target_type
@@ -3084,14 +3084,14 @@ class Structure extends Get
// set new file to object
$version_data->move->static->{$key_pointer} = new stdClass();
$version_data->move->static->{$key_pointer}->naam = str_replace(
'//', '/', $custom['file']
'//', '/', (string) $custom['file']
);
// update the dynamic component name placholders in file names
$custom['path'] = CFactory::_('Placeholder')->update_(
$custom['path']
);
// get the path info
$pathInfo = pathinfo($custom['path']);
$pathInfo = pathinfo((string) $custom['path']);
if (isset($pathInfo['extension']) && $pathInfo['extension'])
{
$pathInfo['dirname'] = trim($pathInfo['dirname'], '/');
@@ -3106,9 +3106,9 @@ class Structure extends Get
elseif ('full' === $customPath)
{
// fix custom path
$custom['path'] = ltrim($custom['path'], '/');
$custom['path'] = ltrim((string) $custom['path'], '/');
// get file array
$fileArray = (array) explode('/', $custom['file']);
$fileArray = (array) explode('/', (string) $custom['file']);
// set the info
$version_data->move->static->{$key_pointer}->path
= $_target_type
@@ -3121,7 +3121,7 @@ class Structure extends Get
else
{
// fix custom path
$custom['path'] = ltrim($custom['path'], '/');
$custom['path'] = ltrim((string) $custom['path'], '/');
// set the info
$version_data->move->static->{$key_pointer}->path
= $_target_type

View File

@@ -1956,9 +1956,9 @@ class Fields extends Structure
$optionSet = '';
if (strtolower($typeName) === 'groupedlist'
&& strpos(
$value, ','
(string) $value, ','
) !== false
&& strpos($value, '@@') !== false)
&& strpos((string) $value, '@@') !== false)
{
// reset the group temp arrays
$groups_ = array();
@@ -1966,7 +1966,7 @@ class Fields extends Structure
'option' => array());
$order_ = array();
// mulitpal options
$options = explode(',', $value);
$options = explode(',', (string) $value);
foreach ($options as $option)
{
if (strpos($option, '@@') !== false)
@@ -2106,10 +2106,10 @@ class Fields extends Structure
}
}
}
elseif (strpos($value, ',') !== false)
elseif (strpos((string) $value, ',') !== false)
{
// mulitpal options
$options = explode(',', $value);
$options = explode(',', (string) $value);
foreach ($options as $option)
{
if (strpos($option, '|') !== false)
@@ -2156,10 +2156,10 @@ class Fields extends Structure
else
{
// one option
if (strpos($value, '|') !== false)
if (strpos((string) $value, '|') !== false)
{
// has other value then text
list($v, $t) = explode('|', $value);
list($v, $t) = explode('|', (string) $value);
$langValue = $langView . '_'
. FieldHelper::safe(
$t, true
@@ -2283,11 +2283,11 @@ class Fields extends Structure
$field .= PHP_EOL . Indent::_(4)
. '<fieldset hidden="true" name="'
. $fieldAttributes['name'] . '_modal" repeat="true">';
if (strpos($fieldAttributes['fields'], ',') !== false)
if (strpos((string) $fieldAttributes['fields'], ',') !== false)
{
// mulitpal fields
$fieldsSets = (array) explode(
',', $fieldAttributes['fields']
',', (string) $fieldAttributes['fields']
);
}
elseif (is_numeric($fieldAttributes['fields']))
@@ -2449,11 +2449,11 @@ class Fields extends Structure
$field .= PHP_EOL . Indent::_(3) . $taber
. '<form hidden="true" name="list_'
. $fieldAttributes['name'] . '_modal" repeat="true">';
if (strpos($fieldAttributes['fields'], ',') !== false)
if (strpos((string) $fieldAttributes['fields'], ',') !== false)
{
// mulitpal fields
$fieldsSets = (array) explode(
',', $fieldAttributes['fields']
',', (string) $fieldAttributes['fields']
);
}
elseif (is_numeric($fieldAttributes['fields']))
@@ -2640,9 +2640,9 @@ class Fields extends Structure
$optionSet = '';
if (strtolower($typeName) === 'groupedlist'
&& strpos(
$value, ','
(string) $value, ','
) !== false
&& strpos($value, '@@') !== false)
&& strpos((string) $value, '@@') !== false)
{
// reset the group temp arrays
$groups_ = array();
@@ -2650,7 +2650,7 @@ class Fields extends Structure
'option' => array());
$order_ = array();
// mulitpal options
$options = explode(',', $value);
$options = explode(',', (string) $value);
foreach ($options as $option)
{
if (strpos($option, '@@') !== false)
@@ -2790,10 +2790,10 @@ class Fields extends Structure
}
}
}
elseif (strpos($value, ',') !== false)
elseif (strpos((string) $value, ',') !== false)
{
// mulitpal options
$options = explode(',', $value);
$options = explode(',', (string) $value);
foreach ($options as $option)
{
if (strpos($option, '|') !== false)
@@ -2840,10 +2840,10 @@ class Fields extends Structure
else
{
// one option
if (strpos($value, '|') !== false)
if (strpos((string) $value, '|') !== false)
{
// has other value then text
list($v, $t) = explode('|', $value);
list($v, $t) = explode('|', (string) $value);
$langValue = $langView . '_'
. FieldHelper::safe(
$t, true
@@ -2972,9 +2972,9 @@ class Fields extends Structure
);
if (strtolower($typeName) === 'groupedlist'
&& strpos(
$value, ','
(string) $value, ','
) !== false
&& strpos($value, '@@') !== false)
&& strpos((string) $value, '@@') !== false)
{
// reset the group temp arrays
$groups_ = array();
@@ -2982,7 +2982,7 @@ class Fields extends Structure
'option' => array());
$order_ = array();
// mulitpal options
$options = explode(',', $value);
$options = explode(',', (string) $value);
foreach ($options as $option)
{
if (strpos($option, '@@') !== false)
@@ -3125,10 +3125,10 @@ class Fields extends Structure
}
}
}
elseif (strpos($value, ',') !== false)
elseif (strpos((string) $value, ',') !== false)
{
// mulitpal options
$options = explode(',', $value);
$options = explode(',', (string) $value);
foreach ($options as $option)
{
$optionXML = $field->fieldXML->addChild('option');
@@ -3170,10 +3170,10 @@ class Fields extends Structure
{
// one option
$optionXML = $field->fieldXML->addChild('option');
if (strpos($value, '|') !== false)
if (strpos((string) $value, '|') !== false)
{
// has other value then text
list($v, $t) = explode('|', $value);
list($v, $t) = explode('|', (string) $value);
$langValue = $langView . '_'
. FieldHelper::safe(
$t, true
@@ -3279,11 +3279,11 @@ class Fields extends Structure
);
$fieldSetXML->addAttribute('repeat', 'true');
if (strpos($fieldAttributes['fields'], ',') !== false)
if (strpos((string) $fieldAttributes['fields'], ',') !== false)
{
// mulitpal fields
$fieldsSets = (array) explode(
',', $fieldAttributes['fields']
',', (string) $fieldAttributes['fields']
);
}
elseif (is_numeric($fieldAttributes['fields']))
@@ -3462,11 +3462,11 @@ class Fields extends Structure
$form, $attributes
);
if (strpos($fieldAttributes['fields'], ',') !== false)
if (strpos((string) $fieldAttributes['fields'], ',') !== false)
{
// multiple fields
$fieldsSets = (array) explode(
',', $fieldAttributes['fields']
',', (string) $fieldAttributes['fields']
);
}
elseif (is_numeric($fieldAttributes['fields']))
@@ -3657,9 +3657,9 @@ class Fields extends Structure
);
if (strtolower($typeName) === 'groupedlist'
&& strpos(
$value, ','
(string) $value, ','
) !== false
&& strpos($value, '@@') !== false)
&& strpos((string) $value, '@@') !== false)
{
// reset the group temp arrays
$groups_ = array();
@@ -3667,7 +3667,7 @@ class Fields extends Structure
'option' => array());
$order_ = array();
// mulitpal options
$options = explode(',', $value);
$options = explode(',', (string) $value);
foreach ($options as $option)
{
if (strpos($option, '@@') !== false)
@@ -3810,10 +3810,10 @@ class Fields extends Structure
}
}
}
elseif (strpos($value, ',') !== false)
elseif (strpos((string) $value, ',') !== false)
{
// municipal options
$options = explode(',', $value);
$options = explode(',', (string) $value);
foreach ($options as $option)
{
$optionXML = $field->fieldXML->addChild('option');
@@ -3855,10 +3855,10 @@ class Fields extends Structure
{
// one option
$optionXML = $field->fieldXML->addChild('option');
if (strpos($value, '|') !== false)
if (strpos((string) $value, '|') !== false)
{
// has other value then text
list($v, $t) = explode('|', $value);
list($v, $t) = explode('|', (string) $value);
$langValue = $langView . '_'
. FieldHelper::safe(
$t, true
@@ -4053,7 +4053,7 @@ class Fields extends Structure
foreach ($this->siteFields[$view][$field] as $codeString => $array)
{
// get the code array
$codeArray = explode('___', $codeString);
$codeArray = explode('___', (string) $codeString);
// set the code
$code = trim($codeArray[0]);
// set the decoding methods
@@ -4189,18 +4189,18 @@ class Fields extends Structure
);
}
// catch all PHP here
elseif (strpos($property['name'], 'type_php') !== false
elseif (strpos((string) $property['name'], 'type_php') !== false
&& $setCustom)
{
// set the line number
$phpLine = (int) preg_replace(
'/[^0-9]/', '', $property['name']
'/[^0-9]/', '', (string) $property['name']
);
// set the type key
$phpKey = (string) trim(
str_replace(
'type_', '',
preg_replace('/[0-9]+/', '', $property['name'])
preg_replace('/[0-9]+/', '', (string) $property['name'])
), '_'
);
// load the php for the custom field file
@@ -4619,7 +4619,7 @@ class Fields extends Structure
&& !is_numeric($number_check))
{
$number_check = str_replace(
',', '.', $field['settings']->datadefault_other
',', '.', (string) $field['settings']->datadefault_other
);
}
// check if we have a valid number value
@@ -4962,14 +4962,14 @@ class Fields extends Structure
. $otherView;
}
// 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
// so I will here check that it does, and if not raise an error message to fix this
if ($target_view !== $otherView)
{
$target_extension = trim(explode('.', $_extension)[0]);
$target_extension = trim(explode('.', (string) $_extension)[0]);
$correction = $target_extension . '.' . $otherView;
$this->app->enqueueMessage(
JText::sprintf(
@@ -5242,7 +5242,7 @@ class Fields extends Structure
$filter_type_code = StringHelper::safe(
$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(
$name, 'F'
);
@@ -5338,10 +5338,10 @@ class Fields extends Structure
// set J prefix
$jprefix = 'J';
// 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
$dotTypeArray = explode('.', $data['type']);
$dotTypeArray = explode('.', (string) $data['type']);
// set the J prefix
if (count((array) $dotTypeArray) > 1)
{
@@ -5527,7 +5527,7 @@ class Fields extends Structure
);
}
// 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)
{
CFactory::_('Content')->add_('customfield_' . $data['type'], 'JFORM_TYPE_HEADER',
@@ -5873,7 +5873,7 @@ class Fields extends Structure
$field_filter_sets[] = Indent::_(3) . 'type="'
. $filter['type'] . '"';
// set css classname of this field
$filter['class'] = ucfirst($filter['type']);
$filter['class'] = ucfirst((string) $filter['type']);
}
else
{
@@ -5881,7 +5881,7 @@ class Fields extends Structure
$field_filter_sets[] = Indent::_(3) . 'type="'
. $filter['filter_type'] . '"';
// 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="'
. $filter['code'] . '"';
@@ -6124,17 +6124,17 @@ class Fields extends Structure
$fieldData['component'] = $local_component;
}
// check that the component has the com_ value in it
if (strpos($fieldData['component'], 'com_') === false
if (strpos((string) $fieldData['component'], 'com_') === false
|| strpos(
$fieldData['component'], '='
(string) $fieldData['component'], '='
) !== false)
{
$fieldData['component'] = "com_" . $fieldData['component'];
}
// 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(
$fieldData['component'], Placefix::b()
(string) $fieldData['component'], (string) Placefix::b()
) !== false) // should not be needed... but
{
$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
CFactory::_('Content')->set('COMPANYNAME', trim(
JFilterOutput::cleanText($this->componentData->companyname)
(string) JFilterOutput::cleanText($this->componentData->companyname)
));
// CREATIONDATE
@@ -121,31 +121,31 @@ class Infusion extends Interpretation
// AUTHOR
CFactory::_('Content')->set('AUTHOR', trim(
JFilterOutput::cleanText($this->componentData->author)
(string) JFilterOutput::cleanText($this->componentData->author)
));
// AUTHOREMAIL
CFactory::_('Content')->set('AUTHOREMAIL', trim($this->componentData->email));
CFactory::_('Content')->set('AUTHOREMAIL', trim((string) $this->componentData->email));
// AUTHORWEBSITE
CFactory::_('Content')->set('AUTHORWEBSITE', trim($this->componentData->website));
CFactory::_('Content')->set('AUTHORWEBSITE', trim((string) $this->componentData->website));
// COPYRIGHT
CFactory::_('Content')->set('COPYRIGHT', trim($this->componentData->copyright));
CFactory::_('Content')->set('COPYRIGHT', trim((string) $this->componentData->copyright));
// LICENSE
CFactory::_('Content')->set('LICENSE', trim($this->componentData->license));
CFactory::_('Content')->set('LICENSE', trim((string) $this->componentData->license));
// 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
CFactory::_('Content')->set('ACTUALVERSION', CFactory::_('Content')->get('VERSION'));
// 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(
'.', CFactory::_('Content')->get('VERSION')
'.', (string) CFactory::_('Content')->get('VERSION')
);
}
// load only first two values
@@ -177,13 +177,13 @@ class Infusion extends Interpretation
// SHORT_DISCRIPTION
CFactory::_('Content')->set('SHORT_DESCRIPTION', trim(
JFilterOutput::cleanText(
(string) JFilterOutput::cleanText(
$this->componentData->short_description
)
));
// DESCRIPTION
CFactory::_('Content')->set('DESCRIPTION', trim($this->componentData->description));
CFactory::_('Content')->set('DESCRIPTION', trim((string) $this->componentData->description));
// COMP_IMAGE_TYPE
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(
'$document->', '$this->document->', $phpDocument
'$document->', '$this->document->', (string) $phpDocument
));
// clear some memory
unset($phpDocument);
@@ -835,7 +835,7 @@ class Infusion extends Interpretation
{
// only minfy if no php is added to the footer script
if (CFactory::_('Config')->get('minify', 0)
&& strpos($footerScript, '<?php') === false)
&& strpos((string) $footerScript, '<?php') === false)
{
// minfy the script
$minifier = new JS;
@@ -1425,7 +1425,7 @@ class Infusion extends Interpretation
$target = array('admin' => 'a_rule_zi');
$this->buildDynamique($target, 'rule', $rule);
// 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
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)
{
// trim the tag
$tag = trim($tag);
$tag = trim((string) $tag);
foreach ($areas as $area => $languageStrings)
{
// set naming convention
$p = 'admin';
$t = '';
if (strpos($area, 'site') !== false)
if (strpos((string) $area, 'site') !== false)
{
if (CFactory::_('Config')->remove_site_folder
&& CFactory::_('Config')->remove_site_edit_folder)
@@ -2133,7 +2133,7 @@ class Infusion extends Interpretation
}
$p = 'site';
}
if (strpos($area, 'sys') !== false)
if (strpos((string) $area, 'sys') !== false)
{
$t = '.sys';
}

View File

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

View File

@@ -26,6 +26,10 @@
// No direct access to this file
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
*/
@@ -102,7 +106,7 @@ class Builder extends Mapping
{
// set the view object
$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_list = $name. 's';
$object->short_description = $name. ' view (dynamic build)';
@@ -257,14 +261,14 @@ class Builder extends Mapping
}
return false;
}
/**
* get the field type id from system
*/
protected function getFieldType($fieldName)
{
// 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
defined('_JEXEC') or die('Restricted access');
use VDM\Joomla\Utilities\GetHelper;
use VDM\Joomla\Utilities\ArrayHelper;
/**
* Extrusion class
*/
@@ -58,10 +61,10 @@ class Extrusion extends Builder
protected function setAdminViews(&$component_id)
{
// check if views were set
if (ComponentbuilderHelper::checkArray($this->views))
if (ArrayHelper::check($this->views))
{
$count = 0;
if (ComponentbuilderHelper::checkArray($this->addadmin_views))
if (ArrayHelper::check($this->addadmin_views))
{
$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;
}
}
if (isset($this->addadmin_views) && ComponentbuilderHelper::checkArray($this->addadmin_views))
if (isset($this->addadmin_views) && ArrayHelper::check($this->addadmin_views))
{
// set the field object
$object = new stdClass();
@@ -94,7 +97,7 @@ class Extrusion extends Builder
$object->created_by = $this->user->id;
$object->published = 1;
// 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
$object->id = (int) $item_id;