Move the Power, Plugin and Module builders into the container. Many more PHP 8 improvments.

This commit is contained in:
2023-01-29 22:12:42 +02:00
parent e6c02a29f6
commit 7edbe20c33
68 changed files with 3443 additions and 1681 deletions

View File

@ -2681,70 +2681,38 @@ class Get
* get the module xml template
*
* @return string
*
* @deprecated 3.3
*/
public function getModuleXMLTemplate(&$module)
{
$xml = '<?xml version="1.0" encoding="utf-8"?>';
$xml .= PHP_EOL . '<extension type="module" version="'
. $this->joomlaVersions[CFactory::_('Config')->joomla_version]['xml_version'] . '" client="'
. $module->target_client . '" method="upgrade">';
$xml .= PHP_EOL . Indent::_(1) . '<name>' . $module->lang_prefix
. '</name>';
$xml .= PHP_EOL . Indent::_(1) . '<creationDate>' . Placefix::_h('BUILDDATE') . '</creationDate>';
$xml .= PHP_EOL . Indent::_(1) . '<author>' . Placefix::_h('AUTHOR') . '</author>';
$xml .= PHP_EOL . Indent::_(1) . '<authorEmail>' . Placefix::_h('AUTHOREMAIL') . '</authorEmail>';
$xml .= PHP_EOL . Indent::_(1) . '<authorUrl>' . Placefix::_h('AUTHORWEBSITE') . '</authorUrl>';
$xml .= PHP_EOL . Indent::_(1) . '<copyright>' . Placefix::_h('COPYRIGHT') . '</copyright>';
$xml .= PHP_EOL . Indent::_(1) . '<license>' . Placefix::_h('LICENSE') . '</license>';
$xml .= PHP_EOL . Indent::_(1) . '<version>' . $module->module_version
. '</version>';
$xml .= PHP_EOL . Indent::_(1) . '<description>' . $module->lang_prefix
. '_XML_DESCRIPTION</description>';
$xml .= Placefix::_h('MAINXML');
$xml .= PHP_EOL . '</extension>';
return $xml;
// set notice that we could not get a valid string from the target
$this->app->enqueueMessage(
JText::sprintf('<hr /><h3>%s Warning</h3>', __CLASS__), 'Error'
);
$this->app->enqueueMessage(
JText::sprintf(
'Use of a deprecated method (%s)!', __METHOD__
), 'Error'
);
}
/**
* get the module admin custom script field
*
* @return string
*
* @deprecated 3.3
*/
public function getModAdminVvvvvvvdm($fieldScriptBucket)
{
$form_field_class = array();
$form_field_class[] = Placefix::_h('BOM') . PHP_EOL;
$form_field_class[] = "//" . Line::_(__Line__, __Class__)
. " No direct access to this file";
$form_field_class[] = "defined('_JEXEC') or die('Restricted access');";
$form_field_class[] = PHP_EOL . "use Joomla\CMS\Form\FormField;";
$form_field_class[] = "use Joomla\CMS\Factory;";
$form_field_class[] = PHP_EOL
. "class JFormFieldModadminvvvvvvvdm extends FormField";
$form_field_class[] = "{";
$form_field_class[] = Indent::_(1)
. "protected \$type = 'modadminvvvvvvvdm';";
$form_field_class[] = PHP_EOL . Indent::_(1)
. "protected function getLabel()";
$form_field_class[] = Indent::_(1) . "{";
$form_field_class[] = Indent::_(2) . "return;";
$form_field_class[] = Indent::_(1) . "}";
$form_field_class[] = PHP_EOL . Indent::_(1)
. "protected function getInput()";
$form_field_class[] = Indent::_(1) . "{";
$form_field_class[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__)
. " Get the document";
$form_field_class[] = Indent::_(2)
. "\$document = Factory::getDocument();";
$form_field_class[] = implode(PHP_EOL, $fieldScriptBucket);
$form_field_class[] = Indent::_(2) . "return; // noting for now :)";
$form_field_class[] = Indent::_(1) . "}";
$form_field_class[] = "}";
return implode(PHP_EOL, $form_field_class);
// set notice that we could not get a valid string from the target
$this->app->enqueueMessage(
JText::sprintf('<hr /><h3>%s Warning</h3>', __CLASS__), 'Error'
);
$this->app->enqueueMessage(
JText::sprintf(
'Use of a deprecated method (%s)!', __METHOD__
), 'Error'
);
}
/**
@ -2810,7 +2778,7 @@ class Get
{
$xml = '<?xml version="1.0" encoding="utf-8"?>';
$xml .= PHP_EOL . '<extension type="plugin" version="'
. $this->joomlaVersions[CFactory::_('Config')->joomla_version]['xml_version'] . '" group="'
. CFactory::_('Config')->joomla_versions[CFactory::_('Config')->joomla_version]['xml_version'] . '" group="'
. strtolower((string) $plugin->group) . '" method="upgrade">';
$xml .= PHP_EOL . Indent::_(1) . '<name>' . $plugin->lang_prefix
. '</name>';

File diff suppressed because it is too large Load Diff

View File

@ -658,7 +658,7 @@ class Fields extends Structure
$fieldSet[] = Indent::_(3) . 'readonly="true"';
$fieldSet[] = Indent::_(2) . "/>";
// count the static field created
CFactory::_('Counter')->field++;
CFactory::_('Utilities.Counter')->field++;
}
// if created is not set
if (!isset($this->fieldsNames[$nameSingleCode]['created']))
@ -681,7 +681,7 @@ class Fields extends Structure
$fieldSet[] = Indent::_(3) . "filter=" . '"user_utc"';
$fieldSet[] = Indent::_(2) . "/>";
// count the static field created
CFactory::_('Counter')->field++;
CFactory::_('Utilities.Counter')->field++;
}
// if created_by is not set
if (!isset($this->fieldsNames[$nameSingleCode]['created_by']))
@ -701,7 +701,7 @@ class Fields extends Structure
. '_CREATED_BY_DESC"';
$fieldSet[] = Indent::_(2) . "/>";
// count the static field created
CFactory::_('Counter')->field++;
CFactory::_('Utilities.Counter')->field++;
}
// if published is not set
if (!isset($this->fieldsNames[$nameSingleCode]['published']))
@ -728,7 +728,7 @@ class Fields extends Structure
$fieldSet[] = Indent::_(4) . "JTRASHED</option>";
$fieldSet[] = Indent::_(2) . "</field>";
// count the static field created
CFactory::_('Counter')->field++;
CFactory::_('Utilities.Counter')->field++;
}
// if modified is not set
if (!isset($this->fieldsNames[$nameSingleCode]['modified']))
@ -743,7 +743,7 @@ class Fields extends Structure
$fieldSet[] = Indent::_(3)
. 'size="22" readonly="true" format="%Y-%m-%d %H:%M:%S" filter="user_utc" />';
// count the static field created
CFactory::_('Counter')->field++;
CFactory::_('Utilities.Counter')->field++;
}
// if modified_by is not set
if (!isset($this->fieldsNames[$nameSingleCode]['modified_by']))
@ -761,7 +761,7 @@ class Fields extends Structure
$fieldSet[] = Indent::_(3) . 'filter="unset"';
$fieldSet[] = Indent::_(2) . "/>";
// count the static field created
CFactory::_('Counter')->field++;
CFactory::_('Utilities.Counter')->field++;
}
// check if view has access
if (isset($this->accessBuilder[$nameSingleCode])
@ -784,7 +784,7 @@ class Fields extends Structure
$fieldSet[] = Indent::_(3) . 'required="false"';
$fieldSet[] = Indent::_(2) . "/>";
// count the static field created
CFactory::_('Counter')->field++;
CFactory::_('Utilities.Counter')->field++;
}
// if ordering is not set
if (!isset($this->fieldsNames[$nameSingleCode]['ordering']))
@ -807,7 +807,7 @@ class Fields extends Structure
$fieldSet[] = Indent::_(3) . 'required="false"';
$fieldSet[] = Indent::_(2) . "/>";
// count the static field created
CFactory::_('Counter')->field++;
CFactory::_('Utilities.Counter')->field++;
}
// if version is not set
if (!isset($this->fieldsNames[$nameSingleCode]['version']))
@ -827,7 +827,7 @@ class Fields extends Structure
$fieldSet[] = Indent::_(3) . 'filter="unset"';
$fieldSet[] = Indent::_(2) . "/>";
// count the static field created
CFactory::_('Counter')->field++;
CFactory::_('Utilities.Counter')->field++;
}
// check if metadata is added to this view
if (isset($this->metadataBuilder[$nameSingleCode])
@ -851,7 +851,7 @@ class Fields extends Structure
$fieldSet[] = Indent::_(3) . 'cols="30"';
$fieldSet[] = Indent::_(2) . "/>";
// count the static field created
CFactory::_('Counter')->field++;
CFactory::_('Utilities.Counter')->field++;
}
// metadesc
if (!isset($this->fieldsNames[$nameSingleCode]['metadesc']))
@ -869,7 +869,7 @@ class Fields extends Structure
$fieldSet[] = Indent::_(3) . 'cols="30"';
$fieldSet[] = Indent::_(2) . "/>";
// count the static field created
CFactory::_('Counter')->field++;
CFactory::_('Utilities.Counter')->field++;
}
}
// fix the permissions field "title" issue gh-629
@ -896,7 +896,7 @@ class Fields extends Structure
. $nameSingleCode . '"';
$fieldSet[] = Indent::_(2) . "/>";
// count the static field created
CFactory::_('Counter')->field++;
CFactory::_('Utilities.Counter')->field++;
// setup needed field values for layout
$field_array = array();
$field_array['order_edit'] = 0;
@ -957,7 +957,7 @@ class Fields extends Structure
. '<option value="noindex, nofollow">JGLOBAL_NOINDEX_NOFOLLOW</option>';
$fieldSet[] = Indent::_(3) . '</field>';
// count the static field created
CFactory::_('Counter')->field++;
CFactory::_('Utilities.Counter')->field++;
}
// author
if (!isset($this->fieldsNames[$nameSingleCode]['author']))
@ -972,7 +972,7 @@ class Fields extends Structure
$fieldSet[] = Indent::_(4) . 'size="20"';
$fieldSet[] = Indent::_(3) . "/>";
// count the static field created
CFactory::_('Counter')->field++;
CFactory::_('Utilities.Counter')->field++;
}
// rights
if (!isset($this->fieldsNames[$nameSingleCode]['rights']))
@ -987,7 +987,7 @@ class Fields extends Structure
$fieldSet[] = Indent::_(4) . 'cols="30" rows="2"';
$fieldSet[] = Indent::_(3) . "/>";
// count the static field created
CFactory::_('Counter')->field++;
CFactory::_('Utilities.Counter')->field++;
}
$fieldSet[] = Indent::_(2) . "</fieldset>";
$fieldSet[] = Indent::_(1) . "</fields>";
@ -1084,7 +1084,7 @@ class Fields extends Structure
$fieldXML = $fieldSetXML->addChild('field');
ComponentbuilderHelper::xmlAddAttributes($fieldXML, $attributes);
// count the static field created
CFactory::_('Counter')->field++;
CFactory::_('Utilities.Counter')->field++;
}
// if created is not set
if (!isset($this->fieldsNames[$nameSingleCode]['created']))
@ -1106,7 +1106,7 @@ class Fields extends Structure
$fieldXML = $fieldSetXML->addChild('field');
ComponentbuilderHelper::xmlAddAttributes($fieldXML, $attributes);
// count the static field created
CFactory::_('Counter')->field++;
CFactory::_('Utilities.Counter')->field++;
}
// if created_by is not set
if (!isset($this->fieldsNames[$nameSingleCode]['created_by']))
@ -1125,7 +1125,7 @@ class Fields extends Structure
$fieldXML = $fieldSetXML->addChild('field');
ComponentbuilderHelper::xmlAddAttributes($fieldXML, $attributes);
// count the static field created
CFactory::_('Counter')->field++;
CFactory::_('Utilities.Counter')->field++;
}
// if published is not set
if (!isset($this->fieldsNames[$nameSingleCode]['published']))
@ -1143,7 +1143,7 @@ class Fields extends Structure
$fieldXML = $fieldSetXML->addChild('field');
ComponentbuilderHelper::xmlAddAttributes($fieldXML, $attributes);
// count the static field created
CFactory::_('Counter')->field++;
CFactory::_('Utilities.Counter')->field++;
foreach (
array('JPUBLISHED' => 1, 'JUNPUBLISHED' => 0, 'JARCHIVED' => 2,
'JTRASHED' => -2) as $text => $value
@ -1175,7 +1175,7 @@ class Fields extends Structure
$fieldXML = $fieldSetXML->addChild('field');
ComponentbuilderHelper::xmlAddAttributes($fieldXML, $attributes);
// count the static field created
CFactory::_('Counter')->field++;
CFactory::_('Utilities.Counter')->field++;
}
// if modified_by is not set
if (!isset($this->fieldsNames[$nameSingleCode]['modified_by']))
@ -1196,7 +1196,7 @@ class Fields extends Structure
$fieldXML = $fieldSetXML->addChild('field');
ComponentbuilderHelper::xmlAddAttributes($fieldXML, $attributes);
// count the static field created
CFactory::_('Counter')->field++;
CFactory::_('Utilities.Counter')->field++;
}
// check if view has access
if (isset($this->accessBuilder[$nameSingleCode])
@ -1221,7 +1221,7 @@ class Fields extends Structure
$fieldXML = $fieldSetXML->addChild('field');
ComponentbuilderHelper::xmlAddAttributes($fieldXML, $attributes);
// count the static field created
CFactory::_('Counter')->field++;
CFactory::_('Utilities.Counter')->field++;
}
// if ordering is not set
if (!isset($this->fieldsNames[$nameSingleCode]['ordering']))
@ -1244,7 +1244,7 @@ class Fields extends Structure
$fieldXML = $fieldSetXML->addChild('field');
ComponentbuilderHelper::xmlAddAttributes($fieldXML, $attributes);
// count the static field created
CFactory::_('Counter')->field++;
CFactory::_('Utilities.Counter')->field++;
}
// if version is not set
if (!isset($this->fieldsNames[$nameSingleCode]['version']))
@ -1266,7 +1266,7 @@ class Fields extends Structure
$fieldXML = $fieldSetXML->addChild('field');
ComponentbuilderHelper::xmlAddAttributes($fieldXML, $attributes);
// count the static field created
CFactory::_('Counter')->field++;
CFactory::_('Utilities.Counter')->field++;
}
// check if metadata is added to this view
if (isset($this->metadataBuilder[$nameSingleCode])
@ -1294,7 +1294,7 @@ class Fields extends Structure
$fieldXML, $attributes
);
// count the static field created
CFactory::_('Counter')->field++;
CFactory::_('Utilities.Counter')->field++;
}
// metadesc
if (!isset($this->fieldsNames[$nameSingleCode]['metadesc']))
@ -1311,7 +1311,7 @@ class Fields extends Structure
$fieldXML, $attributes
);
// count the static field created
CFactory::_('Counter')->field++;
CFactory::_('Utilities.Counter')->field++;
}
}
// fix the permissions field "title" issue gh-629
@ -1346,7 +1346,7 @@ class Fields extends Structure
$fieldXML = $fieldSetXML->addChild('field');
ComponentbuilderHelper::xmlAddAttributes($fieldXML, $attributes);
// count the static field created
CFactory::_('Counter')->field++;
CFactory::_('Utilities.Counter')->field++;
// setup needed field values for layout
$field_array = array();
$field_array['order_edit'] = 0;
@ -1409,7 +1409,7 @@ class Fields extends Structure
$robots, $attributes
);
// count the static field created
CFactory::_('Counter')->field++;
CFactory::_('Utilities.Counter')->field++;
$options = array(
'JGLOBAL_USE_GLOBAL' => '',
'JGLOBAL_INDEX_FOLLOW' => 'index, follow',
@ -1443,7 +1443,7 @@ class Fields extends Structure
$author, $attributes
);
// count the static field created
CFactory::_('Counter')->field++;
CFactory::_('Utilities.Counter')->field++;
}
// rights
if (!isset($this->fieldsNames[$nameSingleCode]['rights']))
@ -1467,7 +1467,7 @@ class Fields extends Structure
$rights, $attributes
);
// count the static field created
CFactory::_('Counter')->field++;
CFactory::_('Utilities.Counter')->field++;
}
}
}
@ -1891,7 +1891,7 @@ class Fields extends Structure
&$optionArray, $custom = null, $taber = ''
) {
// count the dynamic fields created
CFactory::_('Counter')->field++;
CFactory::_('Utilities.Counter')->field++;
// check what type of field builder to use
if (CFactory::_('Config')->get('field_builder_type', 2) == 1)
{

View File

@ -1234,9 +1234,10 @@ class Interpretation extends Fields
}
// stop it from being added double
$addDynamicSQL = false;
CFactory::_('Component')->appendArray('version_update', $update_);
// add dynamic SQL
$this->setUpdateXMLSQL($update_, $updateXML, $addDynamicSQL);
CFactory::_('Component')->appendArray('version_update', $update_);
}
/**
@ -1249,7 +1250,7 @@ class Interpretation extends Fields
public function setUpdateXMLSQL(&$update, &$updateXML, &$addDynamicSQL)
{
// ensure version naming is correct
$update['version'] = preg_replace('/[^0-9.]+/', '', (string) $update['version']);
$update['version'] = preg_replace('/[^0-9\.]+/', '', (string) $update['version']);
// setup SQL
if (StringHelper::check($update['mysql']))
{
@ -1284,7 +1285,8 @@ class Interpretation extends Fields
$name = StringHelper::safe($update['version']);
$target = array('admin' => $name);
$this->buildDynamique($target, 'sql_update', $update['version']);
CFactory::_('Content')->set_($name . '_' . $update['version'], 'UPDATE_VERSION_MYSQL',
$_name = preg_replace('/[\.]+/', '_', (string) $update['version']);
CFactory::_('Content')->set_($name . '_' . $_name, 'UPDATE_VERSION_MYSQL',
$update['mysql']
);
}
@ -6294,7 +6296,7 @@ class Interpretation extends Fields
if (isset($folder['rename']) && 1 == $folder['rename'])
{
if ($_paths = FileHelper::getPaths(
$this->componentPath . $path
CFactory::_('Utilities.Paths')->component_path . $path
))
{
$files[$path] = $_paths;
@ -6304,7 +6306,7 @@ class Interpretation extends Fields
{
$path = $path . '/' . trim((string)$folder['folder'], '/');
if ($_paths = FileHelper::getPaths(
$this->componentPath . $path
CFactory::_('Utilities.Paths')->component_path . $path
))
{
$files[$path] = $_paths;
@ -7087,7 +7089,7 @@ class Interpretation extends Fields
public function getReplacementNames()
{
foreach ($this->newFiles as $type => $files)
foreach (CFactory::_('Utilities.Files')->toArray() as $type => $files)
{
foreach ($files as $view => $file)
{
@ -8512,7 +8514,7 @@ class Interpretation extends Fields
public function setMoveFolderScript()
{
if ($this->setMoveFolders)
if (CFactory::_('Registry')->get('set_move_folders_install_script'))
{
// reset script
$script = array();
@ -8530,7 +8532,7 @@ class Interpretation extends Fields
public function setMoveFolderMethod()
{
if ($this->setMoveFolders)
if (CFactory::_('Registry')->get('set_move_folders_install_script'))
{
// reset script
$script = array();
@ -22535,7 +22537,7 @@ class Interpretation extends Fields
$type = ComponentbuilderHelper::imageInfo($path);
if ($type)
{
$imagePath = $this->componentPath . '/admin/assets/images';
$imagePath = CFactory::_('Utilities.Paths')->component_path . '/admin/assets/images';
// move the image to its place
File::copy(
JPATH_SITE . '/' . $path,
@ -22757,7 +22759,7 @@ class Interpretation extends Fields
$this->iconBuilder
))
{
$imagePath = $this->componentPath
$imagePath = CFactory::_('Utilities.Paths')->component_path
. '/admin/assets/images/icons';
foreach ($this->iconBuilder as $icon => $path)
{
@ -27924,20 +27926,20 @@ function vdm_dkim() {
{
Folder::create($path);
// count the folder created
CFactory::_('Counter')->folder++;
CFactory::_('Utilities.Counter')->folder++;
}
// add to language files (for now we add all to both TODO)
$this->writeFile(
CFactory::_('Utilities.File')->write(
$path . $file_name,
implode(PHP_EOL, $lang)
);
$this->writeFile(
CFactory::_('Utilities.File')->write(
$path . $tag . '.' . $module->file_name
. '.sys.ini',
implode(PHP_EOL, $lang)
);
// set the line counter
CFactory::_('Counter')->line += count(
CFactory::_('Utilities.Counter')->line += count(
(array) $lang
);
unset($lang);
@ -28316,14 +28318,14 @@ function vdm_dkim() {
{
Folder::create($path);
// count the folder created
CFactory::_('Counter')->folder++;
CFactory::_('Utilities.Counter')->folder++;
}
// add to language file
$this->writeFile(
CFactory::_('Utilities.File')->write(
$path . $file_name,
implode(PHP_EOL, $lang)
);
$this->writeFile(
CFactory::_('Utilities.File')->write(
$path . $tag . '.plg_' . strtolower(
(string) $plugin->group
)
@ -28332,7 +28334,7 @@ function vdm_dkim() {
implode(PHP_EOL, $lang)
);
// set the line counter
CFactory::_('Counter')->line += count(
CFactory::_('Utilities.Counter')->line += count(
(array) $lang
);
unset($lang);

View File

@ -172,7 +172,7 @@ class Infusion extends Interpretation
CFactory::_('Content')->set('GLOBALVERSION', CFactory::_('Content')->get('VERSION'));
// set the joomla target xml version
CFactory::_('Content')->set('XMLVERSION', $this->joomlaVersions[CFactory::_('Config')->joomla_version]['xml_version']);
CFactory::_('Content')->set('XMLVERSION', CFactory::_('Config')->joomla_versions[CFactory::_('Config')->joomla_version]['xml_version']);
// Component_name
$name = CFactory::_('Component')->get('name');
@ -2095,7 +2095,7 @@ class Infusion extends Interpretation
// remove old unused language strings
$this->purgeLanuageStrings($values, CFactory::_('Config')->component_id);
// path to INI file
$getPAth = $this->templatePath . '/en-GB.com_admin.ini';
$getPAth = CFactory::_('Utilities.Paths')->template_path . '/en-GB.com_admin.ini';
// for plugin event TODO change event api signatures
$component_context = CFactory::_('Config')->component_context;
// Trigger Event: jcb_ce_onBeforeBuildAllLangFiles
@ -2143,18 +2143,18 @@ class Infusion extends Interpretation
))
{
// build the path to place the lang file
$path = $this->componentPath . '/' . $p . '/language/'
$path = CFactory::_('Utilities.Paths')->component_path . '/' . $p . '/language/'
. $tag . '/';
if (!Folder::exists($path))
{
Folder::create($path);
// count the folder created
CFactory::_('Counter')->folder++;
CFactory::_('Utilities.Counter')->folder++;
}
// move the file to its place
File::copy($getPAth, $path . $file_name);
// count the file created
CFactory::_('Counter')->file++;
CFactory::_('Utilities.Counter')->file++;
// add content to it
$lang = array_map(
fn($langstring, $placeholder) => $placeholder . '="' . $langstring . '"',
@ -2162,11 +2162,11 @@ class Infusion extends Interpretation
array_keys($languageStrings)
);
// add to language file
$this->writeFile(
CFactory::_('Utilities.File')->write(
$path . $file_name, implode(PHP_EOL, $lang)
);
// set the line counter
CFactory::_('Counter')->line += count(
CFactory::_('Utilities.Counter')->line += count(
(array) $lang
);
unset($lang);
@ -2199,7 +2199,7 @@ class Infusion extends Interpretation
= implode(PHP_EOL . Indent::_(2), $langXML['site']);
}
// build xml path
$xmlPath = $this->componentPath . '/' . CFactory::_('Config')->component_code_name
$xmlPath = CFactory::_('Utilities.Paths')->component_path . '/' . CFactory::_('Config')->component_code_name
. '.xml';
// get the content in xml
$componentXML = FileHelper::getContent(
@ -2208,7 +2208,7 @@ class Infusion extends Interpretation
// update the xml content
$componentXML = CFactory::_('Placeholder')->update($componentXML, $replace);
// store the values back to xml
$this->writeFile($xmlPath, $componentXML);
CFactory::_('Utilities.File')->write($xmlPath, $componentXML);
}
}
}