[ Index ] |
PHP Cross Reference of Joomla 4.2.2 documentation |
[Summary view] [Print] [Text view]
1 <?php 2 3 /** 4 * @package Joomla.Administrator 5 * @subpackage com_modules 6 * 7 * @copyright (C) 2018 Open Source Matters, Inc. <https://www.joomla.org> 8 * @license GNU General Public License version 2 or later; see LICENSE.txt 9 */ 10 11 namespace Joomla\Component\Modules\Administrator\Field; 12 13 use Joomla\CMS\Form\FormField; 14 use Joomla\CMS\HTML\HTMLHelper; 15 16 // phpcs:disable PSR1.Files.SideEffects 17 \defined('_JEXEC') or die; 18 // phpcs:enable PSR1.Files.SideEffects 19 20 /** 21 * Edit Modules Position field. 22 * 23 * @since 4.0.0 24 */ 25 class ModulesPositioneditField extends FormField 26 { 27 /** 28 * The form field type. 29 * 30 * @var string 31 * @since 4.0.0 32 */ 33 protected $type = 'ModulesPositionedit'; 34 35 /** 36 * Name of the layout being used to render the field 37 * 38 * @var string 39 * @since 4.0.0 40 */ 41 protected $layout = 'joomla.form.field.modulespositionedit'; 42 43 /** 44 * Client name. 45 * 46 * @var string 47 * @since 4.0.0 48 */ 49 protected $client; 50 51 /** 52 * Method to get certain otherwise inaccessible properties from the form field object. 53 * 54 * @param string $name The property name for which to get the value. 55 * 56 * @return mixed The property value or null. 57 * 58 * @since 4.0.0 59 */ 60 public function __get($name) 61 { 62 switch ($name) { 63 case 'client': 64 return $this->$name; 65 } 66 67 return parent::__get($name); 68 } 69 70 /** 71 * Method to set certain otherwise inaccessible properties of the form field object. 72 * 73 * @param string $name The property name for which to set the value. 74 * @param mixed $value The value of the property. 75 * 76 * @return void 77 * 78 * @since 4.0.0 79 */ 80 public function __set($name, $value) 81 { 82 switch ($name) { 83 case 'client': 84 $this->$name = (string) $value; 85 break; 86 87 default: 88 parent::__set($name, $value); 89 } 90 } 91 92 /** 93 * Method to attach a Form object to the field. 94 * 95 * @param \SimpleXMLElement $element The SimpleXMLElement object representing the `<field>` tag for the form field object. 96 * @param mixed $value The form field value to validate. 97 * @param string $group The field name group control value. This acts as an array container for the field. 98 * For example if the field has name="foo" and the group value is set to "bar" then the 99 * full field name would end up being "bar[foo]". 100 * 101 * @return boolean True on success. 102 * 103 * @see FormField::setup() 104 * @since 4.0.0 105 */ 106 public function setup(\SimpleXMLElement $element, $value, $group = null) 107 { 108 $result = parent::setup($element, $value, $group); 109 110 if ($result === true) { 111 $this->client = $this->element['client'] ? (string) $this->element['client'] : 'site'; 112 } 113 114 return $result; 115 } 116 117 /** 118 * Method to get the field input markup. 119 * 120 * @return string The field input markup. 121 * 122 * @since 4.0.0 123 */ 124 protected function getInput() 125 { 126 $data = $this->getLayoutData(); 127 128 $clientId = $this->client === 'administrator' ? 1 : 0; 129 $positions = HTMLHelper::_('modules.positions', $clientId, 1, $this->value); 130 131 $data['client'] = $clientId; 132 $data['positions'] = $positions; 133 134 $renderer = $this->getRenderer($this->layout); 135 $renderer->setComponent('com_modules'); 136 $renderer->setClient(1); 137 138 return $renderer->render($data); 139 } 140 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Wed Sep 7 05:41:13 2022 | Chilli.vc Blog - For Webmaster,Blog-Writer,System Admin and Domainer |