29
0
mirror of https://github.com/joomla/joomla-cms.git synced 2024-06-25 23:02:55 +00:00

[4.0] Rename Fields - Subfields plugin to Fields - Subform plugin (#33200)

This commit is contained in:
Tuan Pham Ngoc 2021-04-23 14:44:15 +07:00 committed by GitHub
parent ed9d8e8771
commit 015a957432
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
18 changed files with 58 additions and 63 deletions

View File

@ -1,2 +1,2 @@
INSERT INTO `#__extensions` (`package_id`, `name`, `type`, `element`, `folder`, `client_id`, `enabled`, `access`, `protected`, `manifest_cache`, `params`, `custom_data`, `checked_out`, `checked_out_time`, `ordering`, `state`) VALUES
(0, 'plg_fields_subfields', 'plugin', 'subfields', 'fields', 0, 1, 1, 0, '', '', '', 0, '0000-00-00 00:00:00', 0, 0);
(0, 'plg_fields_subform', 'plugin', 'subform', 'fields', 0, 1, 1, 0, '', '', '', 0, '0000-00-00 00:00:00', 0, 0);

View File

@ -104,7 +104,7 @@ OR (`type` = 'plugin' AND
OR (`folder` = 'editors' AND `element` IN ('codemirror', 'none', 'tinymce'))
OR (`folder` = 'editors-xtd' AND `element` IN ('article', 'contact', 'fields', 'image', 'menu', 'module', 'pagebreak', 'readmore'))
OR (`folder` = 'extension' AND `element` IN ('finder', 'joomla', 'namespacemap'))
OR (`folder` = 'fields' AND `element` IN ('calendar', 'checkboxes', 'color', 'editor', 'imagelist', 'integer', 'list', 'media', 'radio', 'sql', 'subfields', 'text', 'textarea', 'url', 'user', 'usergrouplist'))
OR (`folder` = 'fields' AND `element` IN ('calendar', 'checkboxes', 'color', 'editor', 'imagelist', 'integer', 'list', 'media', 'radio', 'sql', 'subform', 'text', 'textarea', 'url', 'user', 'usergrouplist'))
OR (`folder` = 'filesystem' AND `element` IN ('local'))
OR (`folder` = 'finder' AND `element` IN ('categories', 'contacts', 'content', 'newsfeeds', 'tags'))
OR (`folder` = 'installer' AND `element` IN ('folderinstaller', 'override', 'packageinstaller', 'urlinstaller', 'webinstaller'))

View File

@ -0,0 +1,2 @@
UPDATE `#__extensions` SET `name` = 'plg_fields_subform', `element` = 'subform' WHERE `name` = 'plg_fields_subfields' AND `type` = 'plugin' AND `element` = 'subfields' AND `folder` = 'fields' AND `client_id` = 0;
UPDATE `#__fields` SET `type` = 'subform' WHERE `type` = 'subfields';

View File

@ -1,2 +1,2 @@
INSERT INTO "#__extensions" ("package_id", "name", "type", "element", "folder", "client_id", "enabled", "access", "protected", "manifest_cache", "params", "custom_data", "checked_out", "checked_out_time", "ordering", "state") VALUES
(0, 'plg_fields_subfields', 'plugin', 'subfields', 'fields', 0, 1, 1, 0, '', '', '', 0, '1970-01-01 00:00:00', 0, 0);
(0, 'plg_fields_subform', 'plugin', 'subform', 'fields', 0, 1, 1, 0, '', '', '', 0, '1970-01-01 00:00:00', 0, 0);

View File

@ -106,7 +106,7 @@ OR ("type" = 'plugin' AND
OR ("folder" = 'editors' AND "element" IN ('codemirror', 'none', 'tinymce'))
OR ("folder" = 'editors-xtd' AND "element" IN ('article', 'contact', 'fields', 'image', 'menu', 'module', 'pagebreak', 'readmore'))
OR ("folder" = 'extension' AND "element" IN ('finder', 'joomla', 'namespacemap'))
OR ("folder" = 'fields' AND "element" IN ('calendar', 'checkboxes', 'color', 'editor', 'imagelist', 'integer', 'list', 'media', 'radio', 'sql', 'subfields', 'text', 'textarea', 'url', 'user', 'usergrouplist'))
OR ("folder" = 'fields' AND "element" IN ('calendar', 'checkboxes', 'color', 'editor', 'imagelist', 'integer', 'list', 'media', 'radio', 'sql', 'subform', 'text', 'textarea', 'url', 'user', 'usergrouplist'))
OR ("folder" = 'filesystem' AND "element" IN ('local'))
OR ("folder" = 'finder' AND "element" IN ('categories', 'contacts', 'content', 'newsfeeds', 'tags'))
OR ("folder" = 'installer' AND "element" IN ('folderinstaller', 'override', 'packageinstaller', 'urlinstaller', 'webinstaller'))

View File

@ -0,0 +1,2 @@
UPDATE "#__extensions" SET "name" = 'plg_fields_subform', "element" = 'subform' WHERE "name" = 'plg_fields_subfields' AND "type" = 'plugin' AND "element" = 'subfields' AND "folder" = 'fields' AND "client_id" = 0;
UPDATE "#__fields" SET "type" = 'subform' WHERE "type" = 'subfields';

View File

@ -16,12 +16,12 @@ use Joomla\CMS\HTML\HTMLHelper;
use Joomla\Component\Fields\Administrator\Helper\FieldsHelper;
/**
* Fields Subfieldstype. Represents a list field with the options being all possible
* custom field types, except the 'subfields' custom field type.
* Fields Subfields. Represents a list field with the options being all possible
* custom field types, except the 'subform' custom field type.
*
* @since 4.0.0
*/
class SubfieldstypeField extends ListField
class SubfieldsField extends ListField
{
/**
* The name of this Field type.
@ -30,7 +30,7 @@ class SubfieldstypeField extends ListField
*
* @since 4.0.0
*/
public $type = 'Subfieldstype';
public $type = 'Subfields';
/**
* Configuration option for this field type to could filter the displayed custom field instances
@ -72,17 +72,8 @@ class SubfieldstypeField extends ListField
// Iterate over the custom fields for this context
foreach (static::$customFieldsCache[$this->context] as $customField)
{
// Skip our own subfields type. We won't have subfields in subfields.
if ($customField->type == 'subfields')
{
continue;
}
/**
* Skip the repeatable custom field type too. It is currently still part of the Joomla! core, but it
* shall be removed soon. See issue #23659
*/
if ($customField->type == 'repeatable')
// Skip our own subform type. We won't have subform in subform.
if ($customField->type == 'subform')
{
continue;
}

View File

@ -1,12 +0,0 @@
; Joomla! Project
; (C) 2019 Open Source Matters, Inc. <https://www.joomla.org>
; License GNU General Public License version 2 or later; see LICENSE.txt
; Note : All ini files need to be saved as UTF-8
PLG_FIELDS_SUBFIELDS="Fields - Subform"
PLG_FIELDS_SUBFIELDS_LABEL="Subform (%s)"
PLG_FIELDS_SUBFIELDS_PARAMS_CUSTOMFIELD_LABEL="Field"
PLG_FIELDS_SUBFIELDS_PARAMS_OPTIONS_LABEL="Fields"
PLG_FIELDS_SUBFIELDS_PARAMS_RENDER_VALUES_LABEL="Render Values"
PLG_FIELDS_SUBFIELDS_PARAMS_REPEAT_LABEL="Repeatable"
PLG_FIELDS_SUBFIELDS_XML_DESCRIPTION="This plugin lets you create new fields of type 'subform' which contain one or more fields in any extension where custom fields are supported."

View File

@ -1,7 +0,0 @@
; Joomla! Project
; (C) 2019 Open Source Matters, Inc. <https://www.joomla.org>
; License GNU General Public License version 2 or later; see LICENSE.txt
; Note : All ini files need to be saved as UTF-8
PLG_FIELDS_SUBFIELDS="Fields - Subform"
PLG_FIELDS_SUBFIELDS_XML_DESCRIPTION="This plugin lets you create new fields of type 'subform' which contain one or more fields in any extension where custom fields are supported."

View File

@ -0,0 +1,12 @@
; Joomla! Project
; (C) 2019 Open Source Matters, Inc. <https://www.joomla.org>
; License GNU General Public License version 2 or later; see LICENSE.txt
; Note : All ini files need to be saved as UTF-8
PLG_FIELDS_SUBFORM="Fields - Subform"
PLG_FIELDS_SUBFORM_LABEL="Subform (%s)"
PLG_FIELDS_SUBFORM_PARAMS_CUSTOMFIELD_LABEL="Field"
PLG_FIELDS_SUBFORM_PARAMS_OPTIONS_LABEL="Fields"
PLG_FIELDS_SUBFORM_PARAMS_RENDER_VALUES_LABEL="Render Values"
PLG_FIELDS_SUBFORM_PARAMS_REPEAT_LABEL="Repeatable"
PLG_FIELDS_SUBFORM_XML_DESCRIPTION="This plugin lets you create new fields of type 'subform' which contain one or more fields in any extension where custom fields are supported."

View File

@ -0,0 +1,7 @@
; Joomla! Project
; (C) 2019 Open Source Matters, Inc. <https://www.joomla.org>
; License GNU General Public License version 2 or later; see LICENSE.txt
; Note : All ini files need to be saved as UTF-8
PLG_FIELDS_SUBFORM="Fields - Subform"
PLG_FIELDS_SUBFORM_XML_DESCRIPTION="This plugin lets you create new fields of type 'subform' which contain one or more fields in any extension where custom fields are supported."

View File

@ -282,7 +282,7 @@ INSERT INTO `#__extensions` (`package_id`, `name`, `type`, `element`, `folder`,
(0, 'plg_fields_media', 'plugin', 'media', 'fields', 0, 1, 1, 0, 1, '', '', '', 8, 0),
(0, 'plg_fields_radio', 'plugin', 'radio', 'fields', 0, 1, 1, 0, 1, '', '', '', 9, 0),
(0, 'plg_fields_sql', 'plugin', 'sql', 'fields', 0, 1, 1, 0, 1, '', '', '', 10, 0),
(0, 'plg_fields_subfields', 'plugin', 'subfields', 'fields', 0, 1, 1, 0, 1, '', '', '', 11, 0),
(0, 'plg_fields_subform', 'plugin', 'subform', 'fields', 0, 1, 1, 0, 1, '', '', '', 11, 0),
(0, 'plg_fields_text', 'plugin', 'text', 'fields', 0, 1, 1, 0, 1, '', '', '', 12, 0),
(0, 'plg_fields_textarea', 'plugin', 'textarea', 'fields', 0, 1, 1, 0, 1, '', '', '', 13, 0),
(0, 'plg_fields_url', 'plugin', 'url', 'fields', 0, 1, 1, 0, 1, '', '', '', 14, 0),

View File

@ -288,7 +288,7 @@ INSERT INTO "#__extensions" ("package_id", "name", "type", "element", "folder",
(0, 'plg_fields_media', 'plugin', 'media', 'fields', 0, 1, 1, 0, 1, '', '', '', 8, 0),
(0, 'plg_fields_radio', 'plugin', 'radio', 'fields', 0, 1, 1, 0, 1, '', '', '', 9, 0),
(0, 'plg_fields_sql', 'plugin', 'sql', 'fields', 0, 1, 1, 0, 1, '', '', '', 10, 0),
(0, 'plg_fields_subfields', 'plugin', 'subfields', 'fields', 0, 1, 1, 0, 1, '', '', '', 11, 0),
(0, 'plg_fields_subform', 'plugin', 'subform', 'fields', 0, 1, 1, 0, 1, '', '', '', 11, 0),
(0, 'plg_fields_text', 'plugin', 'text', 'fields', 0, 1, 1, 0, 1, '', '', '', 12, 0),
(0, 'plg_fields_textarea', 'plugin', 'textarea', 'fields', 0, 1, 1, 0, 1, '', '', '', 13, 0),
(0, 'plg_fields_url', 'plugin', 'url', 'fields', 0, 1, 1, 0, 1, '', '', '', 14, 0),

View File

@ -219,7 +219,7 @@ class ExtensionHelper
array('plugin', 'media', 'fields', 0),
array('plugin', 'radio', 'fields', 0),
array('plugin', 'sql', 'fields', 0),
array('plugin', 'subfields', 'fields', 0),
array('plugin', 'subform', 'fields', 0),
array('plugin', 'text', 'fields', 0),
array('plugin', 'textarea', 'fields', 0),
array('plugin', 'url', 'fields', 0),

View File

@ -11,7 +11,7 @@
<field
name="repeat"
type="radio"
label="PLG_FIELDS_SUBFIELDS_PARAMS_REPEAT_LABEL"
label="PLG_FIELDS_SUBFORM_PARAMS_REPEAT_LABEL"
layout="joomla.form.field.radio.switcher"
default="1"
>
@ -22,7 +22,7 @@
<field
name="options"
type="subform"
label="PLG_FIELDS_SUBFIELDS_PARAMS_OPTIONS_LABEL"
label="PLG_FIELDS_SUBFORM_PARAMS_OPTIONS_LABEL"
icon="list"
layout="joomla.form.field.subform.repeatable-table"
min="1"
@ -33,8 +33,8 @@
<field
context=""
name="customfield"
type="subfieldstype"
label="PLG_FIELDS_SUBFIELDS_PARAMS_CUSTOMFIELD_LABEL"
type="subfields"
label="PLG_FIELDS_SUBFORM_PARAMS_CUSTOMFIELD_LABEL"
default=""
required="true"
/>
@ -42,7 +42,7 @@
<field
name="render_values"
type="radio"
label="PLG_FIELDS_SUBFIELDS_PARAMS_RENDER_VALUES_LABEL"
label="PLG_FIELDS_SUBFORM_PARAMS_RENDER_VALUES_LABEL"
layout="joomla.form.field.radio.switcher"
default="1"
>

View File

@ -15,11 +15,11 @@ use Joomla\Component\Fields\Administrator\Helper\FieldsHelper;
use Joomla\Component\Fields\Administrator\Plugin\FieldsPlugin;
/**
* Fields subfields Plugin
* Fields subform Plugin
*
* @since 4.0.0
*/
class PlgFieldsSubfields extends FieldsPlugin
class PlgFieldsSubform extends FieldsPlugin
{
/**
* Two-dimensional array to hold to do a fast in-memory caching of rendered
@ -52,7 +52,7 @@ class PlgFieldsSubfields extends FieldsPlugin
*/
public function onContentPrepareForm(Form $form, $data)
{
// Get the path to our own form definition (basically ./params/subfields.xml)
// Get the path to our own form definition (basically ./params/subform.xml)
$path = $this->getFormPath($form, $data);
if ($path === null)
@ -71,11 +71,11 @@ class PlgFieldsSubfields extends FieldsPlugin
$xmlxpath = new DOMXPath($xml);
/**
* Get all fields of type "subfieldstype" in our own XML
* Get all fields of type "subfields" in our own XML
*
* @var $valuefields \DOMNodeList
*/
$valuefields = $xmlxpath->evaluate('//field[@type="subfieldstype"]');
$valuefields = $xmlxpath->evaluate('//field[@type="subfields"]');
// If we haven't found it, something is wrong
if (!$valuefields || $valuefields->length != 1)
@ -166,7 +166,7 @@ class PlgFieldsSubfields extends FieldsPlugin
* Each array entry is another array representing a row, containing all of the sub fields that
* are valid for this row and their raw and rendered values.
*/
$subfields_rows = array();
$subform_rows = array();
// Create an array with entries being subfields forms, and if not repeatable, containing only one element.
$rows = $field->value;
@ -234,11 +234,11 @@ class PlgFieldsSubfields extends FieldsPlugin
}
// Store all the sub fields of this row
$subfields_rows[] = $row_subfields;
$subform_rows[] = $row_subfields;
}
// Store all the rows and their corresponding sub fields in $field->subfields_rows
$field->subfields_rows = $subfields_rows;
// Store all the rows and their corresponding sub fields in $field->subform_rows
$field->subform_rows = $subform_rows;
// Call our parent to combine all those together for the final $field->value
return parent::onCustomFieldsPrepareField($context, $item, $field);

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<extension type="plugin" group="fields" method="upgrade">
<name>plg_fields_subfields</name>
<name>plg_fields_subform</name>
<author>Joomla! Project</author>
<creationDate>June 2017</creationDate>
<copyright>(C) 2019 Open Source Matters, Inc.</copyright>
@ -8,12 +8,12 @@
<authorEmail>admin@joomla.org</authorEmail>
<authorUrl>www.joomla.org</authorUrl>
<version>4.0.0</version>
<description>PLG_FIELDS_SUBFIELDS_XML_DESCRIPTION</description>
<description>PLG_FIELDS_SUBFORM_XML_DESCRIPTION</description>
<files>
<filename plugin="subfields">subfields.php</filename>
<filename plugin="subform">subform.php</filename>
</files>
<languages>
<language tag="en-GB">en-GB.plg_fields_subfields.ini</language>
<language tag="en-GB">en-GB.plg_fields_subfields.sys.ini</language>
<language tag="en-GB">en-GB.plg_fields_subform.ini</language>
<language tag="en-GB">en-GB.plg_fields_subform.sys.ini</language>
</languages>
</extension>

View File

@ -11,7 +11,7 @@ use Joomla\Component\Fields\Administrator\Helper\FieldsHelper;
defined('_JEXEC') or die;
if (!$context || empty($field->subfields_rows))
if (!$context || empty($field->subform_rows))
{
return;
}
@ -19,13 +19,13 @@ if (!$context || empty($field->subfields_rows))
$result = '';
// Iterate over each row that we have
foreach ($field->subfields_rows as $subfields_row)
foreach ($field->subform_rows as $subform_row)
{
// Placeholder array to generate this rows output
$row_output = array();
// Iterate over each sub field inside of that row
foreach ($subfields_row as $subfield)
foreach ($subform_row as $subfield)
{
$class = trim($subfield->params->get('render_class', ''));
$layout = trim($subfield->params->get('layout', 'render'));