Skip to content

Commit

Permalink
Merge branch 'base' into blogposting
Browse files Browse the repository at this point in the history
  • Loading branch information
shazmasiddiqui authored Dec 31, 2022
2 parents f36440c + bdc7acb commit 78c903e
Show file tree
Hide file tree
Showing 12 changed files with 389 additions and 2 deletions.
3 changes: 2 additions & 1 deletion administrator/components/com_admin/sql/updates/mysql/4.2.3-2022-12-10.sql
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@ CREATE TABLE IF NOT EXISTS `#__schemaorg` (

-- Add plugins to `#__extensions`
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_blogposting', 'plugin', 'blogposting', 'schemaorg', 0, 1, 1, 0, 0, '', '{}', '', 0, 0);
(0, 'plg_schemaorg_blogposting', 'plugin', 'blogposting', 'schemaorg', 0, 1, 1, 0, 0, '', '{}', '', 0, 0),
(0, 'plg_schemaorg_organization', 'plugin', 'organization', 'schemaorg', 0, 1, 1, 0, 0, '', '{}', '', 0, 0);
3 changes: 2 additions & 1 deletion administrator/components/com_admin/sql/updates/postgresql/4.2.3-2022-12-10.sql
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@ CREATE TABLE IF NOT EXISTS "#__schemaorg"

-- Add plugins to "#__extensions"
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_blogposting', 'plugin', 'blogposting', 'schemaorg', 0, 1, 1, 0, 0, '', '{}', '', 0, 0);
(0, 'plg_schemaorg_blogposting', 'plugin', 'blogposting', 'schemaorg', 0, 1, 1, 0, 0, '', '{}', '', 0, 0),
(0, 'plg_schemaorg_organization', 'plugin', 'organization', 'schemaorg', 0, 1, 1, 0, 0, '', '{}', '', 0, 0);
7 changes: 7 additions & 0 deletions administrator/language/en-GB/joomla.ini
Original file line number Diff line number Diff line change
Expand Up @@ -824,6 +824,13 @@ JWARNING_REMOVE_ROOT_USER_ADMIN="The emergency Root User setting is enabled for
JWARNING_TRASH_MUST_SELECT="You must select at least one item to remove."
JWARNING_UNPUBLISH_MUST_SELECT="You must select at least one item to unpublish."

; Schemaorg
JSCHEMAORG_EXTENSION_ALLOWED_DESCRIPTION="Activate this plugin only for listed extensions. If used all other extensions are disabled."
JSCHEMAORG_EXTENSION_ALLOWED_LABEL="Allowed Extension"
JSCHEMAORG_EXTENSION_FORBIDDEN_DESCRIPTION="Disable this plugin for listed extensions."
JSCHEMAORG_EXTENSION_FORBIDDEN_LABEL="Forbidden Extensions"
JSCHEMAORG_FIELD_COMPONENT_SECTIONS_TEXT="%2$s"

; Workflow
JWORKFLOW="Workflow: %s"
JWORKFLOW_ENABLED_LABEL="Enable Workflow"
Expand Down
14 changes: 14 additions & 0 deletions administrator/language/en-GB/plg_schemaorg_organization.ini
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"
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"
7 changes: 7 additions & 0 deletions api/language/en-GB/joomla.ini
Original file line number Diff line number Diff line change
Expand Up @@ -817,6 +817,13 @@ JWARNING_REMOVE_ROOT_USER_ADMIN="The emergency Root User setting is enabled for
JWARNING_TRASH_MUST_SELECT="You must select at least one item to remove."
JWARNING_UNPUBLISH_MUST_SELECT="You must select at least one item to unpublish."

; Schemaorg
JSCHEMAORG_EXTENSION_ALLOWED_DESCRIPTION="Activate this plugin only for listed extensions. If used all other extensions are disabled."
JSCHEMAORG_EXTENSION_ALLOWED_LABEL="Allowed Extension"
JSCHEMAORG_EXTENSION_FORBIDDEN_DESCRIPTION="Disable this plugin for listed extensions."
JSCHEMAORG_EXTENSION_FORBIDDEN_LABEL="Forbidden Extensions"
JSCHEMAORG_FIELD_COMPONENT_SECTIONS_TEXT="%2$s"

; Workflow
JWORKFLOW="Workflow: %s"
JWORKFLOW_ENABLED_LABEL="Enable Workflow"
Expand Down
1 change: 1 addition & 0 deletions installation/sql/mysql/base.sql
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,7 @@ INSERT INTO `#__extensions` (`package_id`, `name`, `type`, `element`, `folder`,
(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, '', '{}', '', 0, 0),
(0, 'plg_schemaorg_organization', 'plugin', 'organization', 'schemaorg', 0, 1, 1, 0, 0, '', '{}', '', 0, 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),
Expand Down
1 change: 1 addition & 0 deletions installation/sql/postgresql/base.sql
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,7 @@ INSERT INTO "#__extensions" ("package_id", "name", "type", "element", "folder",
(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, '', '{}', '', 0, 0),
(0, 'plg_schemaorg_organization', 'plugin', 'organization', 'schemaorg', 0, 1, 1, 0, 0, '', '{}', '', 0, 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),
Expand Down
43 changes: 43 additions & 0 deletions plugins/schemaorg/organization/organization.xml
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>
48 changes: 48 additions & 0 deletions plugins/schemaorg/organization/services/provider.php
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 plugins/schemaorg/organization/src/Extension/Organization.php
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;
}
}
Loading

0 comments on commit 78c903e

Please sign in to comment.