forked from joomla/joomla-cms
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'base' into blogposting
- Loading branch information
Showing
12 changed files
with
389 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
administrator/language/en-GB/plg_schemaorg_organization.ini
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
PLG_SCHEMAORG_ORGANIZATION_DESCRIPTION_LABEL="A Schema.org Type <a href=\"https://schema.org/Organization\" target=\"_blank\">More information</a>" | ||
PLG_SCHEMAORG_ORGANIZATION_FIELD_ADDRESS_LABEL="Address" | ||
PLG_SCHEMAORG_ORGANIZATION_FIELD_EMAIL_LABEL="Email" | ||
PLG_SCHEMAORG_ORGANIZATION_FIELD_GENERIC_FIELD_LABEL="Generic Field" | ||
PLG_SCHEMAORG_ORGANIZATION_FIELD_GENERIC_TITLE_LABEL="Title" | ||
PLG_SCHEMAORG_ORGANIZATION_FIELD_GENERIC_VALUE_LABEL="Value" | ||
PLG_SCHEMAORG_ORGANIZATION_FIELD_LOCALITY_LABEL="Locality" | ||
PLG_SCHEMAORG_ORGANIZATION_FIELD_LOGO_LABEL="Logo" | ||
PLG_SCHEMAORG_ORGANIZATION_FIELD_NAME_LABEL="Name" | ||
PLG_SCHEMAORG_ORGANIZATION_FIELD_POSTAL_CODE_LABEL="Postal Code" | ||
PLG_SCHEMAORG_ORGANIZATION_FIELD_STREET_ADDRESS_LABEL="Street Address" | ||
PLG_SCHEMAORG_ORGANIZATION_FIELD_URL_LABEL="URL" | ||
PLG_SCHEMAORG_ORGANIZATION_XML_DESCRIPTION="Adds Organization as a new schema type in existing schemas" | ||
PLG_SCHEMAORG_ORGANIZATION="Schema.org Organization Plugin" |
2 changes: 2 additions & 0 deletions
2
administrator/language/en-GB/plg_schemaorg_organization.sys.ini
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
PLG_SCHEMAORG_ORGANIZATION="Schema.org Organization Plugin" | ||
PLG_SCHEMAORG_ORGANIZATION_XML_DESCRIPTION="Adds Organization as a new schema type in existing schemas" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<extension type="plugin" group="schemaorg" method="upgrade"> | ||
<name>plg_schemaorg_organization</name> | ||
<author>Joomla! Project</author> | ||
<creationDate>June 2022</creationDate> | ||
<copyright>(C) 2022 Open Source Matters, Inc.</copyright> | ||
<license>GNU General Public License version 2 or later; see LICENSE.txt</license> | ||
<authorEmail>admin@joomla.org</authorEmail> | ||
<authorUrl>www.joomla.org</authorUrl> | ||
<version>__DEPLOY_VERSION__</version> | ||
<description>PLG_SCHEMAORG_ORGANIZATION_XML_DESCRIPTION</description> | ||
<namespace path="src">Joomla\Plugin\Schemaorg\Organization</namespace> | ||
<files> | ||
<folder plugin="organization">services</folder> | ||
<folder>src</folder> | ||
</files> | ||
<languages> | ||
<language tag="en-GB">language/en-GB/plg_schemaorg_organization.ini</language> | ||
<language tag="en-GB">language/en-GB/plg_schemaorg_organization.sys.ini</language> | ||
</languages> | ||
<config> | ||
<fields name="params"> | ||
<fieldset name="basic"> | ||
<field | ||
name="allowedlist" | ||
type="SchemaorgComponentSections" | ||
label="JSCHEMAORG_EXTENSION_ALLOWED_LABEL" | ||
description="JSCHEMAORG_EXTENSION_ALLOWED_DESCRIPTION" | ||
multiple="multiple" | ||
layout="joomla.form.field.list-fancy-select" | ||
/> | ||
<field | ||
name="forbiddenlist" | ||
type="SchemaorgComponentSections" | ||
label="JSCHEMAORG_EXTENSION_FORBIDDEN_LABEL" | ||
description="JSCHEMAORG_EXTENSION_FORBIDDEN_DESCRIPTION" | ||
multiple="multiple" | ||
layout="joomla.form.field.list-fancy-select" | ||
/> | ||
</fieldset> | ||
</fields> | ||
</config> | ||
</extension> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<?php | ||
|
||
/** | ||
* @package Joomla.Plugin | ||
* @subpackage Schemaorg.organization | ||
* | ||
* @copyright (C) 2022 Open Source Matters, Inc. <https://www.joomla.org> | ||
* @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\Organization\Extension\Organization; | ||
|
||
return new class implements ServiceProviderInterface | ||
{ | ||
/** | ||
* Registers the service provider with a DI container. | ||
* | ||
* @param Container $container The DI container. | ||
* | ||
* @return void | ||
* | ||
* @since 4.2.0 | ||
*/ | ||
public function register(Container $container) | ||
{ | ||
$container->set( | ||
PluginInterface::class, | ||
function (Container $container) { | ||
$dispatcher = $container->get(DispatcherInterface::class); | ||
$plugin = new Organization( | ||
$dispatcher, | ||
(array) PluginHelper::getPlugin('schemaorg', 'organization') | ||
); | ||
$plugin->setApplication(Factory::getApplication()); | ||
|
||
return $plugin; | ||
} | ||
); | ||
} | ||
}; |
144 changes: 144 additions & 0 deletions
144
plugins/schemaorg/organization/src/Extension/Organization.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,144 @@ | ||
<?php | ||
|
||
/** | ||
* @package Joomla.Plugin | ||
* | ||
* @copyright (C) 2022 Open Source Matters, Inc. <https://www.joomla.org> | ||
* @license GNU General Public License version 2 or later; see LICENSE.txt | ||
* @phpcs:disable PSR1.Classes.ClassDeclaration.MissingNamespace | ||
*/ | ||
|
||
namespace Joomla\Plugin\Schemaorg\Organization\Extension; | ||
|
||
use Joomla\CMS\Application\CMSApplicationInterface; | ||
use Joomla\CMS\Form\Form; | ||
use Joomla\CMS\Plugin\CMSPlugin; | ||
use Joomla\CMS\Schemaorg\SchemaorgPluginTrait; | ||
use Joomla\CMS\Event\AbstractEvent; | ||
use Joomla\Event\SubscriberInterface; | ||
|
||
// phpcs:disable PSR1.Files.SideEffects | ||
\defined('_JEXEC') or die; | ||
// phpcs:enable PSR1.Files.SideEffects | ||
|
||
/** | ||
* Schemaorg Plugin | ||
* | ||
* @since 4.0.0 | ||
*/ | ||
final class Organization extends CMSPlugin implements SubscriberInterface | ||
{ | ||
use SchemaorgPluginTrait; | ||
|
||
/** | ||
* @var \Joomla\Database\DatabaseDriver | ||
* | ||
*/ | ||
protected $db; | ||
|
||
/** | ||
* Load the language file on instantiation. | ||
* | ||
* @var boolean | ||
* @since 4.0.0 | ||
*/ | ||
protected $autoloadLanguage = true; | ||
|
||
/** | ||
* Loads the CMS Application for direct access | ||
* | ||
* @var CMSApplicationInterface | ||
* @since 4.0.0 | ||
*/ | ||
protected $app; | ||
|
||
/** | ||
* The name of the supported name to check against | ||
* | ||
* @var string | ||
* @since 4.0.0 | ||
*/ | ||
protected $supportFunctionality = 'core.state'; | ||
|
||
/** | ||
* The name of the schema form | ||
* | ||
* @var string | ||
* @since 4.0.0 | ||
*/ | ||
protected $pluginName = 'Organization'; | ||
|
||
/** | ||
* Returns an array of events this subscriber will listen to. | ||
* | ||
* @return array | ||
* | ||
* @since 4.0.0 | ||
*/ | ||
public static function getSubscribedEvents(): array | ||
{ | ||
return [ | ||
'onSchemaPrepareData' => 'onSchemaPrepareData', | ||
'onSchemaPrepareForm' => 'onSchemaPrepareForm', | ||
'onSchemaAfterSave' => 'onSchemaAfterSave', | ||
'onSchemaBeforeCompileHead' => 'pushSchema', | ||
]; | ||
} | ||
|
||
/** | ||
* Update existing schema form with data from database | ||
* | ||
* @param $data The form to be altered. | ||
* | ||
* @return boolean | ||
*/ | ||
public function onSchemaPrepareData(AbstractEvent $event) | ||
{ | ||
$context = $event->getArgument('context'); | ||
if (!$this->isSupported($context) || !$this->isSchemaSupported($event)) { | ||
return false; | ||
} | ||
$this->updateSchemaForm($event); | ||
return true; | ||
} | ||
|
||
/** | ||
* Add a new option to the schema type in the article editing page | ||
* | ||
* @param Form $form The form to be altered. | ||
* | ||
* @return boolean | ||
*/ | ||
public function onSchemaPrepareForm(AbstractEvent $event) | ||
{ | ||
$form = $event->getArgument('subject'); | ||
$context = $form->getName(); | ||
if (!$this->isSupported($context)) { | ||
return false; | ||
} | ||
$this->addSchemaType($event); | ||
//Load the form fields | ||
$form->loadFile(JPATH_PLUGINS . '/' . $this->_type . '/' . $this->_name . '/src/forms/schemaorg.xml'); | ||
return true; | ||
} | ||
|
||
/** | ||
* Saves the schema to the database | ||
* | ||
* @param AbstractEvent $event | ||
* | ||
* @return boolean | ||
*/ | ||
public function onSchemaAfterSave(AbstractEvent $event) | ||
{ | ||
$data = $event->getArgument('data')->toArray(); | ||
$form = $data['schema']['schemaType']; | ||
|
||
if ($form != $this->pluginName) { | ||
return false; | ||
} | ||
$this->storeSchemaToStandardLocation($event); | ||
return true; | ||
} | ||
} |
Oops, something went wrong.