From 8346ffcf1c04da5a83184a6366e5e13d9f5e407a Mon Sep 17 00:00:00 2001 From: Benjamin Trenkle Date: Wed, 4 Oct 2023 16:17:17 +0200 Subject: [PATCH 01/21] First version of generic plugin --- .../language/en-GB/plg_schemaorg_generic.ini | 9 ++ .../en-GB/plg_schemaorg_generic.sys.ini | 9 ++ plugins/schemaorg/generic/forms/schemaorg.xml | 24 +++++ plugins/schemaorg/generic/generic.xml | 43 +++++++++ .../schemaorg/generic/services/provider.php | 48 ++++++++++ .../generic/src/Extension/Generic.php | 89 +++++++++++++++++++ 6 files changed, 222 insertions(+) create mode 100755 administrator/language/en-GB/plg_schemaorg_generic.ini create mode 100755 administrator/language/en-GB/plg_schemaorg_generic.sys.ini create mode 100755 plugins/schemaorg/generic/forms/schemaorg.xml create mode 100755 plugins/schemaorg/generic/generic.xml create mode 100644 plugins/schemaorg/generic/services/provider.php create mode 100755 plugins/schemaorg/generic/src/Extension/Generic.php diff --git a/administrator/language/en-GB/plg_schemaorg_generic.ini b/administrator/language/en-GB/plg_schemaorg_generic.ini new file mode 100755 index 0000000000000..ac3a80cfadfa5 --- /dev/null +++ b/administrator/language/en-GB/plg_schemaorg_generic.ini @@ -0,0 +1,9 @@ +; Joomla! Project +; (C) 2023 Open Source Matters, Inc. +; License GNU General Public License version 2 or later; see LICENSE.txt +; Note : All ini files need to be saved as UTF-8 + +PLG_SCHEMAORG_GENERIC="Schema.org - Generic" +PLG_SCHEMAORG_GENEIRC_DESCRIPTION_LABEL="More information on the Schema.org Event Type can be found at https://schema.org/Event" +PLG_SCHEMAORG_GENEIRC_FIELD_ADDRESS_LABEL="JSON" +PLG_SCHEMAORG_GENEIRC_XML_DESCRIPTION="Adds a gernic field to add any schema type." diff --git a/administrator/language/en-GB/plg_schemaorg_generic.sys.ini b/administrator/language/en-GB/plg_schemaorg_generic.sys.ini new file mode 100755 index 0000000000000..0434ff5c9e220 --- /dev/null +++ b/administrator/language/en-GB/plg_schemaorg_generic.sys.ini @@ -0,0 +1,9 @@ +; Joomla! Project +; (C) 2023 Open Source Matters, Inc. +; License GNU General Public License version 2 or later; see LICENSE.txt +; Note : All ini files need to be saved as UTF-8 + +PLG_SCHEMAORG_GENERIC="Schema.org - Generic" +PLG_SCHEMAORG_GENEIC_DESCRIPTION_LABEL="More information on the Schema.org Event Type can be found at https://schema.org/Event" +PLG_SCHEMAORG_GENERIC_FIELD_ADDRESS_LABEL="JSON" +PLG_SCHEMAORG_GENERIC_XML_DESCRIPTION="Adds a gernic field to add any schema type." \ No newline at end of file diff --git a/plugins/schemaorg/generic/forms/schemaorg.xml b/plugins/schemaorg/generic/forms/schemaorg.xml new file mode 100755 index 0000000000000..929e5597daf48 --- /dev/null +++ b/plugins/schemaorg/generic/forms/schemaorg.xml @@ -0,0 +1,24 @@ + +
+ +
+ + + + + + + +
+
+ diff --git a/plugins/schemaorg/generic/generic.xml b/plugins/schemaorg/generic/generic.xml new file mode 100755 index 0000000000000..3414ae110121c --- /dev/null +++ b/plugins/schemaorg/generic/generic.xml @@ -0,0 +1,43 @@ + + + plg_schemaorg_generic + Joomla! Project + 2024-09 + (C) 2023 Open Source Matters, Inc. + GNU General Public License version 2 or later; see LICENSE.txt + admin@joomla.org + www.joomla.org + 5.0.0 + PLG_SCHEMAORG_GENERIC_XML_DESCRIPTION + Joomla\Plugin\Schemaorg\Generic + + services + src + + + language/en-GB/plg_schemaorg_generic.ini + language/en-GB/plg_schemaorg_generic.sys.ini + + + +
+ + +
+
+
+
\ No newline at end of file diff --git a/plugins/schemaorg/generic/services/provider.php b/plugins/schemaorg/generic/services/provider.php new file mode 100644 index 0000000000000..484dec2aaab0f --- /dev/null +++ b/plugins/schemaorg/generic/services/provider.php @@ -0,0 +1,48 @@ + + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +defined('_JEXEC') or die; + +use Joomla\CMS\Extension\PluginInterface; +use Joomla\CMS\Factory; +use Joomla\CMS\Plugin\PluginHelper; +use Joomla\DI\Container; +use Joomla\DI\ServiceProviderInterface; +use Joomla\Event\DispatcherInterface; +use Joomla\Plugin\Schemaorg\Generic\Extension\Generic; + +return new class () implements ServiceProviderInterface { + /** + * Registers the service provider with a DI container. + * + * @param Container $container The DI container. + * + * @return void + * + * @since __DEPLOY_VERSION__ + */ + public function register(Container $container) + { + $container->set( + PluginInterface::class, + function (Container $container) { + $dispatcher = $container->get(DispatcherInterface::class); + $plugin = new Generic( + $dispatcher, + (array) PluginHelper::getPlugin('schemaorg', 'generic') + ); + + $plugin->setApplication(Factory::getApplication()); + + return $plugin; + } + ); + } +}; diff --git a/plugins/schemaorg/generic/src/Extension/Generic.php b/plugins/schemaorg/generic/src/Extension/Generic.php new file mode 100755 index 0000000000000..dff51b95f6f07 --- /dev/null +++ b/plugins/schemaorg/generic/src/Extension/Generic.php @@ -0,0 +1,89 @@ + + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace Joomla\Plugin\Schemaorg\Generic\Extension; + +use Joomla\CMS\Event\Application\BeforeCompileHeadEvent as ApplicationBeforeCompileHeadEvent; +use Joomla\CMS\Event\Plugin\System\Schemaorg\BeforeCompileHeadEvent; +use Joomla\CMS\Plugin\CMSPlugin; +use Joomla\CMS\Schemaorg\SchemaorgPluginTrait; +use Joomla\CMS\Schemaorg\SchemaorgPrepareDateTrait; +use Joomla\CMS\Schemaorg\SchemaorgPrepareImageTrait; +use Joomla\Event\Priority; +use Joomla\Event\SubscriberInterface; + +// phpcs:disable PSR1.Files.SideEffects +\defined('_JEXEC') or die; +// phpcs:enable PSR1.Files.SideEffects + +/** + * Schemaorg Plugin + * + * @since 5.0.0 + */ +final class Generic extends CMSPlugin implements SubscriberInterface +{ + use SchemaorgPluginTrait; + + /** + * Load the language file on instantiation. + * + * @var boolean + * @since 5.0.0 + */ + protected $autoloadLanguage = true; + + /** + * The name of the schema form + * + * @var string + * @since 5.0.0 + */ + protected $pluginName = 'Generic'; + + /** + * Returns an array of events this subscriber will listen to. + * + * @return array + * + * @since 5.0.0 + */ + public static function getSubscribedEvents(): array + { + return [ + 'onSchemaPrepareForm' => 'onSchemaPrepareForm', + 'onSchemaBeforeCompileHead' => ['onSchemaBeforeCompileHead', Priority::BELOW_NORMAL], + ]; + } + + /** + * Cleanup all Generic types + * + * @param BeforeCompileHeadEvent $event The given event + * + * @return void + * + * @since 5.0.0 + */ + public function onSchemaBeforeCompileHead(ApplicationBeforeCompileHeadEvent $event): void + { + $schema = $event->getSchema(); + + $graph = $schema->get('@graph'); + + foreach ($graph as &$entry) { + if (!isset($entry['@type']) || $entry['@type'] !== 'Generic') { + continue; + } + } + + $schema->set('@graph', $graph); + } +} From 93d7ffa127ac895b4c8217534332f1902cb9fe90 Mon Sep 17 00:00:00 2001 From: Benjamin Trenkle Date: Thu, 18 Jan 2024 17:24:18 +0100 Subject: [PATCH 02/21] Add plugin to the database --- .../components/com_admin/sql/updates/mysql/5.1.0-2024-01-18.sql | 2 ++ .../com_admin/sql/updates/postgresql/5.1.0-2024-01-18.sql | 2 ++ installation/sql/mysql/base.sql | 1 + installation/sql/postgresql/base.sql | 1 + 4 files changed, 6 insertions(+) create mode 100644 administrator/components/com_admin/sql/updates/mysql/5.1.0-2024-01-18.sql create mode 100644 administrator/components/com_admin/sql/updates/postgresql/5.1.0-2024-01-18.sql diff --git a/administrator/components/com_admin/sql/updates/mysql/5.1.0-2024-01-18.sql b/administrator/components/com_admin/sql/updates/mysql/5.1.0-2024-01-18.sql new file mode 100644 index 0000000000000..39cc8745b4512 --- /dev/null +++ b/administrator/components/com_admin/sql/updates/mysql/5.1.0-2024-01-18.sql @@ -0,0 +1,2 @@ +INSERT INTO `#__extensions` (`package_id`, `name`, `type`, `element`, `folder`, `client_id`, `enabled`, `access`, `protected`, `locked`, `manifest_cache`, `params`, `custom_data`, `ordering`, `state`) VALUES +(0, 'plg_schemaorg_generic', 'plugin', 'generic', 'schemaorg', 0, 1, 1, 0, 0, '', '{}', '', 0, 0); \ No newline at end of file diff --git a/administrator/components/com_admin/sql/updates/postgresql/5.1.0-2024-01-18.sql b/administrator/components/com_admin/sql/updates/postgresql/5.1.0-2024-01-18.sql new file mode 100644 index 0000000000000..5e3f73b1c80af --- /dev/null +++ b/administrator/components/com_admin/sql/updates/postgresql/5.1.0-2024-01-18.sql @@ -0,0 +1,2 @@ +INSERT INTO "#__extensions" ("package_id", "name", "type", "element", "folder", "client_id", "enabled", "access", "protected", "locked", "manifest_cache", "params", "custom_data", "ordering", "state") VALUES +(0, 'plg_schemaorg_generic', 'plugin', 'generic', 'schemaorg', 0, 1, 1, 0, 0, '', '{}', '', 0, 0); \ No newline at end of file diff --git a/installation/sql/mysql/base.sql b/installation/sql/mysql/base.sql index c34c49dd41e0a..eb6a8ddc7a36a 100644 --- a/installation/sql/mysql/base.sql +++ b/installation/sql/mysql/base.sql @@ -341,6 +341,7 @@ INSERT INTO `#__extensions` (`package_id`, `name`, `type`, `element`, `folder`, (0, 'plg_schemaorg_organization', 'plugin', 'organization', 'schemaorg', 0, 1, 1, 0, 0, '', '{}', '', 6, 0), (0, 'plg_schemaorg_person', 'plugin', 'person', 'schemaorg', 0, 1, 1, 0, 0, '', '{}', '', 7, 0), (0, 'plg_schemaorg_recipe', 'plugin', 'recipe', 'schemaorg', 0, 1, 1, 0, 0, '', '{}', '', 8, 0), +(0, 'plg_schemaorg_generic', 'plugin', 'generic', 'schemaorg', 0, 1, 1, 0, 0, '', '{}', '', 9, 0), (0, 'plg_system_accessibility', 'plugin', 'accessibility', 'system', 0, 0, 1, 0, 1, '', '{}', '', 1, 0), (0, 'plg_system_actionlogs', 'plugin', 'actionlogs', 'system', 0, 1, 1, 0, 1, '', '{}', '', 2, 0), (0, 'plg_system_cache', 'plugin', 'cache', 'system', 0, 0, 1, 0, 1, '', '{"browsercache":"0","cachetime":"15"}', '', 3, 0), diff --git a/installation/sql/postgresql/base.sql b/installation/sql/postgresql/base.sql index 435afc0ee2112..e4d0949a7a1e9 100644 --- a/installation/sql/postgresql/base.sql +++ b/installation/sql/postgresql/base.sql @@ -347,6 +347,7 @@ INSERT INTO "#__extensions" ("package_id", "name", "type", "element", "folder", (0, 'plg_schemaorg_organization', 'plugin', 'organization', 'schemaorg', 0, 1, 1, 0, 0, '', '{}', '', 6, 0), (0, 'plg_schemaorg_person', 'plugin', 'person', 'schemaorg', 0, 1, 1, 0, 0, '', '{}', '', 7, 0), (0, 'plg_schemaorg_recipe', 'plugin', 'recipe', 'schemaorg', 0, 1, 1, 0, 0, '', '{}', '', 8, 0), +(0, 'plg_schemaorg_generic', 'plugin', 'generic', 'schemaorg', 0, 1, 1, 0, 0, '', '{}', '', 9, 0), (0, 'plg_system_accessibility', 'plugin', 'accessibility', 'system', 0, 0, 1, 0, 1, '', '{}', '', 1, 0), (0, 'plg_system_actionlogs', 'plugin', 'actionlogs', 'system', 0, 1, 1, 0, 1, '', '{}', '', 2, 0), (0, 'plg_system_cache', 'plugin', 'cache', 'system', 0, 0, 1, 0, 1, '', '{"browsercache":"0","cachetime":"15"}', '', 3, 0), From 3535b4e4f96b9585dbfb0a6b4d7d8a4fe75bddb8 Mon Sep 17 00:00:00 2001 From: Benjamin Trenkle Date: Thu, 18 Jan 2024 23:10:28 +0100 Subject: [PATCH 03/21] Add translations --- .../language/en-GB/plg_schemaorg_generic.ini | 6 ++++-- plugins/schemaorg/generic/forms/schemaorg.xml | 14 ++++++++++++-- .../schemaorg/generic/src/Extension/Generic.php | 5 +---- 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/administrator/language/en-GB/plg_schemaorg_generic.ini b/administrator/language/en-GB/plg_schemaorg_generic.ini index ac3a80cfadfa5..6c535eae60935 100755 --- a/administrator/language/en-GB/plg_schemaorg_generic.ini +++ b/administrator/language/en-GB/plg_schemaorg_generic.ini @@ -3,7 +3,9 @@ ; License GNU General Public License version 2 or later; see LICENSE.txt ; Note : All ini files need to be saved as UTF-8 -PLG_SCHEMAORG_GENERIC="Schema.org - Generic" PLG_SCHEMAORG_GENEIRC_DESCRIPTION_LABEL="More information on the Schema.org Event Type can be found at https://schema.org/Event" -PLG_SCHEMAORG_GENEIRC_FIELD_ADDRESS_LABEL="JSON" PLG_SCHEMAORG_GENEIRC_XML_DESCRIPTION="Adds a gernic field to add any schema type." +PLG_SCHEMAORG_GENERIC="Schema.org - Generic" +PLG_SCHEMAORG_GENERIC_DESCRIPTION_LABEL="Use any JSON-LD code here to add currently unsupported schema types." +PLG_SCHEMAORG_GENERIC_JSON_FIELD_DESC="Paste the full JSON-LD code here." +PLG_SCHEMAORG_GENERIC_JSON_FIELD_LABEL="JSON code" diff --git a/plugins/schemaorg/generic/forms/schemaorg.xml b/plugins/schemaorg/generic/forms/schemaorg.xml index 929e5597daf48..732a1188c396c 100755 --- a/plugins/schemaorg/generic/forms/schemaorg.xml +++ b/plugins/schemaorg/generic/forms/schemaorg.xml @@ -6,15 +6,25 @@ label="PLG_SYSTEM_SCHEMA_FIELD_SCHEMA_LABEL" >
+ + diff --git a/plugins/schemaorg/generic/src/Extension/Generic.php b/plugins/schemaorg/generic/src/Extension/Generic.php index dff51b95f6f07..a4600aaf95086 100755 --- a/plugins/schemaorg/generic/src/Extension/Generic.php +++ b/plugins/schemaorg/generic/src/Extension/Generic.php @@ -10,12 +10,9 @@ namespace Joomla\Plugin\Schemaorg\Generic\Extension; -use Joomla\CMS\Event\Application\BeforeCompileHeadEvent as ApplicationBeforeCompileHeadEvent; use Joomla\CMS\Event\Plugin\System\Schemaorg\BeforeCompileHeadEvent; use Joomla\CMS\Plugin\CMSPlugin; use Joomla\CMS\Schemaorg\SchemaorgPluginTrait; -use Joomla\CMS\Schemaorg\SchemaorgPrepareDateTrait; -use Joomla\CMS\Schemaorg\SchemaorgPrepareImageTrait; use Joomla\Event\Priority; use Joomla\Event\SubscriberInterface; @@ -72,7 +69,7 @@ public static function getSubscribedEvents(): array * * @since 5.0.0 */ - public function onSchemaBeforeCompileHead(ApplicationBeforeCompileHeadEvent $event): void + public function onSchemaBeforeCompileHead(BeforeCompileHeadEvent $event): void { $schema = $event->getSchema(); From 81cfb1542dfd7e17fb51620de08578146cf97df1 Mon Sep 17 00:00:00 2001 From: Benjamin Trenkle Date: Tue, 23 Jan 2024 00:25:27 +0100 Subject: [PATCH 04/21] Implement output & saving --- .../language/en-GB/plg_schemaorg_generic.ini | 1 + plugins/schemaorg/generic/forms/schemaorg.xml | 32 ++++++++------ .../generic/src/Extension/Generic.php | 42 ++++++++++++++++++- 3 files changed, 61 insertions(+), 14 deletions(-) diff --git a/administrator/language/en-GB/plg_schemaorg_generic.ini b/administrator/language/en-GB/plg_schemaorg_generic.ini index 6c535eae60935..e20bd8bd08411 100755 --- a/administrator/language/en-GB/plg_schemaorg_generic.ini +++ b/administrator/language/en-GB/plg_schemaorg_generic.ini @@ -7,5 +7,6 @@ PLG_SCHEMAORG_GENEIRC_DESCRIPTION_LABEL="More information on the Schema.org Even PLG_SCHEMAORG_GENEIRC_XML_DESCRIPTION="Adds a gernic field to add any schema type." PLG_SCHEMAORG_GENERIC="Schema.org - Generic" PLG_SCHEMAORG_GENERIC_DESCRIPTION_LABEL="Use any JSON-LD code here to add currently unsupported schema types." +PLG_SCHEMAORG_GENERIC_JSON_ERROR="The JSON code is not valid or @context or @type is missing." PLG_SCHEMAORG_GENERIC_JSON_FIELD_DESC="Paste the full JSON-LD code here." PLG_SCHEMAORG_GENERIC_JSON_FIELD_LABEL="JSON code" diff --git a/plugins/schemaorg/generic/forms/schemaorg.xml b/plugins/schemaorg/generic/forms/schemaorg.xml index 732a1188c396c..d189059c83187 100755 --- a/plugins/schemaorg/generic/forms/schemaorg.xml +++ b/plugins/schemaorg/generic/forms/schemaorg.xml @@ -12,20 +12,26 @@ >
- + - + + + diff --git a/plugins/schemaorg/generic/src/Extension/Generic.php b/plugins/schemaorg/generic/src/Extension/Generic.php index a4600aaf95086..22244a905b9f6 100755 --- a/plugins/schemaorg/generic/src/Extension/Generic.php +++ b/plugins/schemaorg/generic/src/Extension/Generic.php @@ -11,10 +11,13 @@ namespace Joomla\Plugin\Schemaorg\Generic\Extension; use Joomla\CMS\Event\Plugin\System\Schemaorg\BeforeCompileHeadEvent; +use Joomla\CMS\Event\Plugin\System\Schemaorg\PrepareSaveEvent; +use Joomla\CMS\Language\Text; use Joomla\CMS\Plugin\CMSPlugin; use Joomla\CMS\Schemaorg\SchemaorgPluginTrait; use Joomla\Event\Priority; use Joomla\Event\SubscriberInterface; +use Joomla\Registry\Registry; // phpcs:disable PSR1.Files.SideEffects \defined('_JEXEC') or die; @@ -57,9 +60,37 @@ public static function getSubscribedEvents(): array return [ 'onSchemaPrepareForm' => 'onSchemaPrepareForm', 'onSchemaBeforeCompileHead' => ['onSchemaBeforeCompileHead', Priority::BELOW_NORMAL], + 'onSchemaPrepareSave' => 'onSchemaPrepareSave', ]; } + public function onSchemaPrepareSave(PrepareSaveEvent $event): void + { + $subject = $event->getData(); + + if (empty($subject->schemaType) || $subject->schemaType !== 'Generic' || !isset($subject->schema)) { + return; + } + + try { + $schema = new Registry($subject->schema); + + $json = (new Registry($schema->get('json')))->toArray(); + } catch (\RuntimeException $e) { + throw new \RuntimeException('PLG_SCHEMAORG_GENERIC_JSON_ERROR'); + } + + if (!isset($json['@context']) || $json['@context'] !== 'https://schema.org' || !isset($json['@type'])) { + throw new \RuntimeException(Text::_('PLG_SCHEMAORG_GENERIC_JSON_ERROR')); + } + + $schema->set('json', json_encode($json, JSON_PRETTY_PRINT)); + + $subject->schema = $schema->toString(); + + $event->setArgument('subject', $subject); + } + /** * Cleanup all Generic types * @@ -75,10 +106,19 @@ public function onSchemaBeforeCompileHead(BeforeCompileHeadEvent $event): void $graph = $schema->get('@graph'); - foreach ($graph as &$entry) { + foreach ($graph as $i => $entry) { + if (!isset($entry['@type']) || $entry['@type'] !== 'Generic') { continue; } + + $json = (new Registry($entry['json']))->toArray(); + + if (isset($json['@context'])) { + unset($json['@context']); + } + + $graph[$i] = $json; } $schema->set('@graph', $graph); From 80c9b8db756f6b86f9a9329c010a00bab8a44dbd Mon Sep 17 00:00:00 2001 From: Benjamin Trenkle Date: Tue, 23 Jan 2024 00:47:12 +0100 Subject: [PATCH 05/21] Add some spacing nd ordering --- .../components/com_admin/sql/updates/mysql/5.1.0-2024-01-18.sql | 2 +- .../com_admin/sql/updates/postgresql/5.1.0-2024-01-18.sql | 2 +- administrator/language/en-GB/plg_schemaorg_generic.ini | 2 +- administrator/language/en-GB/plg_schemaorg_generic.sys.ini | 2 +- plugins/schemaorg/generic/generic.xml | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/administrator/components/com_admin/sql/updates/mysql/5.1.0-2024-01-18.sql b/administrator/components/com_admin/sql/updates/mysql/5.1.0-2024-01-18.sql index 39cc8745b4512..af9294c9fc29f 100644 --- a/administrator/components/com_admin/sql/updates/mysql/5.1.0-2024-01-18.sql +++ b/administrator/components/com_admin/sql/updates/mysql/5.1.0-2024-01-18.sql @@ -1,2 +1,2 @@ INSERT INTO `#__extensions` (`package_id`, `name`, `type`, `element`, `folder`, `client_id`, `enabled`, `access`, `protected`, `locked`, `manifest_cache`, `params`, `custom_data`, `ordering`, `state`) VALUES -(0, 'plg_schemaorg_generic', 'plugin', 'generic', 'schemaorg', 0, 1, 1, 0, 0, '', '{}', '', 0, 0); \ No newline at end of file +(0, 'plg_schemaorg_generic', 'plugin', 'generic', 'schemaorg', 0, 1, 1, 0, 0, '', '{}', '', 0, 0); diff --git a/administrator/components/com_admin/sql/updates/postgresql/5.1.0-2024-01-18.sql b/administrator/components/com_admin/sql/updates/postgresql/5.1.0-2024-01-18.sql index 5e3f73b1c80af..a3b9ab1c43488 100644 --- a/administrator/components/com_admin/sql/updates/postgresql/5.1.0-2024-01-18.sql +++ b/administrator/components/com_admin/sql/updates/postgresql/5.1.0-2024-01-18.sql @@ -1,2 +1,2 @@ INSERT INTO "#__extensions" ("package_id", "name", "type", "element", "folder", "client_id", "enabled", "access", "protected", "locked", "manifest_cache", "params", "custom_data", "ordering", "state") VALUES -(0, 'plg_schemaorg_generic', 'plugin', 'generic', 'schemaorg', 0, 1, 1, 0, 0, '', '{}', '', 0, 0); \ No newline at end of file +(0, 'plg_schemaorg_generic', 'plugin', 'generic', 'schemaorg', 0, 1, 1, 0, 0, '', '{}', '', 0, 0); diff --git a/administrator/language/en-GB/plg_schemaorg_generic.ini b/administrator/language/en-GB/plg_schemaorg_generic.ini index e20bd8bd08411..89c2fe3228f8e 100755 --- a/administrator/language/en-GB/plg_schemaorg_generic.ini +++ b/administrator/language/en-GB/plg_schemaorg_generic.ini @@ -3,9 +3,9 @@ ; License GNU General Public License version 2 or later; see LICENSE.txt ; Note : All ini files need to be saved as UTF-8 +PLG_SCHEMAORG_GENERIC="Schema.org - Generic" PLG_SCHEMAORG_GENEIRC_DESCRIPTION_LABEL="More information on the Schema.org Event Type can be found at https://schema.org/Event" PLG_SCHEMAORG_GENEIRC_XML_DESCRIPTION="Adds a gernic field to add any schema type." -PLG_SCHEMAORG_GENERIC="Schema.org - Generic" PLG_SCHEMAORG_GENERIC_DESCRIPTION_LABEL="Use any JSON-LD code here to add currently unsupported schema types." PLG_SCHEMAORG_GENERIC_JSON_ERROR="The JSON code is not valid or @context or @type is missing." PLG_SCHEMAORG_GENERIC_JSON_FIELD_DESC="Paste the full JSON-LD code here." diff --git a/administrator/language/en-GB/plg_schemaorg_generic.sys.ini b/administrator/language/en-GB/plg_schemaorg_generic.sys.ini index 0434ff5c9e220..fda3a31534fd6 100755 --- a/administrator/language/en-GB/plg_schemaorg_generic.sys.ini +++ b/administrator/language/en-GB/plg_schemaorg_generic.sys.ini @@ -6,4 +6,4 @@ PLG_SCHEMAORG_GENERIC="Schema.org - Generic" PLG_SCHEMAORG_GENEIC_DESCRIPTION_LABEL="More information on the Schema.org Event Type can be found at https://schema.org/Event" PLG_SCHEMAORG_GENERIC_FIELD_ADDRESS_LABEL="JSON" -PLG_SCHEMAORG_GENERIC_XML_DESCRIPTION="Adds a gernic field to add any schema type." \ No newline at end of file +PLG_SCHEMAORG_GENERIC_XML_DESCRIPTION="Adds a gernic field to add any schema type." diff --git a/plugins/schemaorg/generic/generic.xml b/plugins/schemaorg/generic/generic.xml index 3414ae110121c..797d4ed873142 100755 --- a/plugins/schemaorg/generic/generic.xml +++ b/plugins/schemaorg/generic/generic.xml @@ -40,4 +40,4 @@ - \ No newline at end of file + From 816823c2e546b1a39aad340209471acbcd5c7f63 Mon Sep 17 00:00:00 2001 From: Benjamin Trenkle Date: Tue, 23 Jan 2024 01:02:50 +0100 Subject: [PATCH 06/21] Code style --- plugins/schemaorg/generic/services/provider.php | 2 +- plugins/schemaorg/generic/src/Extension/Generic.php | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/plugins/schemaorg/generic/services/provider.php b/plugins/schemaorg/generic/services/provider.php index 484dec2aaab0f..aa79ab8755acb 100644 --- a/plugins/schemaorg/generic/services/provider.php +++ b/plugins/schemaorg/generic/services/provider.php @@ -8,7 +8,7 @@ * @license GNU General Public License version 2 or later; see LICENSE.txt */ -defined('_JEXEC') or die; +\defined('_JEXEC') or die; use Joomla\CMS\Extension\PluginInterface; use Joomla\CMS\Factory; diff --git a/plugins/schemaorg/generic/src/Extension/Generic.php b/plugins/schemaorg/generic/src/Extension/Generic.php index 22244a905b9f6..711f6a5c2e3ab 100755 --- a/plugins/schemaorg/generic/src/Extension/Generic.php +++ b/plugins/schemaorg/generic/src/Extension/Generic.php @@ -107,7 +107,6 @@ public function onSchemaBeforeCompileHead(BeforeCompileHeadEvent $event): void $graph = $schema->get('@graph'); foreach ($graph as $i => $entry) { - if (!isset($entry['@type']) || $entry['@type'] !== 'Generic') { continue; } From 03a8d60f9f2505e938860a4d718b375460d99e67 Mon Sep 17 00:00:00 2001 From: Benjamin Trenkle Date: Tue, 23 Jan 2024 10:53:57 +0100 Subject: [PATCH 07/21] Apply suggestions from code review Co-authored-by: Brian Teeman --- .../language/en-GB/plg_schemaorg_generic.ini | 2 +- .../language/en-GB/plg_schemaorg_generic.sys.ini | 6 ++++-- plugins/schemaorg/generic/generic.xml | 6 +++--- plugins/schemaorg/generic/services/provider.php | 4 ++-- plugins/schemaorg/generic/src/Extension/Generic.php | 12 ++++++------ 5 files changed, 16 insertions(+), 14 deletions(-) diff --git a/administrator/language/en-GB/plg_schemaorg_generic.ini b/administrator/language/en-GB/plg_schemaorg_generic.ini index 89c2fe3228f8e..1433ae3f5868b 100755 --- a/administrator/language/en-GB/plg_schemaorg_generic.ini +++ b/administrator/language/en-GB/plg_schemaorg_generic.ini @@ -1,5 +1,5 @@ ; Joomla! Project -; (C) 2023 Open Source Matters, Inc. +; (C) 2024 Open Source Matters, Inc. ; License GNU General Public License version 2 or later; see LICENSE.txt ; Note : All ini files need to be saved as UTF-8 diff --git a/administrator/language/en-GB/plg_schemaorg_generic.sys.ini b/administrator/language/en-GB/plg_schemaorg_generic.sys.ini index fda3a31534fd6..066262ad2be94 100755 --- a/administrator/language/en-GB/plg_schemaorg_generic.sys.ini +++ b/administrator/language/en-GB/plg_schemaorg_generic.sys.ini @@ -1,9 +1,11 @@ ; Joomla! Project -; (C) 2023 Open Source Matters, Inc. +; (C) 2024 Open Source Matters, Inc. + ; License GNU General Public License version 2 or later; see LICENSE.txt ; Note : All ini files need to be saved as UTF-8 PLG_SCHEMAORG_GENERIC="Schema.org - Generic" PLG_SCHEMAORG_GENEIC_DESCRIPTION_LABEL="More information on the Schema.org Event Type can be found at https://schema.org/Event" PLG_SCHEMAORG_GENERIC_FIELD_ADDRESS_LABEL="JSON" -PLG_SCHEMAORG_GENERIC_XML_DESCRIPTION="Adds a gernic field to add any schema type." +PLG_SCHEMAORG_GENERIC_XML_DESCRIPTION="Adds a generic field to add any schema type." + diff --git a/plugins/schemaorg/generic/generic.xml b/plugins/schemaorg/generic/generic.xml index 797d4ed873142..ace5bc6fbc4e6 100755 --- a/plugins/schemaorg/generic/generic.xml +++ b/plugins/schemaorg/generic/generic.xml @@ -2,12 +2,12 @@ plg_schemaorg_generic Joomla! Project - 2024-09 - (C) 2023 Open Source Matters, Inc. + 2024-01 + (C) 2024 Open Source Matters, Inc. GNU General Public License version 2 or later; see LICENSE.txt admin@joomla.org www.joomla.org - 5.0.0 + __DEPLOY_VERSION__ PLG_SCHEMAORG_GENERIC_XML_DESCRIPTION Joomla\Plugin\Schemaorg\Generic diff --git a/plugins/schemaorg/generic/services/provider.php b/plugins/schemaorg/generic/services/provider.php index aa79ab8755acb..68a766b09350c 100644 --- a/plugins/schemaorg/generic/services/provider.php +++ b/plugins/schemaorg/generic/services/provider.php @@ -2,9 +2,9 @@ /** * @package Joomla.Plugin - * @subpackage Schemaorg.event + * @subpackage Schemaorg.generic * - * @copyright (C) 2023 Open Source Matters, Inc. + * @copyright (C) 2024 Open Source Matters, Inc. * @license GNU General Public License version 2 or later; see LICENSE.txt */ diff --git a/plugins/schemaorg/generic/src/Extension/Generic.php b/plugins/schemaorg/generic/src/Extension/Generic.php index 711f6a5c2e3ab..d0750fba172d4 100755 --- a/plugins/schemaorg/generic/src/Extension/Generic.php +++ b/plugins/schemaorg/generic/src/Extension/Generic.php @@ -4,7 +4,7 @@ * @package Joomla.Plugin * @subpackage Schemaorg.generic * - * @copyright (C) 2023 Open Source Matters, Inc. + * @copyright (C) 2024 Open Source Matters, Inc. * @license GNU General Public License version 2 or later; see LICENSE.txt */ @@ -26,7 +26,7 @@ /** * Schemaorg Plugin * - * @since 5.0.0 + * @since __DEPLOY_VERSION__ */ final class Generic extends CMSPlugin implements SubscriberInterface { @@ -36,7 +36,7 @@ final class Generic extends CMSPlugin implements SubscriberInterface * Load the language file on instantiation. * * @var boolean - * @since 5.0.0 + * @since __DEPLOY_VERSION__ */ protected $autoloadLanguage = true; @@ -44,7 +44,7 @@ final class Generic extends CMSPlugin implements SubscriberInterface * The name of the schema form * * @var string - * @since 5.0.0 + * @since __DEPLOY_VERSION__ */ protected $pluginName = 'Generic'; @@ -53,7 +53,7 @@ final class Generic extends CMSPlugin implements SubscriberInterface * * @return array * - * @since 5.0.0 + * @since __DEPLOY_VERSION__ */ public static function getSubscribedEvents(): array { @@ -98,7 +98,7 @@ public function onSchemaPrepareSave(PrepareSaveEvent $event): void * * @return void * - * @since 5.0.0 + * @since __DEPLOY_VERSION__ */ public function onSchemaBeforeCompileHead(BeforeCompileHeadEvent $event): void { From b4eeabda073a0fa191e9b326426a60f5587a6b7f Mon Sep 17 00:00:00 2001 From: Benjamin Trenkle Date: Tue, 23 Jan 2024 10:57:05 +0100 Subject: [PATCH 08/21] Update administrator/language/en-GB/plg_schemaorg_generic.ini Co-authored-by: Brian Teeman --- administrator/language/en-GB/plg_schemaorg_generic.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/administrator/language/en-GB/plg_schemaorg_generic.ini b/administrator/language/en-GB/plg_schemaorg_generic.ini index 1433ae3f5868b..eabc9b00e994d 100755 --- a/administrator/language/en-GB/plg_schemaorg_generic.ini +++ b/administrator/language/en-GB/plg_schemaorg_generic.ini @@ -5,7 +5,7 @@ PLG_SCHEMAORG_GENERIC="Schema.org - Generic" PLG_SCHEMAORG_GENEIRC_DESCRIPTION_LABEL="More information on the Schema.org Event Type can be found at https://schema.org/Event" -PLG_SCHEMAORG_GENEIRC_XML_DESCRIPTION="Adds a gernic field to add any schema type." +PLG_SCHEMAORG_GENEIRC_XML_DESCRIPTION="Adds a generic field to add any schema type." PLG_SCHEMAORG_GENERIC_DESCRIPTION_LABEL="Use any JSON-LD code here to add currently unsupported schema types." PLG_SCHEMAORG_GENERIC_JSON_ERROR="The JSON code is not valid or @context or @type is missing." PLG_SCHEMAORG_GENERIC_JSON_FIELD_DESC="Paste the full JSON-LD code here." From 3c17c17b3c2fb535ba8805cec998d18b47c47e57 Mon Sep 17 00:00:00 2001 From: Benjamin Trenkle Date: Tue, 23 Jan 2024 21:37:30 +0100 Subject: [PATCH 09/21] Rename schemaorg Generic to Custom --- .../sql/updates/mysql/5.1.0-2024-01-18.sql | 2 +- .../updates/postgresql/5.1.0-2024-01-18.sql | 2 +- ...rg_generic.ini => plg_schemaorg_custom.ini} | 0 ...ic.sys.ini => plg_schemaorg_custom.sys.ini} | 0 installation/sql/mysql/base.sql | 2 +- installation/sql/postgresql/base.sql | 2 +- .../{generic/generic.xml => custom/custom.xml} | 12 ++++++------ .../{generic => custom}/forms/schemaorg.xml | 14 +++++++------- .../{generic => custom}/services/provider.php | 8 ++++---- .../src/Extension/Custom.php} | 18 +++++++++--------- 10 files changed, 30 insertions(+), 30 deletions(-) rename administrator/language/en-GB/{plg_schemaorg_generic.ini => plg_schemaorg_custom.ini} (100%) rename administrator/language/en-GB/{plg_schemaorg_generic.sys.ini => plg_schemaorg_custom.sys.ini} (100%) rename plugins/schemaorg/{generic/generic.xml => custom/custom.xml} (75%) rename plugins/schemaorg/{generic => custom}/forms/schemaorg.xml (63%) rename plugins/schemaorg/{generic => custom}/services/provider.php (89%) rename plugins/schemaorg/{generic/src/Extension/Generic.php => custom/src/Extension/Custom.php} (86%) diff --git a/administrator/components/com_admin/sql/updates/mysql/5.1.0-2024-01-18.sql b/administrator/components/com_admin/sql/updates/mysql/5.1.0-2024-01-18.sql index af9294c9fc29f..d1f08f1cd2e60 100644 --- a/administrator/components/com_admin/sql/updates/mysql/5.1.0-2024-01-18.sql +++ b/administrator/components/com_admin/sql/updates/mysql/5.1.0-2024-01-18.sql @@ -1,2 +1,2 @@ INSERT INTO `#__extensions` (`package_id`, `name`, `type`, `element`, `folder`, `client_id`, `enabled`, `access`, `protected`, `locked`, `manifest_cache`, `params`, `custom_data`, `ordering`, `state`) VALUES -(0, 'plg_schemaorg_generic', 'plugin', 'generic', 'schemaorg', 0, 1, 1, 0, 0, '', '{}', '', 0, 0); +(0, 'plg_schemaorg_custom', 'plugin', 'custom', 'schemaorg', 0, 1, 1, 0, 0, '', '{}', '', 0, 0); diff --git a/administrator/components/com_admin/sql/updates/postgresql/5.1.0-2024-01-18.sql b/administrator/components/com_admin/sql/updates/postgresql/5.1.0-2024-01-18.sql index a3b9ab1c43488..665ac55ee84ff 100644 --- a/administrator/components/com_admin/sql/updates/postgresql/5.1.0-2024-01-18.sql +++ b/administrator/components/com_admin/sql/updates/postgresql/5.1.0-2024-01-18.sql @@ -1,2 +1,2 @@ INSERT INTO "#__extensions" ("package_id", "name", "type", "element", "folder", "client_id", "enabled", "access", "protected", "locked", "manifest_cache", "params", "custom_data", "ordering", "state") VALUES -(0, 'plg_schemaorg_generic', 'plugin', 'generic', 'schemaorg', 0, 1, 1, 0, 0, '', '{}', '', 0, 0); +(0, 'plg_schemaorg_custom', 'plugin', 'custom', 'schemaorg', 0, 1, 1, 0, 0, '', '{}', '', 0, 0); diff --git a/administrator/language/en-GB/plg_schemaorg_generic.ini b/administrator/language/en-GB/plg_schemaorg_custom.ini similarity index 100% rename from administrator/language/en-GB/plg_schemaorg_generic.ini rename to administrator/language/en-GB/plg_schemaorg_custom.ini diff --git a/administrator/language/en-GB/plg_schemaorg_generic.sys.ini b/administrator/language/en-GB/plg_schemaorg_custom.sys.ini similarity index 100% rename from administrator/language/en-GB/plg_schemaorg_generic.sys.ini rename to administrator/language/en-GB/plg_schemaorg_custom.sys.ini diff --git a/installation/sql/mysql/base.sql b/installation/sql/mysql/base.sql index eb6a8ddc7a36a..4a54aee554c09 100644 --- a/installation/sql/mysql/base.sql +++ b/installation/sql/mysql/base.sql @@ -341,7 +341,7 @@ INSERT INTO `#__extensions` (`package_id`, `name`, `type`, `element`, `folder`, (0, 'plg_schemaorg_organization', 'plugin', 'organization', 'schemaorg', 0, 1, 1, 0, 0, '', '{}', '', 6, 0), (0, 'plg_schemaorg_person', 'plugin', 'person', 'schemaorg', 0, 1, 1, 0, 0, '', '{}', '', 7, 0), (0, 'plg_schemaorg_recipe', 'plugin', 'recipe', 'schemaorg', 0, 1, 1, 0, 0, '', '{}', '', 8, 0), -(0, 'plg_schemaorg_generic', 'plugin', 'generic', 'schemaorg', 0, 1, 1, 0, 0, '', '{}', '', 9, 0), +(0, 'plg_schemaorg_custom', 'plugin', 'custom', 'schemaorg', 0, 1, 1, 0, 0, '', '{}', '', 9, 0), (0, 'plg_system_accessibility', 'plugin', 'accessibility', 'system', 0, 0, 1, 0, 1, '', '{}', '', 1, 0), (0, 'plg_system_actionlogs', 'plugin', 'actionlogs', 'system', 0, 1, 1, 0, 1, '', '{}', '', 2, 0), (0, 'plg_system_cache', 'plugin', 'cache', 'system', 0, 0, 1, 0, 1, '', '{"browsercache":"0","cachetime":"15"}', '', 3, 0), diff --git a/installation/sql/postgresql/base.sql b/installation/sql/postgresql/base.sql index e4d0949a7a1e9..57493f9568d90 100644 --- a/installation/sql/postgresql/base.sql +++ b/installation/sql/postgresql/base.sql @@ -347,7 +347,7 @@ INSERT INTO "#__extensions" ("package_id", "name", "type", "element", "folder", (0, 'plg_schemaorg_organization', 'plugin', 'organization', 'schemaorg', 0, 1, 1, 0, 0, '', '{}', '', 6, 0), (0, 'plg_schemaorg_person', 'plugin', 'person', 'schemaorg', 0, 1, 1, 0, 0, '', '{}', '', 7, 0), (0, 'plg_schemaorg_recipe', 'plugin', 'recipe', 'schemaorg', 0, 1, 1, 0, 0, '', '{}', '', 8, 0), -(0, 'plg_schemaorg_generic', 'plugin', 'generic', 'schemaorg', 0, 1, 1, 0, 0, '', '{}', '', 9, 0), +(0, 'plg_schemaorg_custom', 'plugin', 'custom', 'schemaorg', 0, 1, 1, 0, 0, '', '{}', '', 9, 0), (0, 'plg_system_accessibility', 'plugin', 'accessibility', 'system', 0, 0, 1, 0, 1, '', '{}', '', 1, 0), (0, 'plg_system_actionlogs', 'plugin', 'actionlogs', 'system', 0, 1, 1, 0, 1, '', '{}', '', 2, 0), (0, 'plg_system_cache', 'plugin', 'cache', 'system', 0, 0, 1, 0, 1, '', '{"browsercache":"0","cachetime":"15"}', '', 3, 0), diff --git a/plugins/schemaorg/generic/generic.xml b/plugins/schemaorg/custom/custom.xml similarity index 75% rename from plugins/schemaorg/generic/generic.xml rename to plugins/schemaorg/custom/custom.xml index ace5bc6fbc4e6..b9794ae30b4cd 100755 --- a/plugins/schemaorg/generic/generic.xml +++ b/plugins/schemaorg/custom/custom.xml @@ -1,6 +1,6 @@ - plg_schemaorg_generic + plg_schemaorg_custom Joomla! Project 2024-01 (C) 2024 Open Source Matters, Inc. @@ -8,15 +8,15 @@ admin@joomla.org www.joomla.org __DEPLOY_VERSION__ - PLG_SCHEMAORG_GENERIC_XML_DESCRIPTION - Joomla\Plugin\Schemaorg\Generic + PLG_SCHEMAORG_CUSTOM_XML_DESCRIPTION + Joomla\Plugin\Schemaorg\Custom - services + services src - language/en-GB/plg_schemaorg_generic.ini - language/en-GB/plg_schemaorg_generic.sys.ini + language/en-GB/plg_schemaorg_custom.ini + language/en-GB/plg_schemaorg_custom.sys.ini diff --git a/plugins/schemaorg/generic/forms/schemaorg.xml b/plugins/schemaorg/custom/forms/schemaorg.xml similarity index 63% rename from plugins/schemaorg/generic/forms/schemaorg.xml rename to plugins/schemaorg/custom/forms/schemaorg.xml index d189059c83187..86fb886bdf1b6 100755 --- a/plugins/schemaorg/generic/forms/schemaorg.xml +++ b/plugins/schemaorg/custom/forms/schemaorg.xml @@ -6,30 +6,30 @@ label="PLG_SYSTEM_SCHEMA_FIELD_SCHEMA_LABEL" >
diff --git a/plugins/schemaorg/generic/services/provider.php b/plugins/schemaorg/custom/services/provider.php similarity index 89% rename from plugins/schemaorg/generic/services/provider.php rename to plugins/schemaorg/custom/services/provider.php index 68a766b09350c..ffb9e1767bcbd 100644 --- a/plugins/schemaorg/generic/services/provider.php +++ b/plugins/schemaorg/custom/services/provider.php @@ -2,7 +2,7 @@ /** * @package Joomla.Plugin - * @subpackage Schemaorg.generic + * @subpackage Schemaorg.Custom * * @copyright (C) 2024 Open Source Matters, Inc. * @license GNU General Public License version 2 or later; see LICENSE.txt @@ -16,7 +16,7 @@ use Joomla\DI\Container; use Joomla\DI\ServiceProviderInterface; use Joomla\Event\DispatcherInterface; -use Joomla\Plugin\Schemaorg\Generic\Extension\Generic; +use Joomla\Plugin\Schemaorg\Custom\Extension\Custom; return new class () implements ServiceProviderInterface { /** @@ -34,9 +34,9 @@ public function register(Container $container) PluginInterface::class, function (Container $container) { $dispatcher = $container->get(DispatcherInterface::class); - $plugin = new Generic( + $plugin = new Custom( $dispatcher, - (array) PluginHelper::getPlugin('schemaorg', 'generic') + (array) PluginHelper::getPlugin('schemaorg', 'custom') ); $plugin->setApplication(Factory::getApplication()); diff --git a/plugins/schemaorg/generic/src/Extension/Generic.php b/plugins/schemaorg/custom/src/Extension/Custom.php similarity index 86% rename from plugins/schemaorg/generic/src/Extension/Generic.php rename to plugins/schemaorg/custom/src/Extension/Custom.php index d0750fba172d4..3bdc3448eca4c 100755 --- a/plugins/schemaorg/generic/src/Extension/Generic.php +++ b/plugins/schemaorg/custom/src/Extension/Custom.php @@ -2,13 +2,13 @@ /** * @package Joomla.Plugin - * @subpackage Schemaorg.generic + * @subpackage Schemaorg.Custom * * @copyright (C) 2024 Open Source Matters, Inc. * @license GNU General Public License version 2 or later; see LICENSE.txt */ -namespace Joomla\Plugin\Schemaorg\Generic\Extension; +namespace Joomla\Plugin\Schemaorg\Custom\Extension; use Joomla\CMS\Event\Plugin\System\Schemaorg\BeforeCompileHeadEvent; use Joomla\CMS\Event\Plugin\System\Schemaorg\PrepareSaveEvent; @@ -28,7 +28,7 @@ * * @since __DEPLOY_VERSION__ */ -final class Generic extends CMSPlugin implements SubscriberInterface +final class Custom extends CMSPlugin implements SubscriberInterface { use SchemaorgPluginTrait; @@ -46,7 +46,7 @@ final class Generic extends CMSPlugin implements SubscriberInterface * @var string * @since __DEPLOY_VERSION__ */ - protected $pluginName = 'Generic'; + protected $pluginName = 'Custom'; /** * Returns an array of events this subscriber will listen to. @@ -68,7 +68,7 @@ public function onSchemaPrepareSave(PrepareSaveEvent $event): void { $subject = $event->getData(); - if (empty($subject->schemaType) || $subject->schemaType !== 'Generic' || !isset($subject->schema)) { + if (empty($subject->schemaType) || $subject->schemaType !== 'Custom' || !isset($subject->schema)) { return; } @@ -77,11 +77,11 @@ public function onSchemaPrepareSave(PrepareSaveEvent $event): void $json = (new Registry($schema->get('json')))->toArray(); } catch (\RuntimeException $e) { - throw new \RuntimeException('PLG_SCHEMAORG_GENERIC_JSON_ERROR'); + throw new \RuntimeException('PLG_SCHEMAORG_CUSTOM_JSON_ERROR'); } if (!isset($json['@context']) || $json['@context'] !== 'https://schema.org' || !isset($json['@type'])) { - throw new \RuntimeException(Text::_('PLG_SCHEMAORG_GENERIC_JSON_ERROR')); + throw new \RuntimeException(Text::_('PLG_SCHEMAORG_CUSTOM_JSON_ERROR')); } $schema->set('json', json_encode($json, JSON_PRETTY_PRINT)); @@ -92,7 +92,7 @@ public function onSchemaPrepareSave(PrepareSaveEvent $event): void } /** - * Cleanup all Generic types + * Cleanup all Custom types * * @param BeforeCompileHeadEvent $event The given event * @@ -107,7 +107,7 @@ public function onSchemaBeforeCompileHead(BeforeCompileHeadEvent $event): void $graph = $schema->get('@graph'); foreach ($graph as $i => $entry) { - if (!isset($entry['@type']) || $entry['@type'] !== 'Generic') { + if (!isset($entry['@type']) || $entry['@type'] !== 'Custom') { continue; } From 05d1f73b8f2171d388e35f8607ebbc1747a30232 Mon Sep 17 00:00:00 2001 From: Benjamin Trenkle Date: Tue, 23 Jan 2024 21:39:15 +0100 Subject: [PATCH 10/21] Add plugin to core extensions --- libraries/src/Extension/ExtensionHelper.php | 1 + 1 file changed, 1 insertion(+) diff --git a/libraries/src/Extension/ExtensionHelper.php b/libraries/src/Extension/ExtensionHelper.php index f74d6bed987e9..752c51f24bc9b 100644 --- a/libraries/src/Extension/ExtensionHelper.php +++ b/libraries/src/Extension/ExtensionHelper.php @@ -280,6 +280,7 @@ class ExtensionHelper ['plugin', 'article', 'schemaorg', 0], ['plugin', 'blogposting', 'schemaorg', 0], ['plugin', 'book', 'schemaorg', 0], + ['plugin', 'custom', 'schemaorg', 0], ['plugin', 'event', 'schemaorg', 0], ['plugin', 'jobposting', 'schemaorg', 0], ['plugin', 'organization', 'schemaorg', 0], From bdc054c68a277db591f083e961a8ffa42bc661a7 Mon Sep 17 00:00:00 2001 From: Benjamin Trenkle Date: Tue, 23 Jan 2024 21:41:27 +0100 Subject: [PATCH 11/21] Apply suggestions from code review Co-authored-by: Brian Teeman --- administrator/language/en-GB/plg_schemaorg_custom.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/administrator/language/en-GB/plg_schemaorg_custom.ini b/administrator/language/en-GB/plg_schemaorg_custom.ini index eabc9b00e994d..52f1183bea692 100755 --- a/administrator/language/en-GB/plg_schemaorg_custom.ini +++ b/administrator/language/en-GB/plg_schemaorg_custom.ini @@ -3,7 +3,7 @@ ; License GNU General Public License version 2 or later; see LICENSE.txt ; Note : All ini files need to be saved as UTF-8 -PLG_SCHEMAORG_GENERIC="Schema.org - Generic" +PLG_SCHEMAORG_GENERIC="Schema.org - Custom" PLG_SCHEMAORG_GENEIRC_DESCRIPTION_LABEL="More information on the Schema.org Event Type can be found at https://schema.org/Event" PLG_SCHEMAORG_GENEIRC_XML_DESCRIPTION="Adds a generic field to add any schema type." PLG_SCHEMAORG_GENERIC_DESCRIPTION_LABEL="Use any JSON-LD code here to add currently unsupported schema types." From 1b92f9d355f798375637c787dd5a8b5ddd4d58ed Mon Sep 17 00:00:00 2001 From: Benjamin Trenkle Date: Tue, 23 Jan 2024 21:42:51 +0100 Subject: [PATCH 12/21] Rename generic to custom in language file --- administrator/language/en-GB/plg_schemaorg_custom.ini | 2 +- administrator/language/en-GB/plg_schemaorg_custom.sys.ini | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/administrator/language/en-GB/plg_schemaorg_custom.ini b/administrator/language/en-GB/plg_schemaorg_custom.ini index 52f1183bea692..de9309c31e18a 100755 --- a/administrator/language/en-GB/plg_schemaorg_custom.ini +++ b/administrator/language/en-GB/plg_schemaorg_custom.ini @@ -5,7 +5,7 @@ PLG_SCHEMAORG_GENERIC="Schema.org - Custom" PLG_SCHEMAORG_GENEIRC_DESCRIPTION_LABEL="More information on the Schema.org Event Type can be found at https://schema.org/Event" -PLG_SCHEMAORG_GENEIRC_XML_DESCRIPTION="Adds a generic field to add any schema type." +PLG_SCHEMAORG_GENEIRC_XML_DESCRIPTION="Adds a custom field to add any schema type." PLG_SCHEMAORG_GENERIC_DESCRIPTION_LABEL="Use any JSON-LD code here to add currently unsupported schema types." PLG_SCHEMAORG_GENERIC_JSON_ERROR="The JSON code is not valid or @context or @type is missing." PLG_SCHEMAORG_GENERIC_JSON_FIELD_DESC="Paste the full JSON-LD code here." diff --git a/administrator/language/en-GB/plg_schemaorg_custom.sys.ini b/administrator/language/en-GB/plg_schemaorg_custom.sys.ini index 066262ad2be94..b45eac69c7aa2 100755 --- a/administrator/language/en-GB/plg_schemaorg_custom.sys.ini +++ b/administrator/language/en-GB/plg_schemaorg_custom.sys.ini @@ -4,8 +4,8 @@ ; License GNU General Public License version 2 or later; see LICENSE.txt ; Note : All ini files need to be saved as UTF-8 -PLG_SCHEMAORG_GENERIC="Schema.org - Generic" +PLG_SCHEMAORG_GENERIC="Schema.org - Custom" PLG_SCHEMAORG_GENEIC_DESCRIPTION_LABEL="More information on the Schema.org Event Type can be found at https://schema.org/Event" PLG_SCHEMAORG_GENERIC_FIELD_ADDRESS_LABEL="JSON" -PLG_SCHEMAORG_GENERIC_XML_DESCRIPTION="Adds a generic field to add any schema type." +PLG_SCHEMAORG_GENERIC_XML_DESCRIPTION="Adds a custom field to add any schema type." From c35db76d7c3ae7f08b7ad47cb5e79518521eb432 Mon Sep 17 00:00:00 2001 From: Benjamin Trenkle Date: Tue, 23 Jan 2024 21:47:04 +0100 Subject: [PATCH 13/21] Fix language constants --- .../language/en-GB/plg_schemaorg_custom.ini | 14 +++++++------- .../language/en-GB/plg_schemaorg_custom.sys.ini | 9 ++++----- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/administrator/language/en-GB/plg_schemaorg_custom.ini b/administrator/language/en-GB/plg_schemaorg_custom.ini index de9309c31e18a..80ffad08c1d4f 100755 --- a/administrator/language/en-GB/plg_schemaorg_custom.ini +++ b/administrator/language/en-GB/plg_schemaorg_custom.ini @@ -3,10 +3,10 @@ ; License GNU General Public License version 2 or later; see LICENSE.txt ; Note : All ini files need to be saved as UTF-8 -PLG_SCHEMAORG_GENERIC="Schema.org - Custom" -PLG_SCHEMAORG_GENEIRC_DESCRIPTION_LABEL="More information on the Schema.org Event Type can be found at https://schema.org/Event" -PLG_SCHEMAORG_GENEIRC_XML_DESCRIPTION="Adds a custom field to add any schema type." -PLG_SCHEMAORG_GENERIC_DESCRIPTION_LABEL="Use any JSON-LD code here to add currently unsupported schema types." -PLG_SCHEMAORG_GENERIC_JSON_ERROR="The JSON code is not valid or @context or @type is missing." -PLG_SCHEMAORG_GENERIC_JSON_FIELD_DESC="Paste the full JSON-LD code here." -PLG_SCHEMAORG_GENERIC_JSON_FIELD_LABEL="JSON code" +PLG_SCHEMAORG_CUSTOM="Schema.org - Custom" +PLG_SCHEMAORG_CUSTOM_DESCRIPTION_LABEL="More information on the Schema.org Event Type can be found at https://schema.org/Event" +PLG_SCHEMAORG_CUSTOM_XML_DESCRIPTION="Adds a custom field to add any schema type." +PLG_SCHEMAORG_CUSTOM_DESCRIPTION_LABEL="Use any JSON-LD code here to add currently unsupported schema types." +PLG_SCHEMAORG_CUSTOM_JSON_ERROR="The JSON code is not valid or @context or @type is missing." +PLG_SCHEMAORG_CUSTOM_JSON_FIELD_DESC="Paste the full JSON-LD code here." +PLG_SCHEMAORG_CUSTOM_JSON_FIELD_LABEL="JSON code" diff --git a/administrator/language/en-GB/plg_schemaorg_custom.sys.ini b/administrator/language/en-GB/plg_schemaorg_custom.sys.ini index b45eac69c7aa2..d33168282b5e1 100755 --- a/administrator/language/en-GB/plg_schemaorg_custom.sys.ini +++ b/administrator/language/en-GB/plg_schemaorg_custom.sys.ini @@ -4,8 +4,7 @@ ; License GNU General Public License version 2 or later; see LICENSE.txt ; Note : All ini files need to be saved as UTF-8 -PLG_SCHEMAORG_GENERIC="Schema.org - Custom" -PLG_SCHEMAORG_GENEIC_DESCRIPTION_LABEL="More information on the Schema.org Event Type can be found at https://schema.org/Event" -PLG_SCHEMAORG_GENERIC_FIELD_ADDRESS_LABEL="JSON" -PLG_SCHEMAORG_GENERIC_XML_DESCRIPTION="Adds a custom field to add any schema type." - +PLG_SCHEMAORG_CUSTOM="Schema.org - Custom" +PLG_SCHEMAORG_CUSTOM_DESCRIPTION_LABEL="More information on the Schema.org Event Type can be found at https://schema.org/Event" +PLG_SCHEMAORG_CUSTOM_FIELD_ADDRESS_LABEL="JSON" +PLG_SCHEMAORG_CUSTOM_XML_DESCRIPTION="Adds a custom field to add any schema type." From 13737cb51fb4950025f3b0489ab2e9775698dcea Mon Sep 17 00:00:00 2001 From: Benjamin Trenkle Date: Tue, 23 Jan 2024 21:51:09 +0100 Subject: [PATCH 14/21] Cleanup language strings --- administrator/language/en-GB/plg_schemaorg_custom.ini | 1 - administrator/language/en-GB/plg_schemaorg_custom.sys.ini | 2 -- 2 files changed, 3 deletions(-) diff --git a/administrator/language/en-GB/plg_schemaorg_custom.ini b/administrator/language/en-GB/plg_schemaorg_custom.ini index 80ffad08c1d4f..c2d638c27e8a1 100755 --- a/administrator/language/en-GB/plg_schemaorg_custom.ini +++ b/administrator/language/en-GB/plg_schemaorg_custom.ini @@ -4,7 +4,6 @@ ; Note : All ini files need to be saved as UTF-8 PLG_SCHEMAORG_CUSTOM="Schema.org - Custom" -PLG_SCHEMAORG_CUSTOM_DESCRIPTION_LABEL="More information on the Schema.org Event Type can be found at https://schema.org/Event" PLG_SCHEMAORG_CUSTOM_XML_DESCRIPTION="Adds a custom field to add any schema type." PLG_SCHEMAORG_CUSTOM_DESCRIPTION_LABEL="Use any JSON-LD code here to add currently unsupported schema types." PLG_SCHEMAORG_CUSTOM_JSON_ERROR="The JSON code is not valid or @context or @type is missing." diff --git a/administrator/language/en-GB/plg_schemaorg_custom.sys.ini b/administrator/language/en-GB/plg_schemaorg_custom.sys.ini index d33168282b5e1..69568f944c3ef 100755 --- a/administrator/language/en-GB/plg_schemaorg_custom.sys.ini +++ b/administrator/language/en-GB/plg_schemaorg_custom.sys.ini @@ -5,6 +5,4 @@ ; Note : All ini files need to be saved as UTF-8 PLG_SCHEMAORG_CUSTOM="Schema.org - Custom" -PLG_SCHEMAORG_CUSTOM_DESCRIPTION_LABEL="More information on the Schema.org Event Type can be found at https://schema.org/Event" -PLG_SCHEMAORG_CUSTOM_FIELD_ADDRESS_LABEL="JSON" PLG_SCHEMAORG_CUSTOM_XML_DESCRIPTION="Adds a custom field to add any schema type." From a1ae93d2aba939eb826655b3fe096d1f25d4ac1f Mon Sep 17 00:00:00 2001 From: Benjamin Trenkle Date: Wed, 24 Jan 2024 15:36:06 +0100 Subject: [PATCH 15/21] Code style --- plugins/schemaorg/custom/src/Extension/Custom.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/schemaorg/custom/src/Extension/Custom.php b/plugins/schemaorg/custom/src/Extension/Custom.php index 3bdc3448eca4c..dd2dfbcb25ac4 100755 --- a/plugins/schemaorg/custom/src/Extension/Custom.php +++ b/plugins/schemaorg/custom/src/Extension/Custom.php @@ -26,7 +26,7 @@ /** * Schemaorg Plugin * - * @since __DEPLOY_VERSION__ + * @since __DEPLOY_VERSION__ */ final class Custom extends CMSPlugin implements SubscriberInterface { From 271bc547f3318766a56460584f1659eaf9ae321a Mon Sep 17 00:00:00 2001 From: Benjamin Trenkle Date: Thu, 25 Jan 2024 04:11:39 +0100 Subject: [PATCH 16/21] Update administrator/language/en-GB/plg_schemaorg_custom.ini Co-authored-by: Quy --- administrator/language/en-GB/plg_schemaorg_custom.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/administrator/language/en-GB/plg_schemaorg_custom.ini b/administrator/language/en-GB/plg_schemaorg_custom.ini index c2d638c27e8a1..0594497e12aa0 100755 --- a/administrator/language/en-GB/plg_schemaorg_custom.ini +++ b/administrator/language/en-GB/plg_schemaorg_custom.ini @@ -8,4 +8,4 @@ PLG_SCHEMAORG_CUSTOM_XML_DESCRIPTION="Adds a custom field to add any schema type PLG_SCHEMAORG_CUSTOM_DESCRIPTION_LABEL="Use any JSON-LD code here to add currently unsupported schema types." PLG_SCHEMAORG_CUSTOM_JSON_ERROR="The JSON code is not valid or @context or @type is missing." PLG_SCHEMAORG_CUSTOM_JSON_FIELD_DESC="Paste the full JSON-LD code here." -PLG_SCHEMAORG_CUSTOM_JSON_FIELD_LABEL="JSON code" +PLG_SCHEMAORG_CUSTOM_JSON_FIELD_LABEL="JSON Code" From 133e9ae45db07fcd8498968498445e37324883ea Mon Sep 17 00:00:00 2001 From: Benjamin Trenkle Date: Mon, 5 Feb 2024 21:53:35 +0100 Subject: [PATCH 17/21] Apply suggestions from code review Co-authored-by: Martina Scholz <64533137+LadySolveig@users.noreply.github.com> --- plugins/schemaorg/custom/src/Extension/Custom.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/plugins/schemaorg/custom/src/Extension/Custom.php b/plugins/schemaorg/custom/src/Extension/Custom.php index dd2dfbcb25ac4..73335ead2efa3 100755 --- a/plugins/schemaorg/custom/src/Extension/Custom.php +++ b/plugins/schemaorg/custom/src/Extension/Custom.php @@ -77,11 +77,13 @@ public function onSchemaPrepareSave(PrepareSaveEvent $event): void $json = (new Registry($schema->get('json')))->toArray(); } catch (\RuntimeException $e) { - throw new \RuntimeException('PLG_SCHEMAORG_CUSTOM_JSON_ERROR'); + $this->getApplication()->enqueueMessage(Text::_('PLG_SCHEMAORG_CUSTOM_JSON_ERROR'), 'error'); + return; } - if (!isset($json['@context']) || $json['@context'] !== 'https://schema.org' || !isset($json['@type'])) { - throw new \RuntimeException(Text::_('PLG_SCHEMAORG_CUSTOM_JSON_ERROR')); + if (!isset($json['@context']) || !preg_match('#^https://schema.org/?$#', $json['@context']) || !isset($json['@type'])) { + $this->getApplication()->enqueueMessage(Text::_('PLG_SCHEMAORG_CUSTOM_JSON_ERROR'), 'error'); + return; } $schema->set('json', json_encode($json, JSON_PRETTY_PRINT)); From 9e72b02f7f614e539c7411bc12a1f86808619d58 Mon Sep 17 00:00:00 2001 From: Benjamin Trenkle Date: Wed, 14 Feb 2024 22:06:18 +0100 Subject: [PATCH 18/21] Update schemaorg.xml --- plugins/schemaorg/custom/forms/schemaorg.xml | 1 - 1 file changed, 1 deletion(-) diff --git a/plugins/schemaorg/custom/forms/schemaorg.xml b/plugins/schemaorg/custom/forms/schemaorg.xml index 86fb886bdf1b6..ed5dcff482a71 100755 --- a/plugins/schemaorg/custom/forms/schemaorg.xml +++ b/plugins/schemaorg/custom/forms/schemaorg.xml @@ -29,7 +29,6 @@ name="json" type="textarea" label="PLG_SCHEMAORG_CUSTOM_JSON_FIELD_LABEL" - description="PLG_SCHEMAORG_CUSTOM_JSON_FIELD_DESC" rows="8" /> From 53793d034210e639d4f23ec006431036a8e8cf1c Mon Sep 17 00:00:00 2001 From: Benjamin Trenkle Date: Wed, 14 Feb 2024 22:06:42 +0100 Subject: [PATCH 19/21] Update plg_schemaorg_custom.ini --- administrator/language/en-GB/plg_schemaorg_custom.ini | 1 - 1 file changed, 1 deletion(-) diff --git a/administrator/language/en-GB/plg_schemaorg_custom.ini b/administrator/language/en-GB/plg_schemaorg_custom.ini index 0594497e12aa0..26431d79293ce 100755 --- a/administrator/language/en-GB/plg_schemaorg_custom.ini +++ b/administrator/language/en-GB/plg_schemaorg_custom.ini @@ -7,5 +7,4 @@ PLG_SCHEMAORG_CUSTOM="Schema.org - Custom" PLG_SCHEMAORG_CUSTOM_XML_DESCRIPTION="Adds a custom field to add any schema type." PLG_SCHEMAORG_CUSTOM_DESCRIPTION_LABEL="Use any JSON-LD code here to add currently unsupported schema types." PLG_SCHEMAORG_CUSTOM_JSON_ERROR="The JSON code is not valid or @context or @type is missing." -PLG_SCHEMAORG_CUSTOM_JSON_FIELD_DESC="Paste the full JSON-LD code here." PLG_SCHEMAORG_CUSTOM_JSON_FIELD_LABEL="JSON Code" From 2d03bbba6c7babfc510036fe1c086fbae38627e9 Mon Sep 17 00:00:00 2001 From: Benjamin Trenkle Date: Sun, 25 Feb 2024 00:02:58 +0100 Subject: [PATCH 20/21] Rename 5.1.0-2024-01-18.sql to 5.1.0-2024-02-25.sql --- .../updates/mysql/{5.1.0-2024-01-18.sql => 5.1.0-2024-02-25.sql} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename administrator/components/com_admin/sql/updates/mysql/{5.1.0-2024-01-18.sql => 5.1.0-2024-02-25.sql} (100%) diff --git a/administrator/components/com_admin/sql/updates/mysql/5.1.0-2024-01-18.sql b/administrator/components/com_admin/sql/updates/mysql/5.1.0-2024-02-25.sql similarity index 100% rename from administrator/components/com_admin/sql/updates/mysql/5.1.0-2024-01-18.sql rename to administrator/components/com_admin/sql/updates/mysql/5.1.0-2024-02-25.sql From e9d44681a18d427e9af594730771a38da4ab3729 Mon Sep 17 00:00:00 2001 From: Benjamin Trenkle Date: Sun, 25 Feb 2024 00:03:13 +0100 Subject: [PATCH 21/21] Rename 5.1.0-2024-01-18.sql to 5.1.0-2024-02-25.sql --- .../postgresql/{5.1.0-2024-01-18.sql => 5.1.0-2024-02-25.sql} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename administrator/components/com_admin/sql/updates/postgresql/{5.1.0-2024-01-18.sql => 5.1.0-2024-02-25.sql} (100%) diff --git a/administrator/components/com_admin/sql/updates/postgresql/5.1.0-2024-01-18.sql b/administrator/components/com_admin/sql/updates/postgresql/5.1.0-2024-02-25.sql similarity index 100% rename from administrator/components/com_admin/sql/updates/postgresql/5.1.0-2024-01-18.sql rename to administrator/components/com_admin/sql/updates/postgresql/5.1.0-2024-02-25.sql