From 692879ea2d5dabc4f88b0319e37416d3189eaaff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=81Z=C3=81R=20Imre=20AI=20Agent?= Date: Thu, 16 Jul 2026 11:39:02 +0200 Subject: [PATCH] feat(deployed): add Advanced Modules site component (completeness) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit components/com_advancedmodules (RegularLabs) frontend — completes the module. Signed-off-by: LÁZÁR Imre Assisted-by: claude-code@claude-opus-4-8 --- .../com_advancedmodules/advancedmodules.php | 68 ++++++ .../com_advancedmodules/controller.php | 36 +++ .../com_advancedmodules/controllers/edit.php | 18 ++ .../controllers/module.php | 15 ++ .../components/com_advancedmodules/empty.xml | 4 + .../helpers/html/modules.php | 14 ++ .../layouts/joomla/edit/params.php | 106 +++++++++ .../com_advancedmodules/models/edit.php | 22 ++ .../models/forms/module.xml | 133 +++++++++++ .../com_advancedmodules/models/module.php | 14 ++ .../tables/advancedmodules.php | 74 ++++++ .../views/edit/tmpl/edit.php | 222 ++++++++++++++++++ .../views/edit/tmpl/edit_assignment.php | 14 ++ .../views/edit/tmpl/edit_positions.php | 14 ++ .../views/edit/view.html.php | 62 +++++ 15 files changed, 816 insertions(+) create mode 100644 deployed/regularlabs/components/com_advancedmodules/advancedmodules.php create mode 100644 deployed/regularlabs/components/com_advancedmodules/controller.php create mode 100644 deployed/regularlabs/components/com_advancedmodules/controllers/edit.php create mode 100644 deployed/regularlabs/components/com_advancedmodules/controllers/module.php create mode 100644 deployed/regularlabs/components/com_advancedmodules/empty.xml create mode 100644 deployed/regularlabs/components/com_advancedmodules/helpers/html/modules.php create mode 100644 deployed/regularlabs/components/com_advancedmodules/layouts/joomla/edit/params.php create mode 100644 deployed/regularlabs/components/com_advancedmodules/models/edit.php create mode 100644 deployed/regularlabs/components/com_advancedmodules/models/forms/module.xml create mode 100644 deployed/regularlabs/components/com_advancedmodules/models/module.php create mode 100644 deployed/regularlabs/components/com_advancedmodules/tables/advancedmodules.php create mode 100644 deployed/regularlabs/components/com_advancedmodules/views/edit/tmpl/edit.php create mode 100644 deployed/regularlabs/components/com_advancedmodules/views/edit/tmpl/edit_assignment.php create mode 100644 deployed/regularlabs/components/com_advancedmodules/views/edit/tmpl/edit_positions.php create mode 100644 deployed/regularlabs/components/com_advancedmodules/views/edit/view.html.php diff --git a/deployed/regularlabs/components/com_advancedmodules/advancedmodules.php b/deployed/regularlabs/components/com_advancedmodules/advancedmodules.php new file mode 100644 index 00000000..ff2a026c --- /dev/null +++ b/deployed/regularlabs/components/com_advancedmodules/advancedmodules.php @@ -0,0 +1,68 @@ + + * @link http://www.regularlabs.com + * @copyright Copyright © 2018 Regular Labs All Rights Reserved + * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL + */ + +defined('_JEXEC') or die; + +$app = JFactory::getApplication(); + +if ( ! JFactory::getUser()->authorise('module.edit.frontend', 'com_modules.module.' . $app->input->get('id')) + && ! JFactory::getUser()->authorise('module.edit.frontend', 'com_modules') +) +{ + throw new JAccessExceptionNotallowed(JText::_('JERROR_ALERTNOAUTHOR'), 403); +} + +JFactory::getLanguage()->load('com_modules', JPATH_ADMINISTRATOR); +JFactory::getLanguage()->load('com_advancedmodules', JPATH_ADMINISTRATOR . '/components/com_advancedmodules'); + +jimport('joomla.filesystem.file'); + +// return if Regular Labs Library plugin is not installed +if ( + ! is_file(JPATH_PLUGINS . '/system/regularlabs/regularlabs.xml') + || ! is_file(JPATH_LIBRARIES . '/regularlabs/autoload.php') +) +{ + $msg = JText::_('AMM_REGULAR_LABS_LIBRARY_NOT_INSTALLED') + . ' ' . JText::sprintf('AMM_EXTENSION_CAN_NOT_FUNCTION', JText::_('COM_ADVANCEDMODULES')); + JFactory::getApplication()->enqueueMessage($msg, 'error'); + + return; +} + +// give notice if Regular Labs Library plugin is not enabled +if ( ! JPluginHelper::isEnabled('system', 'regularlabs')) +{ + $msg = JText::_('AMM_REGULAR_LABS_LIBRARY_NOT_ENABLED') + . ' ' . JText::sprintf('AMM_EXTENSION_CAN_NOT_FUNCTION', JText::_('COM_ADVANCEDMODULES')); + JFactory::getApplication()->enqueueMessage($msg, 'notice'); +} + +require_once JPATH_LIBRARIES . '/regularlabs/autoload.php'; + +use RegularLabs\Library\Language as RL_Language; + +RL_Language::load('plg_system_regularlabs'); +// Load admin main core language strings +RL_Language::load('', JPATH_ADMINISTRATOR); + +// Tell the browser not to cache this page. +$app->setHeader('Expires', 'Mon, 26 Jul 1997 05:00:00 GMT', true); + +$config = []; +if ($app->input->get('task') === 'module.orderPosition') +{ + $config['base_path'] = JPATH_COMPONENT_ADMINISTRATOR; +} + +$controller = JControllerLegacy::getInstance('AdvancedModules', $config); +$controller->execute($app->input->get('task')); +$controller->redirect(); diff --git a/deployed/regularlabs/components/com_advancedmodules/controller.php b/deployed/regularlabs/components/com_advancedmodules/controller.php new file mode 100644 index 00000000..f7f7a449 --- /dev/null +++ b/deployed/regularlabs/components/com_advancedmodules/controller.php @@ -0,0 +1,36 @@ + + * @link http://www.regularlabs.com + * @copyright Copyright © 2018 Regular Labs All Rights Reserved + * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL + */ + +defined('_JEXEC') or die; + +class AdvancedModulesController extends JControllerLegacy +{ + protected $default_view = 'edit'; + + public function display($cachable = false, $urlparams = false) + { + return parent::display(); + } + + public function __construct($config = []) + { + $this->input = JFactory::getApplication()->input; + + // Modules frontpage Editor Module proxying: + if ($this->input->get('view') === 'modules' && $this->input->get('layout') === 'modal') + { + JHtml::_('stylesheet', 'system/adminlist.css', [], true); + $config['base_path'] = JPATH_COMPONENT_ADMINISTRATOR; + } + + parent::__construct($config); + } +} diff --git a/deployed/regularlabs/components/com_advancedmodules/controllers/edit.php b/deployed/regularlabs/components/com_advancedmodules/controllers/edit.php new file mode 100644 index 00000000..4f19daa9 --- /dev/null +++ b/deployed/regularlabs/components/com_advancedmodules/controllers/edit.php @@ -0,0 +1,18 @@ + + * @link http://www.regularlabs.com + * @copyright Copyright © 2018 Regular Labs All Rights Reserved + * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL + */ + +defined('_JEXEC') or die; + +require_once JPATH_ADMINISTRATOR . '/components/com_advancedmodules/controllers/module.php'; + +class AdvancedModulesControllerEdit extends AdvancedModulesControllerModule +{ +} diff --git a/deployed/regularlabs/components/com_advancedmodules/controllers/module.php b/deployed/regularlabs/components/com_advancedmodules/controllers/module.php new file mode 100644 index 00000000..16aa36e0 --- /dev/null +++ b/deployed/regularlabs/components/com_advancedmodules/controllers/module.php @@ -0,0 +1,15 @@ + + * @link http://www.regularlabs.com + * @copyright Copyright © 2018 Regular Labs All Rights Reserved + * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL + */ + +defined('_JEXEC') or die; + +require_once JPATH_ADMINISTRATOR . '/components/com_advancedmodules/controllers/module.php'; + diff --git a/deployed/regularlabs/components/com_advancedmodules/empty.xml b/deployed/regularlabs/components/com_advancedmodules/empty.xml new file mode 100644 index 00000000..0f384d61 --- /dev/null +++ b/deployed/regularlabs/components/com_advancedmodules/empty.xml @@ -0,0 +1,4 @@ + + + + diff --git a/deployed/regularlabs/components/com_advancedmodules/helpers/html/modules.php b/deployed/regularlabs/components/com_advancedmodules/helpers/html/modules.php new file mode 100644 index 00000000..954125cb --- /dev/null +++ b/deployed/regularlabs/components/com_advancedmodules/helpers/html/modules.php @@ -0,0 +1,14 @@ + + * @link http://www.regularlabs.com + * @copyright Copyright © 2018 Regular Labs All Rights Reserved + * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL + */ + +defined('_JEXEC') or die; + +require_once JPATH_ADMINISTRATOR . '/components/com_advancedmodules/helpers/html/modules.php'; diff --git a/deployed/regularlabs/components/com_advancedmodules/layouts/joomla/edit/params.php b/deployed/regularlabs/components/com_advancedmodules/layouts/joomla/edit/params.php new file mode 100644 index 00000000..529ab67b --- /dev/null +++ b/deployed/regularlabs/components/com_advancedmodules/layouts/joomla/edit/params.php @@ -0,0 +1,106 @@ + + * @link http://www.regularlabs.com + * @copyright Copyright © 2018 Regular Labs All Rights Reserved + * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL + */ + +defined('_JEXEC') or die; + +$app = JFactory::getApplication(); +$form = $displayData->getForm(); + +$fieldSets = $form->getFieldsets('params'); + +// For BC with versions < 3.2 we need to render the attribs too +$attribsFieldSet = $form->getFieldsets('attribs'); + +$fieldSets = array_merge($fieldSets, $attribsFieldSet); + +if (empty($fieldSets)) +{ + return; +} + +$ignoreFieldsets = $displayData->get('ignore_fieldsets') ?: []; +$ignoreFields = $displayData->get('ignore_fields') ?: []; +$extraFields = $displayData->get('extra_fields') ?: []; + +if ( ! empty($displayData->hiddenFieldsets)) +{ + // These are required to preserve data on save when fields are not displayed. + $hiddenFieldsets = $displayData->hiddenFieldsets ?: []; +} + +if ( ! empty($displayData->configFieldsets)) +{ + // These are required to configure showing and hiding fields in the editor. + $configFieldsets = $displayData->configFieldsets ?: []; +} + +if ($displayData->get('show_options', 1)) +{ + foreach ($fieldSets as $name => $fieldSet) + { + if (in_array($name, $ignoreFieldsets) || ( ! empty($configFieldsets) && in_array($name, $configFieldsets)) + || ! empty($hiddenFieldsets) && in_array($name, $hiddenFieldsets) + || (isset($fieldSet->repeat) && $fieldSet->repeat == true) + ) + { + continue; + } + + if ( ! empty($fieldSet->label)) + { + $label = JText::_($fieldSet->label); + } + else + { + $label = strtoupper('JGLOBAL_FIELDSET_' . $name); + if (JText::_($label) == $label) + { + $label = strtoupper('COM_MODULES_' . $name . '_FIELDSET_LABEL'); + } + $label = JText::_($label); + } + + echo JHtml::_('bootstrap.addSlide', 'moduleSlide', $label, 'attrib-' . $name); + + if (isset($fieldSet->description) && trim($fieldSet->description)) + { + echo '

' . $this->escape(JText::_($fieldSet->description)) . '

'; + } + + $displayData->fieldset = $name; + echo JLayoutHelper::render('joomla.edit.fieldset', $displayData); + + echo JHtml::_('bootstrap.endSlide'); + } +} +else +{ + $html = []; + $html[] = '
'; + foreach ($fieldSets as $name => $fieldSet) + { + if (in_array($name, $ignoreFieldsets)) + { + continue; + } + + if (in_array($name, $hiddenFieldsets)) + { + foreach ($form->getFieldset($name) as $field) + { + echo $field->input; + } + } + } + $html[] = '
'; + + echo implode('', $html); +} diff --git a/deployed/regularlabs/components/com_advancedmodules/models/edit.php b/deployed/regularlabs/components/com_advancedmodules/models/edit.php new file mode 100644 index 00000000..48c65488 --- /dev/null +++ b/deployed/regularlabs/components/com_advancedmodules/models/edit.php @@ -0,0 +1,22 @@ + + * @link http://www.regularlabs.com + * @copyright Copyright © 2018 Regular Labs All Rights Reserved + * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL + */ + +defined('_JEXEC') or die; + +require_once JPATH_ADMINISTRATOR . '/components/com_advancedmodules/models/module.php'; + +class AdvancedModulesModelEdit extends AdvancedModulesModelModule +{ + public function __construct($config = []) + { + parent::__construct($config); + } +} diff --git a/deployed/regularlabs/components/com_advancedmodules/models/forms/module.xml b/deployed/regularlabs/components/com_advancedmodules/models/forms/module.xml new file mode 100644 index 00000000..480eb5fb --- /dev/null +++ b/deployed/regularlabs/components/com_advancedmodules/models/forms/module.xml @@ -0,0 +1,133 @@ + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
diff --git a/deployed/regularlabs/components/com_advancedmodules/models/module.php b/deployed/regularlabs/components/com_advancedmodules/models/module.php new file mode 100644 index 00000000..3aebd9a3 --- /dev/null +++ b/deployed/regularlabs/components/com_advancedmodules/models/module.php @@ -0,0 +1,14 @@ + + * @link http://www.regularlabs.com + * @copyright Copyright © 2018 Regular Labs All Rights Reserved + * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL + */ + +defined('_JEXEC') or die; + +require_once JPATH_ADMINISTRATOR . '/components/com_advancedmodules/models/module.php'; diff --git a/deployed/regularlabs/components/com_advancedmodules/tables/advancedmodules.php b/deployed/regularlabs/components/com_advancedmodules/tables/advancedmodules.php new file mode 100644 index 00000000..acb4f559 --- /dev/null +++ b/deployed/regularlabs/components/com_advancedmodules/tables/advancedmodules.php @@ -0,0 +1,74 @@ + + * @link http://www.regularlabs.com + * @copyright Copyright © 2018 Regular Labs All Rights Reserved + * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL + */ + +defined('_JEXEC') or die; + +class AdvancedModulesTable extends JTable +{ + public function __construct(&$db) + { + parent::__construct('#__advancedmodules', 'moduleid', $db); + } + + protected function _getAssetName() + { + $k = $this->_tbl_key; + + return 'com_modules.module.' . (int) $this->{$k}; + } + + protected function _getAssetTitle() + { + if (isset($this->_title)) + { + return $this->_title; + } + + return $this->_getAssetName(); + } + + protected function getAssetParentId(JTable $table = null, $id = null) + { + // Initialise variables. + $assetId = null; + $db = $this->getDbo(); + + $query = $db->getQuery(true) + ->select('id') + ->from('#__assets') + ->where('name = ' . $db->quote('com_modules')); + + // Get the asset id from the database. + $db->setQuery($query); + if ($result = $db->loadResult()) + { + $assetId = (int) $result; + } + + // Return the asset id. + if ($assetId) + { + return $assetId; + } + else + { + return parent::_getAssetParentId($table, $id); + } + } +} + +class AdvancedModulesTableAdvancedModules extends AdvancedModulesTable +{ + protected function _getAssetParentId(JTable $table = null, $id = null) + { + return parent::getAssetParentId($table, $id); + } +} diff --git a/deployed/regularlabs/components/com_advancedmodules/views/edit/tmpl/edit.php b/deployed/regularlabs/components/com_advancedmodules/views/edit/tmpl/edit.php new file mode 100644 index 00000000..e0616c8a --- /dev/null +++ b/deployed/regularlabs/components/com_advancedmodules/views/edit/tmpl/edit.php @@ -0,0 +1,222 @@ + + * @link http://www.regularlabs.com + * @copyright Copyright © 2018 Regular Labs All Rights Reserved + * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL + */ + +defined('_JEXEC') or die; + +use RegularLabs\Library\Document as RL_Document; + +JHtml::addIncludePath(JPATH_COMPONENT . '/helpers/html'); + +JHtml::_('jquery.framework'); +JHtml::_('bootstrap.framework'); +JHtml::_('behavior.formvalidator'); +JHtml::_('behavior.combobox'); +JHtml::_('formbehavior.chosen', 'select'); + +$hasContent = empty($this->item->module) || isset($this->item->xml->customContent); +$hasContentFieldName = 'content'; + +// For a later improvement +if ($hasContent) +{ + $hasContentFieldName = 'content'; +} + +// Get Params Fieldsets +$this->fieldsets = $this->form->getFieldsets('params'); +$this->hidden_fields = ''; + +$uri = JUri::getInstance(); + +$script = " +Joomla.submitbutton = function(task) +{ + if (task == 'module.cancel' || document.formvalidator.isValid(document.id('module-form'))) {"; +if ($hasContent) +{ + $script .= $this->form->getField($hasContentFieldName)->save(); +} +$script .= " Joomla.submitform(task, document.getElementById('module-form')); + if (self != top) + { + window.top.setTimeout('window.parent.SqueezeBox.close();', 1000); + } + } + };"; +if (JFactory::getUser()->authorise('core.admin')) +{ + $script .= " + jQuery(document).ready(function() + { + // add alert on remove assignment buttons + jQuery('button.rl_remove_assignment').click(function() + { + if(confirm('" . str_replace('
', '\n', JText::_('AMM_DISABLE_ASSIGNMENT', true)) . "')) { + jQuery('div#toolbar-options button').click(); + } + }); + });"; +} + +JFactory::getDocument()->addScriptDeclaration($script); +RL_Document::script('regularlabs/script.min.js'); +RL_Document::script('regularlabs/toggler.min.js'); + +JFactory::getDocument()->addStyleSheetVersion(JUri::root(true) . '/media/regularlabs/css/frontend.min.css'); +?> + +
+ +
+ + +
+ +

+ item->title . ' ' . $this->item->module . ''); ?> +

+ +
+
+ +
+
+ +
+
+ +
+
+ +
+ +
+
+
+
+
+ form->getLabel('title'); ?> +
+
+ form->getInput('title')); ?> +
+
+ + ' . $this->form->getInput($hasContentFieldName) . '
'; + } + $this->fieldset = 'basic'; + $html = JLayoutHelper::render('joomla.edit.fieldset', $this); + echo $html ? $html . '
' : ''; + ?> + + form->getControlGroup('showtitle'); ?> +
+
+ form->getLabel('position'); ?> +
+
+ loadTemplate('positions'); ?> +
+
+
+ fields = [ + 'published', + 'access', + 'ordering', + 'note', + ]; + ?> + +
+ item->client_id == 0) : ?> + render($this->assignments, 'pre_post_html'); ?> + + item->client_id == 0 && $this->config->show_hideempty) : ?> + render($this->assignments, 'hideempty'); ?> + +
+ + + + item->client_id == 0) : ?> + + loadTemplate('assignment'); ?> + + + +
+ fieldsets = []; + $this->ignore_fieldsets = ['basic', 'description']; + echo JLayoutHelper::render('joomla.edit.params', $this); + ?> +
+ + + +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+ +
+ + hidden_fields; ?> + + + + + + form->getInput('module'); ?> + form->getInput('client_id'); ?> +
diff --git a/deployed/regularlabs/components/com_advancedmodules/views/edit/tmpl/edit_assignment.php b/deployed/regularlabs/components/com_advancedmodules/views/edit/tmpl/edit_assignment.php new file mode 100644 index 00000000..480fcb35 --- /dev/null +++ b/deployed/regularlabs/components/com_advancedmodules/views/edit/tmpl/edit_assignment.php @@ -0,0 +1,14 @@ + + * @link http://www.regularlabs.com + * @copyright Copyright © 2018 Regular Labs All Rights Reserved + * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL + */ + +defined('_JEXEC') or die; + +require_once JPATH_ADMINISTRATOR . '/components/com_advancedmodules/views/module/tmpl/edit_assignment.php'; diff --git a/deployed/regularlabs/components/com_advancedmodules/views/edit/tmpl/edit_positions.php b/deployed/regularlabs/components/com_advancedmodules/views/edit/tmpl/edit_positions.php new file mode 100644 index 00000000..426b22bf --- /dev/null +++ b/deployed/regularlabs/components/com_advancedmodules/views/edit/tmpl/edit_positions.php @@ -0,0 +1,14 @@ + + * @link http://www.regularlabs.com + * @copyright Copyright © 2018 Regular Labs All Rights Reserved + * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL + */ + +defined('_JEXEC') or die; + +require_once JPATH_ADMINISTRATOR . '/components/com_advancedmodules/views/module/tmpl/edit_positions.php'; diff --git a/deployed/regularlabs/components/com_advancedmodules/views/edit/view.html.php b/deployed/regularlabs/components/com_advancedmodules/views/edit/view.html.php new file mode 100644 index 00000000..dae4fa73 --- /dev/null +++ b/deployed/regularlabs/components/com_advancedmodules/views/edit/view.html.php @@ -0,0 +1,62 @@ + + * @link http://www.regularlabs.com + * @copyright Copyright © 2018 Regular Labs All Rights Reserved + * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL + */ + +defined('_JEXEC') or die; + +require_once JPATH_ADMINISTRATOR . '/components/com_advancedmodules/views/module/view.html.php'; +require_once JPATH_ADMINISTRATOR . '/components/com_advancedmodules/helpers/modules.php'; + +class AdvancedModulesViewEdit extends AdvancedModulesViewModule +{ + protected $form; + + protected $item; + + protected $state; + + /** + * Display the view + * + * @param string $tpl The name of the template file to parse; automatically searches through the template paths. + * + * @return void + */ + public function display($tpl = null) + { + $this->setLayout('edit'); + + parent::display($tpl); + } + + /** + * Function that gets the config settings + * + * @return Object + */ + protected function addToolbar() + { + return; + } + + /** + * Method to get the record form. + * + * @param array $data Data for the form. + * @param boolean $loadData True if the form is to load its own data (default case), false if not. + * + * @return JForm A JForm object on success, false on failure + */ + public function getForm($data = [], $loadData = true) + { + return $this->getModel()->getForm($data, $loadData); + } + +}