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:
@ -17,7 +17,7 @@ defined('_JEXEC') or die('Restricted access');
|
||||
// No direct access to this file
|
||||
defined('_JEXEC') or die('Restricted access');
|
||||
|
||||
###CUSTOM_POWER_AUTOLOADER###
|
||||
###POWER_AUTOLOADER###
|
||||
|
||||
###ADMIN_HELPER_CLASS_HEADER###
|
||||
|
||||
|
@ -17,7 +17,7 @@ defined('_JEXEC') or die('Restricted access');
|
||||
// No direct access to this file
|
||||
defined('_JEXEC') or die('Restricted access');
|
||||
|
||||
###SITE_CUSTOM_POWER_AUTOLOADER###
|
||||
###SITE_POWER_AUTOLOADER###
|
||||
|
||||
###SITE_HELPER_CLASS_HEADER###
|
||||
|
||||
|
@ -17,7 +17,7 @@ defined('_JEXEC') or die('Restricted access');
|
||||
// No direct access to this file
|
||||
defined('_JEXEC') or die('Restricted access');
|
||||
|
||||
###CUSTOM_POWER_AUTOLOADER###
|
||||
###POWER_AUTOLOADER###
|
||||
|
||||
###ADMIN_COMPONENT_HEADER###
|
||||
|
||||
|
@ -17,7 +17,7 @@ defined('_JEXEC') or die('Restricted access');
|
||||
// No direct access to this file
|
||||
defined('_JEXEC') or die('Restricted access');
|
||||
|
||||
###SITE_CUSTOM_POWER_AUTOLOADER###
|
||||
###SITE_POWER_AUTOLOADER###
|
||||
|
||||
###SITE_COMPONENT_HEADER###
|
||||
|
||||
|
@ -138,76 +138,77 @@ class Com_###Component###InstallerScript
|
||||
}
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -216,6 +217,7 @@ class Com_###Component###InstallerScript
|
||||
* @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)
|
||||
{
|
||||
@ -236,5 +238,29 @@ class Com_###Component###InstallerScript
|
||||
return $nr;
|
||||
}
|
||||
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))
|
||||
{
|
||||
###THREE_POWER_AUTOLOADER###
|
||||
|
||||
// Check again if the class now exists after requiring the autoloader
|
||||
if (!class_exists($className, true))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}###INSTALLERMETHODS###
|
||||
}
|
||||
|
@ -15,7 +15,7 @@ defined('_JCB_TEMPLATE') or die;
|
||||
###BOM###
|
||||
namespace ###NAMESPACEPREFIX###\Component\###ComponentNamespace###\Administrator\Helper;
|
||||
|
||||
###CUSTOM_POWER_AUTOLOADER###
|
||||
###POWER_AUTOLOADER###
|
||||
|
||||
###ADMIN_HELPER_CLASS_HEADER###
|
||||
|
||||
|
@ -14,7 +14,7 @@ defined('_JCB_TEMPLATE') or die;
|
||||
?>
|
||||
###BOM###
|
||||
|
||||
###CUSTOM_POWER_AUTOLOADER###
|
||||
###POWER_AUTOLOADER###
|
||||
|
||||
// (soon) use Joomla\CMS\Association\AssociationExtensionInterface;
|
||||
use Joomla\CMS\Categories\CategoryFactoryInterface;
|
||||
@ -55,10 +55,10 @@ return new class () implements ServiceProviderInterface
|
||||
{
|
||||
// (soon) $container->set(AssociationExtensionInterface::class, new AssociationsHelper());
|
||||
|
||||
$container->registerServiceProvider(new CategoryFactory('\\###NAMESPACEPREFIX###\\Component\\###Component###'));
|
||||
$container->registerServiceProvider(new MVCFactory('\\###NAMESPACEPREFIX###\\Component\\###Component###'));
|
||||
$container->registerServiceProvider(new ComponentDispatcherFactory('\\###NAMESPACEPREFIX###\\Component\\###Component###'));
|
||||
$container->registerServiceProvider(new RouterFactory('\\###NAMESPACEPREFIX###\\Component\\###Component###'));
|
||||
$container->registerServiceProvider(new CategoryFactory('\\###NAMESPACEPREFIX###\\Component\\###ComponentNamespace###'));
|
||||
$container->registerServiceProvider(new MVCFactory('\\###NAMESPACEPREFIX###\\Component\\###ComponentNamespace###'));
|
||||
$container->registerServiceProvider(new ComponentDispatcherFactory('\\###NAMESPACEPREFIX###\\Component\\###ComponentNamespace###'));
|
||||
$container->registerServiceProvider(new RouterFactory('\\###NAMESPACEPREFIX###\\Component\\###ComponentNamespace###'));
|
||||
|
||||
$container->set(
|
||||
ComponentInterface::class,
|
||||
|
@ -279,6 +279,80 @@ class Com_###Component###InstallerScript implements InstallerScriptInterface
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove folders with files (with ignore options)
|
||||
*
|
||||
* @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(string $dir, ?array $ignore = null): bool
|
||||
{
|
||||
if (!is_dir($dir))
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the files and folders in the given array from
|
||||
*
|
||||
@ -1095,5 +1169,29 @@ class Com_###Component###InstallerScript implements InstallerScriptInterface
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 4.0.1
|
||||
*/
|
||||
protected function classExists(string $className): bool
|
||||
{
|
||||
if (!class_exists($className, true))
|
||||
{
|
||||
###THREE_POWER_AUTOLOADER###
|
||||
|
||||
// Check again if the class now exists after requiring the autoloader
|
||||
if (!class_exists($className, true))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}###INSTALLERMETHODS###
|
||||
}
|
||||
|
@ -15,7 +15,7 @@ defined('_JCB_TEMPLATE') or die;
|
||||
###BOM###
|
||||
namespace ###NAMESPACEPREFIX###\Component\###ComponentNamespace###\Site\Helper;
|
||||
|
||||
###SITE_CUSTOM_POWER_AUTOLOADER###
|
||||
###SITE_POWER_AUTOLOADER###
|
||||
|
||||
###SITE_HELPER_CLASS_HEADER###
|
||||
|
||||
|
Reference in New Issue
Block a user