Release of v3.2.2-beta1

Fix subform set methods. Improved the Joomla Power Push path. Fix the metadata, metadesc, metakey database issue.
This commit is contained in:
2024-07-17 02:39:35 +02:00
parent 9e59163661
commit b656269527
79 changed files with 3332 additions and 1250 deletions

View File

@ -23,8 +23,8 @@ use VDM\Joomla\FOF\Encrypt\AES;
use VDM\Joomla\Utilities\StringHelper;
use VDM\Joomla\Utilities\JsonHelper;
use VDM\Joomla\Utilities\ArrayHelper;
use VDM\Joomla\Componentbuilder\Table\SchemaChecker;
use VDM\Joomla\Utilities\GetHelper;
use VDM\Joomla\Componentbuilder\Table\Schema;
HTML::_('bootstrap.renderModal');
/**
@ -6438,7 +6438,7 @@ class Com_ComponentbuilderInstallerScript
}
}
}
// all things to clear out
$jcb_cleaner = [];
$jcb_cleaner[] = JPATH_ADMINISTRATOR . '/components/com_componentbuilder/helpers/compiler';
@ -6454,7 +6454,7 @@ class Com_ComponentbuilderInstallerScript
foreach ($jcb_cleaner as $cleaner)
{
ComponentbuilderHelper::removeFolder($cleaner);
$this->removeFolder($cleaner);
}
// Check that the required configuration are set for PHP
@ -7170,7 +7170,10 @@ class Com_ComponentbuilderInstallerScript
// Check that the database is up-to date
$this->databaseSchemaCheck($app);
if ($this->classExists(SchemaChecker::class))
{
(new SchemaChecker())->run();
}
echo '<div style="background-color: #fff;" class="alert alert-info"><a target="_blank" href="https://dev.vdm.io" title="Component Builder">
<img src="components/com_componentbuilder/assets/images/vdm-component.jpg"/>
@ -9974,12 +9977,15 @@ class Com_ComponentbuilderInstallerScript
}
// Check that the database is up-to date
$this->databaseSchemaCheck($app);
if ($this->classExists(SchemaChecker::class))
{
(new SchemaChecker())->run();
}
echo '<div style="background-color: #fff;" class="alert alert-info"><a target="_blank" href="https://dev.vdm.io" title="Component Builder">
<img src="components/com_componentbuilder/assets/images/vdm-component.jpg"/>
</a>
<h3>Upgrade to Version 3.2.2-alpha7 Was Successful! Let us know if anything is not working as expected.</h3></div>';
<h3>Upgrade to Version 3.2.2-beta1 Was Successful! Let us know if anything is not working as expected.</h3></div>';
// Set db if not set already.
if (!isset($db))
@ -11742,76 +11748,77 @@ class Com_ComponentbuilderInstallerScript
}
/**
* Remove folders with files
* Remove folders with files (with ignore options)
*
* @param string $dir The path to folder to remove
* @param boolean $ignore The folders and files to ignore and not remove
*
* @return boolean True in all is removed
* @param string $dir The path to the folder to remove.
* @param array|null $ignore The folders and files to ignore and not remove.
*
* @return bool True if all specified files/folders are removed, false otherwise.
* @since 3.2.2
*/
protected function removeFolder($dir, $ignore = false)
protected function removeFolder(string $dir, ?array $ignore = null): bool
{
if (Folder::exists($dir))
if (!is_dir($dir))
{
$it = new RecursiveDirectoryIterator($dir);
$it = new RecursiveIteratorIterator($it, RecursiveIteratorIterator::CHILD_FIRST);
// remove ending /
$dir = rtrim($dir, '/');
// now loop the files & folders
foreach ($it as $file)
{
if ('.' === $file->getBasename() || '..' === $file->getBasename()) continue;
// set file dir
$file_dir = $file->getPathname();
// check if this is a dir or a file
if ($file->isDir())
{
$keeper = false;
if ($this->checkArray($ignore))
{
foreach ($ignore as $keep)
{
if (strpos($file_dir, $dir.'/'.$keep) !== false)
{
$keeper = true;
}
}
}
if ($keeper)
{
continue;
}
Folder::delete($file_dir);
}
else
{
$keeper = false;
if ($this->checkArray($ignore))
{
foreach ($ignore as $keep)
{
if (strpos($file_dir, $dir.'/'.$keep) !== false)
{
$keeper = true;
}
}
}
if ($keeper)
{
continue;
}
File::delete($file_dir);
}
}
// delete the root folder if not ignore found
if (!$this->checkArray($ignore))
{
return Folder::delete($dir);
}
return true;
return false;
}
return false;
$it = new \RecursiveDirectoryIterator($dir, \FilesystemIterator::SKIP_DOTS);
$it = new \RecursiveIteratorIterator($it, \RecursiveIteratorIterator::CHILD_FIRST);
// Remove trailing slash
$dir = rtrim($dir, '/');
foreach ($it as $file)
{
$filePath = $file->getPathname();
$relativePath = str_replace($dir . '/', '', $filePath);
if ($ignore !== null && in_array($relativePath, $ignore, true))
{
continue;
}
if ($file->isDir())
{
Folder::delete($filePath);
}
else
{
File::delete($filePath);
}
}
// Delete the root folder if there are no ignored files/folders left
if ($ignore === null || $this->isDirEmpty($dir, $ignore))
{
return Folder::delete($dir);
}
return true;
}
/**
* Check if a directory is empty considering ignored files/folders.
*
* @param string $dir The path to the folder to check.
* @param array $ignore The folders and files to ignore.
*
* @return bool True if the directory is empty or contains only ignored items, false otherwise.
* @since 3.2.1
*/
protected function isDirEmpty(string $dir, array $ignore): bool
{
$it = new \RecursiveDirectoryIterator($dir, \FilesystemIterator::SKIP_DOTS);
foreach ($it as $file)
{
$relativePath = str_replace($dir . '/', '', $file->getPathname());
if (!in_array($relativePath, $ignore, true))
{
return false;
}
}
return true;
}
/**
@ -11820,6 +11827,7 @@ class Com_ComponentbuilderInstallerScript
* @input array The array to check
*
* @returns bool/int number of items in array on success
* @since 3.2.2
*/
protected function checkArray($array, $removeEmptyString = false)
{
@ -11842,6 +11850,35 @@ class Com_ComponentbuilderInstallerScript
return false;
}
/**
* Ensures that a class in the namespace is available.
* If the class is not already loaded, it attempts to load it via the specified autoloader.
*
* @param string $className The fully qualified name of the class to check.
*
* @return bool True if the class exists or was successfully loaded, false otherwise.
* @since 3.2.2
*/
protected function classExists(string $className): bool
{
if (!class_exists($className, true))
{
// The power autoloader for this project (JPATH_ADMINISTRATOR) area.
$power_autoloader = JPATH_ADMINISTRATOR . '/components/com_componentbuilder/helpers/powerloader.php';
if (file_exists($power_autoloader))
{
require_once $power_autoloader;
}
// Check again if the class now exists after requiring the autoloader
if (!class_exists($className, true))
{
return false;
}
}
return true;
}
/**
* Define the required limits with specific messages for success and warning scenarios
*
@ -11948,66 +11985,6 @@ class Com_ComponentbuilderInstallerScript
$app->enqueueMessage('To optimize your Joomla Component Builder (JCB) development environment, specific PHP settings must be enhanced.<br>These settings are crucial for ensuring the successful installation and compilation of extensions.<br>We\'ve identified that certain configurations currently do not meet the recommended standards.<br>To adjust these settings and prevent potential issues, please consult our detailed guide available at <a href="https://git.vdm.dev/joomla/Component-Builder/wiki/PHP-Settings" target="_blank">JCB PHP Settings Wiki</a>.
', 'notice');
}
}
/**
* Make sure that the componentbuilder database schema is up to date.
*
* @return void
* @since 3.2.1
*/
protected function databaseSchemaCheck($app): void
{
// try to load the schema class
try
{
// make sure the class is loaded
$this->ensureClassExists(
Schema::class
);
// instantiate the schema class and check/update the database
$messages = (new Schema())->update();
}
catch (\Exception $e)
{
$app->enqueueMessage($e->getMessage(), 'warning');
return;
}
foreach ($messages as $message)
{
$app->enqueueMessage($message, 'message');
}
}
/**
* Ensures that a class in the namespace is available.
* If the class is not already loaded, it attempts to load it via the power autoloader.
*
* @param mixed $nameClass The name::class we are looking for.
*
* @return void
* @since 3.2.1
* @throws \Exception If the class could not be loaded.
*/
protected function ensureClassExists($nameClass): void
{
if (!class_exists($nameClass, true))
{
// The power autoloader for this project admin area.
$power_autoloader = JPATH_ADMINISTRATOR . '/components/com_componentbuilder/helpers/powerloader.php';
if (file_exists($power_autoloader))
{
require_once $power_autoloader;
}
// Check again if the class now exists after requiring it
if (!class_exists($nameClass, true))
{
throw new \Exception("We failed to find/load the $nameClass");
}
}
}
/**