feat(deployed): add Advanced Modules site component (completeness)

components/com_advancedmodules (RegularLabs) frontend — completes the module.

Signed-off-by: LÁZÁR Imre <imre@illusion.hu>
Assisted-by: claude-code@claude-opus-4-8
This commit is contained in:
LÁZÁR Imre AI Agent 2026-07-16 11:39:02 +02:00
parent c315434f07
commit 692879ea2d
15 changed files with 816 additions and 0 deletions

View File

@ -0,0 +1,68 @@
<?php
/**
* @package Advanced Module Manager
* @version 7.7.1
*
* @author Peter van Westen <info@regularlabs.com>
* @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();

View File

@ -0,0 +1,36 @@
<?php
/**
* @package Advanced Module Manager
* @version 7.7.1
*
* @author Peter van Westen <info@regularlabs.com>
* @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);
}
}

View File

@ -0,0 +1,18 @@
<?php
/**
* @package Advanced Module Manager
* @version 7.7.1
*
* @author Peter van Westen <info@regularlabs.com>
* @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
{
}

View File

@ -0,0 +1,15 @@
<?php
/**
* @package Advanced Module Manager
* @version 7.7.1
*
* @author Peter van Westen <info@regularlabs.com>
* @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';

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<extension>
<!-- Necessary because the Joomla installer can't handle component folders not having xml files -->
</extension>

View File

@ -0,0 +1,14 @@
<?php
/**
* @package Advanced Module Manager
* @version 7.7.1
*
* @author Peter van Westen <info@regularlabs.com>
* @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';

View File

@ -0,0 +1,106 @@
<?php
/**
* @package Advanced Module Manager
* @version 7.7.1
*
* @author Peter van Westen <info@regularlabs.com>
* @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 '<p class="alert alert-info">' . $this->escape(JText::_($fieldSet->description)) . '</p>';
}
$displayData->fieldset = $name;
echo JLayoutHelper::render('joomla.edit.fieldset', $displayData);
echo JHtml::_('bootstrap.endSlide');
}
}
else
{
$html = [];
$html[] = '<div style="display:none;">';
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[] = '</div>';
echo implode('', $html);
}

View File

@ -0,0 +1,22 @@
<?php
/**
* @package Advanced Module Manager
* @version 7.7.1
*
* @author Peter van Westen <info@regularlabs.com>
* @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);
}
}

View File

@ -0,0 +1,133 @@
<?xml version="1.0" encoding="utf-8"?>
<form>
<fieldset>
<field name="id" type="text"
label="JGLOBAL_FIELD_ID_LABEL"
description="JGLOBAL_FIELD_ID_DESC"
default="0"
readonly="true"
/>
<field name="title" type="text"
label="JGLOBAL_TITLE"
description="COM_MODULES_FIELD_TITLE_DESC"
class="inputbox input-xxlarge input-large-text"
size="40"
maxlength="100"
required="true"
/>
<field name="note" type="text"
label="COM_MODULES_FIELD_NOTE_LABEL"
description="COM_MODULES_FIELD_NOTE_DESC"
maxlength="100"
size="40"
class="inputbox input-full"
/>
<field name="module" type="hidden"
label="COM_MODULES_FIELD_MODULE_LABEL"
description="COM_MODULES_FIELD_MODULE_DESC"
readonly="readonly"
size="20"
/>
<field name="showtitle" type="radio"
class="btn-group btn-group-yesno"
default="1"
label="COM_MODULES_FIELD_SHOWTITLE_LABEL"
description="COM_MODULES_FIELD_SHOWTITLE_DESC"
size="1"
>
<option value="1">JSHOW</option>
<option value="0">JHIDE</option>
</field>
<field name="published" type="list"
class="chzn-color-state"
default="1"
label="JSTATUS"
description="COM_MODULES_FIELD_PUBLISHED_DESC"
size="1"
>
<option value="1">JPUBLISHED</option>
<option value="0">JUNPUBLISHED</option>
<option value="-2">JTRASHED</option>
</field>
<field name="publish_up" type="calendar"
description="COM_MODULES_FIELD_PUBLISH_UP_DESC"
filter="user_utc"
format="%Y-%m-%d %H:%M:%S"
label="COM_MODULES_FIELD_PUBLISH_UP_LABEL"
size="22"
/>
<field name="publish_down" type="calendar"
description="COM_MODULES_FIELD_PUBLISH_DOWN_DESC"
filter="user_utc"
format="%Y-%m-%d %H:%M:%S"
label="COM_MODULES_FIELD_PUBLISH_DOWN_LABEL"
size="22"
/>
<field name="client_id" type="hidden"
label="COM_MODULES_FIELD_CLIENT_ID_LABEL"
description="COM_MODULES_FIELD_CLIENT_ID_DESC"
readonly="true"
size="1"
/>
<field name="position" type="moduleposition"
default=""
label="COM_MODULES_FIELD_POSITION_LABEL"
description="COM_MODULES_FIELD_POSITION_DESC"
maxlength="50"
/>
<field name="access" type="accesslevel"
label="JFIELD_ACCESS_LABEL"
description="JFIELD_ACCESS_DESC"
size="1"
/>
<field name="ordering" type="moduleorder"
label="JFIELD_ORDERING_LABEL"
description="JFIELD_ORDERING_DESC"
/>
<field name="content" type="editor"
buttons="true"
class="inputbox"
description="COM_MODULES_FIELD_CONTENT_DESC"
filter="AdvancedModulesModelModule::filterText"
label="COM_MODULES_FIELD_CONTENT_LABEL"
hide="readmore,pagebreak"
/>
<field name="language" type="contentlanguage"
label="JFIELD_LANGUAGE_LABEL"
description="JFIELD_MODULE_LANGUAGE_DESC"
>
<option value="*">JALL</option>
</field>
<field name="assignment" type="hidden" />
<field name="assigned" type="hidden" />
<field name="asset_id" type="hidden"
filter="unset"
/>
<field name="rules" type="rules"
label="JFIELD_RULES_LABEL"
translate_label="false"
class="inputbox"
filter="rules"
component="com_modules"
section="module"
validate="rules"
/>
</fieldset>
</form>

View File

@ -0,0 +1,14 @@
<?php
/**
* @package Advanced Module Manager
* @version 7.7.1
*
* @author Peter van Westen <info@regularlabs.com>
* @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';

View File

@ -0,0 +1,74 @@
<?php
/**
* @package Advanced Module Manager
* @version 7.7.1
*
* @author Peter van Westen <info@regularlabs.com>
* @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);
}
}

View File

@ -0,0 +1,222 @@
<?php
/**
* @package Advanced Module Manager
* @version 7.7.1
*
* @author Peter van Westen <info@regularlabs.com>
* @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('<br>', '\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');
?>
<form action="<?php echo JRoute::_('index.php?option=com_advancedmodules&view=edit&layout=edit&id=' . (int) $this->item->id); ?>" method="post" name="adminForm"
id="module-form" class="form-validate">
<div class="row-fluid">
<!-- Begin Content -->
<div class="span12">
<h1 class="page_title">
<?php echo JText::sprintf('AMM_MODULE_EDIT', $this->item->title . ' <span class="label label-default">' . $this->item->module . '</span>'); ?>
</h1>
<div class="btn-toolbar">
<div class="btn-group">
<button type="button" class="btn btn-default btn-primary"
onclick="Joomla.submitbutton('module.apply')">
<i class="icon-apply"></i>
<?php echo JText::_('JAPPLY') ?>
</button>
</div>
<div class="btn-group">
<button type="button" class="btn btn-default"
onclick="Joomla.submitbutton('module.save')">
<i class="icon-save"></i>
<?php echo JText::_('JSAVE') ?>
</button>
</div>
<div class="btn-group">
<button type="button" class="btn btn-default"
onclick="Joomla.submitbutton('module.cancel')">
<i class="icon-cancel"></i>
<?php echo JText::_('JCANCEL') ?>
</button>
</div>
</div>
<hr class="hr-condensed">
<div class="row-fluid">
<div class="span12">
<fieldset class="form-horizontal">
<div class="control-group">
<div class="control-label">
<?php echo $this->form->getLabel('title'); ?>
</div>
<div class="controls">
<?php echo str_replace('input-xxlarge', '', $this->form->getInput('title')); ?>
</div>
</div>
<?php
if ($hasContent)
{
echo '<hr>' . $this->form->getInput($hasContentFieldName) . '<hr>';
}
$this->fieldset = 'basic';
$html = JLayoutHelper::render('joomla.edit.fieldset', $this);
echo $html ? $html . '<hr>' : '';
?>
<?php echo $this->form->getControlGroup('showtitle'); ?>
<div class="control-group">
<div class="control-label">
<?php echo $this->form->getLabel('position'); ?>
</div>
<div class="controls">
<?php echo $this->loadTemplate('positions'); ?>
</div>
</div>
</fieldset>
<?php
// Set main fields.
$this->fields = [
'published',
'access',
'ordering',
'note',
];
?>
<?php echo str_replace('form-vertical', 'form-horizontal', JLayoutHelper::render('joomla.edit.global', $this)); ?>
<fieldset class="form-horizontal">
<?php if ($this->item->client_id == 0) : ?>
<?php echo $this->render($this->assignments, 'pre_post_html'); ?>
<?php endif; ?>
<?php if ($this->item->client_id == 0 && $this->config->show_hideempty) : ?>
<?php echo $this->render($this->assignments, 'hideempty'); ?>
<?php endif; ?>
</fieldset>
<?php echo JHtml::_('bootstrap.startAccordion', 'moduleSlide'); ?>
<?php if ($this->item->client_id == 0) : ?>
<?php echo JHtml::_('bootstrap.addSlide', 'moduleSlide', JText::_('AMM_ASSIGNMENTS'), 'assignment'); ?>
<?php echo $this->loadTemplate('assignment'); ?>
<?php echo JHtml::_('bootstrap.endSlide'); ?>
<?php endif; ?>
<div class="form-horizontal">
<?php
$this->fieldsets = [];
$this->ignore_fieldsets = ['basic', 'description'];
echo JLayoutHelper::render('joomla.edit.params', $this);
?>
</div>
<?php echo JHtml::_('bootstrap.endAccordion'); ?>
</div>
</div>
<div class="btn-toolbar">
<div class="btn-group">
<button type="button" class="btn btn-default btn-primary"
onclick="Joomla.submitbutton('module.apply')">
<i class="icon-apply"></i>
<?php echo JText::_('JAPPLY') ?>
</button>
</div>
<div class="btn-group">
<button type="button" class="btn btn-default"
onclick="Joomla.submitbutton('module.save')">
<i class="icon-save"></i>
<?php echo JText::_('JSAVE') ?>
</button>
</div>
<div class="btn-group">
<button type="button" class="btn btn-default"
onclick="Joomla.submitbutton('module.cancel')">
<i class="icon-cancel"></i>
<?php echo JText::_('JCANCEL') ?>
</button>
</div>
</div>
</div>
<!-- End Content -->
</div>
<?php echo $this->hidden_fields; ?>
<input type="hidden" name="task" value="">
<input type="hidden" name="current" value="<?php echo base64_encode($uri->toString()); ?>">
<input type="hidden" name="return" value="<?php echo JFactory::getApplication()->input->get('return', null, 'base64'); ?>">
<?php echo JHtml::_('form.token'); ?>
<?php echo $this->form->getInput('module'); ?>
<?php echo $this->form->getInput('client_id'); ?>
</form>

View File

@ -0,0 +1,14 @@
<?php
/**
* @package Advanced Module Manager
* @version 7.7.1
*
* @author Peter van Westen <info@regularlabs.com>
* @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';

View File

@ -0,0 +1,14 @@
<?php
/**
* @package Advanced Module Manager
* @version 7.7.1
*
* @author Peter van Westen <info@regularlabs.com>
* @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';

View File

@ -0,0 +1,62 @@
<?php
/**
* @package Advanced Module Manager
* @version 7.7.1
*
* @author Peter van Westen <info@regularlabs.com>
* @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);
}
}