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
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,83 @@ class ModulesPositioneditField extends FormField
*/
protected $layout = 'joomla.form.field.modulespositionedit';

/**
* Client name.
*
* @var string
* @since __DEPLOY_VERSION__
*/
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 __DEPLOY_VERSION__
*/
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 __DEPLOY_VERSION__
*/
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 __DEPLOY_VERSION__
*/
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 input markup.
*
Expand All @@ -49,7 +126,7 @@ protected function getInput()
{
$data = $this->getLayoutData();

$clientId = Factory::getApplication()->getUserState('com_modules.modules.client_id', 0);
$clientId = $this->client === 'administrator' ? 1 : 0;
$positions = HTMLHelper::_('modules.positions', $clientId, 1, $this->value);

$data['client'] = $clientId;
Expand Down
2 changes: 0 additions & 2 deletions administrator/components/com_modules/Model/ModuleModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -572,8 +572,6 @@ public function getForm($data = array(), $loadData = true)
return false;
}

$form->setFieldAttribute('position', 'client', $this->getState('item.client_id') == 0 ? 'site' : 'administrator');

$user = Factory::getUser();

/**
Expand Down
1 change: 1 addition & 0 deletions administrator/components/com_modules/forms/module.xml
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@
label="COM_MODULES_FIELD_POSITION_LABEL"
default=""
maxlength="50"
client="site"
/>

<field
Expand Down
1 change: 1 addition & 0 deletions administrator/components/com_modules/forms/moduleadmin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@
label="COM_MODULES_FIELD_POSITION_LABEL"
default=""
maxlength="50"
client="administrator"
/>

<field
Expand Down
2 changes: 0 additions & 2 deletions components/com_config/Model/ModulesModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,6 @@ public function getForm($data = array(), $loadData = true)
return false;
}

$form->setFieldAttribute('position', 'client', 'site');

return $form;
}

Expand Down
1 change: 1 addition & 0 deletions components/com_config/forms/modules.xml
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@
addfieldprefix="Joomla\Component\Modules\Administrator\Field"
default=""
maxlength="50"
client="site"
/>

<field
Expand Down