Skip to content

Commit ae47b89

Browse files
authored
[5.1] Schemaorg => Custom plugin (#42699)
1 parent c3800db commit ae47b89

File tree

11 files changed

+282
-0
lines changed

11 files changed

+282
-0
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
INSERT INTO `#__extensions` (`package_id`, `name`, `type`, `element`, `folder`, `client_id`, `enabled`, `access`, `protected`, `locked`, `manifest_cache`, `params`, `custom_data`, `ordering`, `state`) VALUES
2+
(0, 'plg_schemaorg_custom', 'plugin', 'custom', 'schemaorg', 0, 1, 1, 0, 0, '', '{}', '', 0, 0);
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
INSERT INTO "#__extensions" ("package_id", "name", "type", "element", "folder", "client_id", "enabled", "access", "protected", "locked", "manifest_cache", "params", "custom_data", "ordering", "state") VALUES
2+
(0, 'plg_schemaorg_custom', 'plugin', 'custom', 'schemaorg', 0, 1, 1, 0, 0, '', '{}', '', 0, 0);
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
; Joomla! Project
2+
; (C) 2024 Open Source Matters, Inc. <https://www.joomla.org>
3+
; License GNU General Public License version 2 or later; see LICENSE.txt
4+
; Note : All ini files need to be saved as UTF-8
5+
6+
PLG_SCHEMAORG_CUSTOM="Schema.org - Custom"
7+
PLG_SCHEMAORG_CUSTOM_XML_DESCRIPTION="Adds a custom field to add any schema type."
8+
PLG_SCHEMAORG_CUSTOM_DESCRIPTION_LABEL="Use any JSON-LD code here to add currently unsupported schema types."
9+
PLG_SCHEMAORG_CUSTOM_JSON_ERROR="The JSON code is not valid or @context or @type is missing."
10+
PLG_SCHEMAORG_CUSTOM_JSON_FIELD_LABEL="JSON Code"
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
; Joomla! Project
2+
; (C) 2024 Open Source Matters, Inc. <https://www.joomla.org>
3+
4+
; License GNU General Public License version 2 or later; see LICENSE.txt
5+
; Note : All ini files need to be saved as UTF-8
6+
7+
PLG_SCHEMAORG_CUSTOM="Schema.org - Custom"
8+
PLG_SCHEMAORG_CUSTOM_XML_DESCRIPTION="Adds a custom field to add any schema type."

installation/sql/mysql/base.sql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,7 @@ INSERT INTO `#__extensions` (`package_id`, `name`, `type`, `element`, `folder`,
341341
(0, 'plg_schemaorg_organization', 'plugin', 'organization', 'schemaorg', 0, 1, 1, 0, 0, '', '{}', '', 6, 0),
342342
(0, 'plg_schemaorg_person', 'plugin', 'person', 'schemaorg', 0, 1, 1, 0, 0, '', '{}', '', 7, 0),
343343
(0, 'plg_schemaorg_recipe', 'plugin', 'recipe', 'schemaorg', 0, 1, 1, 0, 0, '', '{}', '', 8, 0),
344+
(0, 'plg_schemaorg_custom', 'plugin', 'custom', 'schemaorg', 0, 1, 1, 0, 0, '', '{}', '', 9, 0),
344345
(0, 'plg_system_accessibility', 'plugin', 'accessibility', 'system', 0, 0, 1, 0, 1, '', '{}', '', 1, 0),
345346
(0, 'plg_system_actionlogs', 'plugin', 'actionlogs', 'system', 0, 1, 1, 0, 1, '', '{}', '', 2, 0),
346347
(0, 'plg_system_cache', 'plugin', 'cache', 'system', 0, 0, 1, 0, 1, '', '{"browsercache":"0","cachetime":"15"}', '', 3, 0),

installation/sql/postgresql/base.sql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,7 @@ INSERT INTO "#__extensions" ("package_id", "name", "type", "element", "folder",
347347
(0, 'plg_schemaorg_organization', 'plugin', 'organization', 'schemaorg', 0, 1, 1, 0, 0, '', '{}', '', 6, 0),
348348
(0, 'plg_schemaorg_person', 'plugin', 'person', 'schemaorg', 0, 1, 1, 0, 0, '', '{}', '', 7, 0),
349349
(0, 'plg_schemaorg_recipe', 'plugin', 'recipe', 'schemaorg', 0, 1, 1, 0, 0, '', '{}', '', 8, 0),
350+
(0, 'plg_schemaorg_custom', 'plugin', 'custom', 'schemaorg', 0, 1, 1, 0, 0, '', '{}', '', 9, 0),
350351
(0, 'plg_system_accessibility', 'plugin', 'accessibility', 'system', 0, 0, 1, 0, 1, '', '{}', '', 1, 0),
351352
(0, 'plg_system_actionlogs', 'plugin', 'actionlogs', 'system', 0, 1, 1, 0, 1, '', '{}', '', 2, 0),
352353
(0, 'plg_system_cache', 'plugin', 'cache', 'system', 0, 0, 1, 0, 1, '', '{"browsercache":"0","cachetime":"15"}', '', 3, 0),

libraries/src/Extension/ExtensionHelper.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,7 @@ class ExtensionHelper
280280
['plugin', 'article', 'schemaorg', 0],
281281
['plugin', 'blogposting', 'schemaorg', 0],
282282
['plugin', 'book', 'schemaorg', 0],
283+
['plugin', 'custom', 'schemaorg', 0],
283284
['plugin', 'event', 'schemaorg', 0],
284285
['plugin', 'jobposting', 'schemaorg', 0],
285286
['plugin', 'organization', 'schemaorg', 0],
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<extension type="plugin" group="schemaorg" method="upgrade">
3+
<name>plg_schemaorg_custom</name>
4+
<author>Joomla! Project</author>
5+
<creationDate>2024-01</creationDate>
6+
<copyright>(C) 2024 Open Source Matters, Inc.</copyright>
7+
<license>GNU General Public License version 2 or later; see LICENSE.txt</license>
8+
<authorEmail>[email protected]</authorEmail>
9+
<authorUrl>www.joomla.org</authorUrl>
10+
<version>__DEPLOY_VERSION__</version>
11+
<description>PLG_SCHEMAORG_CUSTOM_XML_DESCRIPTION</description>
12+
<namespace path="src">Joomla\Plugin\Schemaorg\Custom</namespace>
13+
<files>
14+
<folder plugin="custom">services</folder>
15+
<folder>src</folder>
16+
</files>
17+
<languages>
18+
<language tag="en-GB">language/en-GB/plg_schemaorg_custom.ini</language>
19+
<language tag="en-GB">language/en-GB/plg_schemaorg_custom.sys.ini</language>
20+
</languages>
21+
<config>
22+
<fields name="params">
23+
<fieldset name="basic">
24+
<field
25+
name="allowedlist"
26+
type="SchemaorgComponentSections"
27+
label="JSCHEMAORG_EXTENSION_ALLOWED_LABEL"
28+
description="JSCHEMAORG_EXTENSION_ALLOWED_DESCRIPTION"
29+
multiple="multiple"
30+
layout="joomla.form.field.list-fancy-select"
31+
/>
32+
<field
33+
name="forbiddenlist"
34+
type="SchemaorgComponentSections"
35+
label="JSCHEMAORG_EXTENSION_FORBIDDEN_LABEL"
36+
description="JSCHEMAORG_EXTENSION_FORBIDDEN_DESCRIPTION"
37+
multiple="multiple"
38+
layout="joomla.form.field.list-fancy-select"
39+
/>
40+
</fieldset>
41+
</fields>
42+
</config>
43+
</extension>
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<form>
3+
<fields name="schema">
4+
<fieldset
5+
name="schema"
6+
label="PLG_SYSTEM_SCHEMA_FIELD_SCHEMA_LABEL"
7+
>
8+
<field
9+
name="Custom"
10+
type="subform"
11+
showon="schemaType:Custom"
12+
>
13+
<form>
14+
15+
<field
16+
name="@type"
17+
type="hidden"
18+
default="Custom"
19+
/>
20+
21+
<field
22+
name="noteCustom"
23+
type="note"
24+
description="PLG_SCHEMAORG_CUSTOM_DESCRIPTION_LABEL"
25+
class="alert alert-info w-100"
26+
/>
27+
28+
<field
29+
name="json"
30+
type="textarea"
31+
label="PLG_SCHEMAORG_CUSTOM_JSON_FIELD_LABEL"
32+
rows="8"
33+
/>
34+
35+
</form>
36+
</field>
37+
</fieldset>
38+
</fields>
39+
</form>
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<?php
2+
3+
/**
4+
* @package Joomla.Plugin
5+
* @subpackage Schemaorg.Custom
6+
*
7+
* @copyright (C) 2024 Open Source Matters, Inc. <https://www.joomla.org>
8+
* @license GNU General Public License version 2 or later; see LICENSE.txt
9+
*/
10+
11+
\defined('_JEXEC') or die;
12+
13+
use Joomla\CMS\Extension\PluginInterface;
14+
use Joomla\CMS\Factory;
15+
use Joomla\CMS\Plugin\PluginHelper;
16+
use Joomla\DI\Container;
17+
use Joomla\DI\ServiceProviderInterface;
18+
use Joomla\Event\DispatcherInterface;
19+
use Joomla\Plugin\Schemaorg\Custom\Extension\Custom;
20+
21+
return new class () implements ServiceProviderInterface {
22+
/**
23+
* Registers the service provider with a DI container.
24+
*
25+
* @param Container $container The DI container.
26+
*
27+
* @return void
28+
*
29+
* @since __DEPLOY_VERSION__
30+
*/
31+
public function register(Container $container)
32+
{
33+
$container->set(
34+
PluginInterface::class,
35+
function (Container $container) {
36+
$dispatcher = $container->get(DispatcherInterface::class);
37+
$plugin = new Custom(
38+
$dispatcher,
39+
(array) PluginHelper::getPlugin('schemaorg', 'custom')
40+
);
41+
42+
$plugin->setApplication(Factory::getApplication());
43+
44+
return $plugin;
45+
}
46+
);
47+
}
48+
};

0 commit comments

Comments
 (0)