Release of v5.1.1-beta1

Add JCB new package engine.
This commit is contained in:
2025-06-18 19:49:35 +00:00
parent 3b502eb09b
commit 70718936b4
464 changed files with 34151 additions and 13973 deletions

View File

@@ -24,9 +24,8 @@ use Joomla\Input\Input;
use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper;
use Joomla\CMS\Helper\TagsHelper;
use VDM\Joomla\Utilities\ArrayHelper as UtilitiesArrayHelper;
use VDM\Joomla\Utilities\StringHelper;
use VDM\Joomla\Utilities\GetHelper;
use VDM\Joomla\Utilities\ObjectHelper;
use VDM\Joomla\Utilities\StringHelper;
// No direct access to this file
\defined('_JEXEC') or die;
@@ -98,175 +97,6 @@ class Joomla_pluginsModel extends ListModel
$this->app ??= Factory::getApplication();
}
/**
* get Boilerplate
*
* @return boolean
*/
public function getBoilerplate()
{
// get boilerplate repo root details
if (($repo_tree = ComponentbuilderHelper::getGithubRepoFileList('boilerplate', ComponentbuilderHelper::$bolerplateAPI)) !== false)
{
$found = array_values(array_filter(
$repo_tree,
function($tree) {
if (isset($tree->path) && $tree->path === 'plugins')
{
return true;
}
return false;
}
));
// make sure we have the correct boilerplate
if (UtilitiesArrayHelper::check($found) && count($found) == 1 && method_exists(__CLASS__, 'getPluginsBoilerplate'))
{
// get the plugins boilerplate
return $this->getPluginsBoilerplate($found[0]->url);
}
}
return false;
}
/**
* get Plugin Boilerplate
*
* @return boolean true on success
*
*/
protected function getPluginsBoilerplate($url)
{
// get boilerplate root for plugins
if (($plugin_tree = ComponentbuilderHelper::getGithubRepoFileList('boilerplate_plugins', $url)) !== false)
{
// get the app object
$app = Factory::getApplication();
// set the table names
$tables = array();
$tables['e'] = 'class_extends';
$tables['g'] = 'joomla_plugin_group';
$tables['m'] = 'class_method';
$tables['p'] = 'class_property';
// load the needed models
$models = array();
$models['e'] = ComponentbuilderHelper::getModel($tables['e']);
$models['g'] = ComponentbuilderHelper::getModel($tables['g']);
$models['p'] = ComponentbuilderHelper::getModel($tables['p']);
$models['m'] = ComponentbuilderHelper::getModel($tables['m']);
// get the needed data of each plugin group
$groups = array_map(
function($tree) use(&$app, &$models, &$tables){
if (($fooClass = ComponentbuilderHelper::getFileContents(ComponentbuilderHelper::$bolerplatePath . '/plugins/' . $tree->path . '/foo.php')) !== false && StringHelper::check($fooClass))
{
// extract the boilerplate class extends and check if already set
if (($classExtends = ComponentbuilderHelper::extractBoilerplateClassExtends($fooClass, 'plugins')) !== false &&
($classExtendsID = GetHelper::var('class_extends', $classExtends, 'name', 'id')) === false)
{
// load the extends class name
$class = array('id' => 0, 'published' => 1, 'version' => 1, 'name' => $classExtends);
// extract the boilerplate class header
$class['head'] = ComponentbuilderHelper::extractBoilerplateClassHeader($fooClass, $classExtends, 'plugins');
// extract the boilerplate class comment
$class['comment'] = ComponentbuilderHelper::extractBoilerplateClassComment($fooClass, $classExtends, 'plugins');
// set the extension type
$class['extension_type'] = 'plugins';
// store the class
$this->storePluginBoilerplate($tables['e'], $models['e'], $class, $app);
// work around
$classExtendsID = GetHelper::var('class_extends', $classExtends, 'name', 'id');
}
// set plugin group if not already set
if (($pluginGroupID = GetHelper::var('joomla_plugin_group', $tree->path, 'name', 'id')) === false)
{
// load the plugin group name
$pluginGroup = array('id' => 0, 'published' => 1, 'version' => 1, 'name' => $tree->path, 'class_extends' => $classExtendsID);
// store the group
$this->storePluginBoilerplate($tables['g'], $models['g'], $pluginGroup, $app);
// work around
$pluginGroupID = GetHelper::var('joomla_plugin_group', $tree->path, 'name', 'id');
}
// extract the boilerplate class property and methods
if (($classProperiesMethods = ComponentbuilderHelper::extractBoilerplateClassPropertiesMethods($fooClass, $classExtends, 'plugins', $pluginGroupID)) !== false)
{
// create the properties found
if (isset($classProperiesMethods['property']) && UtilitiesArrayHelper::check($classProperiesMethods['property']))
{
foreach ($classProperiesMethods['property'] as $_property)
{
// force update by default
$this->storePluginBoilerplate($tables['p'], $models['p'], $_property, $app);
}
}
// create the method found (TODO just create for now but we could later add a force update)
if (isset($classProperiesMethods['method']) && UtilitiesArrayHelper::check($classProperiesMethods['method']))
{
foreach ($classProperiesMethods['method'] as $_method)
{
// force update by default
$this->storePluginBoilerplate($tables['m'], $models['m'], $_method, $app);
}
}
}
}
},
$plugin_tree
);
}
}
/**
* store Plugin Boilerplate
*
* @return boolean true on success
*
*/
protected function storePluginBoilerplate(&$table, &$method, &$boilerplate, &$app)
{
// Sometimes the form needs some posted data, such as for plugins and modules.
$form = $method->getForm($boilerplate, false);
if (!$form)
{
$app->enqueueMessage($method->getError(), 'error');
return false;
}
// Send an object which can be modified through the plugin event
$objData = (object) $boilerplate;
$app->triggerEvent(
'onContentNormaliseRequestData',
array('com_componentbuilder.' . $table, $objData, $form)
);
$boilerplate = (array) $objData;
// Test whether the data is valid.
$validData = $method->validate($form, $boilerplate);
// Check for validation errors.
if ($validData === false)
{
// Get the validation messages.
$errors = $method->getErrors();
// Push up to three validation messages out to the user.
for ($i = 0, $n = count($errors); $i < $n && $i < 3; $i++)
{
if ($errors[$i] instanceof \Exception)
{
$app->enqueueMessage($errors[$i]->getMessage(), 'warning');
}
else
{
$app->enqueueMessage($errors[$i], 'warning');
}
}
return false;
}
// Attempt to save the data.
if (!$method->save($validData))
{
$app->enqueueMessage(Text::sprintf('COM_COMPONENTBUILDER_BOILERPLATE_PLUGIN_S_DATA_COULD_NOT_BE_SAVED', $table), 'error');
return false;
}
return true;
}
/**
* Method to auto-populate the model state.
*