JoomlaPolska / jezyk-J4

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

[5.1] Article Schemaorg plugin #451

Closed joomlapl-bot closed 7 months ago

joomlapl-bot commented 10 months ago

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

Click to expand the diff! ```diff diff --git a/administrator/components/com_admin/sql/updates/mysql/5.1.0-2023-11-28.sql b/administrator/components/com_admin/sql/updates/mysql/5.1.0-2023-11-28.sql new file mode 100644 index 0000000000000..98c6889baaa47 --- /dev/null +++ b/administrator/components/com_admin/sql/updates/mysql/5.1.0-2023-11-28.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_article', 'plugin', 'article', 'schemaorg', 0, 1, 1, 0, 0, '', '{}', '', 0, 0); diff --git a/administrator/components/com_admin/sql/updates/postgresql/5.1.0-2023-11-28.sql b/administrator/components/com_admin/sql/updates/postgresql/5.1.0-2023-11-28.sql new file mode 100644 index 0000000000000..523b7057ecc3a --- /dev/null +++ b/administrator/components/com_admin/sql/updates/postgresql/5.1.0-2023-11-28.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_article', 'plugin', 'article', 'schemaorg', 0, 1, 1, 0, 0, '', '{}', '', 0, 0); diff --git a/administrator/language/en-GB/plg_schemaorg_article.ini b/administrator/language/en-GB/plg_schemaorg_article.ini new file mode 100644 index 0000000000000..d4fd8dca6f197 --- /dev/null +++ b/administrator/language/en-GB/plg_schemaorg_article.ini @@ -0,0 +1,28 @@ +; Joomla! Project +; (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_ARTICLE="Schema.org - Article" +PLG_SCHEMAORG_ARTICLE_DESCRIPTION_LABEL="More information on the Schema.org Article Type can be found at https://schema.org/Article" +PLG_SCHEMAORG_ARTICLE_FIELD_ADDRESS_LABEL="Address" +PLG_SCHEMAORG_ARTICLE_FIELD_AUTHOR_LABEL="Author" +PLG_SCHEMAORG_ARTICLE_FIELD_DATE_MODIFIED_LABEL="Date Modified" +PLG_SCHEMAORG_ARTICLE_FIELD_DATE_PUBLISHED_LABEL="Date Published" +PLG_SCHEMAORG_ARTICLE_FIELD_DESCRIPTION_LABEL="Description" +PLG_SCHEMAORG_ARTICLE_FIELD_EMAIL_LABEL="Email" +PLG_SCHEMAORG_ARTICLE_FIELD_GENERIC_FIELD_LABEL="Generic Field" +PLG_SCHEMAORG_ARTICLE_FIELD_GENERIC_TITLE_LABEL="Title" +PLG_SCHEMAORG_ARTICLE_FIELD_GENERIC_VALUE_LABEL="Value" +PLG_SCHEMAORG_ARTICLE_FIELD_HEADLINE_LABEL="Headline" +PLG_SCHEMAORG_ARTICLE_FIELD_IMAGE_LABEL="Image" +PLG_SCHEMAORG_ARTICLE_FIELD_LOCALITY_LABEL="Locality" +PLG_SCHEMAORG_ARTICLE_FIELD_LOGO_LABEL="Logo" +PLG_SCHEMAORG_ARTICLE_FIELD_NAME_LABEL="Name" +PLG_SCHEMAORG_ARTICLE_FIELD_ORGANIZATION_LABEL="Organization" +PLG_SCHEMAORG_ARTICLE_FIELD_PERSON_LABEL="Person" +PLG_SCHEMAORG_ARTICLE_FIELD_POSTAL_CODE_LABEL="Postal Code" +PLG_SCHEMAORG_ARTICLE_FIELD_STREET_ADDRESS_LABEL="Street Address" +PLG_SCHEMAORG_ARTICLE_FIELD_TYPE_LABEL="Type" +PLG_SCHEMAORG_ARTICLE_FIELD_URL_LABEL="Url" +PLG_SCHEMAORG_ARTICLE_XML_DESCRIPTION="Adds Article as a new schema type in existing schemas." diff --git a/administrator/language/en-GB/plg_schemaorg_article.sys.ini b/administrator/language/en-GB/plg_schemaorg_article.sys.ini new file mode 100644 index 0000000000000..c2d56801161fb --- /dev/null +++ b/administrator/language/en-GB/plg_schemaorg_article.sys.ini @@ -0,0 +1,7 @@ +; Joomla! Project +; (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_ARTICLE="Schema.org - Article" +PLG_SCHEMAORG_ARTICLE_XML_DESCRIPTION="Adds Article as a new schema type in existing schemas." diff --git a/installation/sql/mysql/base.sql b/installation/sql/mysql/base.sql index de2267be2bf7b..c34c49dd41e0a 100644 --- a/installation/sql/mysql/base.sql +++ b/installation/sql/mysql/base.sql @@ -333,13 +333,14 @@ INSERT INTO `#__extensions` (`package_id`, `name`, `type`, `element`, `folder`, (0, 'plg_quickicon_eos', 'plugin', 'eos', 'quickicon', 0, 1, 1, 0, 1, '', '', '', 7, 0), (0, 'plg_sampledata_blog', 'plugin', 'blog', 'sampledata', 0, 1, 1, 0, 1, '', '', '', 1, 0), (0, 'plg_sampledata_multilang', 'plugin', 'multilang', 'sampledata', 0, 1, 1, 0, 1, '', '', '', 2, 0), -(0, 'plg_schemaorg_blogposting', 'plugin', 'blogposting', 'schemaorg', 0, 1, 1, 0, 0, '', '{}', '', 1, 0), -(0, 'plg_schemaorg_book', 'plugin', 'book', 'schemaorg', 0, 1, 1, 0, 0, '', '{}', '', 2, 0), -(0, 'plg_schemaorg_event', 'plugin', 'event', 'schemaorg', 0, 1, 1, 0, 0, '', '{}', '', 3, 0), -(0, 'plg_schemaorg_organization', 'plugin', 'organization', 'schemaorg', 0, 1, 1, 0, 0, '', '{}', '', 4, 0), -(0, 'plg_schemaorg_person', 'plugin', 'person', 'schemaorg', 0, 1, 1, 0, 0, '', '{}', '', 5, 0), -(0, 'plg_schemaorg_recipe', 'plugin', 'recipe', 'schemaorg', 0, 1, 1, 0, 0, '', '{}', '', 6, 0), -(0, 'plg_schemaorg_jobposting', 'plugin', 'jobposting', 'schemaorg', 0, 1, 1, 0, 0, '', '{}', '', 7, 0), +(0, 'plg_schemaorg_article', 'plugin', 'article', 'schemaorg', 0, 1, 1, 0, 0, '', '{}', '', 1, 0), +(0, 'plg_schemaorg_blogposting', 'plugin', 'blogposting', 'schemaorg', 0, 1, 1, 0, 0, '', '{}', '', 2, 0), +(0, 'plg_schemaorg_book', 'plugin', 'book', 'schemaorg', 0, 1, 1, 0, 0, '', '{}', '', 3, 0), +(0, 'plg_schemaorg_event', 'plugin', 'event', 'schemaorg', 0, 1, 1, 0, 0, '', '{}', '', 4, 0), +(0, 'plg_schemaorg_jobposting', 'plugin', 'jobposting', 'schemaorg', 0, 1, 1, 0, 0, '', '{}', '', 5, 0), +(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_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 f18dca65ddbdd..435afc0ee2112 100644 --- a/installation/sql/postgresql/base.sql +++ b/installation/sql/postgresql/base.sql @@ -339,13 +339,14 @@ INSERT INTO "#__extensions" ("package_id", "name", "type", "element", "folder", (0, 'plg_quickicon_eos', 'plugin', 'eos', 'quickicon', 0, 1, 1, 0, 1, '', '', '', 7, 0), (0, 'plg_sampledata_blog', 'plugin', 'blog', 'sampledata', 0, 1, 1, 0, 1, '', '', '', 1, 0), (0, 'plg_sampledata_multilang', 'plugin', 'multilang', 'sampledata', 0, 1, 1, 0, 1, '', '', '', 2, 0), -(0, 'plg_schemaorg_blogposting', 'plugin', 'blogposting', 'schemaorg', 0, 1, 1, 0, 0, '', '{}', '', 1, 0), -(0, 'plg_schemaorg_book', 'plugin', 'book', 'schemaorg', 0, 1, 1, 0, 0, '', '{}', '', 2, 0), -(0, 'plg_schemaorg_event', 'plugin', 'event', 'schemaorg', 0, 1, 1, 0, 0, '', '{}', '', 3, 0), -(0, 'plg_schemaorg_organization', 'plugin', 'organization', 'schemaorg', 0, 1, 1, 0, 0, '', '{}', '', 4, 0), -(0, 'plg_schemaorg_person', 'plugin', 'person', 'schemaorg', 0, 1, 1, 0, 0, '', '{}', '', 5, 0), -(0, 'plg_schemaorg_recipe', 'plugin', 'recipe', 'schemaorg', 0, 1, 1, 0, 0, '', '{}', '', 6, 0), -(0, 'plg_schemaorg_jobposting', 'plugin', 'jobposting', 'schemaorg', 0, 1, 1, 0, 0, '', '{}', '', 7, 0), +(0, 'plg_schemaorg_article', 'plugin', 'article', 'schemaorg', 0, 1, 1, 0, 0, '', '{}', '', 1, 0), +(0, 'plg_schemaorg_blogposting', 'plugin', 'blogposting', 'schemaorg', 0, 1, 1, 0, 0, '', '{}', '', 2, 0), +(0, 'plg_schemaorg_book', 'plugin', 'book', 'schemaorg', 0, 1, 1, 0, 0, '', '{}', '', 3, 0), +(0, 'plg_schemaorg_event', 'plugin', 'event', 'schemaorg', 0, 1, 1, 0, 0, '', '{}', '', 4, 0), +(0, 'plg_schemaorg_jobposting', 'plugin', 'jobposting', 'schemaorg', 0, 1, 1, 0, 0, '', '{}', '', 5, 0), +(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_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/libraries/src/Extension/ExtensionHelper.php b/libraries/src/Extension/ExtensionHelper.php index 3e0ac57e16aeb..8757e7616068f 100644 --- a/libraries/src/Extension/ExtensionHelper.php +++ b/libraries/src/Extension/ExtensionHelper.php @@ -277,6 +277,7 @@ class ExtensionHelper ['plugin', 'multilang', 'sampledata', 0], // Core plugin extensions - schemaorg + ['plugin', 'article', 'schemaorg', 0], ['plugin', 'blogposting', 'schemaorg', 0], ['plugin', 'book', 'schemaorg', 0], ['plugin', 'event', 'schemaorg', 0], diff --git a/plugins/schemaorg/article/article.xml b/plugins/schemaorg/article/article.xml new file mode 100644 index 0000000000000..0e38050623cdf --- /dev/null +++ b/plugins/schemaorg/article/article.xml @@ -0,0 +1,43 @@ + + + plg_schemaorg_article + Joomla! Project + 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 + __DEPLOY_VERSION__ + PLG_SCHEMAORG_ARTICLE_XML_DESCRIPTION + Joomla\Plugin\Schemaorg\Article + + services + src + + + language/en-GB/plg_schemaorg_article.ini + language/en-GB/plg_schemaorg_article.sys.ini + + + +
+ + +
+
+
+
diff --git a/plugins/schemaorg/article/forms/schemaorg.xml b/plugins/schemaorg/article/forms/schemaorg.xml new file mode 100644 index 0000000000000..df464544719a1 --- /dev/null +++ b/plugins/schemaorg/article/forms/schemaorg.xml @@ -0,0 +1,199 @@ + +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + +
+ + + + + + + +
+
+
+ diff --git a/plugins/schemaorg/article/services/provider.php b/plugins/schemaorg/article/services/provider.php new file mode 100644 index 0000000000000..fe01212232e01 --- /dev/null +++ b/plugins/schemaorg/article/services/provider.php @@ -0,0 +1,47 @@ + + * @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\Article\Extension\Article; + +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 Article( + $dispatcher, + (array) PluginHelper::getPlugin('schemaorg', 'article') + ); + $plugin->setApplication(Factory::getApplication()); + + return $plugin; + } + ); + } +}; diff --git a/plugins/schemaorg/article/src/Extension/Article.php b/plugins/schemaorg/article/src/Extension/Article.php new file mode 100644 index 0000000000000..71f3cc9d94383 --- /dev/null +++ b/plugins/schemaorg/article/src/Extension/Article.php @@ -0,0 +1,102 @@ + + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace Joomla\Plugin\Schemaorg\Article\Extension; + +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 __DEPLOY_VERSION__ + */ +final class Article extends CMSPlugin implements SubscriberInterface +{ + use SchemaorgPluginTrait; + use SchemaorgPrepareDateTrait; + use SchemaorgPrepareImageTrait; + + /** + * Load the language file on instantiation. + * + * @var boolean + * @since __DEPLOY_VERSION__ + */ + protected $autoloadLanguage = true; + + /** + * The name of the schema form + * + * @var string + * @since __DEPLOY_VERSION__ + */ + protected $pluginName = 'Article'; + + /** + * Returns an array of events this subscriber will listen to. + * + * @return array + * + * @since __DEPLOY_VERSION__ + */ + public static function getSubscribedEvents(): array + { + return [ + 'onSchemaPrepareForm' => 'onSchemaPrepareForm', + 'onSchemaBeforeCompileHead' => ['onSchemaBeforeCompileHead', Priority::BELOW_NORMAL], + ]; + } + + /** + * Cleanup all Article types + * + * @param BeforeCompileHeadEvent $event The given event + * + * @return void + * + * @since __DEPLOY_VERSION__ + */ + public function onSchemaBeforeCompileHead(BeforeCompileHeadEvent $event): void + { + $schema = $event->getSchema(); + + $graph = $schema->get('@graph'); + + foreach ($graph as &$entry) { + if (!isset($entry['@type']) || $entry['@type'] !== 'Article') { + continue; + } + + if (!empty($entry['datePublished'])) { + $entry['datePublished'] = $this->prepareDate($entry['datePublished']); + } + + if (!empty($entry['dateModified'])) { + $entry['dateModified'] = $this->prepareDate($entry['dateModified']); + } + + if (!empty($entry['image'])) { + $entry['image'] = $this->prepareImage($entry['image']); + } + } + + $schema->set('@graph', $graph); + } +} ```
zwiastunsw commented 7 months ago

rozwiązane w 5.0.3