Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 23 additions & 1 deletion administrator/components/com_menus/presets/joomla.xml
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,29 @@
element="com_modules"
link="index.php?option=com_modules"
class="class:module"
/>
>
<menuitem
title="MOD_MENU_EXTENSIONS_MODULE_MANAGER"
type="component"
element="com_modules"
link="index.php?option=com_modules"
class="class:module"
/>
<menuitem
title="MOD_MENU_FIELDS"
type="component"
element="com_fields"
link="index.php?option=com_fields&amp;context=com_modules.module"
class="class:fields"
/>
<menuitem
title="MOD_MENU_FIELDS_GROUP"
type="component"
element="com_fields"
link="index.php?option=com_fields&amp;view=groups&amp;context=com_modules.module"
class="class:category"
/>
</menuitem>
<menuitem
title="MOD_MENU_EXTENSIONS_PLUGIN_MANAGER"
type="component"
Expand Down
17 changes: 17 additions & 0 deletions administrator/components/com_modules/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,23 @@
</field>
</fieldset>

<fieldset
name="integration"
label="JGLOBAL_INTEGRATION_LABEL"
>
<field
name="custom_fields_enable"
type="radio"
label="JGLOBAL_CUSTOM_FIELDS_ENABLE_LABEL"
description="JGLOBAL_CUSTOM_FIELDS_ENABLE_DESC"
class="btn-group btn-group-yesno"
default="1"
>
<option value="1">JYES</option>
<option value="0">JNO</option>
</field>
</fieldset>

<fieldset
name="permissions"
label="JCONFIG_PERMISSIONS_LABEL"
Expand Down
22 changes: 21 additions & 1 deletion administrator/components/com_modules/helpers/modules.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

defined('_JEXEC') or die;

use Joomla\CMS\Component\ComponentHelper;
use Joomla\CMS\Factory;
use Joomla\Utilities\ArrayHelper;

/**
Expand All @@ -27,7 +29,25 @@ abstract class ModulesHelper
*/
public static function addSubmenu($vName)
{
// Not used in this component.
JHtmlSidebar::addEntry(
JText::_('COM_MODULES_MODULES'),
'index.php?option=com_modules',
$vName == 'modules'
);

if (ComponentHelper::isEnabled('com_fields') && ComponentHelper::getParams('com_modules')->get('custom_fields_enable', '1'))
{
JHtmlSidebar::addEntry(
JText::_('JGLOBAL_FIELDS'),
'index.php?option=com_fields&context=com_modules.module',
$vName == 'fields.fields'
);
JHtmlSidebar::addEntry(
JText::_('JGLOBAL_FIELD_GROUPS'),
'index.php?option=com_fields&view=groups&context=com_modules.module',
$vName == 'fields.groups'
);
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<form>
<fields name="params" label="COM_FIELDS_FIELD_BASIC_LABEL">
<fieldset name="basic">
<field
name="display"
type="hidden"
default="2"
/>
</fieldset>
</fields>
</form>
4 changes: 2 additions & 2 deletions administrator/components/com_modules/models/module.php
Original file line number Diff line number Diff line change
Expand Up @@ -951,7 +951,7 @@ public function save($data)
}

// Trigger the before save event.
$result = $dispatcher->trigger($this->event_before_save, array($context, &$table, $isNew));
$result = $dispatcher->trigger($this->event_before_save, array($context, &$table, $isNew, $data));

if (in_array(false, $result, true))
{
Expand Down Expand Up @@ -1053,7 +1053,7 @@ public function save($data)
}

// Trigger the after save event.
$dispatcher->trigger($this->event_after_save, array($context, &$table, $isNew));
$dispatcher->trigger($this->event_after_save, array($context, &$table, $isNew, $data));

// Compute the extension id of this module in case the controller wants it.
$query->clear()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
defined('_JEXEC') or die;

$fieldSets = $this->form->getFieldsets('params');
$fieldSets = array_merge($fieldSets, $this->form->getFieldsets('com_fields'));

echo JHtml::_('bootstrap.startAccordion', 'collapseTypes');
$i = 0;
Expand Down
22 changes: 22 additions & 0 deletions libraries/src/Helper/ModuleHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -644,4 +644,26 @@ public static function isAdminMultilang()

return $enabled;
}

/**
* Returns a list of fields for the module with the given id.
*
* @return \stdClass[] An array of fields
*
* @since __DEPLOY_VERSION__
*/
public static function getFields($moduleId)
{
foreach (self::getModuleList() as $module)
{
if ($module->id != $moduleId)
{
continue;
}

return \FieldsHelper::getFields('com_modules.module', $module, true);
}

return array();
}
}
35 changes: 32 additions & 3 deletions plugins/system/fields/fields.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,29 @@ public function onUserAfterSave($userData, $isNew, $success, $msg)
return true;
}

/**
* The save event.
*
* @param string $context The context
* @param JTable $item The extension
* @param boolean $isNew Is new item
* @param array $data The validated data
*
* @return boolean
*
* @since __DEPLOY_VERSION__
*/
public function onExtensionAfterSave ($context, $item, $isNew, $data = array())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's add an extra check here to only do this for modules? For example when you save a plugin at the moment this is going to trigger this

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

{
// Only support modules
if ($context != 'com_modules.module')
{
return true;
}

return $this->onContentAfterSave($context, $item, $isNew, $data);
}

/**
* The delete event.
*
Expand Down Expand Up @@ -195,6 +218,12 @@ public function onContentPrepareForm(JForm $form, $data)
{
$context = $form->getName();

// Front end editing of modules is done through com_config
if ($context == 'com_config.modules' && JFactory::getApplication()->isClient('site'))
{
$context = 'com_modules.module';
}

// When a category is edited, the context is com_categories.categorycom_content
if (strpos($context, 'com_categories.category') === 0)
{
Expand Down Expand Up @@ -346,9 +375,9 @@ private function display($context, $item, $params, $displayType)
$context,
'fields.render',
array(
'item' => $item,
'context' => $context,
'fields' => $fields
'item' => $item,
'context' => $context,
'fields' => $fields
)
);
}
Expand Down