[ 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_fields 6 * 7 * @copyright (C) 2017 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\Fields\Administrator\Plugin; 12 13 use Joomla\CMS\Form\Form; 14 use Joomla\CMS\Language\Text; 15 16 // phpcs:disable PSR1.Files.SideEffects 17 \defined('_JEXEC') or die; 18 // phpcs:enable PSR1.Files.SideEffects 19 20 /** 21 * Base plugin for all list based plugins 22 * 23 * @since 3.7.0 24 */ 25 class FieldsListPlugin extends FieldsPlugin 26 { 27 /** 28 * Transforms the field into a DOM XML element and appends it as a child on the given parent. 29 * 30 * @param \stdClass $field The field. 31 * @param \DOMElement $parent The field node parent. 32 * @param Form $form The form. 33 * 34 * @return \DOMElement 35 * 36 * @since 3.7.0 37 */ 38 public function onCustomFieldsPrepareDom($field, \DOMElement $parent, Form $form) 39 { 40 $fieldNode = parent::onCustomFieldsPrepareDom($field, $parent, $form); 41 42 if (!$fieldNode) { 43 return $fieldNode; 44 } 45 46 $fieldNode->setAttribute('validate', 'options'); 47 48 foreach ($this->getOptionsFromField($field) as $value => $name) { 49 $option = new \DOMElement('option', htmlspecialchars($value, ENT_COMPAT, 'UTF-8')); 50 $option->textContent = htmlspecialchars(Text::_($name), ENT_COMPAT, 'UTF-8'); 51 52 $element = $fieldNode->appendChild($option); 53 $element->setAttribute('value', $value); 54 } 55 56 return $fieldNode; 57 } 58 59 /** 60 * Returns an array of key values to put in a list from the given field. 61 * 62 * @param \stdClass $field The field. 63 * 64 * @return array 65 * 66 * @since 3.7.0 67 */ 68 public function getOptionsFromField($field) 69 { 70 $data = array(); 71 72 // Fetch the options from the plugin 73 $params = clone $this->params; 74 $params->merge($field->fieldparams); 75 76 foreach ($params->get('options', array()) as $option) { 77 $op = (object) $option; 78 $data[$op->value] = $op->name; 79 } 80 81 return $data; 82 } 83 }
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 |