first commit
This commit is contained in:
22
plugins/fields/color/color.xml
Normal file
22
plugins/fields/color/color.xml
Normal file
@ -0,0 +1,22 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<extension type="plugin" group="fields" method="upgrade">
|
||||
<name>plg_fields_color</name>
|
||||
<author>Joomla! Project</author>
|
||||
<creationDate>2016-03</creationDate>
|
||||
<copyright>(C) 2016 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>3.7.0</version>
|
||||
<description>PLG_FIELDS_COLOR_XML_DESCRIPTION</description>
|
||||
<namespace path="src">Joomla\Plugin\Fields\Color</namespace>
|
||||
<files>
|
||||
<folder plugin="color">services</folder>
|
||||
<folder>src</folder>
|
||||
<folder>tmpl</folder>
|
||||
</files>
|
||||
<languages>
|
||||
<language tag="en-GB">language/en-GB/plg_fields_color.ini</language>
|
||||
<language tag="en-GB">language/en-GB/plg_fields_color.sys.ini</language>
|
||||
</languages>
|
||||
</extension>
|
||||
46
plugins/fields/color/services/provider.php
Normal file
46
plugins/fields/color/services/provider.php
Normal file
@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Plugin
|
||||
* @subpackage Fields.color
|
||||
*
|
||||
* @copyright (C) 2023 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\Fields\Color\Extension\Color;
|
||||
|
||||
return new class () implements ServiceProviderInterface {
|
||||
/**
|
||||
* Registers the service provider with a DI container.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 4.3.0
|
||||
*/
|
||||
public function register(Container $container)
|
||||
{
|
||||
$container->set(
|
||||
PluginInterface::class,
|
||||
function (Container $container) {
|
||||
$plugin = new Color(
|
||||
$container->get(DispatcherInterface::class),
|
||||
(array) PluginHelper::getPlugin('fields', 'color')
|
||||
);
|
||||
$plugin->setApplication(Factory::getApplication());
|
||||
|
||||
return $plugin;
|
||||
}
|
||||
);
|
||||
}
|
||||
};
|
||||
51
plugins/fields/color/src/Extension/Color.php
Normal file
51
plugins/fields/color/src/Extension/Color.php
Normal file
@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Plugin
|
||||
* @subpackage Fields.color
|
||||
*
|
||||
* @copyright (C) 2017 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace Joomla\Plugin\Fields\Color\Extension;
|
||||
|
||||
use Joomla\CMS\Form\Form;
|
||||
use Joomla\Component\Fields\Administrator\Plugin\FieldsPlugin;
|
||||
use Joomla\Event\SubscriberInterface;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
/**
|
||||
* Fields Color Plugin
|
||||
*
|
||||
* @since 3.7.0
|
||||
*/
|
||||
final class Color extends FieldsPlugin implements SubscriberInterface
|
||||
{
|
||||
/**
|
||||
* Transforms the field into a DOM XML element and appends it as a child on the given parent.
|
||||
*
|
||||
* @param stdClass $field The field.
|
||||
* @param \DOMElement $parent The field node parent.
|
||||
* @param Form $form The form.
|
||||
*
|
||||
* @return \DOMElement
|
||||
*
|
||||
* @since 3.7.0
|
||||
*/
|
||||
public function onCustomFieldsPrepareDom($field, \DOMElement $parent, Form $form)
|
||||
{
|
||||
$fieldNode = parent::onCustomFieldsPrepareDom($field, $parent, $form);
|
||||
|
||||
if (!$fieldNode) {
|
||||
return $fieldNode;
|
||||
}
|
||||
|
||||
$fieldNode->setAttribute('validate', 'color');
|
||||
|
||||
return $fieldNode;
|
||||
}
|
||||
}
|
||||
23
plugins/fields/color/tmpl/color.php
Normal file
23
plugins/fields/color/tmpl/color.php
Normal file
@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Plugin
|
||||
* @subpackage Fields.Color
|
||||
*
|
||||
* @copyright (C) 2016 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
$value = $field->value;
|
||||
|
||||
if ($value == '') {
|
||||
return;
|
||||
}
|
||||
|
||||
if (is_array($value)) {
|
||||
$value = implode(', ', $value);
|
||||
}
|
||||
|
||||
echo htmlentities($value);
|
||||
Reference in New Issue
Block a user