Release of v5.1.1-beta1

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

No files matched your search

@@ -24,6 +24,8 @@ use Joomla\CMS\Router\Route;
use Joomla\CMS\Session\Session;
use Joomla\CMS\Uri\Uri;
use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper;
use VDM\Joomla\Utilities\GuidHelper;
use VDM\Joomla\Componentbuilder\Package\Factory as PackageFactory;
// No direct access to this file
\defined('_JEXEC') or die;
@@ -78,6 +80,273 @@ class Class_extendsController extends FormController
*/
protected int $refid;
/**
* Method to edit an existing record.
*
* @param string $key The name of the primary key of the URL variable.
* @param string $urlVar The name of the URL variable if different from the primary key
* (sometimes required to avoid router collisions).
*
* @return boolean True if access level check and checkout passes, false otherwise.
*
* @since 1.6
*/
public function edit($key = null, $urlVar = null)
{
// for modal title key selection (unique key to do mapping)
$titleKey = $this->input->get('titleKey', 'id', 'word');
$guid = null;
$value = null;
// Determine the name of the primary key for the data.
if (empty($key))
{
$model = $this->getModel();
$table = $model->getTable();
$key = $table->getKeyName();
}
if ($titleKey === 'guid')
{
$guid = $this->input->get('guid', null, 'string');
}
if ($guid !== null && GuidHelper::valid($guid))
{
$value = GuidHelper::item($guid, 'class_extends', 'a.' . $key, 'componentbuilder');
}
if ($value !== null)
{
$this->input->set($key, $value);
}
return parent::edit($key, $urlVar);
}
/**
* Resets the specified Class Extends.
*
* This function performs several checks and operations:
* 1. It verifies the authenticity of the request to prevent request forgery.
* 2. It retrieves the item data posted by the user.
* 3. It checks whether the current user has the necessary permissions to reset the Class Extends.
* 4. It validates the presence of the necessary item identifiers (ID and GUID).
* 5. If the user is authorized and the identifiers are valid, it attempts to reset the specified Class Extends.
* 6. Depending on the result of the reset operation, it sets the appropriate success or error message.
* 7. It redirects the user to a specified URL with the result message and status.
*
* @return bool True on successful reset, false on failure.
* @since 5.1.1
*/
public function resetPowers()
{
// Check for request forgeries
Session::checkToken() or die(Text::_('JINVALID_TOKEN'));
// get Item posted
$item = $this->input->post->get('jform', array(), 'array');
// check if user has the right
$user = $this->app->getIdentity();
// set default error message
$message = '<h1>' . Text::_('COM_COMPONENTBUILDER_PERMISSION_DENIED') . '</h1>';
$message .= '<p>' . Text::_('COM_COMPONENTBUILDER_YOU_DO_NOT_HAVE_PERMISSION_TO_RESET_THIS_CLASS_EXTENDS') . '</p>';
$status = 'error';
$success = false;
$has_error = false;
// get the guid field of this entity
$key_field = PackageFactory::_('ClassExtends.Remote.Get')->getGuidField();
// load the ID
$id = $item['id'] ?? null;
$guid = $item[$key_field] ?? null;
$message_bus = ['success', 'warning', 'error'];
// check if there is any selections
if ($id === null || $guid === null)
{
// set error message
$message = '<h1>' . Text::_('COM_COMPONENTBUILDER_NOT_RESET') . '</h1>';
$message .= '<p>' . Text::_('COM_COMPONENTBUILDER_YOU_MUST_FIRST_SAVE_THE_CLASS_EXTENDS_BEFORE_YOU_CAN_USE_THIS_FEATURE') . '</p>';
}
elseif($user->authorise('class_extends.reset', 'com_componentbuilder'))
{
try {
PackageFactory::_('Package.Builder.Get')->reset('class_extends', [$guid]);
foreach ($message_bus as $message_key)
{
if (($messages = PackageFactory::_('Power.Message')->get($message_key, null)) !== null)
{
$messages = '<p>' . implode('<br>', $messages) . '</p>';
$this->app->enqueueMessage($messages, $message_key);
if (!$success && $message_key === 'success')
{
$success = true;
}
if (!$has_error && $message_key === 'error')
{
$has_error = true;
}
}
}
if ($success)
{
// set success message
$message = '<h1>' . Text::_('COM_COMPONENTBUILDER_SUCCESS') . '</h1>';
$message .= '<p>' . Text::_('COM_COMPONENTBUILDER_THE_CLASS_EXTENDS_HAS_SUCCESSFULLY_BEEN_RESET') . '</p>';
$status = 'success';
}
elseif ($has_error)
{
// set error message
$message = '<h1>' . Text::_('COM_COMPONENTBUILDER_RESET_FAILED') . '</h1>';
$message .= '<p>' . Text::_('COM_COMPONENTBUILDER_THE_RESET_OF_THIS_CLASS_EXTENDS_HAS_FAILED') . '</p>';
$status = 'error';
}
else
{
// set warning message
$message = '<h1>' . Text::_('COM_COMPONENTBUILDER_RESET_UNSUCCESSFUL') . '</h1>';
$message .= '<p>' . Text::_('COM_COMPONENTBUILDER_THE_RESET_OF_THIS_CLASS_EXTENDS_HAS_NOT_BEEN_SUCCESSFUL') . '</p>';
$status = 'warning';
}
} catch (\Exception $e) {
$message = '<h1>' . Text::_('COM_COMPONENTBUILDER_RESET_FAILED') . '</h1>';
$message .= '<p>' . \htmlspecialchars($e->getMessage()) . '</p>';
}
}
// set redirect
$redirect_url = Route::_(
'index.php?option=com_componentbuilder&view=class_extends'
. $this->getRedirectToItemAppend($id), false
);
$this->setRedirect($redirect_url, $message, $status);
return $success;
}
/**
* Pushes the specified Class Extends.
*
* This function performs several checks and operations:
* 1. It verifies the authenticity of the request to prevent request forgery.
* 2. It retrieves the item data posted by the user.
* 3. It checks whether the current user has the necessary permissions to push the Class Extends.
* 4. It validates the presence of the necessary item identifiers (ID and GUID).
* 5. If the user is authorized and the identifiers are valid, it attempts to push the specified Class Extends.
* 6. Depending on the result of the push operation, it sets the appropriate success or error message.
* 7. It redirects the user to a specified URL with the result message and status.
*
* @return bool True on successful push, false on failure.
* @since 5.1.1
*/
public function pushPowers()
{
// Check for request forgeries
Session::checkToken() or die(Text::_('JINVALID_TOKEN'));
// get Item posted
$item = $this->input->post->get('jform', array(), 'array');
// check if user has the right
$user = $this->app->getIdentity();
// set default error message
$message = '<h1>' . Text::_('COM_COMPONENTBUILDER_PERMISSION_DENIED') . '</h1>';
$message .= '<p>' . Text::_('COM_COMPONENTBUILDER_YOU_DO_NOT_HAVE_PERMISSION_TO_PUSH_THIS_CLASS_EXTENDS') . '</p>';
$status = 'error';
$success = false;
$has_error = false;
// get the guid field of this entity
$key_field = PackageFactory::_('ClassExtends.Remote.Set')->getGuidField();
// load the ID
$id = $item['id'] ?? null;
$guid = $item[$key_field] ?? null;
$message_bus = ['success', 'warning', 'error'];
// check if there is any selections
if ($id === null || $guid === null)
{
// set error message
$message = '<h1>' . Text::_('COM_COMPONENTBUILDER_NOT_PUSHED') . '</h1>';
$message .= '<p>' . Text::_('COM_COMPONENTBUILDER_YOU_MUST_FIRST_SAVE_THE_CLASS_EXTENDS_BEFORE_YOU_CAN_USE_THIS_FEATURE') . '</p>';
}
elseif($user->authorise('class_extends.push', 'com_componentbuilder'))
{
try {
PackageFactory::_('Package.Builder.Set')->items('class_extends', [$guid]);
foreach ($message_bus as $message_key)
{
if (($messages = PackageFactory::_('Power.Message')->get($message_key, null)) !== null)
{
$messages = '<p>' . implode('<br>', $messages) . '</p>';
$this->app->enqueueMessage($messages, $message_key);
if (!$success && $message_key === 'success')
{
$success = true;
}
if (!$has_error && $message_key === 'error')
{
$has_error = true;
}
}
}
if ($success)
{
// set success message
$message = '<h1>' . Text::_('COM_COMPONENTBUILDER_SUCCESS') . '</h1>';
$message .= '<p>' . Text::_('COM_COMPONENTBUILDER_THE_CLASS_EXTENDS_HAS_SUCCESSFULLY_BEEN_PUSHED') . '</p>';
$status = 'success';
}
elseif ($has_error)
{
// Initialize base values
$message = '<h1>' . Text::_('COM_COMPONENTBUILDER_PUSH_FAILED') . '</h1>';
$message .= '<p>' . Text::_('COM_COMPONENTBUILDER_THE_PUSH_OF_THIS_CLASS_EXTENDS_HAS_FAILED') . '</p>';
$status = 'error';
}
else
{
// Initialize base values
$message = '<h1>' . Text::_('COM_COMPONENTBUILDER_PUSH_UNSUCCESSFUL') . '</h1>';
$message .= '<p>' . Text::_('COM_COMPONENTBUILDER_THE_PUSH_OF_THIS_CLASS_EXTENDS_HAS_NOT_BEEN_SUCCESSFUL') . '</p>';
$status = 'warning';
}
} catch (\Exception $e) {
$message = '<h1>' . Text::_('COM_COMPONENTBUILDER_PUSH_FAILED') . '</h1>';
$message .= '<p>' . \htmlspecialchars($e->getMessage()) . '</p>';
}
}
// set redirect
$redirect_url = Route::_(
'index.php?option=com_componentbuilder&view=class_extends'
. $this->getRedirectToItemAppend($id), false
);
$this->setRedirect($redirect_url, $message, $status);
return $success;
}
/**
* Method override to check if you can add a new record.
*