Skip to content

Commit 8f94056

Browse files
committed
removed the custom field logic from this branch
1 parent 30689d6 commit 8f94056

File tree

3 files changed

+0
-136
lines changed

3 files changed

+0
-136
lines changed

libraries/src/Opengraph/OpengraphServiceInterface.php

Lines changed: 0 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -14,43 +14,6 @@
1414
// phpcs:enable PSR1.Files.SideEffects
1515

1616

17-
18-
/**
19-
* Enumerates the logical OpenGraph groups that a custom field-type can
20-
* register itself under.
21-
*
22-
* Third-party field-type plugins should return one of these cases from
23-
* {@see MappableFieldInterface::getOpengraphGroup()} so the System – OpenGraph
24-
* plugin knows how to categorise the field inside its mapping drop-down.
25-
*
26-
* @since __DEPLOY_VERSION__
27-
*/
28-
enum OpengraphGroup: string
29-
{
30-
/** Standard textual content (e.g. single-line, multi-line). */
31-
case TEXT = 'text-fields';
32-
33-
/** Image or media file (intro/full images, custom media fields, …). */
34-
case IMAGE = 'image-fields';
35-
36-
/** Alternate-text associated with an image (accessibility / SEO). */
37-
case IMAGE_ALT = 'image-alt-fields';
38-
39-
// TODO : implement these cases in the future, if needed
40-
41-
// /** Meta-information such as description or keywords. */
42-
// case META = 'meta-fields';
43-
44-
// /** Locale or language codes (e.g. `en-US`). */
45-
// case LOCALE = 'locale-fields';
46-
47-
// /** Author-related data (creator, modifier, alias, …). */
48-
// case AUTHOR = 'author-fields';
49-
50-
// /** Date-time values (created, modified, publish-up/down, …). */
51-
// case DATE = 'date-fields';
52-
}
53-
5417
/**
5518
* The Opengraph service.
5619
*
@@ -68,18 +31,3 @@ interface OpengraphServiceInterface
6831
*/
6932
public function getOpengraphFields(): array;
7033
}
71-
72-
73-
74-
75-
interface MappableFieldInterface
76-
{
77-
/**
78-
* Returns the OpenGraph group this field should be listed under.
79-
*
80-
* @return OpengraphGroup One of the enum cases defined in {@see OpengraphGroup}.
81-
*
82-
* @since __DEPLOY_VERSION__
83-
*/
84-
public function getOpengraphGroup(): OpengraphGroup;
85-
}

plugins/system/opengraph/src/Extension/opengraph.php

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -364,22 +364,6 @@ private function getOgTagsFromCategoryMappings(Registry $categoryParams, object
364364
*/
365365
private function getFieldValue(object $article, string $fieldName, array $articleImages): string
366366
{
367-
// Check if it's a custom field
368-
if (strpos($fieldName, 'field.') === 0) {
369-
$customFieldName = substr($fieldName, 6);
370-
// Load custom fields for the article
371-
$customFields = FieldsHelper::getFields('com_content.article', $article, true);
372-
373-
foreach ($customFields as $field) {
374-
if ($field->name == $customFieldName) {
375-
return $field->value ?? '';
376-
}
377-
}
378-
379-
return '';
380-
}
381-
382-
// Handle standard article fields
383367
$value = '';
384368

385369
switch ($fieldName) {

plugins/system/opengraph/src/Field/OpengraphField.php

Lines changed: 0 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,10 @@
1010
namespace Joomla\Plugin\System\Opengraph\Field;
1111

1212
use Joomla\CMS\Factory;
13-
use Joomla\CMS\Fields\FieldsServiceInterface;
1413
use Joomla\CMS\Form\Field\GroupedlistField;
1514
use Joomla\CMS\HTML\HTMLHelper;
1615
use Joomla\CMS\Language\Text;
17-
use Joomla\CMS\Opengraph\MappableFieldInterface;
18-
use Joomla\CMS\Opengraph\OpengraphGroup;
1916
use Joomla\CMS\Opengraph\OpengraphServiceInterface;
20-
use Joomla\CMS\Plugin\PluginHelper;
21-
use Joomla\Component\Fields\Administrator\Helper\FieldsHelper;
2217

2318
// phpcs:disable PSR1.Files.SideEffects
2419
\defined('_JEXEC') or die;
@@ -80,69 +75,6 @@ protected function getGroups()
8075
}
8176

8277

83-
if (!$component instanceof FieldsServiceInterface) {
84-
return $groups;
85-
}
86-
87-
// Allowed field types for each OpenGraph group
88-
$allowedFieldTypes = [
89-
OpengraphGroup::TEXT->value => ['text', 'textarea'],
90-
OpengraphGroup::IMAGE->value => ['media', 'imagelist'],
91-
OpengraphGroup::IMAGE_ALT->value => ['text'],
92-
];
93-
94-
$nativeTypes = $allowedFieldTypes[$fieldType] ?? [];
95-
96-
97-
98-
$catId = (int) $this->form->getValue('id'); // editing existing cat
99-
if (!$catId) {
100-
// Creating a new category: use the chosen parent so assignments still work
101-
$catId = (int) $this->form->getValue('parent_id');
102-
}
103-
104-
// Dummy item with catid so FieldsService filters by assignment
105-
$scopeItem = $catId ? (object) ['catid' => $catId] : null;
106-
107-
$customFields = FieldsHelper::getFields('com_content.article', $scopeItem);
108-
$customOptions = [];
109-
110-
foreach ($customFields as $field) {
111-
$accept = \in_array($field->type, $nativeTypes, true);
112-
113-
114-
// If not native-allowed, see if the field’s plugin implements our interface
115-
if (!$accept) {
116-
// Class name convention: PlgFields{Type}
117-
$class = 'PlgFields' . ucfirst($field->type);
118-
119-
// Ensure plugin autoloaded
120-
PluginHelper::importPlugin('fields');
121-
122-
if (
123-
\class_exists($class)
124-
&& \is_subclass_of($class, MappableFieldInterface::class)
125-
&& $class::getOpengraphGroup()->value === $fieldType
126-
) {
127-
$accept = true;
128-
}
129-
}
130-
131-
132-
if (!$accept) {
133-
continue;
134-
}
135-
136-
137-
138-
$label = $field->title . ' (' . $field->name . ')';
139-
$customOptions[] = HTMLHelper::_('select.option', 'field.' . $field->name, $label);
140-
}
141-
142-
if (!empty($customOptions)) {
143-
$groups['Custom Fields'] = $customOptions;
144-
}
145-
14678
return $groups;
14779
}
14880
}

0 commit comments

Comments
 (0)