first commit
This commit is contained in:
23
plugins/fields/calendar/calendar.xml
Normal file
23
plugins/fields/calendar/calendar.xml
Normal file
@ -0,0 +1,23 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<extension type="plugin" group="fields" method="upgrade">
|
||||
<name>plg_fields_calendar</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_CALENDAR_XML_DESCRIPTION</description>
|
||||
<namespace path="src">Joomla\Plugin\Fields\Calendar</namespace>
|
||||
<files>
|
||||
<folder>params</folder>
|
||||
<folder plugin="calendar">services</folder>
|
||||
<folder>src</folder>
|
||||
<folder>tmpl</folder>
|
||||
</files>
|
||||
<languages>
|
||||
<language tag="en-GB">language/en-GB/plg_fields_calendar.ini</language>
|
||||
<language tag="en-GB">language/en-GB/plg_fields_calendar.sys.ini</language>
|
||||
</languages>
|
||||
</extension>
|
||||
19
plugins/fields/calendar/params/calendar.xml
Normal file
19
plugins/fields/calendar/params/calendar.xml
Normal file
@ -0,0 +1,19 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<form>
|
||||
<fields name="fieldparams">
|
||||
<fieldset name="fieldparams">
|
||||
<field
|
||||
name="showtime"
|
||||
type="radio"
|
||||
label="PLG_FIELDS_CALENDAR_PARAMS_SHOWTIME_LABEL"
|
||||
description="PLG_FIELDS_CALENDAR_PARAMS_SHOWTIME_DESC"
|
||||
layout="joomla.form.field.radio.switcher"
|
||||
default="0"
|
||||
filter="integer"
|
||||
>
|
||||
<option value="0">JNO</option>
|
||||
<option value="1">JYES</option>
|
||||
</field>
|
||||
</fieldset>
|
||||
</fields>
|
||||
</form>
|
||||
46
plugins/fields/calendar/services/provider.php
Normal file
46
plugins/fields/calendar/services/provider.php
Normal file
@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Plugin
|
||||
* @subpackage Fields.calendar
|
||||
*
|
||||
* @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\Calendar\Extension\Calendar;
|
||||
|
||||
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 Calendar(
|
||||
$container->get(DispatcherInterface::class),
|
||||
(array) PluginHelper::getPlugin('fields', 'calendar')
|
||||
);
|
||||
$plugin->setApplication(Factory::getApplication());
|
||||
|
||||
return $plugin;
|
||||
}
|
||||
);
|
||||
}
|
||||
};
|
||||
56
plugins/fields/calendar/src/Extension/Calendar.php
Normal file
56
plugins/fields/calendar/src/Extension/Calendar.php
Normal file
@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Plugin
|
||||
* @subpackage Fields.calendar
|
||||
*
|
||||
* @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\Calendar\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 Calendar Plugin
|
||||
*
|
||||
* @since 3.7.0
|
||||
*/
|
||||
final class Calendar 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;
|
||||
}
|
||||
|
||||
// Set filter to user UTC
|
||||
$fieldNode->setAttribute('filter', 'USER_UTC');
|
||||
|
||||
// Set field to use translated formats
|
||||
$fieldNode->setAttribute('translateformat', '1');
|
||||
$fieldNode->setAttribute('showtime', $field->fieldparams->get('showtime', 0) ? 'true' : 'false');
|
||||
|
||||
return $fieldNode;
|
||||
}
|
||||
}
|
||||
28
plugins/fields/calendar/tmpl/calendar.php
Normal file
28
plugins/fields/calendar/tmpl/calendar.php
Normal file
@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Plugin
|
||||
* @subpackage Fields.Calendar
|
||||
*
|
||||
* @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;
|
||||
|
||||
use Joomla\CMS\HTML\HTMLHelper;
|
||||
use Joomla\CMS\Language\Text;
|
||||
|
||||
$value = $field->value;
|
||||
|
||||
if ($value == '') {
|
||||
return;
|
||||
}
|
||||
|
||||
if (is_array($value)) {
|
||||
$value = implode(', ', $value);
|
||||
}
|
||||
|
||||
$formatString = $field->fieldparams->get('showtime', 0) ? 'DATE_FORMAT_LC5' : 'DATE_FORMAT_LC4';
|
||||
|
||||
echo htmlentities(HTMLHelper::_('date', $value, Text::_($formatString)));
|
||||
51
plugins/fields/checkboxes/checkboxes.xml
Normal file
51
plugins/fields/checkboxes/checkboxes.xml
Normal file
@ -0,0 +1,51 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<extension type="plugin" group="fields" method="upgrade">
|
||||
<name>plg_fields_checkboxes</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_CHECKBOXES_XML_DESCRIPTION</description>
|
||||
<namespace path="src">Joomla\Plugin\Fields\Checkboxes</namespace>
|
||||
<files>
|
||||
<folder>params</folder>
|
||||
<folder plugin="checkboxes">services</folder>
|
||||
<folder>src</folder>
|
||||
<folder>tmpl</folder>
|
||||
</files>
|
||||
<languages>
|
||||
<language tag="en-GB">language/en-GB/plg_fields_checkboxes.ini</language>
|
||||
<language tag="en-GB">language/en-GB/plg_fields_checkboxes.sys.ini</language>
|
||||
</languages>
|
||||
<config>
|
||||
<fields name="params">
|
||||
<fieldset name="basic">
|
||||
<field
|
||||
name="options"
|
||||
type="subform"
|
||||
label="PLG_FIELDS_CHECKBOXES_PARAMS_OPTIONS_LABEL"
|
||||
layout="joomla.form.field.subform.repeatable-table"
|
||||
icon="list"
|
||||
multiple="true"
|
||||
>
|
||||
<form hidden="true" name="list_templates_modal" repeat="true">
|
||||
<field
|
||||
name="name"
|
||||
type="text"
|
||||
label="PLG_FIELDS_CHECKBOXES_PARAMS_OPTIONS_NAME_LABEL"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="value"
|
||||
type="text"
|
||||
label="PLG_FIELDS_CHECKBOXES_PARAMS_OPTIONS_VALUE_LABEL"
|
||||
/>
|
||||
</form>
|
||||
</field>
|
||||
</fieldset>
|
||||
</fields>
|
||||
</config>
|
||||
</extension>
|
||||
30
plugins/fields/checkboxes/params/checkboxes.xml
Normal file
30
plugins/fields/checkboxes/params/checkboxes.xml
Normal file
@ -0,0 +1,30 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<form>
|
||||
<fields name="fieldparams">
|
||||
<fieldset name="fieldparams">
|
||||
<field
|
||||
name="options"
|
||||
type="subform"
|
||||
label="PLG_FIELDS_CHECKBOXES_PARAMS_OPTIONS_LABEL"
|
||||
layout="joomla.form.field.subform.repeatable-table"
|
||||
icon="list"
|
||||
multiple="true"
|
||||
>
|
||||
<form hidden="true" name="list_templates_modal" repeat="true">
|
||||
<field
|
||||
name="name"
|
||||
type="text"
|
||||
label="PLG_FIELDS_CHECKBOXES_PARAMS_OPTIONS_NAME_LABEL"
|
||||
required="true"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="value"
|
||||
type="text"
|
||||
label="PLG_FIELDS_CHECKBOXES_PARAMS_OPTIONS_VALUE_LABEL"
|
||||
/>
|
||||
</form>
|
||||
</field>
|
||||
</fieldset>
|
||||
</fields>
|
||||
</form>
|
||||
46
plugins/fields/checkboxes/services/provider.php
Normal file
46
plugins/fields/checkboxes/services/provider.php
Normal file
@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Plugin
|
||||
* @subpackage Fields.checkboxes
|
||||
*
|
||||
* @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\Checkboxes\Extension\Checkboxes;
|
||||
|
||||
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 Checkboxes(
|
||||
$container->get(DispatcherInterface::class),
|
||||
(array) PluginHelper::getPlugin('fields', 'checkboxes')
|
||||
);
|
||||
$plugin->setApplication(Factory::getApplication());
|
||||
|
||||
return $plugin;
|
||||
}
|
||||
);
|
||||
}
|
||||
};
|
||||
63
plugins/fields/checkboxes/src/Extension/Checkboxes.php
Normal file
63
plugins/fields/checkboxes/src/Extension/Checkboxes.php
Normal file
@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Plugin
|
||||
* @subpackage Fields.checkboxes
|
||||
*
|
||||
* @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\Checkboxes\Extension;
|
||||
|
||||
use Joomla\Component\Fields\Administrator\Plugin\FieldsListPlugin;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
/**
|
||||
* Fields Checkboxes Plugin
|
||||
*
|
||||
* @since 3.7.0
|
||||
*/
|
||||
final class Checkboxes extends FieldsListPlugin
|
||||
{
|
||||
/**
|
||||
* Before prepares the field value.
|
||||
*
|
||||
* @param string $context The context.
|
||||
* @param \stdclass $item The item.
|
||||
* @param \stdclass $field The field.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 3.7.0
|
||||
*/
|
||||
public function onCustomFieldsBeforePrepareField($context, $item, $field)
|
||||
{
|
||||
if (!$this->getApplication()->isClient('api')) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!$this->isTypeSupported($field->type)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$field->apivalue = [];
|
||||
|
||||
$options = $this->getOptionsFromField($field);
|
||||
|
||||
if (empty($field->value)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (\is_array($field->value)) {
|
||||
foreach ($field->value as $key => $value) {
|
||||
$field->apivalue[$value] = $options[$value];
|
||||
}
|
||||
} else {
|
||||
$field->apivalue[$field->value] = $options[$field->value];
|
||||
}
|
||||
}
|
||||
}
|
||||
31
plugins/fields/checkboxes/tmpl/checkboxes.php
Normal file
31
plugins/fields/checkboxes/tmpl/checkboxes.php
Normal file
@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Plugin
|
||||
* @subpackage Fields.Checkboxes
|
||||
*
|
||||
* @copyright (C) 2017 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\Language\Text;
|
||||
|
||||
$fieldValue = $field->value;
|
||||
|
||||
if ($fieldValue === '' || $fieldValue === null) {
|
||||
return;
|
||||
}
|
||||
|
||||
$fieldValue = (array) $fieldValue;
|
||||
$texts = [];
|
||||
$options = $this->getOptionsFromField($field);
|
||||
|
||||
foreach ($options as $value => $name) {
|
||||
if (in_array((string) $value, $fieldValue)) {
|
||||
$texts[] = Text::_($name);
|
||||
}
|
||||
}
|
||||
|
||||
echo htmlentities(implode(', ', $texts));
|
||||
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);
|
||||
77
plugins/fields/editor/editor.xml
Normal file
77
plugins/fields/editor/editor.xml
Normal file
@ -0,0 +1,77 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<extension type="plugin" group="fields" method="upgrade">
|
||||
<name>plg_fields_editor</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_EDITOR_XML_DESCRIPTION</description>
|
||||
<namespace path="src">Joomla\Plugin\Fields\Editor</namespace>
|
||||
<files>
|
||||
<folder>params</folder>
|
||||
<folder plugin="editor">services</folder>
|
||||
<folder>src</folder>
|
||||
<folder>tmpl</folder>
|
||||
</files>
|
||||
<languages>
|
||||
<language tag="en-GB">language/en-GB/plg_fields_editor.ini</language>
|
||||
<language tag="en-GB">language/en-GB/plg_fields_editor.sys.ini</language>
|
||||
</languages>
|
||||
<config>
|
||||
<fields name="params">
|
||||
<fieldset name="basic">
|
||||
<field
|
||||
name="buttons"
|
||||
type="radio"
|
||||
label="PLG_FIELDS_EDITOR_PARAMS_SHOW_BUTTONS_LABEL"
|
||||
layout="joomla.form.field.radio.switcher"
|
||||
default="0"
|
||||
filter="integer"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="hide"
|
||||
type="plugins"
|
||||
label="PLG_FIELDS_EDITOR_PARAMS_BUTTONS_HIDE_LABEL"
|
||||
folder="editors-xtd"
|
||||
multiple="true"
|
||||
layout="joomla.form.field.list-fancy-select"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="width"
|
||||
type="text"
|
||||
label="PLG_FIELDS_EDITOR_PARAMS_WIDTH_LABEL"
|
||||
default="100%"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="height"
|
||||
type="text"
|
||||
label="PLG_FIELDS_EDITOR_PARAMS_HEIGHT_LABEL"
|
||||
default="250px"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="filter"
|
||||
type="list"
|
||||
label="PLG_FIELDS_EDITOR_PARAMS_FILTER_LABEL"
|
||||
class="list"
|
||||
default="\Joomla\CMS\Component\ComponentHelper::filterText"
|
||||
validate="options"
|
||||
>
|
||||
<option value="0">JNO</option>
|
||||
<option value="raw">JLIB_FILTER_PARAMS_RAW</option>
|
||||
<option value="safehtml">JLIB_FILTER_PARAMS_SAFEHTML</option>
|
||||
<option value="\Joomla\CMS\Component\ComponentHelper::filterText">JLIB_FILTER_PARAMS_TEXT</option>
|
||||
</field>
|
||||
</fieldset>
|
||||
</fields>
|
||||
</config>
|
||||
</extension>
|
||||
53
plugins/fields/editor/params/editor.xml
Normal file
53
plugins/fields/editor/params/editor.xml
Normal file
@ -0,0 +1,53 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<form>
|
||||
<fields name="fieldparams">
|
||||
<fieldset name="fieldparams">
|
||||
<field
|
||||
name="buttons"
|
||||
type="list"
|
||||
label="PLG_FIELDS_EDITOR_PARAMS_SHOW_BUTTONS_LABEL"
|
||||
filter="integer"
|
||||
validate="options"
|
||||
>
|
||||
<option value="">COM_FIELDS_FIELD_USE_GLOBAL</option>
|
||||
<option value="1">JYES</option>
|
||||
<option value="0">JNO</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="hide"
|
||||
type="plugins"
|
||||
label="PLG_FIELDS_EDITOR_PARAMS_BUTTONS_HIDE_LABEL"
|
||||
folder="editors-xtd"
|
||||
multiple="true"
|
||||
layout="joomla.form.field.list-fancy-select"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="width"
|
||||
type="text"
|
||||
label="PLG_FIELDS_EDITOR_PARAMS_WIDTH_LABEL"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="height"
|
||||
type="text"
|
||||
label="PLG_FIELDS_EDITOR_PARAMS_HEIGHT_LABEL"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="filter"
|
||||
type="list"
|
||||
label="PLG_FIELDS_TEXT_PARAMS_FILTER_LABEL"
|
||||
class="list"
|
||||
validate="options"
|
||||
>
|
||||
<option value="">COM_FIELDS_FIELD_USE_GLOBAL</option>
|
||||
<option value="0">JNO</option>
|
||||
<option value="raw">JLIB_FILTER_PARAMS_RAW</option>
|
||||
<option value="safehtml">JLIB_FILTER_PARAMS_SAFEHTML</option>
|
||||
<option value="\Joomla\CMS\Component\ComponentHelper::filterText">JLIB_FILTER_PARAMS_TEXT</option>
|
||||
</field>
|
||||
</fieldset>
|
||||
</fields>
|
||||
</form>
|
||||
46
plugins/fields/editor/services/provider.php
Normal file
46
plugins/fields/editor/services/provider.php
Normal file
@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Plugin
|
||||
* @subpackage Fields.editor
|
||||
*
|
||||
* @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\Editor\Extension\Editor;
|
||||
|
||||
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 Editor(
|
||||
$container->get(DispatcherInterface::class),
|
||||
(array) PluginHelper::getPlugin('fields', 'editor')
|
||||
);
|
||||
$plugin->setApplication(Factory::getApplication());
|
||||
|
||||
return $plugin;
|
||||
}
|
||||
);
|
||||
}
|
||||
};
|
||||
52
plugins/fields/editor/src/Extension/Editor.php
Normal file
52
plugins/fields/editor/src/Extension/Editor.php
Normal file
@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Plugin
|
||||
* @subpackage Fields.editor
|
||||
*
|
||||
* @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\Editor\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 Editor Plugin
|
||||
*
|
||||
* @since 3.7.0
|
||||
*/
|
||||
final class Editor 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('buttons', $field->fieldparams->get('buttons', $this->params->get('buttons', 0)) ? 'true' : 'false');
|
||||
$fieldNode->setAttribute('hide', implode(',', $field->fieldparams->get('hide', [])));
|
||||
|
||||
return $fieldNode;
|
||||
}
|
||||
}
|
||||
21
plugins/fields/editor/tmpl/editor.php
Normal file
21
plugins/fields/editor/tmpl/editor.php
Normal file
@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Plugin
|
||||
* @subpackage Fields.Editor
|
||||
*
|
||||
* @copyright (C) 2017 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\HTML\HTMLHelper;
|
||||
|
||||
$value = $field->value;
|
||||
|
||||
if ($value == '') {
|
||||
return;
|
||||
}
|
||||
|
||||
echo HTMLHelper::_('content.prepare', $value);
|
||||
62
plugins/fields/imagelist/imagelist.xml
Normal file
62
plugins/fields/imagelist/imagelist.xml
Normal file
@ -0,0 +1,62 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<extension type="plugin" group="fields" method="upgrade">
|
||||
<name>plg_fields_imagelist</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_IMAGELIST_XML_DESCRIPTION</description>
|
||||
<namespace path="src">Joomla\Plugin\Fields\Imagelist</namespace>
|
||||
<files>
|
||||
<folder>params</folder>
|
||||
<folder plugin="imagelist">services</folder>
|
||||
<folder>src</folder>
|
||||
<folder>tmpl</folder>
|
||||
</files>
|
||||
<languages>
|
||||
<language tag="en-GB">language/en-GB/plg_fields_imagelist.ini</language>
|
||||
<language tag="en-GB">language/en-GB/plg_fields_imagelist.sys.ini</language>
|
||||
</languages>
|
||||
<config>
|
||||
<fields name="params">
|
||||
<fieldset name="basic">
|
||||
<field
|
||||
name="directory"
|
||||
type="folderlist"
|
||||
label="PLG_FIELDS_IMAGELIST_PARAMS_DIRECTORY_LABEL"
|
||||
description="PLG_FIELDS_IMAGELIST_PARAMS_DIRECTORY_DESC"
|
||||
directory="images"
|
||||
hide_none="true"
|
||||
hide_default="true"
|
||||
recursive="true"
|
||||
default="/"
|
||||
validate="options"
|
||||
>
|
||||
<option value="/">/</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="multiple"
|
||||
type="radio"
|
||||
label="PLG_FIELDS_IMAGELIST_PARAMS_MULTIPLE_LABEL"
|
||||
layout="joomla.form.field.radio.switcher"
|
||||
default="0"
|
||||
filter="integer"
|
||||
>
|
||||
<option value="0">JNO</option>
|
||||
<option value="1">JYES</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="image_class"
|
||||
type="textarea"
|
||||
label="PLG_FIELDS_IMAGELIST_PARAMS_IMAGE_CLASS_LABEL"
|
||||
validate="CssIdentifier"
|
||||
/>
|
||||
</fieldset>
|
||||
</fields>
|
||||
</config>
|
||||
</extension>
|
||||
40
plugins/fields/imagelist/params/imagelist.xml
Normal file
40
plugins/fields/imagelist/params/imagelist.xml
Normal file
@ -0,0 +1,40 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<form>
|
||||
<fields name="fieldparams">
|
||||
<fieldset name="fieldparams">
|
||||
<field
|
||||
name="directory"
|
||||
type="folderlist"
|
||||
label="PLG_FIELDS_IMAGELIST_PARAMS_DIRECTORY_LABEL"
|
||||
description="PLG_FIELDS_IMAGELIST_PARAMS_DIRECTORY_DESC"
|
||||
directory="images"
|
||||
hide_none="true"
|
||||
hide_default="true"
|
||||
recursive="true"
|
||||
validate="options"
|
||||
>
|
||||
<option value="">COM_FIELDS_FIELD_USE_GLOBAL</option>
|
||||
<option value="/">/</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="multiple"
|
||||
type="list"
|
||||
label="PLG_FIELDS_IMAGELIST_PARAMS_MULTIPLE_LABEL"
|
||||
filter="integer"
|
||||
validate="options"
|
||||
>
|
||||
<option value="">COM_FIELDS_FIELD_USE_GLOBAL</option>
|
||||
<option value="1">JYES</option>
|
||||
<option value="0">JNO</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="image_class"
|
||||
type="textarea"
|
||||
label="PLG_FIELDS_IMAGELIST_PARAMS_IMAGE_CLASS_LABEL"
|
||||
validate="CssIdentifier"
|
||||
/>
|
||||
</fieldset>
|
||||
</fields>
|
||||
</form>
|
||||
46
plugins/fields/imagelist/services/provider.php
Normal file
46
plugins/fields/imagelist/services/provider.php
Normal file
@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Plugin
|
||||
* @subpackage Fields.imagelist
|
||||
*
|
||||
* @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\Imagelist\Extension\Imagelist;
|
||||
|
||||
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 Imagelist(
|
||||
$container->get(DispatcherInterface::class),
|
||||
(array) PluginHelper::getPlugin('fields', 'imagelist')
|
||||
);
|
||||
$plugin->setApplication(Factory::getApplication());
|
||||
|
||||
return $plugin;
|
||||
}
|
||||
);
|
||||
}
|
||||
};
|
||||
52
plugins/fields/imagelist/src/Extension/Imagelist.php
Normal file
52
plugins/fields/imagelist/src/Extension/Imagelist.php
Normal file
@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Plugin
|
||||
* @subpackage Fields.imagelist
|
||||
*
|
||||
* @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\Imagelist\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 Imagelist Plugin
|
||||
*
|
||||
* @since 3.7.0
|
||||
*/
|
||||
final class Imagelist 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('hide_default', 'true');
|
||||
$fieldNode->setAttribute('directory', '/images/' . $fieldNode->getAttribute('directory'));
|
||||
|
||||
return $fieldNode;
|
||||
}
|
||||
}
|
||||
60
plugins/fields/imagelist/tmpl/imagelist.php
Normal file
60
plugins/fields/imagelist/tmpl/imagelist.php
Normal file
@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Plugin
|
||||
* @subpackage Fields.Imagelist
|
||||
*
|
||||
* @copyright (C) 2017 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\Image\Image;
|
||||
|
||||
if ($field->value == '') {
|
||||
return;
|
||||
}
|
||||
|
||||
$class = $fieldParams->get('image_class');
|
||||
|
||||
if ($class) {
|
||||
// space before, so if no class sprintf below works
|
||||
$class = ' class="' . htmlentities($class, ENT_COMPAT, 'UTF-8', true) . '"';
|
||||
}
|
||||
|
||||
$value = (array) $field->value;
|
||||
$buffer = '';
|
||||
|
||||
foreach ($value as $path) {
|
||||
if (!$path || $path == '-1') {
|
||||
continue;
|
||||
}
|
||||
|
||||
$imageFilePath = htmlentities($path, ENT_COMPAT, 'UTF-8', true);
|
||||
|
||||
if ($fieldParams->get('directory', '/') !== '/') {
|
||||
$imageInfo = Image::getImageFileProperties(JPATH_ROOT . '/images/' . $fieldParams->get('directory') . '/' . $imageFilePath);
|
||||
|
||||
$buffer .= sprintf(
|
||||
'<img loading="lazy" width="%s" height="%s" src="images/%s/%s"%s alt="">',
|
||||
$imageInfo->width,
|
||||
$imageInfo->height,
|
||||
$fieldParams->get('directory'),
|
||||
$imageFilePath,
|
||||
$class
|
||||
);
|
||||
} else {
|
||||
$imageInfo = Image::getImageFileProperties(JPATH_ROOT . '/images/' . $imageFilePath);
|
||||
|
||||
$buffer .= sprintf(
|
||||
'<img loading="lazy" width="%s" height="%s" src="images/%s"%s>',
|
||||
$imageInfo->width,
|
||||
$imageInfo->height,
|
||||
$imageFilePath,
|
||||
$class
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
echo $buffer;
|
||||
64
plugins/fields/integer/integer.xml
Normal file
64
plugins/fields/integer/integer.xml
Normal file
@ -0,0 +1,64 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<extension type="plugin" group="fields" method="upgrade">
|
||||
<name>plg_fields_integer</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_INTEGER_XML_DESCRIPTION</description>
|
||||
<namespace path="src">Joomla\Plugin\Fields\Integer</namespace>
|
||||
<files>
|
||||
<folder>params</folder>
|
||||
<folder plugin="integer">services</folder>
|
||||
<folder>src</folder>
|
||||
<folder>tmpl</folder>
|
||||
</files>
|
||||
<languages>
|
||||
<language tag="en-GB">language/en-GB/plg_fields_integer.ini</language>
|
||||
<language tag="en-GB">language/en-GB/plg_fields_integer.sys.ini</language>
|
||||
</languages>
|
||||
<config>
|
||||
<fields name="params">
|
||||
<fieldset name="basic">
|
||||
<field
|
||||
name="multiple"
|
||||
type="radio"
|
||||
label="PLG_FIELDS_INTEGER_PARAMS_MULTIPLE_LABEL"
|
||||
layout="joomla.form.field.radio.switcher"
|
||||
default="0"
|
||||
filter="integer"
|
||||
>
|
||||
<option value="0">JNO</option>
|
||||
<option value="1">JYES</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="first"
|
||||
type="number"
|
||||
label="PLG_FIELDS_INTEGER_PARAMS_FIRST_LABEL"
|
||||
default="1"
|
||||
filter="integer"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="last"
|
||||
type="number"
|
||||
label="PLG_FIELDS_INTEGER_PARAMS_LAST_LABEL"
|
||||
default="100"
|
||||
filter="integer"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="step"
|
||||
type="number"
|
||||
label="PLG_FIELDS_INTEGER_PARAMS_STEP_LABEL"
|
||||
default="1"
|
||||
filter="integer"
|
||||
/>
|
||||
</fieldset>
|
||||
</fields>
|
||||
</config>
|
||||
</extension>
|
||||
39
plugins/fields/integer/params/integer.xml
Normal file
39
plugins/fields/integer/params/integer.xml
Normal file
@ -0,0 +1,39 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<form>
|
||||
<fields name="fieldparams">
|
||||
<fieldset name="fieldparams">
|
||||
<field
|
||||
name="multiple"
|
||||
type="list"
|
||||
label="PLG_FIELDS_INTEGER_PARAMS_MULTIPLE_LABEL"
|
||||
filter="integer"
|
||||
validate="options"
|
||||
>
|
||||
<option value="">COM_FIELDS_FIELD_USE_GLOBAL</option>
|
||||
<option value="1">JYES</option>
|
||||
<option value="0">JNO</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="first"
|
||||
type="number"
|
||||
label="PLG_FIELDS_INTEGER_PARAMS_FIRST_LABEL"
|
||||
filter="integer"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="last"
|
||||
type="number"
|
||||
label="PLG_FIELDS_INTEGER_PARAMS_LAST_LABEL"
|
||||
filter="integer"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="step"
|
||||
type="number"
|
||||
label="PLG_FIELDS_INTEGER_PARAMS_STEP_LABEL"
|
||||
filter="integer"
|
||||
/>
|
||||
</fieldset>
|
||||
</fields>
|
||||
</form>
|
||||
46
plugins/fields/integer/services/provider.php
Normal file
46
plugins/fields/integer/services/provider.php
Normal file
@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Plugin
|
||||
* @subpackage Fields.integer
|
||||
*
|
||||
* @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\Integer\Extension\Integer;
|
||||
|
||||
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 Integer(
|
||||
$container->get(DispatcherInterface::class),
|
||||
(array) PluginHelper::getPlugin('fields', 'integer')
|
||||
);
|
||||
$plugin->setApplication(Factory::getApplication());
|
||||
|
||||
return $plugin;
|
||||
}
|
||||
);
|
||||
}
|
||||
};
|
||||
27
plugins/fields/integer/src/Extension/Integer.php
Normal file
27
plugins/fields/integer/src/Extension/Integer.php
Normal file
@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Plugin
|
||||
* @subpackage Fields.integer
|
||||
*
|
||||
* @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\Integer\Extension;
|
||||
|
||||
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 Integer Plugin
|
||||
*
|
||||
* @since 3.7.0
|
||||
*/
|
||||
final class Integer extends FieldsPlugin implements SubscriberInterface
|
||||
{
|
||||
}
|
||||
25
plugins/fields/integer/tmpl/integer.php
Normal file
25
plugins/fields/integer/tmpl/integer.php
Normal file
@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Plugin
|
||||
* @subpackage Fields.Integer
|
||||
*
|
||||
* @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(', ', array_map('intval', $value));
|
||||
} else {
|
||||
$value = (int) $value;
|
||||
}
|
||||
|
||||
echo $value;
|
||||
63
plugins/fields/list/list.xml
Normal file
63
plugins/fields/list/list.xml
Normal file
@ -0,0 +1,63 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<extension type="plugin" group="fields" method="upgrade">
|
||||
<name>plg_fields_list</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_LIST_XML_DESCRIPTION</description>
|
||||
<namespace path="src">Joomla\Plugin\Fields\ListField</namespace>
|
||||
<files>
|
||||
<folder>params</folder>
|
||||
<folder plugin="list">services</folder>
|
||||
<folder>src</folder>
|
||||
<folder>tmpl</folder>
|
||||
</files>
|
||||
<languages>
|
||||
<language tag="en-GB">language/en-GB/plg_fields_list.ini</language>
|
||||
<language tag="en-GB">language/en-GB/plg_fields_list.sys.ini</language>
|
||||
</languages>
|
||||
<config>
|
||||
<fields name="params">
|
||||
<fieldset name="basic">
|
||||
<field
|
||||
name="multiple"
|
||||
type="radio"
|
||||
label="PLG_FIELDS_LIST_PARAMS_MULTIPLE_LABEL"
|
||||
layout="joomla.form.field.radio.switcher"
|
||||
default="0"
|
||||
filter="integer"
|
||||
>
|
||||
<option value="0">JNO</option>
|
||||
<option value="1">JYES</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="options"
|
||||
type="subform"
|
||||
label="PLG_FIELDS_LIST_PARAMS_OPTIONS_LABEL"
|
||||
layout="joomla.form.field.subform.repeatable-table"
|
||||
icon="list"
|
||||
multiple="true"
|
||||
>
|
||||
<form hidden="true" name="list_templates_modal" repeat="true">
|
||||
<field
|
||||
name="name"
|
||||
type="text"
|
||||
label="PLG_FIELDS_LIST_PARAMS_OPTIONS_NAME_LABEL"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="value"
|
||||
type="text"
|
||||
label="PLG_FIELDS_LIST_PARAMS_OPTIONS_VALUE_LABEL"
|
||||
/>
|
||||
</form>
|
||||
</field>
|
||||
</fieldset>
|
||||
</fields>
|
||||
</config>
|
||||
</extension>
|
||||
57
plugins/fields/list/params/list.xml
Normal file
57
plugins/fields/list/params/list.xml
Normal file
@ -0,0 +1,57 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<form>
|
||||
<fields name="fieldparams">
|
||||
<fieldset name="fieldparams">
|
||||
<field
|
||||
name="multiple"
|
||||
type="list"
|
||||
label="PLG_FIELDS_LIST_PARAMS_MULTIPLE_LABEL"
|
||||
filter="integer"
|
||||
validate="options"
|
||||
>
|
||||
<option value="">COM_FIELDS_FIELD_USE_GLOBAL</option>
|
||||
<option value="1">JYES</option>
|
||||
<option value="0">JNO</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="options"
|
||||
type="subform"
|
||||
label="PLG_FIELDS_LIST_PARAMS_OPTIONS_LABEL"
|
||||
layout="joomla.form.field.subform.repeatable-table"
|
||||
icon="list"
|
||||
multiple="true"
|
||||
>
|
||||
<form hidden="true" name="list_templates_modal" repeat="true">
|
||||
<field
|
||||
name="name"
|
||||
type="text"
|
||||
label="PLG_FIELDS_LIST_PARAMS_OPTIONS_NAME_LABEL"
|
||||
required="true"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="value"
|
||||
type="text"
|
||||
label="PLG_FIELDS_LIST_PARAMS_OPTIONS_VALUE_LABEL"
|
||||
/>
|
||||
</form>
|
||||
</field>
|
||||
</fieldset>
|
||||
</fields>
|
||||
<fields name="params">
|
||||
<fieldset name="basic">
|
||||
<fieldset name="formoptions">
|
||||
<field
|
||||
name="form_layout"
|
||||
type="list"
|
||||
label="COM_FIELDS_FIELD_FORM_LAYOUT_LABEL"
|
||||
class="form-select"
|
||||
>
|
||||
<option value="joomla.form.field.list">JDEFAULT</option>
|
||||
<option value="joomla.form.field.list-fancy-select">PLG_FIELDS_LIST_PARAMS_FORM_LAYOUT_FANCY_SELECT</option>
|
||||
</field>
|
||||
</fieldset>
|
||||
</fieldset>
|
||||
</fields>
|
||||
</form>
|
||||
46
plugins/fields/list/services/provider.php
Normal file
46
plugins/fields/list/services/provider.php
Normal file
@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Plugin
|
||||
* @subpackage Fields.list
|
||||
*
|
||||
* @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\ListField\Extension\ListPlugin;
|
||||
|
||||
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 ListPlugin(
|
||||
$container->get(DispatcherInterface::class),
|
||||
(array) PluginHelper::getPlugin('fields', 'list')
|
||||
);
|
||||
$plugin->setApplication(Factory::getApplication());
|
||||
|
||||
return $plugin;
|
||||
}
|
||||
);
|
||||
}
|
||||
};
|
||||
82
plugins/fields/list/src/Extension/ListPlugin.php
Normal file
82
plugins/fields/list/src/Extension/ListPlugin.php
Normal file
@ -0,0 +1,82 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Plugin
|
||||
* @subpackage Fields.list
|
||||
*
|
||||
* @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\ListField\Extension;
|
||||
|
||||
use Joomla\Component\Fields\Administrator\Plugin\FieldsListPlugin;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
/**
|
||||
* Fields List Plugin
|
||||
*
|
||||
* @since 3.7.0
|
||||
*/
|
||||
final class ListPlugin extends FieldsListPlugin
|
||||
{
|
||||
/**
|
||||
* Before prepares the field value.
|
||||
*
|
||||
* @param string $context The context.
|
||||
* @param \stdclass $item The item.
|
||||
* @param \stdclass $field The field.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 3.7.0
|
||||
*/
|
||||
public function onCustomFieldsBeforePrepareField($context, $item, $field)
|
||||
{
|
||||
if (!$this->getApplication()->isClient('api')) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!$this->isTypeSupported($field->type)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$options = $this->getOptionsFromField($field);
|
||||
$field->apivalue = [];
|
||||
|
||||
if (\is_array($field->value)) {
|
||||
foreach ($field->value as $value) {
|
||||
$field->apivalue[$value] = $options[$value];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepares the field
|
||||
*
|
||||
* @param string $context The context.
|
||||
* @param stdclass $item The item.
|
||||
* @param stdclass $field The field.
|
||||
*
|
||||
* @return object
|
||||
*
|
||||
* @since 3.9.2
|
||||
*/
|
||||
public function onCustomFieldsPrepareField($context, $item, $field)
|
||||
{
|
||||
// Check if the field should be processed
|
||||
if (!$this->isTypeSupported($field->type)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// The field's rawvalue should be an array
|
||||
if (!\is_array($field->rawvalue)) {
|
||||
$field->rawvalue = (array) $field->rawvalue;
|
||||
}
|
||||
|
||||
return parent::onCustomFieldsPrepareField($context, $item, $field);
|
||||
}
|
||||
}
|
||||
31
plugins/fields/list/tmpl/list.php
Normal file
31
plugins/fields/list/tmpl/list.php
Normal file
@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Plugin
|
||||
* @subpackage Fields.List
|
||||
*
|
||||
* @copyright (C) 2017 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\Language\Text;
|
||||
|
||||
$fieldValue = $field->value;
|
||||
|
||||
if ($fieldValue == '') {
|
||||
return;
|
||||
}
|
||||
|
||||
$fieldValue = (array) $fieldValue;
|
||||
$texts = [];
|
||||
$options = $this->getOptionsFromField($field);
|
||||
|
||||
foreach ($options as $value => $name) {
|
||||
if (in_array((string) $value, $fieldValue)) {
|
||||
$texts[] = Text::_($name);
|
||||
}
|
||||
}
|
||||
|
||||
echo htmlentities(implode(', ', $texts));
|
||||
56
plugins/fields/media/media.xml
Normal file
56
plugins/fields/media/media.xml
Normal file
@ -0,0 +1,56 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<extension type="plugin" group="fields" method="upgrade">
|
||||
<name>plg_fields_media</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_MEDIA_XML_DESCRIPTION</description>
|
||||
<namespace path="src">Joomla\Plugin\Fields\Media</namespace>
|
||||
<files>
|
||||
<folder>params</folder>
|
||||
<folder plugin="media">services</folder>
|
||||
<folder>src</folder>
|
||||
<folder>tmpl</folder>
|
||||
</files>
|
||||
<languages>
|
||||
<language tag="en-GB">language/en-GB/plg_fields_media.ini</language>
|
||||
<language tag="en-GB">language/en-GB/plg_fields_media.sys.ini</language>
|
||||
</languages>
|
||||
<config>
|
||||
<fields name="params">
|
||||
<fieldset name="basic">
|
||||
<field
|
||||
name="directory"
|
||||
type="folderlist"
|
||||
label="PLG_FIELDS_MEDIA_PARAMS_DIRECTORY_LABEL"
|
||||
directory="images"
|
||||
hide_none="true"
|
||||
recursive="true"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="preview"
|
||||
type="list"
|
||||
label="PLG_FIELDS_MEDIA_PARAMS_PREVIEW_LABEL"
|
||||
class="list"
|
||||
default="true"
|
||||
validate="options"
|
||||
>
|
||||
<option value="true">PLG_FIELDS_MEDIA_PARAMS_PREVIEW_INLINE</option>
|
||||
<option value="false">JNO</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="image_class"
|
||||
type="textarea"
|
||||
label="PLG_FIELDS_MEDIA_PARAMS_IMAGE_CLASS_LABEL"
|
||||
validate="CssIdentifier"
|
||||
/>
|
||||
</fieldset>
|
||||
</fields>
|
||||
</config>
|
||||
</extension>
|
||||
34
plugins/fields/media/params/media.xml
Normal file
34
plugins/fields/media/params/media.xml
Normal file
@ -0,0 +1,34 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<form>
|
||||
<fields name="fieldparams">
|
||||
<fieldset name="fieldparams">
|
||||
<field
|
||||
name="directory"
|
||||
type="folderlist"
|
||||
label="PLG_FIELDS_MEDIA_PARAMS_DIRECTORY_LABEL"
|
||||
directory="images"
|
||||
hide_none="true"
|
||||
recursive="true"
|
||||
validate="options"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="preview"
|
||||
type="list"
|
||||
label="PLG_FIELDS_MEDIA_PARAMS_PREVIEW_LABEL"
|
||||
validate="options"
|
||||
>
|
||||
<option value="">COM_FIELDS_FIELD_USE_GLOBAL</option>
|
||||
<option value="true">PLG_FIELDS_MEDIA_PARAMS_PREVIEW_INLINE</option>
|
||||
<option value="false">JNO</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="image_class"
|
||||
type="textarea"
|
||||
label="PLG_FIELDS_MEDIA_PARAMS_IMAGE_CLASS_LABEL"
|
||||
validate="CssIdentifier"
|
||||
/>
|
||||
</fieldset>
|
||||
</fields>
|
||||
</form>
|
||||
46
plugins/fields/media/services/provider.php
Normal file
46
plugins/fields/media/services/provider.php
Normal file
@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Plugin
|
||||
* @subpackage Fields.media
|
||||
*
|
||||
* @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\Media\Extension\Media;
|
||||
|
||||
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 Media(
|
||||
$container->get(DispatcherInterface::class),
|
||||
(array) PluginHelper::getPlugin('fields', 'media')
|
||||
);
|
||||
$plugin->setApplication(Factory::getApplication());
|
||||
|
||||
return $plugin;
|
||||
}
|
||||
);
|
||||
}
|
||||
};
|
||||
96
plugins/fields/media/src/Extension/Media.php
Normal file
96
plugins/fields/media/src/Extension/Media.php
Normal file
@ -0,0 +1,96 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Plugin
|
||||
* @subpackage Fields.media
|
||||
*
|
||||
* @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\Media\Extension;
|
||||
|
||||
use Joomla\CMS\Form\Form;
|
||||
use Joomla\Component\Fields\Administrator\Plugin\FieldsPlugin;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
/**
|
||||
* Fields Media Plugin
|
||||
*
|
||||
* @since 3.7.0
|
||||
*/
|
||||
final class Media extends FieldsPlugin
|
||||
{
|
||||
/**
|
||||
* 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 4.0.0
|
||||
*/
|
||||
public function onCustomFieldsPrepareDom($field, \DOMElement $parent, Form $form)
|
||||
{
|
||||
$fieldNode = parent::onCustomFieldsPrepareDom($field, $parent, $form);
|
||||
|
||||
if (!$fieldNode) {
|
||||
return $fieldNode;
|
||||
}
|
||||
|
||||
$fieldNode->setAttribute('type', 'accessiblemedia');
|
||||
|
||||
if ($this->getApplication()->getIdentity()->authorise('core.create', 'com_media')) {
|
||||
$fieldNode->setAttribute('disabled', 'false');
|
||||
}
|
||||
|
||||
return $fieldNode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Before prepares the field value.
|
||||
*
|
||||
* @param string $context The context.
|
||||
* @param \stdclass $item The item.
|
||||
* @param \stdclass $field The field.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
public function onCustomFieldsBeforePrepareField($context, $item, $field)
|
||||
{
|
||||
// Check if the field should be processed by us
|
||||
if (!$this->isTypeSupported($field->type)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Check if the field value is an old (string) value
|
||||
$field->value = $this->checkValue($field->value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Before prepares the field value.
|
||||
*
|
||||
* @param string $value The value to check.
|
||||
*
|
||||
* @return array The checked value
|
||||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
private function checkValue($value)
|
||||
{
|
||||
json_decode($value);
|
||||
|
||||
if (json_last_error() === JSON_ERROR_NONE) {
|
||||
return (array) json_decode($value, true);
|
||||
}
|
||||
|
||||
return ['imagefile' => $value, 'alt_text' => ''];
|
||||
}
|
||||
}
|
||||
29
plugins/fields/media/tmpl/media.php
Normal file
29
plugins/fields/media/tmpl/media.php
Normal file
@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Plugin
|
||||
* @subpackage Fields.Media
|
||||
*
|
||||
* @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;
|
||||
|
||||
use Joomla\CMS\Layout\LayoutHelper;
|
||||
|
||||
if (empty($field->value) || empty($field->value['imagefile'])) {
|
||||
return;
|
||||
}
|
||||
|
||||
$class = $fieldParams->get('image_class');
|
||||
$options = [
|
||||
'src' => $field->value['imagefile'],
|
||||
'alt' => empty($field->value['alt_text']) && empty($field->value['alt_empty']) ? false : $field->value['alt_text'],
|
||||
];
|
||||
|
||||
if ($class) {
|
||||
$options['class'] = $class;
|
||||
}
|
||||
|
||||
echo LayoutHelper::render('joomla.html.image', $options);
|
||||
53
plugins/fields/radio/params/radio.xml
Normal file
53
plugins/fields/radio/params/radio.xml
Normal file
@ -0,0 +1,53 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<form>
|
||||
<fields name="fieldparams">
|
||||
<fieldset name="fieldparams">
|
||||
<field
|
||||
name="options"
|
||||
type="subform"
|
||||
label="PLG_FIELDS_RADIO_PARAMS_OPTIONS_LABEL"
|
||||
layout="joomla.form.field.subform.repeatable-table"
|
||||
icon="list"
|
||||
multiple="true"
|
||||
>
|
||||
<form hidden="true" name="list_templates_modal" repeat="true">
|
||||
<field
|
||||
name="name"
|
||||
type="text"
|
||||
label="PLG_FIELDS_RADIO_PARAMS_OPTIONS_NAME_LABEL"
|
||||
required="true"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="value"
|
||||
type="text"
|
||||
label="PLG_FIELDS_RADIO_PARAMS_OPTIONS_VALUE_LABEL"
|
||||
/>
|
||||
</form>
|
||||
</field>
|
||||
</fieldset>
|
||||
</fields>
|
||||
|
||||
<fields name="params">
|
||||
<fieldset name="basic">
|
||||
<field
|
||||
name="class"
|
||||
type="textarea"
|
||||
label="COM_FIELDS_FIELD_CLASS_LABEL"
|
||||
default="btn-group"
|
||||
validate="CssIdentifier"
|
||||
/>
|
||||
<fieldset name="formoptions">
|
||||
<field
|
||||
name="form_layout"
|
||||
type="list"
|
||||
label="COM_FIELDS_FIELD_FORM_LAYOUT_LABEL"
|
||||
class="form-select"
|
||||
>
|
||||
<option value="joomla.form.field.radio.buttons">PLG_FIELDS_RADIO_PARAMS_FORM_LAYOUT_BUTTONS</option>
|
||||
<option value="joomla.form.field.radio.switcher">PLG_FIELDS_RADIO_PARAMS_FORM_LAYOUT_SWITCHER</option>
|
||||
</field>
|
||||
</fieldset>
|
||||
</fieldset>
|
||||
</fields>
|
||||
</form>
|
||||
51
plugins/fields/radio/radio.xml
Normal file
51
plugins/fields/radio/radio.xml
Normal file
@ -0,0 +1,51 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<extension type="plugin" group="fields" method="upgrade">
|
||||
<name>plg_fields_radio</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_RADIO_XML_DESCRIPTION</description>
|
||||
<namespace path="src">Joomla\Plugin\Fields\Radio</namespace>
|
||||
<files>
|
||||
<folder>params</folder>
|
||||
<folder plugin="radio">services</folder>
|
||||
<folder>src</folder>
|
||||
<folder>tmpl</folder>
|
||||
</files>
|
||||
<languages>
|
||||
<language tag="en-GB">language/en-GB/plg_fields_radio.ini</language>
|
||||
<language tag="en-GB">language/en-GB/plg_fields_radio.sys.ini</language>
|
||||
</languages>
|
||||
<config>
|
||||
<fields name="params">
|
||||
<fieldset name="basic">
|
||||
<field
|
||||
name="options"
|
||||
type="subform"
|
||||
label="PLG_FIELDS_RADIO_PARAMS_OPTIONS_LABEL"
|
||||
layout="joomla.form.field.subform.repeatable-table"
|
||||
icon="list"
|
||||
multiple="true"
|
||||
>
|
||||
<form hidden="true" name="list_templates_modal" repeat="true">
|
||||
<field
|
||||
name="name"
|
||||
type="text"
|
||||
label="PLG_FIELDS_RADIO_PARAMS_OPTIONS_NAME_LABEL"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="value"
|
||||
type="text"
|
||||
label="PLG_FIELDS_RADIO_PARAMS_OPTIONS_VALUE_LABEL"
|
||||
/>
|
||||
</form>
|
||||
</field>
|
||||
</fieldset>
|
||||
</fields>
|
||||
</config>
|
||||
</extension>
|
||||
46
plugins/fields/radio/services/provider.php
Normal file
46
plugins/fields/radio/services/provider.php
Normal file
@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Plugin
|
||||
* @subpackage Fields.radio
|
||||
*
|
||||
* @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\Radio\Extension\Radio;
|
||||
|
||||
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 Radio(
|
||||
$container->get(DispatcherInterface::class),
|
||||
(array) PluginHelper::getPlugin('fields', 'radio')
|
||||
);
|
||||
$plugin->setApplication(Factory::getApplication());
|
||||
|
||||
return $plugin;
|
||||
}
|
||||
);
|
||||
}
|
||||
};
|
||||
54
plugins/fields/radio/src/Extension/Radio.php
Normal file
54
plugins/fields/radio/src/Extension/Radio.php
Normal file
@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Plugin
|
||||
* @subpackage Fields.radio
|
||||
*
|
||||
* @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\Radio\Extension;
|
||||
|
||||
use Joomla\Component\Fields\Administrator\Plugin\FieldsListPlugin;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
/**
|
||||
* Fields Radio Plugin
|
||||
*
|
||||
* @since 3.7.0
|
||||
*/
|
||||
final class Radio extends FieldsListPlugin
|
||||
{
|
||||
/**
|
||||
* Before prepares the field value.
|
||||
*
|
||||
* @param string $context The context.
|
||||
* @param \stdclass $item The item.
|
||||
* @param \stdclass $field The field.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 3.7.0
|
||||
*/
|
||||
public function onCustomFieldsBeforePrepareField($context, $item, $field)
|
||||
{
|
||||
if (!$this->getApplication()->isClient('api')) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!$this->isTypeSupported($field->type)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$options = $this->getOptionsFromField($field);
|
||||
$field->apivalue = [];
|
||||
|
||||
if (!empty($field->value)) {
|
||||
$field->apivalue = [$field->value => $options[$field->value]];
|
||||
}
|
||||
}
|
||||
}
|
||||
31
plugins/fields/radio/tmpl/radio.php
Normal file
31
plugins/fields/radio/tmpl/radio.php
Normal file
@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Plugin
|
||||
* @subpackage Fields.Radio
|
||||
*
|
||||
* @copyright (C) 2017 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\Language\Text;
|
||||
|
||||
$value = $field->value;
|
||||
|
||||
if ($value == '') {
|
||||
return;
|
||||
}
|
||||
|
||||
$value = (array) $value;
|
||||
$texts = [];
|
||||
$options = $this->getOptionsFromField($field);
|
||||
|
||||
foreach ($options as $optionValue => $optionText) {
|
||||
if (in_array((string) $optionValue, $value)) {
|
||||
$texts[] = Text::_($optionText);
|
||||
}
|
||||
}
|
||||
|
||||
echo htmlentities(implode(', ', $texts));
|
||||
49
plugins/fields/sql/params/sql.xml
Normal file
49
plugins/fields/sql/params/sql.xml
Normal file
@ -0,0 +1,49 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<form>
|
||||
<fields name="fieldparams">
|
||||
<fieldset name="fieldparams">
|
||||
<field
|
||||
name="query"
|
||||
type="textarea"
|
||||
label="PLG_FIELDS_SQL_PARAMS_QUERY_LABEL"
|
||||
description="PLG_FIELDS_SQL_PARAMS_QUERY_DESC"
|
||||
filter="raw"
|
||||
rows="10"
|
||||
required="true"
|
||||
/>
|
||||
<field
|
||||
name="header"
|
||||
type="text"
|
||||
label="PLG_FIELDS_SQL_PARAMS_HEADER_LABEL"
|
||||
description="PLG_FIELDS_SQL_PARAMS_HEADER_DESC"
|
||||
filter="string"
|
||||
/>
|
||||
<field
|
||||
name="multiple"
|
||||
type="list"
|
||||
label="PLG_FIELDS_SQL_PARAMS_MULTIPLE_LABEL"
|
||||
filter="integer"
|
||||
validate="options"
|
||||
>
|
||||
<option value="">COM_FIELDS_FIELD_USE_GLOBAL</option>
|
||||
<option value="1">JYES</option>
|
||||
<option value="0">JNO</option>
|
||||
</field>
|
||||
</fieldset>
|
||||
</fields>
|
||||
<fields name="params">
|
||||
<fieldset name="basic">
|
||||
<fieldset name="formoptions">
|
||||
<field
|
||||
name="form_layout"
|
||||
type="list"
|
||||
label="COM_FIELDS_FIELD_FORM_LAYOUT_LABEL"
|
||||
class="form-select"
|
||||
>
|
||||
<option value="joomla.form.field.list">JDEFAULT</option>
|
||||
<option value="joomla.form.field.list-fancy-select">PLG_FIELDS_SQL_PARAMS_FORM_LAYOUT_FANCY_SELECT</option>
|
||||
</field>
|
||||
</fieldset>
|
||||
</fieldset>
|
||||
</fields>
|
||||
</form>
|
||||
46
plugins/fields/sql/services/provider.php
Normal file
46
plugins/fields/sql/services/provider.php
Normal file
@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Plugin
|
||||
* @subpackage Fields.sql
|
||||
*
|
||||
* @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\SQL\Extension\SQL;
|
||||
|
||||
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 SQL(
|
||||
$container->get(DispatcherInterface::class),
|
||||
(array) PluginHelper::getPlugin('fields', 'sql')
|
||||
);
|
||||
$plugin->setApplication(Factory::getApplication());
|
||||
|
||||
return $plugin;
|
||||
}
|
||||
);
|
||||
}
|
||||
};
|
||||
58
plugins/fields/sql/sql.xml
Normal file
58
plugins/fields/sql/sql.xml
Normal file
@ -0,0 +1,58 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<extension type="plugin" group="fields" method="upgrade">
|
||||
<name>plg_fields_sql</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_SQL_XML_DESCRIPTION</description>
|
||||
<namespace path="src">Joomla\Plugin\Fields\SQL</namespace>
|
||||
<files>
|
||||
<folder>params</folder>
|
||||
<folder plugin="sql">services</folder>
|
||||
<folder>src</folder>
|
||||
<folder>tmpl</folder>
|
||||
</files>
|
||||
<languages>
|
||||
<language tag="en-GB">language/en-GB/plg_fields_sql.ini</language>
|
||||
<language tag="en-GB">language/en-GB/plg_fields_sql.sys.ini</language>
|
||||
</languages>
|
||||
<config>
|
||||
<fields name="params">
|
||||
<fieldset name="basic">
|
||||
<field
|
||||
name="query"
|
||||
type="textarea"
|
||||
label="PLG_FIELDS_SQL_PARAMS_QUERY_LABEL"
|
||||
description="PLG_FIELDS_SQL_PARAMS_QUERY_DESC"
|
||||
rows="10"
|
||||
filter="raw"
|
||||
required="true"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="header"
|
||||
type="text"
|
||||
label="PLG_FIELDS_SQL_PARAMS_HEADER_LABEL"
|
||||
description="PLG_FIELDS_SQL_PARAMS_HEADER_DESC"
|
||||
filter="string"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="multiple"
|
||||
type="radio"
|
||||
layout="joomla.form.field.radio.switcher"
|
||||
default="0"
|
||||
label="PLG_FIELDS_SQL_PARAMS_MULTIPLE_LABEL"
|
||||
filter="integer"
|
||||
>
|
||||
<option value="0">JNO</option>
|
||||
<option value="1">JYES</option>
|
||||
</field>
|
||||
</fieldset>
|
||||
</fields>
|
||||
</config>
|
||||
</extension>
|
||||
81
plugins/fields/sql/src/Extension/SQL.php
Normal file
81
plugins/fields/sql/src/Extension/SQL.php
Normal file
@ -0,0 +1,81 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Plugin
|
||||
* @subpackage Fields.sql
|
||||
*
|
||||
* @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\SQL\Extension;
|
||||
|
||||
use Joomla\CMS\Access\Access;
|
||||
use Joomla\CMS\Form\Form;
|
||||
use Joomla\Component\Fields\Administrator\Plugin\FieldsListPlugin;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
/**
|
||||
* Fields SQL Plugin
|
||||
*
|
||||
* @since 3.7.0
|
||||
*/
|
||||
final class SQL extends FieldsListPlugin
|
||||
{
|
||||
/**
|
||||
* 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('value_field', 'text');
|
||||
$fieldNode->setAttribute('key_field', 'value');
|
||||
|
||||
return $fieldNode;
|
||||
}
|
||||
|
||||
/**
|
||||
* The save event.
|
||||
*
|
||||
* @param string $context The context
|
||||
* @param \Joomla\CMS\Table\Table $item The table
|
||||
* @param boolean $isNew Is new item
|
||||
* @param array $data The validated data
|
||||
*
|
||||
* @return boolean
|
||||
*
|
||||
* @since 3.7.0
|
||||
*/
|
||||
public function onContentBeforeSave($context, $item, $isNew, $data = [])
|
||||
{
|
||||
// Only work on new SQL fields
|
||||
if ($context != 'com_fields.field' || !isset($item->type) || $item->type != 'sql') {
|
||||
return true;
|
||||
}
|
||||
|
||||
// If we are not a super admin, don't let the user create or update a SQL field
|
||||
if (!Access::getAssetRules(1)->allow('core.admin', $this->getApplication()->getIdentity()->getAuthorisedGroups())) {
|
||||
$item->setError($this->getApplication()->getLanguage()->_('PLG_FIELDS_SQL_CREATE_NOT_POSSIBLE'));
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
49
plugins/fields/sql/tmpl/sql.php
Normal file
49
plugins/fields/sql/tmpl/sql.php
Normal file
@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Plugin
|
||||
* @subpackage Fields.Sql
|
||||
*
|
||||
* @copyright (C) 2017 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\Factory;
|
||||
use Joomla\Database\ParameterType;
|
||||
|
||||
$value = $field->value;
|
||||
|
||||
if ($value == '') {
|
||||
return;
|
||||
}
|
||||
|
||||
$db = Factory::getDbo();
|
||||
$value = (array) $value;
|
||||
$query = $db->getQuery(true);
|
||||
$sql = $fieldParams->get('query', '');
|
||||
|
||||
$bindNames = $query->bindArray($value, ParameterType::STRING);
|
||||
|
||||
// Run the query with a having condition because it supports aliases
|
||||
$query->setQuery($sql . ' HAVING ' . $db->quoteName('value') . ' IN (' . implode(',', $bindNames) . ')');
|
||||
|
||||
try {
|
||||
$db->setQuery($query);
|
||||
$items = $db->loadObjectList();
|
||||
} catch (Exception $e) {
|
||||
// If the query failed, we fetch all elements
|
||||
$db->setQuery($sql);
|
||||
$items = $db->loadObjectList();
|
||||
}
|
||||
|
||||
$texts = [];
|
||||
|
||||
foreach ($items as $item) {
|
||||
if (in_array($item->value, $value)) {
|
||||
$texts[] = $item->text;
|
||||
}
|
||||
}
|
||||
|
||||
echo htmlentities(implode(', ', $texts));
|
||||
82
plugins/fields/subform/params/subform.xml
Normal file
82
plugins/fields/subform/params/subform.xml
Normal file
@ -0,0 +1,82 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<form>
|
||||
<field
|
||||
name="default_value"
|
||||
type="hidden"
|
||||
default=""
|
||||
/>
|
||||
<fields name="fieldparams">
|
||||
<fieldset name="fieldparams">
|
||||
|
||||
<field
|
||||
name="repeat"
|
||||
type="radio"
|
||||
label="PLG_FIELDS_SUBFORM_PARAMS_REPEAT_LABEL"
|
||||
layout="joomla.form.field.radio.switcher"
|
||||
default="1"
|
||||
>
|
||||
<option value="0">JNO</option>
|
||||
<option value="1">JYES</option>
|
||||
</field>
|
||||
<field
|
||||
name="max_rows"
|
||||
type="number"
|
||||
label="PLG_FIELDS_SUBFORM_PARAMS_MAX_ROWS_LABEL"
|
||||
default=""
|
||||
filter="integer"
|
||||
showon="repeat:1"
|
||||
/>
|
||||
<field
|
||||
name="options"
|
||||
type="subform"
|
||||
label="PLG_FIELDS_SUBFORM_PARAMS_OPTIONS_LABEL"
|
||||
icon="list"
|
||||
layout="joomla.form.field.subform.repeatable-table"
|
||||
min="1"
|
||||
multiple="true"
|
||||
>
|
||||
<form hidden="true" name="options_modal" repeat="true">
|
||||
|
||||
<field
|
||||
context=""
|
||||
name="customfield"
|
||||
type="subfields"
|
||||
label="PLG_FIELDS_SUBFORM_PARAMS_CUSTOMFIELD_LABEL"
|
||||
default=""
|
||||
required="true"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="render_values"
|
||||
type="radio"
|
||||
label="PLG_FIELDS_SUBFORM_PARAMS_RENDER_VALUES_LABEL"
|
||||
layout="joomla.form.field.radio.switcher"
|
||||
default="1"
|
||||
>
|
||||
<option value="0">JNO</option>
|
||||
<option value="1">JYES</option>
|
||||
</field>
|
||||
</form>
|
||||
</field>
|
||||
</fieldset>
|
||||
|
||||
</fields>
|
||||
<fields name="params">
|
||||
<fieldset name="basic">
|
||||
<fieldset name="formoptions">
|
||||
<field
|
||||
name="form_layout"
|
||||
type="list"
|
||||
label="COM_FIELDS_FIELD_FORM_LAYOUT_LABEL"
|
||||
default=""
|
||||
class="form-select"
|
||||
showon="repeat:1"
|
||||
>
|
||||
<option value="">JDEFAULT</option>
|
||||
<option value="joomla.form.field.subform.repeatable-table">PLG_FIELDS_SUBFORM_PARAMS_EDIT_LAYOUT_OPTION_REPEATABLE_TABLE_LABEL</option>
|
||||
<option value="joomla.form.field.subform.repeatable">PLG_FIELDS_SUBFORM_PARAMS_EDIT_LAYOUT_OPTION_REPEATABLE_FORM_LABEL</option>
|
||||
</field>
|
||||
</fieldset>
|
||||
</fieldset>
|
||||
</fields>
|
||||
</form>
|
||||
46
plugins/fields/subform/services/provider.php
Normal file
46
plugins/fields/subform/services/provider.php
Normal file
@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Plugin
|
||||
* @subpackage Fields.subform
|
||||
*
|
||||
* @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\Subform\Extension\Subform;
|
||||
|
||||
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 Subform(
|
||||
$container->get(DispatcherInterface::class),
|
||||
(array) PluginHelper::getPlugin('fields', 'subform')
|
||||
);
|
||||
$plugin->setApplication(Factory::getApplication());
|
||||
|
||||
return $plugin;
|
||||
}
|
||||
);
|
||||
}
|
||||
};
|
||||
418
plugins/fields/subform/src/Extension/Subform.php
Normal file
418
plugins/fields/subform/src/Extension/Subform.php
Normal file
@ -0,0 +1,418 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Plugin
|
||||
* @subpackage Fields.subform
|
||||
*
|
||||
* @copyright (C) 2019 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace Joomla\Plugin\Fields\Subform\Extension;
|
||||
|
||||
use DOMDocument;
|
||||
use DOMElement;
|
||||
use DOMXPath;
|
||||
use Joomla\CMS\Form\Form;
|
||||
use Joomla\Component\Fields\Administrator\Helper\FieldsHelper;
|
||||
use Joomla\Component\Fields\Administrator\Plugin\FieldsPlugin;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
/**
|
||||
* Fields Subform Plugin
|
||||
*
|
||||
* @since 3.7.0
|
||||
*/
|
||||
final class Subform extends FieldsPlugin
|
||||
{
|
||||
/**
|
||||
* Two-dimensional array to hold to do a fast in-memory caching of rendered
|
||||
* subfield values.
|
||||
*
|
||||
* @var array
|
||||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
protected $renderCache = [];
|
||||
|
||||
/**
|
||||
* Array to do a fast in-memory caching of all custom field items.
|
||||
*
|
||||
* @var array
|
||||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
protected static $customFieldsCache = null;
|
||||
|
||||
/**
|
||||
* Handles the onContentPrepareForm event. Adds form definitions to relevant forms.
|
||||
*
|
||||
* @param Form $form The form to manipulate
|
||||
* @param array|object $data The data of the form
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
public function onContentPrepareForm(Form $form, $data)
|
||||
{
|
||||
// Get the path to our own form definition (basically ./params/subform.xml)
|
||||
$path = $this->getFormPath($form, $data);
|
||||
|
||||
if ($path === null) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Ensure it is an object
|
||||
$formData = (object) $data;
|
||||
|
||||
// Now load our own form definition into a DOMDocument, because we want to manipulate it
|
||||
$xml = new \DOMDocument();
|
||||
$xml->load($path);
|
||||
|
||||
// Prepare a DOMXPath object
|
||||
$xmlxpath = new \DOMXPath($xml);
|
||||
|
||||
/**
|
||||
* Get all fields of type "subfields" in our own XML
|
||||
*
|
||||
* @var $valuefields \DOMNodeList
|
||||
*/
|
||||
$valuefields = $xmlxpath->evaluate('//field[@type="subfields"]');
|
||||
|
||||
// If we haven't found it, something is wrong
|
||||
if (!$valuefields || $valuefields->length != 1) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Now iterate over those fields and manipulate them, set its parameter `context` to our context
|
||||
foreach ($valuefields as $valuefield) {
|
||||
$valuefield->setAttribute('context', $formData->context);
|
||||
}
|
||||
|
||||
// When this is not a new instance (editing an existing instance)
|
||||
if (isset($formData->id) && $formData->id > 0) {
|
||||
// Don't allow the 'repeat' attribute to be edited
|
||||
foreach ($xmlxpath->evaluate('//field[@name="repeat"]') as $field) {
|
||||
$field->setAttribute('readonly', '1');
|
||||
}
|
||||
}
|
||||
|
||||
// And now load our manipulated form definition into the JForm
|
||||
$form->load($xml->saveXML(), true, '/form/*');
|
||||
}
|
||||
|
||||
/**
|
||||
* Manipulates the $field->value before the field is being passed to
|
||||
* onCustomFieldsPrepareField.
|
||||
*
|
||||
* @param string $context The context
|
||||
* @param object $item The item
|
||||
* @param \stdClass $field The field
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
public function onCustomFieldsBeforePrepareField($context, $item, $field)
|
||||
{
|
||||
if (!$this->isTypeSupported($field->type)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (\is_array($field->value)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$decoded_value = json_decode($field->value, true);
|
||||
|
||||
if (!$decoded_value || !\is_array($decoded_value)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$field->value = $decoded_value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders this fields value by rendering all sub fields and joining all those rendered sub fields together.
|
||||
*
|
||||
* @param string $context The context
|
||||
* @param object $item The item
|
||||
* @param \stdClass $field The field
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
public function onCustomFieldsPrepareField($context, $item, $field)
|
||||
{
|
||||
// Check if the field should be processed by us
|
||||
if (!$this->isTypeSupported($field->type)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// If we don't have any subfields (or values for them), nothing to do.
|
||||
if (!\is_array($field->value) || \count($field->value) < 1) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Get the field params
|
||||
$field_params = $this->getParamsFromField($field);
|
||||
|
||||
/**
|
||||
* Placeholder to hold all rows (if this field is repeatable).
|
||||
* Each array entry is another array representing a row, containing all of the sub fields that
|
||||
* are valid for this row and their raw and rendered values.
|
||||
*/
|
||||
$subform_rows = [];
|
||||
|
||||
// Create an array with entries being subfields forms, and if not repeatable, containing only one element.
|
||||
$rows = $field->value;
|
||||
|
||||
if ($field_params->get('repeat', '1') == '0') {
|
||||
$rows = [$field->value];
|
||||
}
|
||||
|
||||
// Iterate over each row of the data
|
||||
foreach ($rows as $row) {
|
||||
// Holds all sub fields of this row, incl. their raw and rendered value
|
||||
$row_subfields = [];
|
||||
|
||||
// For each row, iterate over all the subfields
|
||||
foreach ($this->getSubfieldsFromField($field) as $subfield) {
|
||||
// Fill value (and rawvalue) if we have data for this subfield in the current row, otherwise set them to empty
|
||||
$subfield->rawvalue = $subfield->value = $row[$subfield->name] ?? '';
|
||||
|
||||
// Do we want to render the value of this field, and is the value non-empty?
|
||||
if ($subfield->value !== '' && $subfield->render_values == '1') {
|
||||
/**
|
||||
* Construct the cache-key for our renderCache. It is important that the cache key
|
||||
* is as unique as possible to avoid false duplicates (e.g. type and rawvalue is not
|
||||
* enough for the cache key, because type 'list' and value '1' can have different
|
||||
* rendered values, depending on the list items), but it also must be as general as possible
|
||||
* to not cause too many unneeded rendering processes (e.g. the type 'text' will always be
|
||||
* rendered the same when it has the same rawvalue).
|
||||
*/
|
||||
$renderCache_key = serialize(
|
||||
[
|
||||
$subfield->type,
|
||||
$subfield->id,
|
||||
$subfield->rawvalue,
|
||||
]
|
||||
);
|
||||
|
||||
// Let's see if we have a fast in-memory result for this
|
||||
if (isset($this->renderCache[$renderCache_key])) {
|
||||
$subfield->value = $this->renderCache[$renderCache_key];
|
||||
} else {
|
||||
// Render this virtual subfield
|
||||
$subfield->value = $this->getApplication()->triggerEvent(
|
||||
'onCustomFieldsPrepareField',
|
||||
[$context, $item, $subfield]
|
||||
);
|
||||
$this->renderCache[$renderCache_key] = $subfield->value;
|
||||
}
|
||||
}
|
||||
|
||||
// Flatten the value if it is an array (list, checkboxes, etc.) [independent of render_values]
|
||||
if (\is_array($subfield->value)) {
|
||||
$subfield->value = implode(' ', $subfield->value);
|
||||
}
|
||||
|
||||
// Store the subfield (incl. its raw and rendered value) into this rows sub fields
|
||||
$row_subfields[$subfield->fieldname] = $subfield;
|
||||
}
|
||||
|
||||
// Store all the sub fields of this row
|
||||
$subform_rows[] = $row_subfields;
|
||||
}
|
||||
|
||||
// Store all the rows and their corresponding sub fields in $field->subform_rows
|
||||
$field->subform_rows = $subform_rows;
|
||||
|
||||
// Call our parent to combine all those together for the final $field->value
|
||||
return parent::onCustomFieldsPrepareField($context, $item, $field);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a DOMElement which is the child of $parent and represents
|
||||
* the form XML definition for this field.
|
||||
*
|
||||
* @param \stdClass $field The field
|
||||
* @param \DOMElement $parent The original parent element
|
||||
* @param Form $form The form
|
||||
*
|
||||
* @return \DOMElement
|
||||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
public function onCustomFieldsPrepareDom($field, \DOMElement $parent, Form $form)
|
||||
{
|
||||
// Call the onCustomFieldsPrepareDom method on FieldsPlugin
|
||||
$parent_field = parent::onCustomFieldsPrepareDom($field, $parent, $form);
|
||||
|
||||
if (!$parent_field) {
|
||||
return $parent_field;
|
||||
}
|
||||
|
||||
// Override the fieldname attribute of the subform - this is being used to index the rows
|
||||
$parent_field->setAttribute('fieldname', 'row');
|
||||
|
||||
// If the user configured this subform instance as required
|
||||
if ($field->required) {
|
||||
// Then we need to have at least one row
|
||||
$parent_field->setAttribute('min', '1');
|
||||
}
|
||||
|
||||
// Get the configured parameters for this field
|
||||
$field_params = $this->getParamsFromField($field);
|
||||
|
||||
// If this fields should be repeatable, set some attributes on the subform element
|
||||
if ($field_params->get('repeat', '1') == '1') {
|
||||
$parent_field->setAttribute('multiple', 'true');
|
||||
$parent_field->setAttribute('layout', 'joomla.form.field.subform.repeatable-table');
|
||||
}
|
||||
|
||||
// Create a child 'form' DOMElement under the field[type=subform] element.
|
||||
$parent_fieldset = $parent_field->appendChild(new \DOMElement('form'));
|
||||
$parent_fieldset->setAttribute('hidden', 'true');
|
||||
$parent_fieldset->setAttribute('name', ($field->name . '_modal'));
|
||||
|
||||
if ($field_params->get('max_rows')) {
|
||||
$parent_field->setAttribute('max', $field_params->get('max_rows'));
|
||||
}
|
||||
|
||||
// If this field should be repeatable, set some attributes on the modal
|
||||
if ($field_params->get('repeat', '1') == '1') {
|
||||
$parent_fieldset->setAttribute('repeat', 'true');
|
||||
}
|
||||
|
||||
// Get the configured sub fields for this field
|
||||
$subfields = $this->getSubfieldsFromField($field);
|
||||
|
||||
// If we have 5 or more of them, use the `repeatable` layout instead of the `repeatable-table`
|
||||
if (\count($subfields) >= 5) {
|
||||
$parent_field->setAttribute('layout', 'joomla.form.field.subform.repeatable');
|
||||
}
|
||||
|
||||
// Iterate over the sub fields to call prepareDom on each of those sub-fields
|
||||
foreach ($subfields as $subfield) {
|
||||
// Let the relevant plugins do their work and insert the correct
|
||||
// DOMElement's into our $parent_fieldset.
|
||||
$this->getApplication()->triggerEvent(
|
||||
'onCustomFieldsPrepareDom',
|
||||
[$subfield, $parent_fieldset, $form]
|
||||
);
|
||||
}
|
||||
|
||||
// If the edit layout is set we override any automation
|
||||
$editLayout = $field->params->get('form_layout');
|
||||
if ($editLayout) {
|
||||
$parent_field->setAttribute('layout', $editLayout);
|
||||
}
|
||||
|
||||
return $parent_field;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of all options configured for this field.
|
||||
*
|
||||
* @param \stdClass $field The field
|
||||
*
|
||||
* @return \stdClass[]
|
||||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
protected function getOptionsFromField(\stdClass $field)
|
||||
{
|
||||
$result = [];
|
||||
|
||||
// Fetch the options from the plugin
|
||||
$params = $this->getParamsFromField($field);
|
||||
|
||||
foreach ($params->get('options', []) as $option) {
|
||||
$result[] = (object) $option;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the configured params for a given field.
|
||||
*
|
||||
* @param \stdClass $field The field
|
||||
*
|
||||
* @return \Joomla\Registry\Registry
|
||||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
protected function getParamsFromField(\stdClass $field)
|
||||
{
|
||||
$params = (clone $this->params);
|
||||
|
||||
if (isset($field->fieldparams) && \is_object($field->fieldparams)) {
|
||||
$params->merge($field->fieldparams);
|
||||
}
|
||||
|
||||
return $params;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of all subfields for a given field. This will always return a bare clone
|
||||
* of a sub field, so manipulating it is safe.
|
||||
*
|
||||
* @param \stdClass $field The field
|
||||
*
|
||||
* @return \stdClass[]
|
||||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
protected function getSubfieldsFromField(\stdClass $field)
|
||||
{
|
||||
if (static::$customFieldsCache === null) {
|
||||
// Prepare our cache
|
||||
static::$customFieldsCache = [];
|
||||
|
||||
// Get all custom field instances
|
||||
$customFields = FieldsHelper::getFields('', null, false, null, true);
|
||||
|
||||
foreach ($customFields as $customField) {
|
||||
// Store each custom field instance in our cache with its id as key
|
||||
static::$customFieldsCache[$customField->id] = $customField;
|
||||
}
|
||||
}
|
||||
|
||||
$result = [];
|
||||
|
||||
// Iterate over all configured options for this field
|
||||
foreach ($this->getOptionsFromField($field) as $option) {
|
||||
// Check whether the wanted sub field really is an existing custom field
|
||||
if (!isset(static::$customFieldsCache[$option->customfield])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Get a clone of the sub field, so we and the caller can do some manipulation with it.
|
||||
$cur_field = (clone static::$customFieldsCache[$option->customfield]);
|
||||
|
||||
// Manipulate it and add our custom configuration to it
|
||||
$cur_field->render_values = $option->render_values;
|
||||
|
||||
/**
|
||||
* Set the name of the sub field to its id so that the values in the database are being saved
|
||||
* based on the id of the sub fields, not on their name. Actually we do not need the name of
|
||||
* the sub fields to render them, but just to make sure we have the name when we need it, we
|
||||
* store it as `fieldname`.
|
||||
*/
|
||||
$cur_field->fieldname = $cur_field->name;
|
||||
$cur_field->name = 'field' . $cur_field->id;
|
||||
|
||||
// And add it to our result
|
||||
$result[] = $cur_field;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
23
plugins/fields/subform/subform.xml
Normal file
23
plugins/fields/subform/subform.xml
Normal file
@ -0,0 +1,23 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<extension type="plugin" group="fields" method="upgrade">
|
||||
<name>plg_fields_subform</name>
|
||||
<author>Joomla! Project</author>
|
||||
<creationDate>2017-06</creationDate>
|
||||
<copyright>(C) 2019 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>4.0.0</version>
|
||||
<description>PLG_FIELDS_SUBFORM_XML_DESCRIPTION</description>
|
||||
<namespace path="src">Joomla\Plugin\Fields\Subform</namespace>
|
||||
<files>
|
||||
<folder>params</folder>
|
||||
<folder plugin="subform">services</folder>
|
||||
<folder>src</folder>
|
||||
<folder>tmpl</folder>
|
||||
</files>
|
||||
<languages>
|
||||
<language tag="en-GB">language/en-GB/plg_fields_subform.ini</language>
|
||||
<language tag="en-GB">language/en-GB/plg_fields_subform.sys.ini</language>
|
||||
</languages>
|
||||
</extension>
|
||||
60
plugins/fields/subform/tmpl/subform.php
Normal file
60
plugins/fields/subform/tmpl/subform.php
Normal file
@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Plugin
|
||||
* @subpackage Fields.Subform
|
||||
*
|
||||
* @copyright (C) 2019 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
use Joomla\Component\Fields\Administrator\Helper\FieldsHelper;
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
if (!$context || empty($field->subform_rows)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$result = '';
|
||||
|
||||
// Iterate over each row that we have
|
||||
foreach ($field->subform_rows as $subform_row) {
|
||||
// Placeholder array to generate this rows output
|
||||
$row_output = [];
|
||||
|
||||
// Iterate over each sub field inside of that row
|
||||
foreach ($subform_row as $subfield) {
|
||||
$class = trim($subfield->params->get('render_class', ''));
|
||||
$layout = trim($subfield->params->get('layout', 'render'));
|
||||
$content = trim(
|
||||
FieldsHelper::render(
|
||||
$context,
|
||||
'field.' . $layout, // normally just 'field.render'
|
||||
['field' => $subfield]
|
||||
)
|
||||
);
|
||||
|
||||
// Skip empty output
|
||||
if ($content === '') {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Generate the output for this sub field and row
|
||||
$row_output[] = '<span class="field-entry' . ($class ? (' ' . $class) : '') . '">' . $content . '</span>';
|
||||
}
|
||||
|
||||
// Skip empty rows
|
||||
if (count($row_output) == 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$result .= '<li>' . implode(', ', $row_output) . '</li>';
|
||||
}
|
||||
?>
|
||||
|
||||
<?php if (trim($result) != '') : ?>
|
||||
<ul class="fields-container">
|
||||
<?php echo $result; ?>
|
||||
</ul>
|
||||
<?php endif; ?>
|
||||
31
plugins/fields/text/params/text.xml
Normal file
31
plugins/fields/text/params/text.xml
Normal file
@ -0,0 +1,31 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<form>
|
||||
<fields name="fieldparams">
|
||||
<fieldset name="fieldparams">
|
||||
<field
|
||||
name="filter"
|
||||
type="list"
|
||||
label="PLG_FIELDS_TEXT_PARAMS_FILTER_LABEL"
|
||||
class="list"
|
||||
validate="options"
|
||||
>
|
||||
<option value="">COM_FIELDS_FIELD_USE_GLOBAL</option>
|
||||
<option value="0">JNO</option>
|
||||
<option value="raw">JLIB_FILTER_PARAMS_RAW</option>
|
||||
<option value="safehtml">JLIB_FILTER_PARAMS_SAFEHTML</option>
|
||||
<option value="\Joomla\CMS\Component\ComponentHelper::filterText">JLIB_FILTER_PARAMS_TEXT</option>
|
||||
<option value="alnum">JLIB_FILTER_PARAMS_ALNUM</option>
|
||||
<option value="integer">JLIB_FILTER_PARAMS_INTEGER</option>
|
||||
<option value="float">JLIB_FILTER_PARAMS_FLOAT</option>
|
||||
<option value="tel">JLIB_FILTER_PARAMS_TEL</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="maxlength"
|
||||
type="number"
|
||||
label="PLG_FIELDS_TEXT_PARAMS_MAXLENGTH_LABEL"
|
||||
filter="integer"
|
||||
/>
|
||||
</fieldset>
|
||||
</fields>
|
||||
</form>
|
||||
46
plugins/fields/text/services/provider.php
Normal file
46
plugins/fields/text/services/provider.php
Normal file
@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Plugin
|
||||
* @subpackage Fields.text
|
||||
*
|
||||
* @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\Text\Extension\Text;
|
||||
|
||||
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 Text(
|
||||
$container->get(DispatcherInterface::class),
|
||||
(array) PluginHelper::getPlugin('fields', 'text')
|
||||
);
|
||||
$plugin->setApplication(Factory::getApplication());
|
||||
|
||||
return $plugin;
|
||||
}
|
||||
);
|
||||
}
|
||||
};
|
||||
27
plugins/fields/text/src/Extension/Text.php
Normal file
27
plugins/fields/text/src/Extension/Text.php
Normal file
@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Plugin
|
||||
* @subpackage Fields.text
|
||||
*
|
||||
* @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\Text\Extension;
|
||||
|
||||
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 Text Plugin
|
||||
*
|
||||
* @since 3.7.0
|
||||
*/
|
||||
final class Text extends FieldsPlugin implements SubscriberInterface
|
||||
{
|
||||
}
|
||||
53
plugins/fields/text/text.xml
Normal file
53
plugins/fields/text/text.xml
Normal file
@ -0,0 +1,53 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<extension type="plugin" group="fields" method="upgrade">
|
||||
<name>plg_fields_text</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_TEXT_XML_DESCRIPTION</description>
|
||||
<namespace path="src">Joomla\Plugin\Fields\Text</namespace>
|
||||
<files>
|
||||
<folder>params</folder>
|
||||
<folder plugin="text">services</folder>
|
||||
<folder>src</folder>
|
||||
<folder>tmpl</folder>
|
||||
</files>
|
||||
<languages>
|
||||
<language tag="en-GB">language/en-GB/plg_fields_text.ini</language>
|
||||
<language tag="en-GB">language/en-GB/plg_fields_text.sys.ini</language>
|
||||
</languages>
|
||||
<config>
|
||||
<fields name="params">
|
||||
<fieldset name="basic">
|
||||
<field
|
||||
name="filter"
|
||||
type="list"
|
||||
label="PLG_FIELDS_TEXT_PARAMS_FILTER_LABEL"
|
||||
class="list"
|
||||
default="\Joomla\CMS\Component\ComponentHelper::filterText"
|
||||
validate="options"
|
||||
>
|
||||
<option value="0">JNO</option>
|
||||
<option value="raw">JLIB_FILTER_PARAMS_RAW</option>
|
||||
<option value="safehtml">JLIB_FILTER_PARAMS_SAFEHTML</option>
|
||||
<option value="\Joomla\CMS\Component\ComponentHelper::filterText">JLIB_FILTER_PARAMS_TEXT</option>
|
||||
<option value="alnum">JLIB_FILTER_PARAMS_ALNUM</option>
|
||||
<option value="integer">JLIB_FILTER_PARAMS_INTEGER</option>
|
||||
<option value="float">JLIB_FILTER_PARAMS_FLOAT</option>
|
||||
<option value="tel">JLIB_FILTER_PARAMS_TEL</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="maxlength"
|
||||
type="number"
|
||||
label="PLG_FIELDS_TEXT_PARAMS_MAXLENGTH_LABEL"
|
||||
filter="integer"
|
||||
/>
|
||||
</fieldset>
|
||||
</fields>
|
||||
</config>
|
||||
</extension>
|
||||
23
plugins/fields/text/tmpl/text.php
Normal file
23
plugins/fields/text/tmpl/text.php
Normal file
@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Plugin
|
||||
* @subpackage Fields.Text
|
||||
*
|
||||
* @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);
|
||||
45
plugins/fields/textarea/params/textarea.xml
Normal file
45
plugins/fields/textarea/params/textarea.xml
Normal file
@ -0,0 +1,45 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<form>
|
||||
<fields name="fieldparams">
|
||||
<fieldset name="fieldparams">
|
||||
<field
|
||||
name="rows"
|
||||
type="number"
|
||||
label="PLG_FIELDS_TEXTAREA_PARAMS_ROWS_LABEL"
|
||||
filter="integer"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="cols"
|
||||
type="number"
|
||||
label="PLG_FIELDS_TEXTAREA_PARAMS_COLS_LABEL"
|
||||
filter="integer"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="maxlength"
|
||||
type="number"
|
||||
label="PLG_FIELDS_TEXTAREA_PARAMS_MAXLENGTH_LABEL"
|
||||
filter="integer"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="filter"
|
||||
type="list"
|
||||
label="PLG_FIELDS_TEXTAREA_PARAMS_FILTER_LABEL"
|
||||
class="list"
|
||||
validate="options"
|
||||
>
|
||||
<option value="">COM_FIELDS_FIELD_USE_GLOBAL</option>
|
||||
<option value="0">JNO</option>
|
||||
<option value="raw">JLIB_FILTER_PARAMS_RAW</option>
|
||||
<option value="safehtml">JLIB_FILTER_PARAMS_SAFEHTML</option>
|
||||
<option value="\Joomla\CMS\Component\ComponentHelper::filterText">JLIB_FILTER_PARAMS_TEXT</option>
|
||||
<option value="alnum">JLIB_FILTER_PARAMS_ALNUM</option>
|
||||
<option value="integer">JLIB_FILTER_PARAMS_INTEGER</option>
|
||||
<option value="float">JLIB_FILTER_PARAMS_FLOAT</option>
|
||||
<option value="tel">JLIB_FILTER_PARAMS_TEL</option>
|
||||
</field>
|
||||
</fieldset>
|
||||
</fields>
|
||||
</form>
|
||||
46
plugins/fields/textarea/services/provider.php
Normal file
46
plugins/fields/textarea/services/provider.php
Normal file
@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Plugin
|
||||
* @subpackage Fields.textarea
|
||||
*
|
||||
* @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\Textarea\Extension\Textarea;
|
||||
|
||||
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 Textarea(
|
||||
$container->get(DispatcherInterface::class),
|
||||
(array) PluginHelper::getPlugin('fields', 'textarea')
|
||||
);
|
||||
$plugin->setApplication(Factory::getApplication());
|
||||
|
||||
return $plugin;
|
||||
}
|
||||
);
|
||||
}
|
||||
};
|
||||
27
plugins/fields/textarea/src/Extension/Textarea.php
Normal file
27
plugins/fields/textarea/src/Extension/Textarea.php
Normal file
@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Plugin
|
||||
* @subpackage Fields.textarea
|
||||
*
|
||||
* @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\Textarea\Extension;
|
||||
|
||||
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 Textarea Plugin
|
||||
*
|
||||
* @since 3.7.0
|
||||
*/
|
||||
final class Textarea extends FieldsPlugin implements SubscriberInterface
|
||||
{
|
||||
}
|
||||
69
plugins/fields/textarea/textarea.xml
Normal file
69
plugins/fields/textarea/textarea.xml
Normal file
@ -0,0 +1,69 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<extension type="plugin" group="fields" method="upgrade">
|
||||
<name>plg_fields_textarea</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_TEXTAREA_XML_DESCRIPTION</description>
|
||||
<namespace path="src">Joomla\Plugin\Fields\Textarea</namespace>
|
||||
<files>
|
||||
<folder>params</folder>
|
||||
<folder plugin="textarea">services</folder>
|
||||
<folder>src</folder>
|
||||
<folder>tmpl</folder>
|
||||
</files>
|
||||
<languages>
|
||||
<language tag="en-GB">language/en-GB/plg_fields_textarea.ini</language>
|
||||
<language tag="en-GB">language/en-GB/plg_fields_textarea.sys.ini</language>
|
||||
</languages>
|
||||
<config>
|
||||
<fields name="params">
|
||||
<fieldset name="basic">
|
||||
<field
|
||||
name="rows"
|
||||
type="number"
|
||||
label="PLG_FIELDS_TEXTAREA_PARAMS_ROWS_LABEL"
|
||||
default="10"
|
||||
filter="integer"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="cols"
|
||||
type="number"
|
||||
label="PLG_FIELDS_TEXTAREA_PARAMS_COLS_LABEL"
|
||||
default="10"
|
||||
filter="integer"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="maxlength"
|
||||
type="number"
|
||||
label="PLG_FIELDS_TEXTAREA_PARAMS_MAXLENGTH_LABEL"
|
||||
filter="integer"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="filter"
|
||||
type="list"
|
||||
label="PLG_FIELDS_TEXTAREA_PARAMS_FILTER_LABEL"
|
||||
class="list"
|
||||
default="\Joomla\CMS\Component\ComponentHelper::filterText"
|
||||
validate="options"
|
||||
>
|
||||
<option value="0">JNO</option>
|
||||
<option value="raw">JLIB_FILTER_PARAMS_RAW</option>
|
||||
<option value="safehtml">JLIB_FILTER_PARAMS_SAFEHTML</option>
|
||||
<option value="\Joomla\CMS\Component\ComponentHelper::filterText">JLIB_FILTER_PARAMS_TEXT</option>
|
||||
<option value="alnum">JLIB_FILTER_PARAMS_ALNUM</option>
|
||||
<option value="integer">JLIB_FILTER_PARAMS_INTEGER</option>
|
||||
<option value="float">JLIB_FILTER_PARAMS_FLOAT</option>
|
||||
<option value="tel">JLIB_FILTER_PARAMS_TEL</option>
|
||||
</field>
|
||||
</fieldset>
|
||||
</fields>
|
||||
</config>
|
||||
</extension>
|
||||
21
plugins/fields/textarea/tmpl/textarea.php
Normal file
21
plugins/fields/textarea/tmpl/textarea.php
Normal file
@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Plugin
|
||||
* @subpackage Fields.Textarea
|
||||
*
|
||||
* @copyright (C) 2017 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\HTML\HTMLHelper;
|
||||
|
||||
$value = $field->value;
|
||||
|
||||
if ($value == '') {
|
||||
return;
|
||||
}
|
||||
|
||||
echo HTMLHelper::_('content.prepare', $value);
|
||||
46
plugins/fields/url/params/url.xml
Normal file
46
plugins/fields/url/params/url.xml
Normal file
@ -0,0 +1,46 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<form>
|
||||
<fields name="fieldparams">
|
||||
<fieldset name="fieldparams">
|
||||
<field
|
||||
name="schemes"
|
||||
type="list"
|
||||
label="PLG_FIELDS_URL_PARAMS_SCHEMES_LABEL"
|
||||
multiple="true"
|
||||
layout="joomla.form.field.list-fancy-select"
|
||||
validate="options"
|
||||
>
|
||||
<option value="http">HTTP</option>
|
||||
<option value="https">HTTPS</option>
|
||||
<option value="ftp">FTP</option>
|
||||
<option value="ftps">FTPS</option>
|
||||
<option value="file">FILE</option>
|
||||
<option value="mailto">MAILTO</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="relative"
|
||||
type="list"
|
||||
label="PLG_FIELDS_URL_PARAMS_RELATIVE_LABEL"
|
||||
filter="integer"
|
||||
validate="options"
|
||||
>
|
||||
<option value="">COM_FIELDS_FIELD_USE_GLOBAL</option>
|
||||
<option value="1">JYES</option>
|
||||
<option value="0">JNO</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="show_url"
|
||||
type="radio"
|
||||
label="PLG_FIELDS_URL_PARAMS_SHOW_URL"
|
||||
layout="joomla.form.field.radio.switcher"
|
||||
default="1"
|
||||
filter="integer"
|
||||
>
|
||||
<option value="0">JNO</option>
|
||||
<option value="1">JYES</option>
|
||||
</field>
|
||||
</fieldset>
|
||||
</fields>
|
||||
</form>
|
||||
46
plugins/fields/url/services/provider.php
Normal file
46
plugins/fields/url/services/provider.php
Normal file
@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Plugin
|
||||
* @subpackage Fields.url
|
||||
*
|
||||
* @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\Url\Extension\Url;
|
||||
|
||||
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 Url(
|
||||
$container->get(DispatcherInterface::class),
|
||||
(array) PluginHelper::getPlugin('fields', 'url')
|
||||
);
|
||||
$plugin->setApplication(Factory::getApplication());
|
||||
|
||||
return $plugin;
|
||||
}
|
||||
);
|
||||
}
|
||||
};
|
||||
55
plugins/fields/url/src/Extension/Url.php
Normal file
55
plugins/fields/url/src/Extension/Url.php
Normal file
@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Plugin
|
||||
* @subpackage Fields.url
|
||||
*
|
||||
* @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\Url\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 Url Plugin
|
||||
*
|
||||
* @since 3.7.0
|
||||
*/
|
||||
final class Url 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', 'url');
|
||||
|
||||
if (! $fieldNode->getAttribute('relative')) {
|
||||
$fieldNode->removeAttribute('relative');
|
||||
}
|
||||
|
||||
return $fieldNode;
|
||||
}
|
||||
}
|
||||
40
plugins/fields/url/tmpl/url.php
Normal file
40
plugins/fields/url/tmpl/url.php
Normal file
@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Plugin
|
||||
* @subpackage Fields.URL
|
||||
*
|
||||
* @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;
|
||||
|
||||
use Joomla\CMS\Language\Text;
|
||||
use Joomla\CMS\Uri\Uri;
|
||||
|
||||
$value = $field->value;
|
||||
|
||||
if ($value == '') {
|
||||
return;
|
||||
}
|
||||
|
||||
$attributes = '';
|
||||
|
||||
if (!Uri::isInternal($value)) {
|
||||
$attributes = ' rel="nofollow noopener noreferrer" target="_blank"';
|
||||
$text = Text::_('JVISIT_WEBSITE');
|
||||
} else {
|
||||
$text = Text::_('JVISIT_LINK');
|
||||
}
|
||||
|
||||
if ($fieldParams->get('show_url', 0)) {
|
||||
$text = htmlspecialchars($value);
|
||||
}
|
||||
|
||||
echo sprintf(
|
||||
'<a href="%s"%s>%s</a>',
|
||||
htmlspecialchars($value),
|
||||
$attributes,
|
||||
$text
|
||||
);
|
||||
56
plugins/fields/url/url.xml
Normal file
56
plugins/fields/url/url.xml
Normal file
@ -0,0 +1,56 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<extension type="plugin" group="fields" method="upgrade">
|
||||
<name>plg_fields_url</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_URL_XML_DESCRIPTION</description>
|
||||
<namespace path="src">Joomla\Plugin\Fields\Url</namespace>
|
||||
<files>
|
||||
<folder>params</folder>
|
||||
<folder plugin="url">services</folder>
|
||||
<folder>src</folder>
|
||||
<folder>tmpl</folder>
|
||||
</files>
|
||||
<languages>
|
||||
<language tag="en-GB">language/en-GB/plg_fields_url.ini</language>
|
||||
<language tag="en-GB">language/en-GB/plg_fields_url.sys.ini</language>
|
||||
</languages>
|
||||
<config>
|
||||
<fields name="params">
|
||||
<fieldset name="basic">
|
||||
<field
|
||||
name="schemes"
|
||||
type="list"
|
||||
label="PLG_FIELDS_URL_PARAMS_SCHEMES_LABEL"
|
||||
multiple="true"
|
||||
layout="joomla.form.field.list-fancy-select"
|
||||
validate="options"
|
||||
>
|
||||
<option value="http">HTTP</option>
|
||||
<option value="https">HTTPS</option>
|
||||
<option value="ftp">FTP</option>
|
||||
<option value="ftps">FTPS</option>
|
||||
<option value="file">FILE</option>
|
||||
<option value="mailto">MAILTO</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="relative"
|
||||
type="radio"
|
||||
label="PLG_FIELDS_URL_PARAMS_RELATIVE_LABEL"
|
||||
layout="joomla.form.field.radio.switcher"
|
||||
default="1"
|
||||
filter="integer"
|
||||
>
|
||||
<option value="0">JNO</option>
|
||||
<option value="1">JYES</option>
|
||||
</field>
|
||||
</fieldset>
|
||||
</fields>
|
||||
</config>
|
||||
</extension>
|
||||
18
plugins/fields/user/params/user.xml
Normal file
18
plugins/fields/user/params/user.xml
Normal file
@ -0,0 +1,18 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<form>
|
||||
<field
|
||||
name="default_value"
|
||||
type="user"
|
||||
label="PLG_FIELDS_USER_DEFAULT_VALUE_LABEL"
|
||||
validate="UserId"
|
||||
/>
|
||||
<fields name="params" label="COM_FIELDS_FIELD_BASIC_LABEL">
|
||||
<fieldset name="basic">
|
||||
<field
|
||||
name="show_on"
|
||||
type="hidden"
|
||||
filter="unset"
|
||||
/>
|
||||
</fieldset>
|
||||
</fields>
|
||||
</form>
|
||||
48
plugins/fields/user/services/provider.php
Normal file
48
plugins/fields/user/services/provider.php
Normal file
@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Plugin
|
||||
* @subpackage Fields.user
|
||||
*
|
||||
* @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\CMS\User\UserFactoryInterface;
|
||||
use Joomla\DI\Container;
|
||||
use Joomla\DI\ServiceProviderInterface;
|
||||
use Joomla\Event\DispatcherInterface;
|
||||
use Joomla\Plugin\Fields\User\Extension\User;
|
||||
|
||||
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 User(
|
||||
$container->get(DispatcherInterface::class),
|
||||
(array) PluginHelper::getPlugin('fields', 'user')
|
||||
);
|
||||
$plugin->setApplication(Factory::getApplication());
|
||||
$plugin->setUserFactory($container->get(UserFactoryInterface::class));
|
||||
|
||||
return $plugin;
|
||||
}
|
||||
);
|
||||
}
|
||||
};
|
||||
51
plugins/fields/user/src/Extension/User.php
Normal file
51
plugins/fields/user/src/Extension/User.php
Normal file
@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Plugin
|
||||
* @subpackage Fields.user
|
||||
*
|
||||
* @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\User\Extension;
|
||||
|
||||
use Joomla\CMS\Form\Form;
|
||||
use Joomla\CMS\User\UserFactoryAwareTrait;
|
||||
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 User Plugin
|
||||
*
|
||||
* @since 3.7.0
|
||||
*/
|
||||
final class User extends FieldsPlugin implements SubscriberInterface
|
||||
{
|
||||
use UserFactoryAwareTrait;
|
||||
|
||||
/**
|
||||
* 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)
|
||||
{
|
||||
if ($this->getApplication()->isClient('site')) {
|
||||
// The user field is not working on the front end
|
||||
return;
|
||||
}
|
||||
|
||||
return parent::onCustomFieldsPrepareDom($field, $parent, $form);
|
||||
}
|
||||
}
|
||||
39
plugins/fields/user/tmpl/user.php
Normal file
39
plugins/fields/user/tmpl/user.php
Normal file
@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Plugin
|
||||
* @subpackage Fields.User
|
||||
*
|
||||
* @copyright (C) 2017 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;
|
||||
}
|
||||
|
||||
$value = (array) $value;
|
||||
$texts = [];
|
||||
|
||||
foreach ($value as $userId) {
|
||||
if (!$userId) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$user = $this->getUserFactory()->loadUserById($userId);
|
||||
|
||||
if ($user) {
|
||||
// Use the Username
|
||||
$texts[] = $user->name;
|
||||
continue;
|
||||
}
|
||||
|
||||
// Fallback and add the User ID if we get no JUser Object
|
||||
$texts[] = $userId;
|
||||
}
|
||||
|
||||
echo htmlentities(implode(', ', $texts));
|
||||
23
plugins/fields/user/user.xml
Normal file
23
plugins/fields/user/user.xml
Normal file
@ -0,0 +1,23 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<extension type="plugin" group="fields" method="upgrade">
|
||||
<name>plg_fields_user</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_USER_XML_DESCRIPTION</description>
|
||||
<namespace path="src">Joomla\Plugin\Fields\User</namespace>
|
||||
<files>
|
||||
<folder>params</folder>
|
||||
<folder plugin="user">services</folder>
|
||||
<folder>src</folder>
|
||||
<folder>tmpl</folder>
|
||||
</files>
|
||||
<languages>
|
||||
<language tag="en-GB">language/en-GB/plg_fields_user.ini</language>
|
||||
<language tag="en-GB">language/en-GB/plg_fields_user.sys.ini</language>
|
||||
</languages>
|
||||
</extension>
|
||||
18
plugins/fields/usergrouplist/params/usergrouplist.xml
Normal file
18
plugins/fields/usergrouplist/params/usergrouplist.xml
Normal file
@ -0,0 +1,18 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<form>
|
||||
<fields name="fieldparams">
|
||||
<fieldset name="fieldparams">
|
||||
<field
|
||||
name="multiple"
|
||||
type="list"
|
||||
label="PLG_FIELDS_USERGROUPLIST_PARAMS_MULTIPLE_LABEL"
|
||||
filter="integer"
|
||||
validate="options"
|
||||
>
|
||||
<option value="">COM_FIELDS_FIELD_USE_GLOBAL</option>
|
||||
<option value="1">JYES</option>
|
||||
<option value="0">JNO</option>
|
||||
</field>
|
||||
</fieldset>
|
||||
</fields>
|
||||
</form>
|
||||
46
plugins/fields/usergrouplist/services/provider.php
Normal file
46
plugins/fields/usergrouplist/services/provider.php
Normal file
@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Plugin
|
||||
* @subpackage Fields.usergrouplist
|
||||
*
|
||||
* @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\UsergroupList\Extension\UsergroupList;
|
||||
|
||||
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 UsergroupList(
|
||||
$container->get(DispatcherInterface::class),
|
||||
(array) PluginHelper::getPlugin('fields', 'usergrouplist')
|
||||
);
|
||||
$plugin->setApplication(Factory::getApplication());
|
||||
|
||||
return $plugin;
|
||||
}
|
||||
);
|
||||
}
|
||||
};
|
||||
27
plugins/fields/usergrouplist/src/Extension/UsergroupList.php
Normal file
27
plugins/fields/usergrouplist/src/Extension/UsergroupList.php
Normal file
@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Plugin
|
||||
* @subpackage Fields.usergrouplist
|
||||
*
|
||||
* @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\UsergroupList\Extension;
|
||||
|
||||
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 UsergroupList Plugin
|
||||
*
|
||||
* @since 3.7.0
|
||||
*/
|
||||
final class UsergroupList extends FieldsPlugin implements SubscriberInterface
|
||||
{
|
||||
}
|
||||
31
plugins/fields/usergrouplist/tmpl/usergrouplist.php
Normal file
31
plugins/fields/usergrouplist/tmpl/usergrouplist.php
Normal file
@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Plugin
|
||||
* @subpackage Fields.Usergrouplist
|
||||
*
|
||||
* @copyright (C) 2017 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\Component\Users\Administrator\Helper\UsersHelper;
|
||||
|
||||
$value = $field->value;
|
||||
|
||||
if ($value == '') {
|
||||
return;
|
||||
}
|
||||
|
||||
$value = (array) $value;
|
||||
$texts = [];
|
||||
$groups = UsersHelper::getGroups();
|
||||
|
||||
foreach ($groups as $group) {
|
||||
if (in_array($group->value, $value)) {
|
||||
$texts[] = htmlentities(trim($group->text, '- '));
|
||||
}
|
||||
}
|
||||
|
||||
echo htmlentities(implode(', ', $texts));
|
||||
40
plugins/fields/usergrouplist/usergrouplist.xml
Normal file
40
plugins/fields/usergrouplist/usergrouplist.xml
Normal file
@ -0,0 +1,40 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<extension type="plugin" group="fields" method="upgrade">
|
||||
<name>plg_fields_usergrouplist</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_USERGROUPLIST_XML_DESCRIPTION</description>
|
||||
<namespace path="src">Joomla\Plugin\Fields\UsergroupList</namespace>
|
||||
<files>
|
||||
<folder>params</folder>
|
||||
<folder plugin="usergrouplist">services</folder>
|
||||
<folder>src</folder>
|
||||
<folder>tmpl</folder>
|
||||
</files>
|
||||
<languages>
|
||||
<language tag="en-GB">language/en-GB/plg_fields_usergrouplist.ini</language>
|
||||
<language tag="en-GB">language/en-GB/plg_fields_usergrouplist.sys.ini</language>
|
||||
</languages>
|
||||
<config>
|
||||
<fields name="params">
|
||||
<fieldset name="basic">
|
||||
<field
|
||||
name="multiple"
|
||||
type="radio"
|
||||
label="PLG_FIELDS_USERGROUPLIST_PARAMS_MULTIPLE_LABEL"
|
||||
layout="joomla.form.field.radio.switcher"
|
||||
default="0"
|
||||
filter="integer"
|
||||
>
|
||||
<option value="0">JNO</option>
|
||||
<option value="1">JYES</option>
|
||||
</field>
|
||||
</fieldset>
|
||||
</fields>
|
||||
</config>
|
||||
</extension>
|
||||
Reference in New Issue
Block a user