| Server IP : 54.36.91.62 / Your IP : 216.73.217.112 Web Server : Apache System : Linux webm013.cluster127.gra.hosting.ovh.net 5.15.206-ovh-vps-grsec-zfs-classid #1 SMP Fri May 15 02:41:25 UTC 2026 x86_64 User : coopiak ( 151928) PHP Version : 8.3.23 Disable Function : _dyuweyrj4,_dyuweyrj4r,dl MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /home/coopiak/amisdesseniors-fr/lemans/libraries/regularlabs/src/Plugin/ |
Upload File : |
<?php
/**
* @package Regular Labs Library
* @version 25.9.9174
*
* @author Peter van Westen <info@regularlabs.com>
* @link https://regularlabs.com
* @copyright Copyright © 2025 Regular Labs All Rights Reserved
* @license GNU General Public License version 2 or later
*/
namespace RegularLabs\Library\Plugin;
defined('_JEXEC') or die;
use Bluecoder\Component\Jfilters\Administrator\Model\Filter\Option\Collection as JfiltersCollection;
use JLoader;
use Joomla\CMS\Event\AbstractImmutableEvent;
use Joomla\Component\Fields\Administrator\Plugin\FieldsPlugin as JFieldsPlugin;
use Joomla\Event\DispatcherInterface as JDispatcherInterface;
use Joomla\Event\SubscriberInterface;
use ReflectionClass;
use stdclass;
class Fields extends JFieldsPlugin implements SubscriberInterface
{
static $_extra_events = [];
public function __construct($config = [])
{
if ($config instanceof JDispatcherInterface) {
$dispatcher = $config;
$config = func_num_args() > 1 ? func_get_arg(1) : [];
parent::__construct($dispatcher, $config);
} else {
parent::__construct($config);
}
$path = JPATH_PLUGINS . '/fields/' . $this->_name . '/src/Form/Field';
if (!file_exists($path)) {
return;
}
$name = str_replace('PlgFields', '', $this->getClassName());
JLoader::registerAlias('JFormField' . $name, '\RegularLabs\Plugin\Fields\\' . $name . '\Form\Field\\' . $name . 'Field');
}
public static function getSubscribedEvents(): array
{
return ['onCustomFieldsGetTypes' => 'getFieldTypes', 'onCustomFieldsPrepareField' => 'prepareField', 'onCustomFieldsPrepareDom' => 'prepareDom', 'onContentPrepareForm' => 'prepareForm', 'onJFiltersOptionsAfterCreation' => 'onJFiltersOptionsAfterCreation', ...static::$_extra_events];
}
public function onJFiltersOptionsAfterCreation(AbstractImmutableEvent $event): void
{
$options = $event->getArgument('collection');
if ($options->getFilterItem()->getAttributes()->get('type') !== $this->_name) {
return;
}
$this->handleOnJFiltersOptionsAfterCreation($options);
}
/**
* @param string $context The context.
* @param stdclass $item The item.
* @param stdclass $field The field.
*
* @return ?string
*/
public function onCustomFieldsPrepareField($context, $item, $field)
{
// Check if the field should be processed by us
if (!$this->isTypeSupported($field->type)) {
return '';
}
// The field's rawvalue should be an array
if (!is_array($field->rawvalue)) {
$field->rawvalue = (array) $field->rawvalue;
}
$this->handleOnPrepareField($context, $item, $field);
return parent::onCustomFieldsPrepareField($context, $item, $field);
}
protected function handleOnJFiltersOptionsAfterCreation(JfiltersCollection $options): void
{
}
protected function handleOnPrepareField(string $context, object $item, object $field): void
{
}
private function getClassName(): string
{
return (new ReflectionClass($this))->getShortName();
}
}