JoomlaPolska / jezyk-J4

Język polski dla Joomla 4
GNU General Public License v2.0
3 stars 5 forks source link

[5.1] Header list field #465

Closed joomlapl-bot closed 7 months ago

joomlapl-bot commented 8 months ago

PR w związku ze zmianą oryginału https://github.com/joomla/joomla-cms/pull/42736 Poniżej zmiany w oryginale:

Click to expand the diff! ```diff diff --git a/administrator/language/en-GB/plg_fields_list.ini b/administrator/language/en-GB/plg_fields_list.ini index e71aa23ad5f6..4208cf647e8e 100644 --- a/administrator/language/en-GB/plg_fields_list.ini +++ b/administrator/language/en-GB/plg_fields_list.ini @@ -7,6 +7,8 @@ PLG_FIELDS_LIST="Fields - List" PLG_FIELDS_LIST_LABEL="List (%s)" ; The following string is deprecated and will be removed with 6.0 PLG_FIELDS_LIST_PARAMS_FORM_LAYOUT_FANCY_SELECT="Enhanced select" +PLG_FIELDS_LIST_PARAMS_HEADER_DESC="Add a string with no value at the top of the dropdown list eg ' - Select Article - '." +PLG_FIELDS_LIST_PARAMS_HEADER_LABEL="Header" PLG_FIELDS_LIST_PARAMS_MULTIPLE_LABEL="Multiple" PLG_FIELDS_LIST_PARAMS_OPTIONS_LABEL="List Values" PLG_FIELDS_LIST_PARAMS_OPTIONS_NAME_LABEL="Text" diff --git a/libraries/src/Form/Field/ListField.php b/libraries/src/Form/Field/ListField.php index d437c6f6d34a..eecab6e5fce7 100644 --- a/libraries/src/Form/Field/ListField.php +++ b/libraries/src/Form/Field/ListField.php @@ -14,6 +14,7 @@ use Joomla\CMS\Form\FormField; use Joomla\CMS\Form\FormHelper; use Joomla\CMS\Helper\ModuleHelper; +use Joomla\CMS\HTML\HTMLHelper; use Joomla\CMS\Language\Associations; use Joomla\CMS\Language\Multilanguage; use Joomla\CMS\Language\Text; @@ -48,6 +49,14 @@ class ListField extends FormField */ protected $layout = 'joomla.form.field.list'; + /** + * The header. + * + * @var mixed + * @since __DEPLOY_VERSION__ + */ + protected $header; + /** * Method to get the field input markup for a generic list. * Use the multiple attribute to enable multiselect. @@ -74,8 +83,14 @@ protected function getInput() */ protected function getOptions() { + $header = $this->header; $fieldname = preg_replace('/[^a-zA-Z0-9_\-]/', '_', $this->fieldname); $options = []; + // Add header. + if (!empty($header)) { + $header_title = Text::_($header); + $options[] = HTMLHelper::_('select.option', '', $header_title); + } foreach ($this->element->xpath('option') as $option) { // Filter requirements @@ -232,4 +247,30 @@ public function __get($name) return parent::__get($name); } + + /** + * Method to attach a Form object to the field. + * + * @param \SimpleXMLElement $element The SimpleXMLElement object representing the `` 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) + { + $return = parent::setup($element, $value, $group); + + if ($return) { + // Check if it's using the old way + $this->header = (string) $this->element['header'] ?: false; + } + + return $return; + } } diff --git a/libraries/src/Form/Field/SqlField.php b/libraries/src/Form/Field/SqlField.php index caf156ee5795..cb1bd4aeaace 100644 --- a/libraries/src/Form/Field/SqlField.php +++ b/libraries/src/Form/Field/SqlField.php @@ -287,12 +287,6 @@ protected function getOptions() } } - // Add header. - if (!empty($header)) { - $header_title = Text::_($header); - $options[] = HTMLHelper::_('select.option', '', $header_title); - } - // Build the field options. if (!empty($items)) { foreach ($items as $item) { diff --git a/plugins/fields/list/list.xml b/plugins/fields/list/list.xml index f50c406e455f..9220b5a1a5e7 100644 --- a/plugins/fields/list/list.xml +++ b/plugins/fields/list/list.xml @@ -23,6 +23,14 @@
+ +
+ +
zwiastunsw commented 7 months ago

rozwiązane 5.0.3