Release of v5.0.1-alpha7

Add push options to Joomla Power. Complete the Joomla Power Init and Reset features. Fix Gitea Contents class functions. Last Alpha release (feature block).
This commit is contained in:
Robot 2024-07-08 22:55:12 +02:00
parent 0cbf3c0e71
commit 18545c5b8d
Signed by: Robot
GPG Key ID: 14DECD44E7E1BB95
57 changed files with 1343 additions and 688 deletions

View File

@ -1,8 +1,9 @@
# v5.0.1-alpha6
# v5.0.1-alpha7
- Add new subform classes
- Fix registry class methods return type
- Update all list and custom fields to use the new layouts
- Add push options to Joomla Power
- Complete the Joomla Power Init and Reset features
- Fix Gitea Contents class functions
- Last Alpha release (feature block)
# v5.0.1-alpha
@ -15,6 +16,9 @@
- Add repositories for better integration with gitea
- Refactored the Data classes
- Add new Data classes
- Add new subform classes
- Fix registry class methods return type
- Update all list and custom fields to use the new layouts
# v5.0.0

View File

@ -1516,7 +1516,7 @@ class Com_ComponentbuilderInstallerScript implements InstallerScriptInterface
// Fix the assets table rules column size.
$this->setDatabaseAssetsRulesFix(96000, "MEDIUMTEXT");
$this->setDatabaseAssetsRulesFix(96160, "MEDIUMTEXT");
// Install the global extension params.
$this->setExtensionsParams(
'{"autorName":"Llewellyn van der Merwe","autorEmail":"joomla@vdm.io","subform_layouts":"default","editor":"none","manage_jcb_package_directories":"2","set_browser_storage":"1","storage_time_to_live":"global","super_powers_documentation":"0","powers_repository":"0","super_powers_repositories":"0","builder_gif_size":"480-272","compiler_plugin":["componentbuilderactionlogcompiler","componentbuilderfieldorderingcompiler","componentbuilderheaderscompiler","componentbuilderpowersautoloadercompiler","componentbuilderprivacycompiler"],"add_menu_prefix":"1","menu_prefix":"»","namespace_prefix":"JCB","minify":"0","language":"en-GB","percentagelanguageadd":"30","assets_table_fix":"2","compiler_field_builder_type":"2","field_name_builder":"1","type_name_builder":"1","import_guid_only":"1","export_language_strings":"1","development_method":"1","expansion":"0","return_options_build":"2","cronjob_backup_type":"1","cronjob_backup_server":"0","backup_package_name":"JCB_Backup_[YEAR]_[MONTH]_[DAY]","export_license":"GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html","export_copyright":"Copyright (C) 2015. All Rights Reserved","check_in":"-1 day","save_history":"1","history_limit":"10","add_jquery_framework":"1","uikit_load":"1","uikit_min":"","uikit_style":""}'
@ -3266,7 +3266,7 @@ class Com_ComponentbuilderInstallerScript implements InstallerScriptInterface
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 5.0.1-alpha6 Was Successful! Let us know if anything is not working as expected.</h3></div>';
<h3>Upgrade to Version 5.0.1-alpha7 Was Successful! Let us know if anything is not working as expected.</h3></div>';
// Add/Update component in the action logs extensions table.
$this->setActionLogsExtensions();

View File

@ -9,7 +9,7 @@ The Component Builder for [Joomla](https://extensions.joomla.org/extension/compo
Whether you're a seasoned [Joomla](https://extensions.joomla.org/extension/component-builder/) developer, or have just started, Component Builder will save you lots of time and money. A real must have!
You can install it quite easily and with no limitations. On [gitea](https://git.vdm.dev/joomla/Component-Builder/tags) is the latest release (5.0.1-alpha6) with **ALL** its features and **ALL** concepts totally open-source and free!
You can install it quite easily and with no limitations. On [gitea](https://git.vdm.dev/joomla/Component-Builder/tags) is the latest release (5.0.1-alpha7) with **ALL** its features and **ALL** concepts totally open-source and free!
> Watch Quick Build of a Hello World component in [JCB on Youtube](https://www.youtube.com/watch?v=IQfsLYIeblk&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&index=45)
@ -144,13 +144,13 @@ TODO
+ *Author*: [Llewellyn van der Merwe](mailto:joomla@vdm.io)
+ *Name*: [Component Builder](https://git.vdm.dev/joomla/Component-Builder)
+ *First Build*: 30th April, 2015
+ *Last Build*: 28th June, 2024
+ *Version*: 5.0.1-alpha6
+ *Last Build*: 8th July, 2024
+ *Version*: 5.0.1-alpha7
+ *Copyright*: Copyright (C) 2015 Vast Development Method. All rights reserved.
+ *License*: GNU General Public License version 2 or later; see LICENSE.txt
+ *Line count*: **763059**
+ *Line count*: **764707**
+ *Field count*: **2110**
+ *File count*: **5413**
+ *File count*: **5423**
+ *Folder count*: **546**
> This **component** was build with a [Joomla](https://extensions.joomla.org/extension/component-builder/) [Automated Component Builder](https://www.joomlacomponentbuilder.com).

View File

@ -9,7 +9,7 @@ The Component Builder for [Joomla](https://extensions.joomla.org/extension/compo
Whether you're a seasoned [Joomla](https://extensions.joomla.org/extension/component-builder/) developer, or have just started, Component Builder will save you lots of time and money. A real must have!
You can install it quite easily and with no limitations. On [gitea](https://git.vdm.dev/joomla/Component-Builder/tags) is the latest release (5.0.1-alpha6) with **ALL** its features and **ALL** concepts totally open-source and free!
You can install it quite easily and with no limitations. On [gitea](https://git.vdm.dev/joomla/Component-Builder/tags) is the latest release (5.0.1-alpha7) with **ALL** its features and **ALL** concepts totally open-source and free!
> Watch Quick Build of a Hello World component in [JCB on Youtube](https://www.youtube.com/watch?v=IQfsLYIeblk&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&index=45)
@ -144,13 +144,13 @@ TODO
+ *Author*: [Llewellyn van der Merwe](mailto:joomla@vdm.io)
+ *Name*: [Component Builder](https://git.vdm.dev/joomla/Component-Builder)
+ *First Build*: 30th April, 2015
+ *Last Build*: 28th June, 2024
+ *Version*: 5.0.1-alpha6
+ *Last Build*: 8th July, 2024
+ *Version*: 5.0.1-alpha7
+ *Copyright*: Copyright (C) 2015 Vast Development Method. All rights reserved.
+ *License*: GNU General Public License version 2 or later; see LICENSE.txt
+ *Line count*: **763059**
+ *Line count*: **764707**
+ *Field count*: **2110**
+ *File count*: **5413**
+ *File count*: **5423**
+ *Folder count*: **546**
> This **component** was build with a [Joomla](https://extensions.joomla.org/extension/component-builder/) [Automated Component Builder](https://www.joomlacomponentbuilder.com).

View File

@ -388,6 +388,7 @@
<action name="joomla_plugin_updates.edit.state" title="COM_COMPONENTBUILDER_JOOMLA_PLUGINS_UPDATES_EDIT_STATE" description="COM_COMPONENTBUILDER_JOOMLA_PLUGINS_UPDATES_EDIT_STATE_DESC" />
<action name="joomla_plugin_updates.version" title="COM_COMPONENTBUILDER_JOOMLA_PLUGINS_UPDATES_EDIT_VERSION" description="COM_COMPONENTBUILDER_JOOMLA_PLUGINS_UPDATES_EDIT_VERSION_DESC" />
<action name="joomla_power.init" title="COM_COMPONENTBUILDER_JOOMLA_POWER_INIT_BUTTON_ACCESS" description="COM_COMPONENTBUILDER_JOOMLA_POWER_INIT_BUTTON_ACCESS_DESC" />
<action name="joomla_power.push" title="COM_COMPONENTBUILDER_JOOMLA_POWER_PUSH_BUTTON_ACCESS" description="COM_COMPONENTBUILDER_JOOMLA_POWER_PUSH_BUTTON_ACCESS_DESC" />
<action name="joomla_power.reset" title="COM_COMPONENTBUILDER_JOOMLA_POWER_RESET_BUTTON_ACCESS" description="COM_COMPONENTBUILDER_JOOMLA_POWER_RESET_BUTTON_ACCESS_DESC" />
<action name="joomla_power.access" title="COM_COMPONENTBUILDER_JOOMLA_POWERS_ACCESS" description="COM_COMPONENTBUILDER_JOOMLA_POWERS_ACCESS_DESC" />
<action name="joomla_power.batch" title="COM_COMPONENTBUILDER_JOOMLA_POWERS_BATCH_USE" description="COM_COMPONENTBUILDER_JOOMLA_POWERS_BATCH_USE_DESC" />

View File

@ -6901,6 +6901,8 @@ COM_COMPONENTBUILDER_JOOMLA_POWER_NEW="A New Joomla Power"
COM_COMPONENTBUILDER_JOOMLA_POWER_ORDERING_LABEL="Ordering"
COM_COMPONENTBUILDER_JOOMLA_POWER_PERMISSION="Permissions"
COM_COMPONENTBUILDER_JOOMLA_POWER_PUBLISHING="Publishing"
COM_COMPONENTBUILDER_JOOMLA_POWER_PUSH_BUTTON_ACCESS="Joomla Power Push Button Access"
COM_COMPONENTBUILDER_JOOMLA_POWER_PUSH_BUTTON_ACCESS_DESC="Allows the users in this group to access the push button."
COM_COMPONENTBUILDER_JOOMLA_POWER_RESET_BUTTON_ACCESS="Joomla Power Reset Button Access"
COM_COMPONENTBUILDER_JOOMLA_POWER_RESET_BUTTON_ACCESS_DESC="Allows the users in this group to access the reset button."
COM_COMPONENTBUILDER_JOOMLA_POWER_SAVE_WARNING="Alias already existed so a number was added at the end. You can re-edit the Joomla Power to customise the alias."
@ -7655,6 +7657,7 @@ COM_COMPONENTBUILDER_PATH_TO_THE_ZIPPED_PACKAGE_IS_CODESCODE_BR_S_S="Path to the
COM_COMPONENTBUILDER_PERMISSIONS="Permissions"
COM_COMPONENTBUILDER_PERMISSION_DENIED="Permission Denied!"
COM_COMPONENTBUILDER_PFILE_AT_BSSB_GAVE_THE_FOLLOWING_ERRORBR_SP="<p>File at <b>%s/%s</b> gave the following error!<br />%s</p>"
COM_COMPONENTBUILDER_PJOOMLA_POWERB_REPOSITORY_AT_BSSB_GAVE_THE_FOLLOWING_ERRORBR_SP="<p>Joomla Power</b> repository at <b>%s/%s</b> gave the following error!<br />%s</p>"
COM_COMPONENTBUILDER_PJOOMLA_POWER_BGUIDSB_NOT_FOUNDP="<p>Joomla Power <b>guid:%s</b> not found!</p>"
COM_COMPONENTBUILDER_PJOOMLA_POWER_BGUIDSB_WAS_FOUND_BUT_MISSING_A_NAMESPACE_VALUE_FOR_JOOMLA_SP="<p>Joomla Power <b>guid:%s</b> was found, but missing a namespace value for Joomla %s!</p>"
COM_COMPONENTBUILDER_PLACEHOLDER="Placeholder"
@ -7946,6 +7949,8 @@ COM_COMPONENTBUILDER_PS_NAMING_MISMATCH_ERROR_SPPTHE_S_NAME_IS_BSB_AND_THE_ENDIN
COM_COMPONENTBUILDER_PUBLIC_ACCESS="Public Access"
COM_COMPONENTBUILDER_PUBLISHED="Published"
COM_COMPONENTBUILDER_PUBLISHING="Publishing"
COM_COMPONENTBUILDER_PUSH="Push"
COM_COMPONENTBUILDER_PUSH_FAILED="Push Failed!"
COM_COMPONENTBUILDER_READY_TO_COMPILE_A_COMPONENT="Ready to compile a component"
COM_COMPONENTBUILDER_REFRESH="Refresh"
COM_COMPONENTBUILDER_REGEX_SEARCH="Regex Search"
@ -9070,6 +9075,7 @@ COM_COMPONENTBUILDER_THERE_WAS_AN_ERROR_GETTING_THE_PACKAGE_INFO="There was an e
COM_COMPONENTBUILDER_THERE_WAS_A_PROBLEM_BNO_VIEW_OR_ID_FOUND_IN_SESSION_OR_VIEW_NOT_ALLOWED_TO_ACCESS_AREAB_WE_COULD_NOT_LOAD_ANY_LINKED_TO_VALUES_PLEASE_INFORM_YOUR_SYSTEM_ADMINISTRATOR="There was a problem, <b>no view or id found in session or view not allowed to access area</b>, we could not load any linked to values. Please inform your system administrator!"
COM_COMPONENTBUILDER_THESE_ARE_THE_SAME_PACKAGES_FOUND_ON_A_S_GITHUBA_AND_CAN_BE_IMPORTED_BY_SIMPLY_MAKING_A_SELECTION_AND_THEN_CLICKING_THE_BGET_PACKAGEB_BUTTONBR_SOME_OF_THESE_PACKAGES_WOULD_REQUIRE_A_KEY_SINCE_THEY_ARE_NOT_FREE="These are the same packages found on <a %s >gitHub</a> and can be imported by simply making a selection and then clicking the <b>[Get Package]</b> button.<br />Some of these packages would require a key, since they are not free."
COM_COMPONENTBUILDER_THESE_ARE_THE_SAME_PACKAGES_FOUND_ON_A_S_GITHUBA_AND_CAN_BE_IMPORTED_BY_SIMPLY_MAKING_A_SELECTION_AND_THEN_CLICKING_THE_BGET_PACKAGEB_BUTTONBR_SOME_OF_THESE_PACKAGES_WOULD_REQUIRE_A_KEY_SINCE_THEY_ARE_NOT_FREE_A_S_GET_A_KEY_TODAYA="These are the same packages found on <a %s >gitHub</a> and can be imported by simply making a selection and then clicking the <b>[Get Package]</b> button.<br />Some of these packages would require a key, since they are not free. <a %s >Get a key today!</a>."
COM_COMPONENTBUILDER_THESE_JOOMLA_POWERS_HAVE_SUCCESSFULLY_BEEN_PUSHED="These Joomla powers have successfully been pushed."
COM_COMPONENTBUILDER_THESE_JOOMLA_POWERS_HAVE_SUCCESSFULLY_BEEN_RESET="These Joomla powers have successfully been reset."
COM_COMPONENTBUILDER_THESE_OPTIONS_ARE_NOT_AVAILABLE_TO_THE_FIELD_IF_BNONE_DBB_OPTION_IS_SELECTED="These options are not available to the field if <b>None DB</b> option is selected."
COM_COMPONENTBUILDER_THESE_OPTIONS_ARE_ONLY_AVAILABLE_TO_THE_FIELD_IF_BSHOW_IN_LIST_VIEWB_OPTION_IS_SELECTED="These options are only available to the field if <b>Show in list view</b> option is selected."
@ -9120,6 +9126,7 @@ COM_COMPONENTBUILDER_THE_FTP_CONNECTION_FOR_BSB_COULD_NOT_BE_MADE_PLEASE_CHECK_Y
COM_COMPONENTBUILDER_THE_FTP_SIGNATURE_FOR_BSB_WAS_NOT_WELL_FORMED_PLEASE_CHECK_YOUR_SIGNATURE_DETAILS="The FTP signature for <b>%s</b> was not well formed, please check your signature details!"
COM_COMPONENTBUILDER_THE_INITIALIZATION_OF_THIS_JOOMLA_POWERS_HAS_FAILED="The initialization of this Joomla powers has failed."
COM_COMPONENTBUILDER_THE_INITIALIZATION_OF_THIS_POWERS_HAS_FAILED="The initialization of this powers has failed."
COM_COMPONENTBUILDER_THE_JOOMLA_POWER_HAS_SUCCESSFULLY_BEEN_PUSHED="The Joomla power has successfully been pushed."
COM_COMPONENTBUILDER_THE_JOOMLA_POWER_HAS_SUCCESSFULLY_BEEN_RESET="The Joomla power has successfully been reset."
COM_COMPONENTBUILDER_THE_KEY_OF_THIS_PACKAGE="The key of this package."
COM_COMPONENTBUILDER_THE_LIBRARY_CONFIG_FIELDS="The library config fields"
@ -9140,6 +9147,8 @@ COM_COMPONENTBUILDER_THE_POWER_HAS_SUCCESSFULLY_BEEN_RESET="The power has succes
COM_COMPONENTBUILDER_THE_PRIVATE_KEY_FIELD_COULD_NOT_BE_LOADED_FOR_BSB_SERVER="The private key field could not be loaded for <b>%s</b> server!"
COM_COMPONENTBUILDER_THE_PRIVATE_KEY_FILE_COULD_NOT_BE_LOADEDFOUND_FOR_BSB_SERVER="The private key file could not be loaded/found for <b>%s</b> server!"
COM_COMPONENTBUILDER_THE_PRO_BOARD_IS_LOADING="The pro board is loading"
COM_COMPONENTBUILDER_THE_PUSH_OF_THESE_JOOMLA_POWERS_HAS_FAILED="The push of these Joomla powers has failed."
COM_COMPONENTBUILDER_THE_PUSH_OF_THIS_JOOMLA_POWER_HAS_FAILED="The push of this Joomla power has failed."
COM_COMPONENTBUILDER_THE_README_IS_LOADING="The readme is loading"
COM_COMPONENTBUILDER_THE_REPLACE_PROCESS_HAD_AN_ERROR_WITH_TABLE="The replace process had an error with table"
COM_COMPONENTBUILDER_THE_RESET_OF_THESE_JOOMLA_POWERS_HAS_FAILED="The reset of these Joomla powers has failed."
@ -9397,6 +9406,7 @@ COM_COMPONENTBUILDER_YOU_DO_NOT_HAVE_PERMISSION_TO_INSTALL_THESE_EXTENSIONS="You
COM_COMPONENTBUILDER_YOU_DO_NOT_HAVE_PERMISSION_TO_INSTALL_THE_COMPONENT="You do not have permission to install the component!"
COM_COMPONENTBUILDER_YOU_DO_NOT_HAVE_PERMISSION_TO_INSTALL_THE_MODULE="You do not have permission to install the module!"
COM_COMPONENTBUILDER_YOU_DO_NOT_HAVE_PERMISSION_TO_INSTALL_THE_PLUGIN="You do not have permission to install the plugin!"
COM_COMPONENTBUILDER_YOU_DO_NOT_HAVE_PERMISSION_TO_PUSH_THIS_JOOMLA_POWER="You do not have permission to push this Joomla power"
COM_COMPONENTBUILDER_YOU_DO_NOT_HAVE_PERMISSION_TO_RESET_THIS_JOOMLA_POWER="You do not have permission to reset this Joomla power"
COM_COMPONENTBUILDER_YOU_DO_NOT_HAVE_PERMISSION_TO_RESET_THIS_POWER="You do not have permission to reset this power"
COM_COMPONENTBUILDER_YOU_DO_NOT_HAVE_PERMISSION_TO_RUN_THE_EXPANSION_MODULE="You do not have permission to run the expansion module!"

View File

@ -788,6 +788,8 @@ COM_COMPONENTBUILDER_JOOMLA_POWERS_SUBMENU="Joomla Powers Submenu"
COM_COMPONENTBUILDER_JOOMLA_POWERS_SUBMENU_DESC="Allows the users in this group to submenu of joomla power"
COM_COMPONENTBUILDER_JOOMLA_POWER_INIT_BUTTON_ACCESS="Joomla Power Init Button Access"
COM_COMPONENTBUILDER_JOOMLA_POWER_INIT_BUTTON_ACCESS_DESC="Allows the users in this group to access the init button."
COM_COMPONENTBUILDER_JOOMLA_POWER_PUSH_BUTTON_ACCESS="Joomla Power Push Button Access"
COM_COMPONENTBUILDER_JOOMLA_POWER_PUSH_BUTTON_ACCESS_DESC="Allows the users in this group to access the push button."
COM_COMPONENTBUILDER_JOOMLA_POWER_RESET_BUTTON_ACCESS="Joomla Power Reset Button Access"
COM_COMPONENTBUILDER_JOOMLA_POWER_RESET_BUTTON_ACCESS_DESC="Allows the users in this group to access the reset button."
COM_COMPONENTBUILDER_LANGUAGES_ACCESS="Languages Access"

File diff suppressed because one or more lines are too long

View File

@ -56,27 +56,40 @@ class Admin_viewsController extends AdminController
/**
* Run the Expansion
* Runs the expansion module.
*
* @return void
* This function performs several checks and operations:
* 1. It verifies the authenticity of the request to prevent request forgery.
* 2. It checks whether the current user has the necessary permissions to run the expansion module.
* 3. If the user is authorized, it attempts to run the expansion via an API call.
* 4. Depending on the result of the expansion operation, it sets the appropriate success or error message.
* 5. It redirects the user to a specified URL with the result message and status.
*
* @return bool True on successful expansion, false on failure.
*/
public function runExpansion()
{
// Check for request forgeries
Session::checkToken() or \jexit(Text::_('JINVALID_TOKEN'));
Session::checkToken() or die(Text::_('JINVALID_TOKEN'));
// check if user has the right
$user = Factory::getUser();
// set page redirect
$redirect_url = Route::_('index.php?option=com_componentbuilder&view=admin_views', false);
// set massage
$message = Text::_('COM_COMPONENTBUILDER_YOU_DO_NOT_HAVE_PERMISSION_TO_RUN_THE_EXPANSION_MODULE');
// check if this user has the right to run expansion
if($user->authorise('admin_views.run_expansion', 'com_componentbuilder'))
{
// set massage
$message = Text::_('COM_COMPONENTBUILDER_EXPANSION_FAILED_PLEASE_CHECK_YOUR_SETTINGS_IN_THE_GLOBAL_OPTIONS_OF_JCB_UNDER_THE_DEVELOPMENT_METHOD_TAB');
// run expansion via API
$result = ComponentbuilderHelper::getFileContents(Uri::root() . 'index.php?option=com_componentbuilder&task=api.expand');
// is there a message returned
if (!is_numeric($result) && StringHelper::check($result))
{
@ -90,6 +103,7 @@ class Admin_viewsController extends AdminController
return true;
}
}
$this->setRedirect($redirect_url, $message, 'error');
return false;
}

View File

@ -537,27 +537,40 @@ class CompilerController extends AdminController
}
/**
* Run the Expansion
* Runs the expansion module.
*
* @return void
* This function performs several checks and operations:
* 1. It verifies the authenticity of the request to prevent request forgery.
* 2. It checks whether the current user has the necessary permissions to run the expansion module.
* 3. If the user is authorized, it attempts to run the expansion via an API call.
* 4. Depending on the result of the expansion operation, it sets the appropriate success or error message.
* 5. It redirects the user to a specified URL with the result message and status.
*
* @return bool True on successful expansion, false on failure.
*/
public function runExpansion()
{
// Check for request forgeries
Session::checkToken() or \jexit(Text::_('JINVALID_TOKEN'));
Session::checkToken() or die(Text::_('JINVALID_TOKEN'));
// check if user has the right
$user = Factory::getUser();
// set page redirect
$redirect_url = Route::_('index.php?option=com_componentbuilder&view=compiler', false);
// set massage
$message = Text::_('COM_COMPONENTBUILDER_YOU_DO_NOT_HAVE_PERMISSION_TO_RUN_THE_EXPANSION_MODULE');
// check if this user has the right to run expansion
if($user->authorise('compiler.run_expansion', 'com_componentbuilder'))
{
// set massage
$message = Text::_('COM_COMPONENTBUILDER_EXPANSION_FAILED_PLEASE_CHECK_YOUR_SETTINGS_IN_THE_GLOBAL_OPTIONS_OF_JCB_UNDER_THE_DEVELOPMENT_METHOD_TAB');
// run expansion via API
$result = ComponentbuilderHelper::getFileContents(Uri::root() . 'index.php?option=com_componentbuilder&task=api.expand');
// is there a message returned
if (!is_numeric($result) && StringHelper::check($result))
{
@ -571,6 +584,7 @@ class CompilerController extends AdminController
return true;
}
}
$this->setRedirect($redirect_url, $message, 'error');
return false;
}

View File

@ -56,27 +56,40 @@ class Custom_codesController extends AdminController
/**
* Run the Expansion
* Runs the expansion module.
*
* @return void
* This function performs several checks and operations:
* 1. It verifies the authenticity of the request to prevent request forgery.
* 2. It checks whether the current user has the necessary permissions to run the expansion module.
* 3. If the user is authorized, it attempts to run the expansion via an API call.
* 4. Depending on the result of the expansion operation, it sets the appropriate success or error message.
* 5. It redirects the user to a specified URL with the result message and status.
*
* @return bool True on successful expansion, false on failure.
*/
public function runExpansion()
{
// Check for request forgeries
Session::checkToken() or \jexit(Text::_('JINVALID_TOKEN'));
Session::checkToken() or die(Text::_('JINVALID_TOKEN'));
// check if user has the right
$user = Factory::getUser();
// set page redirect
$redirect_url = Route::_('index.php?option=com_componentbuilder&view=custom_codes', false);
// set massage
$message = Text::_('COM_COMPONENTBUILDER_YOU_DO_NOT_HAVE_PERMISSION_TO_RUN_THE_EXPANSION_MODULE');
// check if this user has the right to run expansion
if($user->authorise('custom_codes.run_expansion', 'com_componentbuilder'))
{
// set massage
$message = Text::_('COM_COMPONENTBUILDER_EXPANSION_FAILED_PLEASE_CHECK_YOUR_SETTINGS_IN_THE_GLOBAL_OPTIONS_OF_JCB_UNDER_THE_DEVELOPMENT_METHOD_TAB');
// run expansion via API
$result = ComponentbuilderHelper::getFileContents(Uri::root() . 'index.php?option=com_componentbuilder&task=api.expand');
// is there a message returned
if (!is_numeric($result) && StringHelper::check($result))
{
@ -90,6 +103,7 @@ class Custom_codesController extends AdminController
return true;
}
}
$this->setRedirect($redirect_url, $message, 'error');
return false;
}

View File

@ -56,27 +56,40 @@ class Dynamic_getsController extends AdminController
/**
* Run the Expansion
* Runs the expansion module.
*
* @return void
* This function performs several checks and operations:
* 1. It verifies the authenticity of the request to prevent request forgery.
* 2. It checks whether the current user has the necessary permissions to run the expansion module.
* 3. If the user is authorized, it attempts to run the expansion via an API call.
* 4. Depending on the result of the expansion operation, it sets the appropriate success or error message.
* 5. It redirects the user to a specified URL with the result message and status.
*
* @return bool True on successful expansion, false on failure.
*/
public function runExpansion()
{
// Check for request forgeries
Session::checkToken() or \jexit(Text::_('JINVALID_TOKEN'));
Session::checkToken() or die(Text::_('JINVALID_TOKEN'));
// check if user has the right
$user = Factory::getUser();
// set page redirect
$redirect_url = Route::_('index.php?option=com_componentbuilder&view=dynamic_gets', false);
// set massage
$message = Text::_('COM_COMPONENTBUILDER_YOU_DO_NOT_HAVE_PERMISSION_TO_RUN_THE_EXPANSION_MODULE');
// check if this user has the right to run expansion
if($user->authorise('dynamic_gets.run_expansion', 'com_componentbuilder'))
{
// set massage
$message = Text::_('COM_COMPONENTBUILDER_EXPANSION_FAILED_PLEASE_CHECK_YOUR_SETTINGS_IN_THE_GLOBAL_OPTIONS_OF_JCB_UNDER_THE_DEVELOPMENT_METHOD_TAB');
// run expansion via API
$result = ComponentbuilderHelper::getFileContents(Uri::root() . 'index.php?option=com_componentbuilder&task=api.expand');
// is there a message returned
if (!is_numeric($result) && StringHelper::check($result))
{
@ -90,6 +103,7 @@ class Dynamic_getsController extends AdminController
return true;
}
}
$this->setRedirect($redirect_url, $message, 'error');
return false;
}

View File

@ -56,27 +56,40 @@ class FieldsController extends AdminController
/**
* Run the Expansion
* Runs the expansion module.
*
* @return void
* This function performs several checks and operations:
* 1. It verifies the authenticity of the request to prevent request forgery.
* 2. It checks whether the current user has the necessary permissions to run the expansion module.
* 3. If the user is authorized, it attempts to run the expansion via an API call.
* 4. Depending on the result of the expansion operation, it sets the appropriate success or error message.
* 5. It redirects the user to a specified URL with the result message and status.
*
* @return bool True on successful expansion, false on failure.
*/
public function runExpansion()
{
// Check for request forgeries
Session::checkToken() or \jexit(Text::_('JINVALID_TOKEN'));
Session::checkToken() or die(Text::_('JINVALID_TOKEN'));
// check if user has the right
$user = Factory::getUser();
// set page redirect
$redirect_url = Route::_('index.php?option=com_componentbuilder&view=fields', false);
// set massage
$message = Text::_('COM_COMPONENTBUILDER_YOU_DO_NOT_HAVE_PERMISSION_TO_RUN_THE_EXPANSION_MODULE');
// check if this user has the right to run expansion
if($user->authorise('fields.run_expansion', 'com_componentbuilder'))
{
// set massage
$message = Text::_('COM_COMPONENTBUILDER_EXPANSION_FAILED_PLEASE_CHECK_YOUR_SETTINGS_IN_THE_GLOBAL_OPTIONS_OF_JCB_UNDER_THE_DEVELOPMENT_METHOD_TAB');
// run expansion via API
$result = ComponentbuilderHelper::getFileContents(Uri::root() . 'index.php?option=com_componentbuilder&task=api.expand');
// is there a message returned
if (!is_numeric($result) && StringHelper::check($result))
{
@ -90,6 +103,7 @@ class FieldsController extends AdminController
return true;
}
}
$this->setRedirect($redirect_url, $message, 'error');
return false;
}

View File

@ -122,27 +122,40 @@ class Joomla_componentsController extends AdminController
/**
* Run the Expansion
* Runs the expansion module.
*
* @return void
* This function performs several checks and operations:
* 1. It verifies the authenticity of the request to prevent request forgery.
* 2. It checks whether the current user has the necessary permissions to run the expansion module.
* 3. If the user is authorized, it attempts to run the expansion via an API call.
* 4. Depending on the result of the expansion operation, it sets the appropriate success or error message.
* 5. It redirects the user to a specified URL with the result message and status.
*
* @return bool True on successful expansion, false on failure.
*/
public function runExpansion()
{
// Check for request forgeries
Session::checkToken() or \jexit(Text::_('JINVALID_TOKEN'));
Session::checkToken() or die(Text::_('JINVALID_TOKEN'));
// check if user has the right
$user = Factory::getUser();
// set page redirect
$redirect_url = Route::_('index.php?option=com_componentbuilder&view=joomla_components', false);
// set massage
$message = Text::_('COM_COMPONENTBUILDER_YOU_DO_NOT_HAVE_PERMISSION_TO_RUN_THE_EXPANSION_MODULE');
// check if this user has the right to run expansion
if($user->authorise('joomla_components.run_expansion', 'com_componentbuilder'))
{
// set massage
$message = Text::_('COM_COMPONENTBUILDER_EXPANSION_FAILED_PLEASE_CHECK_YOUR_SETTINGS_IN_THE_GLOBAL_OPTIONS_OF_JCB_UNDER_THE_DEVELOPMENT_METHOD_TAB');
// run expansion via API
$result = ComponentbuilderHelper::getFileContents(Uri::root() . 'index.php?option=com_componentbuilder&task=api.expand');
// is there a message returned
if (!is_numeric($result) && StringHelper::check($result))
{
@ -156,6 +169,7 @@ class Joomla_componentsController extends AdminController
return true;
}
}
$this->setRedirect($redirect_url, $message, 'error');
return false;
}

View File

@ -56,27 +56,40 @@ class Joomla_pluginsController extends AdminController
/**
* Run the Expansion
* Runs the expansion module.
*
* @return void
* This function performs several checks and operations:
* 1. It verifies the authenticity of the request to prevent request forgery.
* 2. It checks whether the current user has the necessary permissions to run the expansion module.
* 3. If the user is authorized, it attempts to run the expansion via an API call.
* 4. Depending on the result of the expansion operation, it sets the appropriate success or error message.
* 5. It redirects the user to a specified URL with the result message and status.
*
* @return bool True on successful expansion, false on failure.
*/
public function runExpansion()
{
// Check for request forgeries
Session::checkToken() or \jexit(Text::_('JINVALID_TOKEN'));
Session::checkToken() or die(Text::_('JINVALID_TOKEN'));
// check if user has the right
$user = Factory::getUser();
// set page redirect
$redirect_url = Route::_('index.php?option=com_componentbuilder&view=joomla_plugins', false);
// set massage
$message = Text::_('COM_COMPONENTBUILDER_YOU_DO_NOT_HAVE_PERMISSION_TO_RUN_THE_EXPANSION_MODULE');
// check if this user has the right to run expansion
if($user->authorise('joomla_plugins.run_expansion', 'com_componentbuilder'))
{
// set massage
$message = Text::_('COM_COMPONENTBUILDER_EXPANSION_FAILED_PLEASE_CHECK_YOUR_SETTINGS_IN_THE_GLOBAL_OPTIONS_OF_JCB_UNDER_THE_DEVELOPMENT_METHOD_TAB');
// run expansion via API
$result = ComponentbuilderHelper::getFileContents(Uri::root() . 'index.php?option=com_componentbuilder&task=api.expand');
// is there a message returned
if (!is_numeric($result) && StringHelper::check($result))
{
@ -90,6 +103,7 @@ class Joomla_pluginsController extends AdminController
return true;
}
}
$this->setRedirect($redirect_url, $message, 'error');
return false;
}

View File

@ -63,6 +63,20 @@ class Joomla_powerController extends FormController
*/
protected $view_list = 'joomla_powers';
/**
* Resets the specified Joomla power.
*
* 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 Joomla power.
* 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 power.
* 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.
*/
public function resetPowers()
{
// Check for request forgeries
@ -93,18 +107,98 @@ class Joomla_powerController extends FormController
}
elseif($user->authorise('power.reset', 'com_componentbuilder'))
{
if (JoomlaPowerFactory::_('Joomlapower')->reset([$guid]))
{
// set success message
$message = '<h1>'.Text::_('COM_COMPONENTBUILDER_SUCCESS').'</h1>';
$message .= '<p>'.Text::_('COM_COMPONENTBUILDER_THE_JOOMLA_POWER_HAS_SUCCESSFULLY_BEEN_RESET').'</p>';
$status = 'success';
$success = true;
}
else
{
try {
if (JoomlaPowerFactory::_('Joomlapower')->reset([$guid]))
{
// set success message
$message = '<h1>'.Text::_('COM_COMPONENTBUILDER_SUCCESS').'</h1>';
$message .= '<p>'.Text::_('COM_COMPONENTBUILDER_THE_JOOMLA_POWER_HAS_SUCCESSFULLY_BEEN_RESET').'</p>';
$status = 'success';
$success = true;
}
else
{
$message = '<h1>' . Text::_('COM_COMPONENTBUILDER_RESET_FAILED') . '</h1>';
$message .= '<p>' . Text::_('COM_COMPONENTBUILDER_THE_RESET_OF_THIS_JOOMLA_POWER_HAS_FAILED') . '</p>';
}
} catch (\Exception $e) {
$message = '<h1>' . Text::_('COM_COMPONENTBUILDER_RESET_FAILED') . '</h1>';
$message .= '<p>' . Text::_('COM_COMPONENTBUILDER_THE_RESET_OF_THIS_JOOMLA_POWER_HAS_FAILED') . '</p>';
$message .= '<p>' . \htmlspecialchars($e->getMessage()) . '</p>';
}
}
// set redirect
$redirect_url = Route::_(
'index.php?option=com_componentbuilder&view=joomla_power'
. $this->getRedirectToItemAppend($id), $success
);
$this->setRedirect($redirect_url, $message, $status);
return $success;
}
/**
* Pushes the specified Joomla power.
*
* 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 Joomla power.
* 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 power.
* 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.
*/
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 = Factory::getUser();
// 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_JOOMLA_POWER') . '</p>';
$status = 'error';
$success = false;
// load the ID
$id = $item['id'] ?? null;
$guid = $item['guid'] ?? null;
// check if there is any selections
if ($id === null || $guid === null)
{
// set error message
$message = '<h1>' . Text::_('COM_COMPONENTBUILDER_NOT_SAVED') . '</h1>';
$message .= '<p>' . Text::_('COM_COMPONENTBUILDER_YOU_MUST_FIRST_SAVE_THE_JOOMLA_POWER_BEFORE_YOU_CAN_USE_THIS_FEATURE') . '</p>';
}
elseif($user->authorise('power.push', 'com_componentbuilder'))
{
try {
if (JoomlaPowerFactory::_('Joomla.Power.Repository')->set([$guid]))
{
// set success message
$message = '<h1>'.Text::_('COM_COMPONENTBUILDER_SUCCESS').'</h1>';
$message .= '<p>'.Text::_('COM_COMPONENTBUILDER_THE_JOOMLA_POWER_HAS_SUCCESSFULLY_BEEN_PUSHED').'</p>';
$status = 'success';
$success = true;
}
else
{
$message = '<h1>' . Text::_('COM_COMPONENTBUILDER_PUSH_FAILED') . '</h1>';
$message .= '<p>' . Text::_('COM_COMPONENTBUILDER_THE_PUSH_OF_THIS_JOOMLA_POWER_HAS_FAILED') . '</p>';
}
} catch (\Exception $e) {
$message = '<h1>' . Text::_('COM_COMPONENTBUILDER_PUSH_FAILED') . '</h1>';
$message .= '<p>' . \htmlspecialchars($e->getMessage()) . '</p>';
}
}

View File

@ -54,6 +54,18 @@ class Joomla_powersController extends AdminController
return parent::getModel($name, $prefix, $config);
}
/**
* Initializes all remote Joomla powers and syncs them with the local database.
*
* This function performs several checks and operations:
* 1. It verifies the authenticity of the request to prevent request forgery.
* 2. It checks whether the current user has the necessary permissions to initialize the Joomla powers.
* 3. If the user is authorized, it attempts to initialize the remote Joomla powers.
* 4. Depending on the result of the initialization operation, it sets the appropriate success or error message.
* 5. It redirects the user to a specified URL with the result message and status.
*
* @return bool True on successful initialization, false on failure.
*/
public function initPowers()
{
// Check for request forgeries
@ -70,19 +82,24 @@ class Joomla_powersController extends AdminController
if($user->authorise('power.init', 'com_componentbuilder'))
{
if (JoomlaPowerFactory::_('Joomlapower')->init())
{
// set success message
$message = '<h1>' . Text::_('COM_COMPONENTBUILDER_SUCCESSFULLY_INITIALIZED_ALL_REMOTE_JOOMLA_POWERS') . '</h1>';
$message .= '<p>' . Text::_('COM_COMPONENTBUILDER_THE_LOCAL_DATABASE_JOOMLA_POWERS_HAS_SUCCESSFULLY_BEEN_SYNCED_WITH_THE_REMOTE_REPOSITORIES') . '</p>';
try {
if (JoomlaPowerFactory::_('Joomlapower')->init())
{
// set success message
$message = '<h1>' . Text::_('COM_COMPONENTBUILDER_SUCCESSFULLY_INITIALIZED_ALL_REMOTE_JOOMLA_POWERS') . '</h1>';
$message .= '<p>' . Text::_('COM_COMPONENTBUILDER_THE_LOCAL_DATABASE_JOOMLA_POWERS_HAS_SUCCESSFULLY_BEEN_SYNCED_WITH_THE_REMOTE_REPOSITORIES') . '</p>';
$status = 'success';
$success = true;
}
else
{
$status = 'success';
$success = true;
}
else
{
$message = '<h1>' . Text::_('COM_COMPONENTBUILDER_INITIALIZATION_FAILED') . '</h1>';
$message .= '<p>' . Text::_('COM_COMPONENTBUILDER_THE_INITIALIZATION_OF_THIS_JOOMLA_POWERS_HAS_FAILED') . '</p>';
}
} catch (\Exception $e) {
$message = '<h1>' . Text::_('COM_COMPONENTBUILDER_INITIALIZATION_FAILED') . '</h1>';
$message .= '<p>' . Text::_('COM_COMPONENTBUILDER_THE_INITIALIZATION_OF_THIS_JOOMLA_POWERS_HAS_FAILED') . '</p>';
$message .= '<p>' . \htmlspecialchars($e->getMessage()) . '</p>';
}
}
@ -93,6 +110,21 @@ class Joomla_powersController extends AdminController
return $success;
}
/**
* Resets the selected Joomla powers.
*
* This function performs several checks and operations:
* 1. It verifies the authenticity of the request to prevent request forgery.
* 2. It retrieves the IDs of the selected powers from the user input.
* 3. It sanitizes the input by converting the IDs to integers.
* 4. It checks whether any powers have been selected.
* 5. It checks whether the current user has the necessary permissions to reset the selected Joomla powers.
* 6. If the user is authorized and powers are selected, it attempts to reset the selected Joomla powers.
* 7. Depending on the result of the reset operation, it sets the appropriate success or error message.
* 8. It redirects the user to a specified URL with the result message and status.
*
* @return bool True on successful reset, false on failure.
*/
public function resetPowers()
{
// Check for request forgeries
@ -125,18 +157,102 @@ class Joomla_powersController extends AdminController
{
$guids = GetHelper::vars('joomla_power', $pks, 'id', 'guid');
if (JoomlaPowerFactory::_('Joomlapower')->reset($guids))
{
// set success message
$message = '<h1>'.Text::_('COM_COMPONENTBUILDER_SUCCESS').'</h1>';
$message .= '<p>'.Text::_('COM_COMPONENTBUILDER_THESE_JOOMLA_POWERS_HAVE_SUCCESSFULLY_BEEN_RESET').'</p>';
$status = 'success';
$success = true;
}
else
{
try {
if (JoomlaPowerFactory::_('Joomlapower')->reset($guids))
{
// set success message
$message = '<h1>'.Text::_('COM_COMPONENTBUILDER_SUCCESS').'</h1>';
$message .= '<p>'.Text::_('COM_COMPONENTBUILDER_THESE_JOOMLA_POWERS_HAVE_SUCCESSFULLY_BEEN_RESET').'</p>';
$status = 'success';
$success = true;
}
else
{
$message = '<h1>' . Text::_('COM_COMPONENTBUILDER_RESET_FAILED') . '</h1>';
$message .= '<p>' . Text::_('COM_COMPONENTBUILDER_THE_RESET_OF_THESE_JOOMLA_POWERS_HAS_FAILED') . '</p>';
}
} catch (\Exception $e) {
$message = '<h1>' . Text::_('COM_COMPONENTBUILDER_RESET_FAILED') . '</h1>';
$message .= '<p>' . Text::_('COM_COMPONENTBUILDER_THE_RESET_OF_THESE_JOOMLA_POWERS_HAS_FAILED') . '</p>';
$message .= '<p>' . \htmlspecialchars($e->getMessage()) . '</p>';
}
// set redirect
$redirect_url = Route::_('index.php?option=com_componentbuilder&view=joomla_powers', $success);
$this->setRedirect($redirect_url, $message, $status);
return $success;
}
// set redirect
$redirect_url = Route::_('index.php?option=com_componentbuilder&view=joomla_powers', false);
$this->setRedirect($redirect_url);
return $success;
}
/**
* Pushes the selected Joomla powers.
*
* This function performs several checks and operations:
* 1. It verifies the authenticity of the request to prevent request forgery.
* 2. It retrieves the IDs of the selected powers from the user input.
* 3. It sanitizes the input by converting the IDs to integers.
* 4. It checks whether any powers have been selected.
* 5. It checks whether the current user has the necessary permissions to push the selected Joomla powers.
* 6. If the user is authorized and powers are selected, it attempts to push the selected Joomla powers.
* 7. Depending on the result of the push operation, it sets the appropriate success or error message.
* 8. It redirects the user to a specified URL with the result message and status.
*
* @return bool True on successful push, false on failure.
*/
public function pushPowers()
{
// Check for request forgeries
Session::checkToken() or die(Text::_('JINVALID_TOKEN'));
// get IDS of the selected powers
$pks = $this->input->post->get('cid', [], 'array');
// Sanitize the input
ArrayHelper::toInteger($pks);
// check if there is any selections
if ($pks === [])
{
// set error message
$message = '<h1>'.Text::_('COM_COMPONENTBUILDER_NO_SELECTION_DETECTED').'</h1>';
$message .= '<p>'.Text::_('COM_COMPONENTBUILDER_PLEASE_FIRST_MAKE_A_SELECTION_FROM_THE_LIST').'</p>';
// set redirect
$redirect_url = Route::_('index.php?option=com_componentbuilder&view=joomla_powers', false);
$this->setRedirect($redirect_url, $message, 'error');
return false;
}
$status = 'error';
$success = false;
// check if user has the right
$user = Factory::getUser();
if($user->authorise('power.push', 'com_componentbuilder'))
{
$guids = GetHelper::vars('joomla_power', $pks, 'id', 'guid');
try {
if (JoomlaPowerFactory::_('Joomla.Power.Repository')->set($guids))
{
// set success message
$message = '<h1>'.Text::_('COM_COMPONENTBUILDER_SUCCESS').'</h1>';
$message .= '<p>'.Text::_('COM_COMPONENTBUILDER_THESE_JOOMLA_POWERS_HAVE_SUCCESSFULLY_BEEN_PUSHED').'</p>';
$status = 'success';
$success = true;
}
else
{
$message = '<h1>' . Text::_('COM_COMPONENTBUILDER_PUSH_FAILED') . '</h1>';
$message .= '<p>' . Text::_('COM_COMPONENTBUILDER_THE_PUSH_OF_THESE_JOOMLA_POWERS_HAS_FAILED') . '</p>';
}
} catch (\Exception $e) {
$message = '<h1>' . Text::_('COM_COMPONENTBUILDER_PUSH_FAILED') . '</h1>';
$message .= '<p>' . \htmlspecialchars($e->getMessage()) . '</p>';
}
// set redirect

View File

@ -63,6 +63,20 @@ class PowerController extends FormController
*/
protected $view_list = 'powers';
/**
* Resets the specified power.
*
* 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 power.
* 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 power.
* 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.
*/
public function resetPowers()
{
// Check for request forgeries

View File

@ -58,27 +58,40 @@ class PowersController extends AdminController
/**
* Run the Expansion
* Runs the expansion module.
*
* @return void
* This function performs several checks and operations:
* 1. It verifies the authenticity of the request to prevent request forgery.
* 2. It checks whether the current user has the necessary permissions to run the expansion module.
* 3. If the user is authorized, it attempts to run the expansion via an API call.
* 4. Depending on the result of the expansion operation, it sets the appropriate success or error message.
* 5. It redirects the user to a specified URL with the result message and status.
*
* @return bool True on successful expansion, false on failure.
*/
public function runExpansion()
{
// Check for request forgeries
Session::checkToken() or \jexit(Text::_('JINVALID_TOKEN'));
Session::checkToken() or die(Text::_('JINVALID_TOKEN'));
// check if user has the right
$user = Factory::getUser();
// set page redirect
$redirect_url = Route::_('index.php?option=com_componentbuilder&view=powers', false);
// set massage
$message = Text::_('COM_COMPONENTBUILDER_YOU_DO_NOT_HAVE_PERMISSION_TO_RUN_THE_EXPANSION_MODULE');
// check if this user has the right to run expansion
if($user->authorise('powers.run_expansion', 'com_componentbuilder'))
{
// set massage
$message = Text::_('COM_COMPONENTBUILDER_EXPANSION_FAILED_PLEASE_CHECK_YOUR_SETTINGS_IN_THE_GLOBAL_OPTIONS_OF_JCB_UNDER_THE_DEVELOPMENT_METHOD_TAB');
// run expansion via API
$result = ComponentbuilderHelper::getFileContents(Uri::root() . 'index.php?option=com_componentbuilder&task=api.expand');
// is there a message returned
if (!is_numeric($result) && StringHelper::check($result))
{
@ -92,10 +105,23 @@ class PowersController extends AdminController
return true;
}
}
$this->setRedirect($redirect_url, $message, 'error');
return false;
}
/**
* Initializes all remote powers and syncs them with the local database.
*
* This function performs several checks and operations:
* 1. It verifies the authenticity of the request to prevent request forgery.
* 2. It checks whether the current user has the necessary permissions to initialize the powers.
* 3. If the user is authorized, it attempts to initialize the remote powers.
* 4. Depending on the result of the initialization operation, it sets the appropriate success or error message.
* 5. It redirects the user to a specified URL with the result message and status.
*
* @return bool True on successful initialization, false on failure.
*/
public function initPowers()
{
// Check for request forgeries
@ -135,6 +161,21 @@ class PowersController extends AdminController
return $success;
}
/**
* Resets the selected powers.
*
* This function performs several checks and operations:
* 1. It verifies the authenticity of the request to prevent request forgery.
* 2. It retrieves the IDs of the selected powers from the user input.
* 3. It sanitizes the input by converting the IDs to integers.
* 4. It checks whether any powers have been selected.
* 5. It checks whether the current user has the necessary permissions to reset the selected powers.
* 6. If the user is authorized and powers are selected, it attempts to reset the selected powers.
* 7. Depending on the result of the reset operation, it sets the appropriate success or error message.
* 8. It redirects the user to a specified URL with the result message and status.
*
* @return bool True on successful reset, false on failure.
*/
public function resetPowers()
{
// Check for request forgeries

View File

@ -56,27 +56,40 @@ class Validation_rulesController extends AdminController
/**
* Run the Expansion
* Runs the expansion module.
*
* @return void
* This function performs several checks and operations:
* 1. It verifies the authenticity of the request to prevent request forgery.
* 2. It checks whether the current user has the necessary permissions to run the expansion module.
* 3. If the user is authorized, it attempts to run the expansion via an API call.
* 4. Depending on the result of the expansion operation, it sets the appropriate success or error message.
* 5. It redirects the user to a specified URL with the result message and status.
*
* @return bool True on successful expansion, false on failure.
*/
public function runExpansion()
{
// Check for request forgeries
Session::checkToken() or \jexit(Text::_('JINVALID_TOKEN'));
Session::checkToken() or die(Text::_('JINVALID_TOKEN'));
// check if user has the right
$user = Factory::getUser();
// set page redirect
$redirect_url = Route::_('index.php?option=com_componentbuilder&view=validation_rules', false);
// set massage
$message = Text::_('COM_COMPONENTBUILDER_YOU_DO_NOT_HAVE_PERMISSION_TO_RUN_THE_EXPANSION_MODULE');
// check if this user has the right to run expansion
if($user->authorise('validation_rules.run_expansion', 'com_componentbuilder'))
{
// set massage
$message = Text::_('COM_COMPONENTBUILDER_EXPANSION_FAILED_PLEASE_CHECK_YOUR_SETTINGS_IN_THE_GLOBAL_OPTIONS_OF_JCB_UNDER_THE_DEVELOPMENT_METHOD_TAB');
// run expansion via API
$result = ComponentbuilderHelper::getFileContents(Uri::root() . 'index.php?option=com_componentbuilder&task=api.expand');
// is there a message returned
if (!is_numeric($result) && StringHelper::check($result))
{
@ -90,6 +103,7 @@ class Validation_rulesController extends AdminController
return true;
}
}
$this->setRedirect($redirect_url, $message, 'error');
return false;
}

View File

@ -119,10 +119,18 @@ class Admin_fields_relationsModel extends AdminModel
/**
* get VDM internal session key
* Retrieves or generates a Vast Development Method (VDM) key for the current item.
*
* @return string the session key
* This function performs the following operations:
* 1. Checks if the VDM key is already set. If not, it proceeds to generate or retrieve one.
* 2. Determines the item ID based on the presence of a specific argument.
* 3. Attempts to retrieve an existing VDM key from a helper method using the item ID.
* 4. If a VDM key is not found, it generates a new random VDM key.
* 5. Stores the VDM key and associates it with the item ID in a helper method.
* 6. Optionally, stores return and GUID values if available.
* 7. Returns the VDM key.
*
* @return string The VDM key for the current item.
*/
public function getVDM()
{

View File

@ -268,10 +268,18 @@ class Admin_viewModel extends AdminModel
/**
* get VDM internal session key
* Retrieves or generates a Vast Development Method (VDM) key for the current item.
*
* @return string the session key
* This function performs the following operations:
* 1. Checks if the VDM key is already set. If not, it proceeds to generate or retrieve one.
* 2. Determines the item ID based on the presence of a specific argument.
* 3. Attempts to retrieve an existing VDM key from a helper method using the item ID.
* 4. If a VDM key is not found, it generates a new random VDM key.
* 5. Stores the VDM key and associates it with the item ID in a helper method.
* 6. Optionally, stores return and GUID values if available.
* 7. Returns the VDM key.
*
* @return string The VDM key for the current item.
*/
public function getVDM()
{

View File

@ -123,10 +123,18 @@ class Class_extendsModel extends AdminModel
/**
* get VDM internal session key
* Retrieves or generates a Vast Development Method (VDM) key for the current item.
*
* @return string the session key
* This function performs the following operations:
* 1. Checks if the VDM key is already set. If not, it proceeds to generate or retrieve one.
* 2. Determines the item ID based on the presence of a specific argument.
* 3. Attempts to retrieve an existing VDM key from a helper method using the item ID.
* 4. If a VDM key is not found, it generates a new random VDM key.
* 5. Stores the VDM key and associates it with the item ID in a helper method.
* 6. Optionally, stores return and GUID values if available.
* 7. Returns the VDM key.
*
* @return string The VDM key for the current item.
*/
public function getVDM()
{

View File

@ -127,10 +127,18 @@ class Class_methodModel extends AdminModel
/**
* get VDM internal session key
* Retrieves or generates a Vast Development Method (VDM) key for the current item.
*
* @return string the session key
* This function performs the following operations:
* 1. Checks if the VDM key is already set. If not, it proceeds to generate or retrieve one.
* 2. Determines the item ID based on the presence of a specific argument.
* 3. Attempts to retrieve an existing VDM key from a helper method using the item ID.
* 4. If a VDM key is not found, it generates a new random VDM key.
* 5. Stores the VDM key and associates it with the item ID in a helper method.
* 6. Optionally, stores return and GUID values if available.
* 7. Returns the VDM key.
*
* @return string The VDM key for the current item.
*/
public function getVDM()
{

View File

@ -124,10 +124,18 @@ class Class_propertyModel extends AdminModel
/**
* get VDM internal session key
* Retrieves or generates a Vast Development Method (VDM) key for the current item.
*
* @return string the session key
* This function performs the following operations:
* 1. Checks if the VDM key is already set. If not, it proceeds to generate or retrieve one.
* 2. Determines the item ID based on the presence of a specific argument.
* 3. Attempts to retrieve an existing VDM key from a helper method using the item ID.
* 4. If a VDM key is not found, it generates a new random VDM key.
* 5. Stores the VDM key and associates it with the item ID in a helper method.
* 6. Optionally, stores return and GUID values if available.
* 7. Returns the VDM key.
*
* @return string The VDM key for the current item.
*/
public function getVDM()
{

View File

@ -127,10 +127,18 @@ class Component_dashboardModel extends AdminModel
/**
* get VDM internal session key
* Retrieves or generates a Vast Development Method (VDM) key for the current item.
*
* @return string the session key
* This function performs the following operations:
* 1. Checks if the VDM key is already set. If not, it proceeds to generate or retrieve one.
* 2. Determines the item ID based on the presence of a specific argument.
* 3. Attempts to retrieve an existing VDM key from a helper method using the item ID.
* 4. If a VDM key is not found, it generates a new random VDM key.
* 5. Stores the VDM key and associates it with the item ID in a helper method.
* 6. Optionally, stores return and GUID values if available.
* 7. Returns the VDM key.
*
* @return string The VDM key for the current item.
*/
public function getVDM()
{

View File

@ -128,10 +128,18 @@ class Component_routerModel extends AdminModel
/**
* get VDM internal session key
* Retrieves or generates a Vast Development Method (VDM) key for the current item.
*
* @return string the session key
* This function performs the following operations:
* 1. Checks if the VDM key is already set. If not, it proceeds to generate or retrieve one.
* 2. Determines the item ID based on the presence of a specific argument.
* 3. Attempts to retrieve an existing VDM key from a helper method using the item ID.
* 4. If a VDM key is not found, it generates a new random VDM key.
* 5. Stores the VDM key and associates it with the item ID in a helper method.
* 6. Optionally, stores return and GUID values if available.
* 7. Returns the VDM key.
*
* @return string The VDM key for the current item.
*/
public function getVDM()
{

View File

@ -185,10 +185,18 @@ class Custom_admin_viewModel extends AdminModel
/**
* get VDM internal session key
* Retrieves or generates a Vast Development Method (VDM) key for the current item.
*
* @return string the session key
* This function performs the following operations:
* 1. Checks if the VDM key is already set. If not, it proceeds to generate or retrieve one.
* 2. Determines the item ID based on the presence of a specific argument.
* 3. Attempts to retrieve an existing VDM key from a helper method using the item ID.
* 4. If a VDM key is not found, it generates a new random VDM key.
* 5. Stores the VDM key and associates it with the item ID in a helper method.
* 6. Optionally, stores return and GUID values if available.
* 7. Returns the VDM key.
*
* @return string The VDM key for the current item.
*/
public function getVDM()
{

View File

@ -139,10 +139,18 @@ class Custom_codeModel extends AdminModel
/**
* get VDM internal session key
* Retrieves or generates a Vast Development Method (VDM) key for the current item.
*
* @return string the session key
* This function performs the following operations:
* 1. Checks if the VDM key is already set. If not, it proceeds to generate or retrieve one.
* 2. Determines the item ID based on the presence of a specific argument.
* 3. Attempts to retrieve an existing VDM key from a helper method using the item ID.
* 4. If a VDM key is not found, it generates a new random VDM key.
* 5. Stores the VDM key and associates it with the item ID in a helper method.
* 6. Optionally, stores return and GUID values if available.
* 7. Returns the VDM key.
*
* @return string The VDM key for the current item.
*/
public function getVDM()
{

View File

@ -179,10 +179,18 @@ class Dynamic_getModel extends AdminModel
/**
* get VDM internal session key
* Retrieves or generates a Vast Development Method (VDM) key for the current item.
*
* @return string the session key
* This function performs the following operations:
* 1. Checks if the VDM key is already set. If not, it proceeds to generate or retrieve one.
* 2. Determines the item ID based on the presence of a specific argument.
* 3. Attempts to retrieve an existing VDM key from a helper method using the item ID.
* 4. If a VDM key is not found, it generates a new random VDM key.
* 5. Stores the VDM key and associates it with the item ID in a helper method.
* 6. Optionally, stores return and GUID values if available.
* 7. Returns the VDM key.
*
* @return string The VDM key for the current item.
*/
public function getVDM()
{

View File

@ -172,10 +172,18 @@ class FieldModel extends AdminModel
/**
* get VDM internal session key
* Retrieves or generates a Vast Development Method (VDM) key for the current item.
*
* @return string the session key
* This function performs the following operations:
* 1. Checks if the VDM key is already set. If not, it proceeds to generate or retrieve one.
* 2. Determines the item ID based on the presence of a specific argument.
* 3. Attempts to retrieve an existing VDM key from a helper method using the item ID.
* 4. If a VDM key is not found, it generates a new random VDM key.
* 5. Stores the VDM key and associates it with the item ID in a helper method.
* 6. Optionally, stores return and GUID values if available.
* 7. Returns the VDM key.
*
* @return string The VDM key for the current item.
*/
public function getVDM()
{

View File

@ -146,10 +146,18 @@ class FieldtypeModel extends AdminModel
/**
* get VDM internal session key
* Retrieves or generates a Vast Development Method (VDM) key for the current item.
*
* @return string the session key
* This function performs the following operations:
* 1. Checks if the VDM key is already set. If not, it proceeds to generate or retrieve one.
* 2. Determines the item ID based on the presence of a specific argument.
* 3. Attempts to retrieve an existing VDM key from a helper method using the item ID.
* 4. If a VDM key is not found, it generates a new random VDM key.
* 5. Stores the VDM key and associates it with the item ID in a helper method.
* 6. Optionally, stores return and GUID values if available.
* 7. Returns the VDM key.
*
* @return string The VDM key for the current item.
*/
public function getVDM()
{

View File

@ -303,10 +303,18 @@ class Joomla_componentModel extends AdminModel
/**
* get VDM internal session key
* Retrieves or generates a Vast Development Method (VDM) key for the current item.
*
* @return string the session key
* This function performs the following operations:
* 1. Checks if the VDM key is already set. If not, it proceeds to generate or retrieve one.
* 2. Determines the item ID based on the presence of a specific argument.
* 3. Attempts to retrieve an existing VDM key from a helper method using the item ID.
* 4. If a VDM key is not found, it generates a new random VDM key.
* 5. Stores the VDM key and associates it with the item ID in a helper method.
* 6. Optionally, stores return and GUID values if available.
* 7. Returns the VDM key.
*
* @return string The VDM key for the current item.
*/
public function getVDM()
{

View File

@ -209,10 +209,18 @@ class Joomla_moduleModel extends AdminModel
/**
* get VDM internal session key
* Retrieves or generates a Vast Development Method (VDM) key for the current item.
*
* @return string the session key
* This function performs the following operations:
* 1. Checks if the VDM key is already set. If not, it proceeds to generate or retrieve one.
* 2. Determines the item ID based on the presence of a specific argument.
* 3. Attempts to retrieve an existing VDM key from a helper method using the item ID.
* 4. If a VDM key is not found, it generates a new random VDM key.
* 5. Stores the VDM key and associates it with the item ID in a helper method.
* 6. Optionally, stores return and GUID values if available.
* 7. Returns the VDM key.
*
* @return string The VDM key for the current item.
*/
public function getVDM()
{

View File

@ -186,10 +186,18 @@ class Joomla_pluginModel extends AdminModel
/**
* get VDM internal session key
* Retrieves or generates a Vast Development Method (VDM) key for the current item.
*
* @return string the session key
* This function performs the following operations:
* 1. Checks if the VDM key is already set. If not, it proceeds to generate or retrieve one.
* 2. Determines the item ID based on the presence of a specific argument.
* 3. Attempts to retrieve an existing VDM key from a helper method using the item ID.
* 4. If a VDM key is not found, it generates a new random VDM key.
* 5. Stores the VDM key and associates it with the item ID in a helper method.
* 6. Optionally, stores return and GUID values if available.
* 7. Returns the VDM key.
*
* @return string The VDM key for the current item.
*/
public function getVDM()
{

View File

@ -119,10 +119,18 @@ class Language_translationModel extends AdminModel
/**
* get VDM internal session key
* Retrieves or generates a Vast Development Method (VDM) key for the current item.
*
* @return string the session key
* This function performs the following operations:
* 1. Checks if the VDM key is already set. If not, it proceeds to generate or retrieve one.
* 2. Determines the item ID based on the presence of a specific argument.
* 3. Attempts to retrieve an existing VDM key from a helper method using the item ID.
* 4. If a VDM key is not found, it generates a new random VDM key.
* 5. Stores the VDM key and associates it with the item ID in a helper method.
* 6. Optionally, stores return and GUID values if available.
* 7. Returns the VDM key.
*
* @return string The VDM key for the current item.
*/
public function getVDM()
{

View File

@ -141,10 +141,18 @@ class LayoutModel extends AdminModel
/**
* get VDM internal session key
* Retrieves or generates a Vast Development Method (VDM) key for the current item.
*
* @return string the session key
* This function performs the following operations:
* 1. Checks if the VDM key is already set. If not, it proceeds to generate or retrieve one.
* 2. Determines the item ID based on the presence of a specific argument.
* 3. Attempts to retrieve an existing VDM key from a helper method using the item ID.
* 4. If a VDM key is not found, it generates a new random VDM key.
* 5. Stores the VDM key and associates it with the item ID in a helper method.
* 6. Optionally, stores return and GUID values if available.
* 7. Returns the VDM key.
*
* @return string The VDM key for the current item.
*/
public function getVDM()
{

View File

@ -157,10 +157,18 @@ class LibraryModel extends AdminModel
/**
* get VDM internal session key
* Retrieves or generates a Vast Development Method (VDM) key for the current item.
*
* @return string the session key
* This function performs the following operations:
* 1. Checks if the VDM key is already set. If not, it proceeds to generate or retrieve one.
* 2. Determines the item ID based on the presence of a specific argument.
* 3. Attempts to retrieve an existing VDM key from a helper method using the item ID.
* 4. If a VDM key is not found, it generates a new random VDM key.
* 5. Stores the VDM key and associates it with the item ID in a helper method.
* 6. Optionally, stores return and GUID values if available.
* 7. Returns the VDM key.
*
* @return string The VDM key for the current item.
*/
public function getVDM()
{

View File

@ -121,10 +121,18 @@ class PlaceholderModel extends AdminModel
/**
* get VDM internal session key
* Retrieves or generates a Vast Development Method (VDM) key for the current item.
*
* @return string the session key
* This function performs the following operations:
* 1. Checks if the VDM key is already set. If not, it proceeds to generate or retrieve one.
* 2. Determines the item ID based on the presence of a specific argument.
* 3. Attempts to retrieve an existing VDM key from a helper method using the item ID.
* 4. If a VDM key is not found, it generates a new random VDM key.
* 5. Stores the VDM key and associates it with the item ID in a helper method.
* 6. Optionally, stores return and GUID values if available.
* 7. Returns the VDM key.
*
* @return string The VDM key for the current item.
*/
public function getVDM()
{

View File

@ -167,10 +167,18 @@ class PowerModel extends AdminModel
/**
* get VDM internal session key
* Retrieves or generates a Vast Development Method (VDM) key for the current item.
*
* @return string the session key
* This function performs the following operations:
* 1. Checks if the VDM key is already set. If not, it proceeds to generate or retrieve one.
* 2. Determines the item ID based on the presence of a specific argument.
* 3. Attempts to retrieve an existing VDM key from a helper method using the item ID.
* 4. If a VDM key is not found, it generates a new random VDM key.
* 5. Stores the VDM key and associates it with the item ID in a helper method.
* 6. Optionally, stores return and GUID values if available.
* 7. Returns the VDM key.
*
* @return string The VDM key for the current item.
*/
public function getVDM()
{

View File

@ -188,10 +188,18 @@ class Site_viewModel extends AdminModel
/**
* get VDM internal session key
* Retrieves or generates a Vast Development Method (VDM) key for the current item.
*
* @return string the session key
* This function performs the following operations:
* 1. Checks if the VDM key is already set. If not, it proceeds to generate or retrieve one.
* 2. Determines the item ID based on the presence of a specific argument.
* 3. Attempts to retrieve an existing VDM key from a helper method using the item ID.
* 4. If a VDM key is not found, it generates a new random VDM key.
* 5. Stores the VDM key and associates it with the item ID in a helper method.
* 6. Optionally, stores return and GUID values if available.
* 7. Returns the VDM key.
*
* @return string The VDM key for the current item.
*/
public function getVDM()
{

View File

@ -141,10 +141,18 @@ class TemplateModel extends AdminModel
/**
* get VDM internal session key
* Retrieves or generates a Vast Development Method (VDM) key for the current item.
*
* @return string the session key
* This function performs the following operations:
* 1. Checks if the VDM key is already set. If not, it proceeds to generate or retrieve one.
* 2. Determines the item ID based on the presence of a specific argument.
* 3. Attempts to retrieve an existing VDM key from a helper method using the item ID.
* 4. If a VDM key is not found, it generates a new random VDM key.
* 5. Stores the VDM key and associates it with the item ID in a helper method.
* 6. Optionally, stores return and GUID values if available.
* 7. Returns the VDM key.
*
* @return string The VDM key for the current item.
*/
public function getVDM()
{

View File

@ -124,10 +124,18 @@ class Validation_ruleModel extends AdminModel
/**
* get VDM internal session key
* Retrieves or generates a Vast Development Method (VDM) key for the current item.
*
* @return string the session key
* This function performs the following operations:
* 1. Checks if the VDM key is already set. If not, it proceeds to generate or retrieve one.
* 2. Determines the item ID based on the presence of a specific argument.
* 3. Attempts to retrieve an existing VDM key from a helper method using the item ID.
* 4. If a VDM key is not found, it generates a new random VDM key.
* 5. Stores the VDM key and associates it with the item ID in a helper method.
* 6. Optionally, stores return and GUID values if available.
* 7. Returns the VDM key.
*
* @return string The VDM key for the current item.
*/
public function getVDM()
{

View File

@ -177,6 +177,11 @@ class HtmlView extends BaseHtmlView
// add Reset button.
ToolbarHelper::custom('joomla_power.resetPowers', 'joomla custom-button-resetpowers', '', 'COM_COMPONENTBUILDER_RESET', false);
}
if ($this->canDo->get('joomla_power.push'))
{
// add Push button.
ToolbarHelper::custom('joomla_power.pushPowers', 'share custom-button-pushpowers', '', 'COM_COMPONENTBUILDER_PUSH', false);
}
ToolbarHelper::cancel('joomla_power.cancel', 'JTOOLBAR_CLOSE');
}
}

View File

@ -151,6 +151,11 @@ class HtmlView extends BaseHtmlView
// add Reset button.
ToolbarHelper::custom('joomla_powers.resetPowers', 'joomla custom-button-resetpowers', '', 'COM_COMPONENTBUILDER_RESET', false);
}
if ($this->user->authorise('joomla_power.push', 'com_componentbuilder'))
{
// add Push button.
ToolbarHelper::custom('joomla_powers.pushPowers', 'share custom-button-pushpowers', '', 'COM_COMPONENTBUILDER_PUSH', false);
}
// set help url for this view if found
$this->help_url = ComponentbuilderHelper::getHelpUrl('joomla_powers');

View File

@ -1,15 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<extension type="component" version="5.0" method="upgrade">
<name>COM_COMPONENTBUILDER</name>
<creationDate>28th June, 2024</creationDate>
<creationDate>8th July, 2024</creationDate>
<author>Llewellyn van der Merwe</author>
<authorEmail>joomla@vdm.io</authorEmail>
<authorUrl>https://dev.vdm.io</authorUrl>
<copyright>Copyright (C) 2015 Vast Development Method. All rights reserved.</copyright>
<license>GNU General Public License version 2 or later; see LICENSE.txt</license>
<version>5.0.1-alpha6</version>
<version>5.0.1-alpha7</version>
<description><![CDATA[
<h1>Component Builder (v.5.0.1-alpha6)</h1>
<h1>Component Builder (v.5.0.1-alpha7)</h1>
<div style="clear: both;"></div>
<p>The Component Builder for [Joomla](https://extensions.joomla.org/extension/component-builder/) is highly advanced tool that is truly able to build extremely complex components in a fraction of the time.

View File

@ -62,7 +62,7 @@
<version>5.0.1-alpha</version>
<infourl title="Component Builder!">https://dev.vdm.io</infourl>
<downloads>
<downloadurl type="full" format="zip">https://git.vdm.dev/api/v1/repos/joomla/pkg-component-builder/archive/v5.0.1-alpha5.zip</downloadurl>
<downloadurl type="full" format="zip">https://git.vdm.dev/api/v1/repos/joomla/pkg-component-builder/archive/v5.0.1-alpha7.zip</downloadurl>
</downloads>
<tags>
<tag>alpha</tag>
@ -77,10 +77,10 @@
<element>pkg_component_builder</element>
<type>package</type>
<client>site</client>
<version>5.0.1-alpha6</version>
<version>5.0.1-alpha7</version>
<infourl title="Component Builder!">https://dev.vdm.io</infourl>
<downloads>
<downloadurl type="full" format="zip">https://git.vdm.dev/api/v1/repos/joomla/pkg-component-builder/archive/v5.0.1-alpha6.zip</downloadurl>
<downloadurl type="full" format="zip">https://git.vdm.dev/api/v1/repos/joomla/pkg-component-builder/archive/v5.0.1-alpha7.zip</downloadurl>
</downloads>
<tags>
<tag>alpha</tag>

View File

@ -64,10 +64,10 @@ class Contents extends Api
* @param string|null $ref Optional. The name of the commit/branch/tag.
* Default the repository's default branch (usually master).
*
* @return object|null
* @return null|array|object
* @since 3.2.0
**/
public function metadata(string $owner, string $repo, string $filepath, ?string $ref = null): ?object
public function metadata(string $owner, string $repo, string $filepath, ?string $ref = null): null|array|object
{
// Build the request path.
$path = "/repos/{$owner}/{$repo}/contents/{$filepath}";
@ -100,7 +100,7 @@ class Contents extends Api
* @param string|null $authorEmail The author's email.
* @param string|null $committerName The committer's name.
* @param string|null $committerEmail The committer's email.
* @param bool|null $newBranch Whether to create a new branch. Defaults to false.
* @param string|null $newBranch Whether to create a new branch. Defaults to null.
* @param string|null $authorDate The author's date.
* @param string|null $committerDate The committer's date.
* @param bool|null $signoff Add a Signed-off-by trailer. Defaults to null.
@ -119,7 +119,7 @@ class Contents extends Api
?string $authorEmail = null,
?string $committerName = null,
?string $committerEmail = null,
?bool $newBranch = false,
?string $newBranch = null,
?string $authorDate = null,
?string $committerDate = null,
?bool $signoff = null

View File

@ -29,7 +29,7 @@ final class Http extends JoomlaHttp
* @var string
* @since 3.2.0
*/
protected string $_token_; // to avoid collusions (but allow swapping)
protected string $_token_; // to avoid collisions (but allow swapping)
/**
* Constructor.
@ -52,7 +52,7 @@ final class Http extends JoomlaHttp
// add the token if given
if (is_string($token))
{
$config['headers']['Authorization'] = $token;
$config['headers']['Authorization'] = 'token ' . $token;
$this->_token_ = $token;
}
@ -78,7 +78,7 @@ final class Http extends JoomlaHttp
);
// add the token
$headers['Authorization'] = $token;
$headers['Authorization'] = 'token ' . $token;
$this->_token_ = $token;
$this->setOption('headers', $headers);

View File

@ -55,6 +55,14 @@ abstract class Grep implements GrepInterface
**/
protected array $order = ['local', 'remote'];
/**
* The target branch field name ['read_branch', 'write_branch']
*
* @var string
* @since 3.2.2
**/
protected string $branch_field = 'read_branch';
/**
* Gitea Repository Contents
*
@ -120,6 +128,19 @@ abstract class Grep implements GrepInterface
return empty($powers) ? null : array_unique($powers);
}
/**
* Set the branch field
*
* @param string $field The global unique id of the power
*
* @return void
* @since 3.2.2
*/
public function setBranchField(string $field): void
{
$this->branch_field = $field;
}
/**
* Get a power
*
@ -196,15 +217,12 @@ abstract class Grep implements GrepInterface
$path->path = trim($path->organisation) . '/' . trim($path->repository);
// update the branch
if ($path->read_branch === 'default' || empty($path->read_branch))
{
$path->read_branch = null;
}
$branch_field = $this->getBranchField();
$branch = $path->{$branch_field} ?? null;
// only update the write branch if set
if (isset($path->write_branch) && ($path->write_branch === 'default' || empty($path->write_branch)))
if ($branch === 'default' || empty($branch))
{
$path->write_branch = null;
$path->{$branch_field} = null;
}
// set local path
@ -220,5 +238,16 @@ abstract class Grep implements GrepInterface
}
}
}
/**
* Get the branch field
*
* @return string
* @since 3.2.2
*/
public function getBranchField(): string
{
return $this->branch_field;
}
}

View File

@ -16,6 +16,7 @@ use Joomla\Registry\Registry as JoomlaRegistry;
use Joomla\CMS\Factory as JoomlaFactory;
use VDM\Joomla\Utilities\GetHelper;
use VDM\Joomla\Utilities\StringHelper;
use VDM\Joomla\Componentbuilder\Utilities\RepoHelper;
use VDM\Joomla\Componentbuilder\Abstraction\BaseConfig;
@ -113,21 +114,6 @@ class Config extends BaseConfig
return $repos;
}
/**
* Get Joomla power push repo
*
* @return object|null The push repository on Gitea
* @since 3.2.1
*/
protected function getJoomlapowerspushrepo(): ?object
{
// some defaults repos we need by JCB
if (!empty($this->gitea_username))
{
return (object) ['organisation' => $this->gitea_username, 'repository' => 'joomla-powers', 'read_branch' => 'master'];
}
}
/**
* Get joomla power approved paths
*
@ -136,7 +122,26 @@ class Config extends BaseConfig
*/
protected function getApprovedjoomlapaths(): array
{
return array_values($this->joomla_powers_init_repos);
// some defaults repos we need by JCB
$approved = $this->joomla_powers_init_repos;
$paths = RepoHelper::get(2); // Joomla Power = 2
if ($paths !== null)
{
foreach ($paths as $path)
{
$owner = $path->organisation ?? null;
$repo = $path->repository ?? null;
if ($owner !== null && $repo !== null)
{
// we make sure to get only the objects
$approved = ["{$owner}.{$repo}" => $path] + $approved;
}
}
}
return array_values($approved);
}
}

View File

@ -54,20 +54,36 @@ final class Grep extends ExtendingGrep implements GrepInterface
return;
}
$path->index = null;
// update the branch
$branch_field = $this->getBranchField();
$branch = $path->{$branch_field} ?? $path->read_branch ?? 'master';
try
{
$this->contents->load_($path->base ?? null, $path->token ?? null);
$path->index = $this->contents->get($path->organisation, $path->repository, 'joomla-powers.json', $path->read_branch);
$source = $this->contents->metadata($path->organisation, $path->repository, 'src', $branch);
if ($source && is_array($source))
{
$path->index = new \stdClass();
foreach ($source as $index)
{
if (is_object($index) && isset($index->name))
{
$path->index->{$index->name} = $index;
}
}
}
$this->contents->reset_();
}
catch (\Exception $e)
{
$this->app->enqueueMessage(
Text::sprintf('COM_COMPONENTBUILDER_PSUPER_POWERB_REPOSITORY_AT_BSSB_GAVE_THE_FOLLOWING_ERRORBR_SP', $this->contents->api(), $path->path, $e->getMessage()),
Text::sprintf('COM_COMPONENTBUILDER_PJOOMLA_POWERB_REPOSITORY_AT_BSSB_GAVE_THE_FOLLOWING_ERRORBR_SP', $this->contents->api(), $path->path, $e->getMessage()),
'Error'
);
$path->index = null;
}
}
@ -82,7 +98,7 @@ final class Grep extends ExtendingGrep implements GrepInterface
protected function searchRemote(string $guid): ?object
{
// we can only search if we have paths
if ($this->path && $this->paths)
if (is_array($this->paths))
{
foreach ($this->paths as $path)
{
@ -100,7 +116,7 @@ final class Grep extends ExtendingGrep implements GrepInterface
}
/**
* Get a remote power
* Get a remote joomla power
*
* @param object $path The repository path details
* @param string $guid The global unique id of the power
@ -111,20 +127,40 @@ final class Grep extends ExtendingGrep implements GrepInterface
protected function getRemote(object $path, string $guid): ?object
{
$power = null;
if (empty($path->index->{$guid}->settings))
if (empty($path->index->{$guid}->path))
{
return $power;
}
// get the branch name
$branch_field = $this->getBranchField();
$branch = $path->{$branch_field} ?? $path->read_branch ?? 'master';
// get the settings
$this->contents->load_($path->base ?? null, $path->token ?? null);
if (($power = $this->loadRemoteFile($path->organisation, $path->repository, $path->index->{$guid}->settings, $path->read_branch)) !== null &&
if (($power = $this->loadRemoteFile($path->organisation, $path->repository, $path->index->{$guid}->path . '/item.json', $branch)) !== null &&
isset($power->guid))
{
// set the git details in params
$power->params = (object) [
'source' => ['guid' => $path->guid ?? null]
];
$path_guid = $path->guid ?? null;
if ($path_guid !== null)
{
if (($meta = $this->contents->metadata($path->organisation, $path->repository, $path->index->{$guid}->path . '/item.json', $branch)) !== null &&
isset($meta->sha))
{
if (isset($power->params) && is_object($power->params) &&
isset($power->params->source) && is_array($power->params->source))
{
$power->params->source[$path_guid] = $meta->sha;
}
else
{
$power->params = (object)[
'source' => [$path_guid => $meta->sha]
];
}
}
}
}
$this->contents->reset_();

View File

@ -0,0 +1,46 @@
<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace VDM\Joomla\Componentbuilder\JoomlaPower;
use VDM\Joomla\Data\Repository as ExtendingRepository;
/**
* Set JoomlaPower based on global unique ids to remote repository
*
* @since 3.2.2
*/
final class Repository extends ExtendingRepository
{
/**
* Table Name
*
* @var string
* @since 3.2.1
*/
protected string $table = 'joomla_power';
/**
* The item map
*
* @var array
* @since 3.2.2
*/
protected array $map = [
'system_name' => 'system_name',
'settings' => 'settings',
'guid' => 'guid',
'description' => 'description'
];
}

View File

@ -18,6 +18,7 @@ use VDM\Joomla\Componentbuilder\JoomlaPower\Config;
use VDM\Joomla\Componentbuilder\Table;
use VDM\Joomla\Componentbuilder\JoomlaPower\Grep;
use VDM\Joomla\Componentbuilder\JoomlaPower\Super as Superpower;
use VDM\Joomla\Componentbuilder\JoomlaPower\Repository;
use VDM\Joomla\Componentbuilder\Compiler\Power\Parser;
@ -34,7 +35,7 @@ class JoomlaPower implements ServiceProviderInterface
* @param Container $container The DI container.
*
* @return void
* @since 3.2.0
* @since 3.2.1
*/
public function register(Container $container)
{
@ -50,6 +51,9 @@ class JoomlaPower implements ServiceProviderInterface
$container->alias(Superpower::class, 'Joomlapower')
->share('Joomlapower', [$this, 'getSuperpower'], true);
$container->alias(Repository::class, 'Joomla.Power.Repository')
->share('Joomla.Power.Repository', [$this, 'getRepository'], true);
$container->alias(Parser::class, 'Power.Parser')
->share('Power.Parser', [$this, 'getParser'], true);
}
@ -60,7 +64,7 @@ class JoomlaPower implements ServiceProviderInterface
* @param Container $container The DI container.
*
* @return Config
* @since 3.2.0
* @since 3.2.1
*/
public function getConfig(Container $container): Config
{
@ -73,7 +77,7 @@ class JoomlaPower implements ServiceProviderInterface
* @param Container $container The DI container.
*
* @return Table
* @since 3.2.0
* @since 3.2.1
*/
public function getTable(Container $container): Table
{
@ -86,7 +90,7 @@ class JoomlaPower implements ServiceProviderInterface
* @param Container $container The DI container.
*
* @return Grep
* @since 3.2.0
* @since 3.2.1
*/
public function getGrep(Container $container): Grep
{
@ -102,7 +106,7 @@ class JoomlaPower implements ServiceProviderInterface
* @param Container $container The DI container.
*
* @return Superpower
* @since 3.2.0
* @since 3.2.1
*/
public function getSuperpower(Container $container): Superpower
{
@ -112,13 +116,31 @@ class JoomlaPower implements ServiceProviderInterface
);
}
/**
* Get The Repository Class.
*
* @param Container $container The DI container.
*
* @return Repository
* @since 3.2.2
*/
public function getRepository(Container $container): Repository
{
return new Repository(
$container->get('Config')->approved_joomla_paths,
$container->get('Joomla.Power.Grep'),
$container->get('Data.Items'),
$container->get('Gitea.Repository.Contents')
);
}
/**
* Get The Parser Class.
*
* @param Container $container The DI container.
*
* @return Parser
* @since 3.2.0
* @since 3.2.1
*/
public function getParser(Container $container): Parser
{

View File

@ -135,26 +135,6 @@ class Config extends BaseConfig
return $repos;
}
/**
* Get super power push repo
*
* @return object|null The push repository on Gitea
* @since 3.2.1
*/
protected function getSuperpowerspushrepo(): ?object
{
if ($this->gitea_username !== null)
{
return (object) [
'organisation' => $this->gitea_username,
'repository' => 'super-powers',
'read_branch' => 'master'
];
}
return null;
}
/**
* get temporary path
*

View File

@ -0,0 +1,386 @@
<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace VDM\Joomla\Data;
use VDM\Joomla\Interfaces\GrepInterface as Grep;
use VDM\Joomla\Interfaces\Data\ItemsInterface as Items;
use VDM\Joomla\Gitea\Repository\Contents as Git;
/**
* Set data based on global unique ids to remote repository
*
* @since 3.2.2
*/
class Repository
{
/**
* The GrepInterface Class.
*
* @var Grep
* @since 3.2.2
*/
protected Grep $grep;
/**
* The ItemsInterface Class.
*
* @var Items
* @since 3.2.2
*/
protected Items $items;
/**
* The Contents Class.
*
* @var Git
* @since 3.2.2
*/
protected Git $git;
/**
* All active repos
*
* @var array
* @since 3.2.0
**/
public array $repos;
/**
* Table Name
*
* @var string
* @since 3.2.1
*/
protected string $table;
/**
* The item map
*
* @var array
* @since 3.2.2
*/
protected array $map;
/**
* Constructor.
*
* @param array $repos The active repos
* @param Grep $grep The GrepInterface Class.
* @param Items $items The ItemsInterface Class.
* @param Git $git The Contents Class.
* @param string|null $table The table name.
*
* @since 3.2.2
*/
public function __construct(array $repos, Grep $grep, Items $items, Git $git, ?string $table = null)
{
$this->repos = $repos;
$this->grep = $grep;
$this->items = $items;
$this->git = $git;
if ($table !== null)
{
$this->table = $table;
}
// set the branch to writing
$this->grep->setBranchField('write_branch');
}
/**
* Set the current active table
*
* @param string $table The table that should be active
*
* @return self
* @since 3.2.2
*/
public function table(string $table): self
{
$this->table = $table;
return $this;
}
/**
* Set items
*
* @param array $guids The global unique id of the item
*
* @return bool
* @throws \Exception
* @since 3.2.0
*/
public function set(array $guids): bool
{
if (($items = $this->getLocalItems($guids)) === null)
{
throw new \Exception("At least one valid local [Joomla Power] must exist for the push function to operate correctly.");
}
if (!$this->canWrite())
{
throw new \Exception("At least one [Joomla Power] content repository must be configured with a [Write Branch] value in the repositories area for the push function to operate correctly.");
}
// update the existing found
if (($existing_items = $this->getRepoItems($guids)) !== [])
{
foreach ($existing_items as $e_guid => $item)
{
if (isset($items[$e_guid]))
{
$this->updateItem($items[$e_guid], $item);
unset($items[$e_guid]);
}
}
}
// create the new items
foreach ($items as $item)
{
$this->createItem($item);
}
return true;
}
/**
* Get the current active table
*
* @return string
* @since 3.2.2
*/
public function getTable(): string
{
return $this->table;
}
/**
* Get items
*
* @param array $guids The global unique id of the item
*
* @return array|null
* @since 3.2.2
*/
public function getLocalItems(array $guids): ?array
{
$items = $this->fetchLocalItems($guids);
if ($items === null)
{
return null;
}
return $this->mapItems($items);
}
/**
* Fetch items from the database
*
* @param array $guids The global unique id of the item
*
* @return array|null
* @since 3.2.2
*/
protected function fetchLocalItems(array $guids): ?array
{
return $this->items->table($this->table)->get($guids);
}
/**
* Map items to their properties
*
* @param array $items The items fetched from the database
*
* @return array
* @since 3.2.2
*/
protected function mapItems(array $items): array
{
$bucket = [];
foreach ($items as $item)
{
if (!isset($item->guid))
{
continue;
}
$bucket[$item->guid] = $this->mapItem($item);
}
return $bucket;
}
/**
* Map a single item to its properties
*
* @param object $item The item to be mapped
*
* @return object
* @since 3.2.2
*/
protected function mapItem(object $item): object
{
$power = [];
foreach ($this->map as $key => $map)
{
$power[$key] = $item->{$map} ?? null;
}
return (object) $power;
}
/**
* get existing items
*
* @param array $guids The global unique id of the item
*
* @return array|null
* @since 3.2.2
*/
protected function getRepoItems(array $guids): ?array
{
$bucket = [];
foreach ($guids as $guid)
{
if (($item = $this->grep->get($guid)) !== null)
{
$bucket[$guid] = (object) $item;
}
}
return $bucket ?? null;
}
/**
* check that we have an active repo towards which we can write data
*
* @return bool
* @since 3.2.2
*/
protected function canWrite(): bool
{
foreach ($this->repos as $repo)
{
if (!empty($repo->write_branch) && $repo->write_branch !== 'default')
{
return true;
}
}
return false;
}
/**
* Checks if two objects are equal by comparing their JSON representations.
*
* This method converts both input objects to JSON strings and compares these strings.
* If the JSON strings are identical, the objects are considered equal.
*
* @param object $obj1 The first object to compare.
* @param object $obj2 The second object to compare.
*
* @return bool True if the objects are equal, false otherwise.
* @since 3.2.2
*/
protected function areObjectsEqual(object $obj1, object $obj2): bool
{
// Convert both objects to JSON strings
$json1 = json_encode($obj1);
$json2 = json_encode($obj2);
// Compare the JSON strings
return $json1 === $json2;
}
/**
* update an existing item (if changed)
*
* @param object $item
* @param object $existing
*
* @return void
* @since 3.2.2
*/
protected function updateItem(object $item, object $existing): void
{
if (isset($existing->params->source) && is_array($existing->params->source))
{
// get the source values
$source = $existing->params->source;
// make sure there was a change
$existing = $this->mapItem($existing);
if ($this->areObjectsEqual($item, $existing))
{
return;
}
foreach ($this->repos as $repo)
{
if (isset($source[$repo->guid]))
{
$this->git->load_($repo->base ?? null, $repo->token ?? null);
$this->git->update(
$repo->organisation, // The owner name.
$repo->repository, // The repository name.
'src/' . $item->guid . '/item.json', // The file path.
json_encode($item, JSON_PRETTY_PRINT), // The file content.
'Update ' . $item->system_name, // The commit message.
$source[$repo->guid], // The blob SHA of the old file.
$repo->write_branch // The branch name.
);
$this->git->reset_();
// only update in the first found repo
return;
}
}
}
}
/**
* create a new item
*
* @param object $item
*
* @return void
* @since 3.2.2
*/
protected function createItem(object $item): void
{
foreach ($this->repos as $repo)
{
if (!empty($repo->write_branch) && $repo->write_branch !== 'default')
{
$this->git->load_($repo->base ?? null, $repo->token ?? null);
$this->git->create(
$repo->organisation, // The owner name.
$repo->repository, // The repository name.
'src/' . $item->guid . '/item.json', // The file path.
json_encode($item, JSON_PRETTY_PRINT), // The file content.
'Create ' . $item->system_name, // The commit message.
$repo->write_branch // The branch name.
);
$this->git->reset_();
// only create in the first found repo
return;
}
}
}
}

View File

@ -27,6 +27,16 @@ interface GrepInterface
*/
public function getRemotePowersGuid(): ?array;
/**
* Set the branch field
*
* @param string $field The global unique id of the power
*
* @return void
* @since 3.2.2
*/
public function setBranchField(string $field): void;
/**
* Get a power
*