Skip to content
Merged
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
2 changes: 2 additions & 0 deletions administrator/components/com_modules/forms/filter_modules.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
name="position"
type="ModulesPosition"
label="COM_MODULES_OPTION_SELECT_POSITION"
client="site"
onchange="this.form.submit();"
>
<option value="">COM_MODULES_OPTION_SELECT_POSITION</option>
Expand All @@ -41,6 +42,7 @@
name="module"
type="ModulesModule"
label="COM_MODULES_OPTION_SELECT_MODULE"
client="site"
onchange="this.form.submit();"
>
<option value="">COM_MODULES_OPTION_SELECT_MODULE</option>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
name="position"
type="ModulesPosition"
label="COM_MODULES_FIELD_POSITION_LABEL"
client="administrator"
onchange="this.form.submit();"
>
<option value="">COM_MODULES_OPTION_SELECT_POSITION</option>
Expand All @@ -43,6 +44,7 @@
name="module"
type="ModulesModule"
label="COM_MODULES_OPTION_SELECT_MODULE"
client="administrator"
onchange="this.form.submit();"
>
<option value="">COM_MODULES_OPTION_SELECT_MODULE</option>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

defined('JPATH_BASE') or die;

use Joomla\CMS\Factory;
use Joomla\CMS\Form\Field\ListField;
use Joomla\Component\Modules\Administrator\Helper\ModulesHelper;

Expand All @@ -30,6 +29,83 @@ class ModulesModuleField extends ListField
*/
protected $type = 'ModulesModule';

/**
* Client name.
*
* @var string
* @since 4.0.0
*/
protected $client;

/**
* Method to get certain otherwise inaccessible properties from the form field object.
*
* @param string $name The property name for which to get the value.
*
* @return mixed The property value or null.
*
* @since 4.0.0
*/
public function __get($name)
{
switch ($name)
{
case 'client':
return $this->$name;
}

return parent::__get($name);
}

/**
* Method to set certain otherwise inaccessible properties of the form field object.
*
* @param string $name The property name for which to set the value.
* @param mixed $value The value of the property.
*
* @return void
*
* @since 4.0.0
*/
public function __set($name, $value)
{
switch ($name)
{
case 'client':
$this->$name = (string) $value;
break;

default:
parent::__set($name, $value);
}
}

/**
* Method to attach a Form object to the field.
*
* @param \SimpleXMLElement $element The SimpleXMLElement object representing the `<field>` tag for the form field object.
* @param mixed $value The form field value to validate.
* @param string $group The field name group control value. This acts as an array container for the field.
* For example if the field has name="foo" and the group value is set to "bar" then the
* full field name would end up being "bar[foo]".
*
* @return boolean True on success.
*
* @see FormField::setup()
* @since 4.0.0
*/
public function setup(\SimpleXMLElement $element, $value, $group = null)
{
$result = parent::setup($element, $value, $group);

if ($result === true)
{
$this->client = $this->element['client'] ? (string) $this->element['client'] : 'site';
}

return $result;
}

/**
* Method to get the field options.
*
Expand All @@ -39,7 +115,8 @@ class ModulesModuleField extends ListField
*/
public function getOptions()
{
$options = ModulesHelper::getModules(Factory::getApplication()->getUserState('com_modules.modules.client_id', 0));
$clientId = $this->client === 'administrator' ? 1 : 0;
$options = ModulesHelper::getModules($clientId);

return array_merge(parent::getOptions(), $options);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

defined('JPATH_BASE') or die;

use Joomla\CMS\Factory;
use Joomla\CMS\Form\Field\ListField;
use Joomla\Component\Modules\Administrator\Helper\ModulesHelper;

Expand All @@ -30,6 +29,83 @@ class ModulesPositionField extends ListField
*/
protected $type = 'ModulesPosition';

/**
* Client name.
*
* @var string
* @since 4.0.0
*/
protected $client;

/**
* Method to get certain otherwise inaccessible properties from the form field object.
*
* @param string $name The property name for which to get the value.
*
* @return mixed The property value or null.
*
* @since 4.0.0
*/
public function __get($name)
{
switch ($name)
{
case 'client':
return $this->$name;
}

return parent::__get($name);
}

/**
* Method to set certain otherwise inaccessible properties of the form field object.
*
* @param string $name The property name for which to set the value.
* @param mixed $value The value of the property.
*
* @return void
*
* @since 4.0.0
*/
public function __set($name, $value)
{
switch ($name)
{
case 'client':
$this->$name = (string) $value;
break;

default:
parent::__set($name, $value);
}
}

/**
* Method to attach a Form object to the field.
*
* @param \SimpleXMLElement $element The SimpleXMLElement object representing the `<field>` tag for the form field object.
* @param mixed $value The form field value to validate.
* @param string $group The field name group control value. This acts as an array container for the field.
* For example if the field has name="foo" and the group value is set to "bar" then the
* full field name would end up being "bar[foo]".
*
* @return boolean True on success.
*
* @see FormField::setup()
* @since 4.0.0
*/
public function setup(\SimpleXMLElement $element, $value, $group = null)
{
$result = parent::setup($element, $value, $group);

if ($result === true)
{
$this->client = $this->element['client'] ? (string) $this->element['client'] : 'site';
}

return $result;
}

/**
* Method to get the field options.
*
Expand All @@ -39,7 +115,8 @@ class ModulesPositionField extends ListField
*/
public function getOptions()
{
$options = ModulesHelper::getPositions(Factory::getApplication()->getUserState('com_modules.modules.client_id', 0));
$clientId = $this->client === 'administrator' ? 1 : 0;
$options = ModulesHelper::getPositions($clientId);

return array_merge(parent::getOptions(), $options);
}
Expand Down
2 changes: 2 additions & 0 deletions components/com_modules/forms/filter_modules.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
name="position"
type="modulesposition"
label="COM_MODULES_FIELD_POSITION_LABEL"
client="site"
onchange="this.form.submit();"
>
<option value="">COM_MODULES_OPTION_SELECT_POSITION</option>
Expand All @@ -24,6 +25,7 @@
name="module"
type="ModulesModule"
label="COM_MODULES_OPTION_SELECT_MODULE"
client="site"
onchange="this.form.submit();"
>
<option value="">COM_MODULES_OPTION_SELECT_MODULE</option>
Expand Down