From cf4b281d08a41942cfc770394d0fc5901f2b43a7 Mon Sep 17 00:00:00 2001 From: Robert Deutz Date: Fri, 11 Oct 2024 14:18:32 +0200 Subject: [PATCH 1/3] implementation --- administrator/components/com_fields/forms/field.xml | 12 ++++++++++++ .../com_fields/src/Helper/FieldsHelper.php | 12 ++++++++++++ administrator/language/en-GB/com_fields.ini | 2 ++ 3 files changed, 26 insertions(+) diff --git a/administrator/components/com_fields/forms/field.xml b/administrator/components/com_fields/forms/field.xml index 53fc2fb858a5a..7464f8cc4293f 100644 --- a/administrator/components/com_fields/forms/field.xml +++ b/administrator/components/com_fields/forms/field.xml @@ -335,6 +335,18 @@ + + + +
get(DispatcherInterface::class); PluginHelper::importPlugin('fields', null, true, $dispatcher); + PluginHelper::importPlugin('content', null, true, $dispatcher); $fieldIds = array_map( function ($f) { @@ -245,6 +248,15 @@ function ($f) { $dispatcher->dispatch('onCustomFieldsAfterPrepareField', $eventAfter); $value = $eventAfter->getValue(); + if ($field->params->get('prepare_content') === 1) { + $subject = new stdClass; + $subject->text = $value; + + $dispatcher->dispatch('onContentPrepare', new ContentPrepareEvent('onContentPrepare', ['com_content.fields', $subject])); + + $value = $subject->text; + } + // Assign the value $field->value = $value; } diff --git a/administrator/language/en-GB/com_fields.ini b/administrator/language/en-GB/com_fields.ini index 1799bf0d9d165..d9161e8bc1b9f 100644 --- a/administrator/language/en-GB/com_fields.ini +++ b/administrator/language/en-GB/com_fields.ini @@ -53,6 +53,8 @@ COM_FIELDS_FIELD_ONLY_USE_IN_SUBFORM_LABEL="Only Use In Subform" COM_FIELDS_FIELD_PLACEHOLDER_DESC="Placeholder text which will appear inside the field as a hint to the user for the required input." COM_FIELDS_FIELD_PLACEHOLDER_LABEL="Placeholder" COM_FIELDS_FIELD_PREFIX_LABEL="Prefix" +COM_FIELDS_FIELD_PREPARE_CONTENT_DESC="Optionally prepare the content with Joomla Content Plugins." +COM_FIELDS_FIELD_PREPARE_CONTENT_LABEL="Prepare Content" COM_FIELDS_FIELD_RENDER_CLASS_DESC="The class of the field container in the output." COM_FIELDS_FIELD_RENDER_CLASS_LABEL="Display Class" COM_FIELDS_FIELD_RENDEROPTIONS_HEADING="Display Options" From 70665a92e16a19143e3ee525a335169577ed484a Mon Sep 17 00:00:00 2001 From: Richard Fath Date: Sun, 13 Oct 2024 14:29:43 +0200 Subject: [PATCH 2/3] Fix PHPCS --- .../components/com_fields/src/Helper/FieldsHelper.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/administrator/components/com_fields/src/Helper/FieldsHelper.php b/administrator/components/com_fields/src/Helper/FieldsHelper.php index 3222e80aea8a7..9533c288268a2 100644 --- a/administrator/components/com_fields/src/Helper/FieldsHelper.php +++ b/administrator/components/com_fields/src/Helper/FieldsHelper.php @@ -27,7 +27,6 @@ use Joomla\Component\Fields\Administrator\Model\FieldsModel; use Joomla\Database\ParameterType; use Joomla\Event\DispatcherInterface; -use stdClass; // phpcs:disable PSR1.Files.SideEffects \defined('_JEXEC') or die; @@ -249,7 +248,7 @@ function ($f) { $value = $eventAfter->getValue(); if ($field->params->get('prepare_content') === 1) { - $subject = new stdClass; + $subject = new \stdClass; $subject->text = $value; $dispatcher->dispatch('onContentPrepare', new ContentPrepareEvent('onContentPrepare', ['com_content.fields', $subject])); From 00fdcef154d69d97721f9ff874ed278e175744af Mon Sep 17 00:00:00 2001 From: Richard Fath Date: Sun, 13 Oct 2024 14:36:55 +0200 Subject: [PATCH 3/3] Apply suggestions from code review Co-authored-by: Brian Teeman --- administrator/components/com_fields/forms/field.xml | 2 +- administrator/components/com_fields/src/Helper/FieldsHelper.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/administrator/components/com_fields/forms/field.xml b/administrator/components/com_fields/forms/field.xml index ed37190d5033b..c7c53f9d2d20d 100644 --- a/administrator/components/com_fields/forms/field.xml +++ b/administrator/components/com_fields/forms/field.xml @@ -341,9 +341,9 @@ diff --git a/administrator/components/com_fields/src/Helper/FieldsHelper.php b/administrator/components/com_fields/src/Helper/FieldsHelper.php index 9533c288268a2..8ee0ad3a0133e 100644 --- a/administrator/components/com_fields/src/Helper/FieldsHelper.php +++ b/administrator/components/com_fields/src/Helper/FieldsHelper.php @@ -248,7 +248,7 @@ function ($f) { $value = $eventAfter->getValue(); if ($field->params->get('prepare_content') === 1) { - $subject = new \stdClass; + $subject = new \stdClass(); $subject->text = $value; $dispatcher->dispatch('onContentPrepare', new ContentPrepareEvent('onContentPrepare', ['com_content.fields', $subject]));