init
This commit is contained in:
@@ -0,0 +1,71 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<extension type="plugin" group="fields" method="upgrade">
|
||||
<name>plg_fields_note</name>
|
||||
<author>Joomla! Project</author>
|
||||
<creationDate>2025-03</creationDate>
|
||||
<copyright>(C) 2025 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>6.0.0</version>
|
||||
<description>PLG_FIELDS_NOTE_XML_DESCRIPTION</description>
|
||||
<namespace path="src">Joomla\Plugin\Fields\Note</namespace>
|
||||
<files>
|
||||
<folder>params</folder>
|
||||
<folder plugin="note">services</folder>
|
||||
<folder>src</folder>
|
||||
<folder>tmpl</folder>
|
||||
</files>
|
||||
<languages>
|
||||
<language tag="en-GB">language/en-GB/plg_fields_note.ini</language>
|
||||
<language tag="en-GB">language/en-GB/plg_fields_note.sys.ini</language>
|
||||
</languages>
|
||||
<config>
|
||||
<fields name="params">
|
||||
<fieldset name="basic">
|
||||
<field
|
||||
name="label"
|
||||
type="text"
|
||||
label="PLG_FIELDS_NOTE_PARAMS_LABEL_LABEL"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="description"
|
||||
type="editor"
|
||||
label="PLG_FIELDS_NOTE_PARAMS_DESCRIPTION_LABEL"
|
||||
filter="\Joomla\CMS\Component\ComponentHelper::filterText"
|
||||
buttons="false"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="class"
|
||||
type="text"
|
||||
label="PLG_FIELDS_NOTE_PARAMS_CLASS_LABEL"
|
||||
description="PLG_FIELDS_NOTE_PARAMS_CLASS_DESC"
|
||||
default="alert alert-info"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="heading"
|
||||
type="list"
|
||||
label="PLG_FIELDS_NOTE_PARAMS_HEADING_LABEL"
|
||||
default="h4"
|
||||
>
|
||||
<option value="h1">JH1</option>
|
||||
<option value="h2">JH2</option>
|
||||
<option value="h3">JH3</option>
|
||||
<option value="h4">JH4</option>
|
||||
<option value="h5">JH5</option>
|
||||
<option value="h6">JH6</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="close"
|
||||
type="text"
|
||||
label="PLG_FIELDS_NOTE_PARAMS_CLOSE_LABEL"
|
||||
description="PLG_FIELDS_NOTE_PARAMS_CLOSE_DESC"
|
||||
/>
|
||||
</fieldset>
|
||||
</fields>
|
||||
</config>
|
||||
</extension>
|
||||
@@ -0,0 +1,70 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<form>
|
||||
<field
|
||||
name="default_value"
|
||||
type="hidden"
|
||||
filter="unset"
|
||||
/>
|
||||
<fields name="params" label="COM_FIELDS_FIELD_BASIC_LABEL">
|
||||
<fieldset name="renderoptions">
|
||||
<field
|
||||
name="display_frontend"
|
||||
type="radio"
|
||||
label="PLG_FIELDS_NOTE_PARAMS_DISPLAY_FRONTEND_LABEL"
|
||||
layout="joomla.form.field.radio.switcher"
|
||||
default="0"
|
||||
filter="integer"
|
||||
>
|
||||
<option value="0">JNO</option>
|
||||
<option value="1">JYES</option>
|
||||
</field>
|
||||
</fieldset>
|
||||
</fields>
|
||||
<fields name="fieldparams">
|
||||
<fieldset name="fieldparams">
|
||||
<field
|
||||
name="label"
|
||||
type="text"
|
||||
label="PLG_FIELDS_NOTE_PARAMS_LABEL_LABEL"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="description"
|
||||
type="editor"
|
||||
label="PLG_FIELDS_NOTE_PARAMS_DESCRIPTION_LABEL"
|
||||
filter="\Joomla\CMS\Component\ComponentHelper::filterText"
|
||||
buttons="false"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="class"
|
||||
type="text"
|
||||
label="PLG_FIELDS_NOTE_PARAMS_CLASS_LABEL"
|
||||
description="PLG_FIELDS_NOTE_PARAMS_CLASS_DESC"
|
||||
default="alert alert-info"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="heading"
|
||||
type="list"
|
||||
label="PLG_FIELDS_NOTE_PARAMS_HEADING_LABEL"
|
||||
default="h4"
|
||||
>
|
||||
<option value="h1">JH1</option>
|
||||
<option value="h2">JH2</option>
|
||||
<option value="h3">JH3</option>
|
||||
<option value="h4">JH4</option>
|
||||
<option value="h5">JH5</option>
|
||||
<option value="h6">JH6</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="close"
|
||||
type="text"
|
||||
label="PLG_FIELDS_NOTE_PARAMS_CLOSE_LABEL"
|
||||
description="PLG_FIELDS_NOTE_PARAMS_CLOSE_DESC"
|
||||
default="true"
|
||||
/>
|
||||
</fieldset>
|
||||
</fields>
|
||||
</form>
|
||||
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Plugin
|
||||
* @subpackage Fields.note
|
||||
*
|
||||
* @copyright (C) 2025 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\Plugin\Fields\Note\Extension\Note;
|
||||
|
||||
return new class () implements ServiceProviderInterface {
|
||||
/**
|
||||
* Registers the service provider with a DI container.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 6.0.0
|
||||
*/
|
||||
public function register(Container $container)
|
||||
{
|
||||
$container->set(
|
||||
PluginInterface::class,
|
||||
$container->lazy(Note::class, function (Container $container) {
|
||||
$plugin = new Note(
|
||||
(array) PluginHelper::getPlugin('fields', 'note')
|
||||
);
|
||||
$plugin->setApplication(Factory::getApplication());
|
||||
|
||||
return $plugin;
|
||||
})
|
||||
);
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Plugin
|
||||
* @subpackage Fields.note
|
||||
*
|
||||
* @copyright (C) 2025 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace Joomla\Plugin\Fields\Note\Extension;
|
||||
|
||||
use Joomla\CMS\Event\Model\PrepareFormEvent;
|
||||
use Joomla\Component\Fields\Administrator\Plugin\FieldsPlugin;
|
||||
use Joomla\Event\SubscriberInterface;
|
||||
use Joomla\Utilities\ArrayHelper;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
/**
|
||||
* Fields Note Plugin
|
||||
*
|
||||
* @since 6.0.0
|
||||
*/
|
||||
final class Note extends FieldsPlugin implements SubscriberInterface
|
||||
{
|
||||
/**
|
||||
* The form event. Load additional parameters when available into the field form.
|
||||
* Only when the type of the form is of interest.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 6.0.0
|
||||
*/
|
||||
public function prepareForm(PrepareFormEvent $event)
|
||||
{
|
||||
parent::prepareForm($event);
|
||||
|
||||
$form = $event->getForm();
|
||||
$data = $event->getData();
|
||||
|
||||
$type = ArrayHelper::getValue((array) $data, 'type');
|
||||
|
||||
if (!$this->getApplication()->isClient('administrator') || $form->getName() !== 'com_fields.field.com_content.article' || $type !== 'note') {
|
||||
return;
|
||||
}
|
||||
|
||||
$form->removeField('required');
|
||||
$form->removeField('hint', 'params');
|
||||
$form->removeField('class', 'params');
|
||||
$form->removeField('label_class', 'params');
|
||||
$form->removeField('showlabel', 'params');
|
||||
$form->removeField('label_render_class', 'params');
|
||||
$form->removeField('render_class', 'params');
|
||||
$form->removeField('value_render_class', 'params');
|
||||
$form->removeField('show_on', 'params');
|
||||
$form->removeField('prefix', 'params');
|
||||
$form->removeField('suffix', 'params');
|
||||
$form->removeField('display_readonly', 'params');
|
||||
|
||||
$xml = $form->getXml();
|
||||
|
||||
foreach ($xml->xpath('//fieldset[@name="smartsearchoptions"]') as $fieldset) {
|
||||
$dom = dom_import_simplexml($fieldset);
|
||||
$dom->parentNode->removeChild($dom);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Plugin
|
||||
* @subpackage Fields.Note
|
||||
*
|
||||
* @copyright (C) 2025 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
use Joomla\CMS\HTML\HTMLHelper;
|
||||
use Joomla\CMS\Language\Text;
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
if (empty($field->params->get('display_frontend', 0))) {
|
||||
return;
|
||||
}
|
||||
|
||||
$html = [];
|
||||
$class = [];
|
||||
|
||||
if (!empty($field->fieldparams->get('class', ''))) {
|
||||
$class[] = $field->fieldparams->get('class', '');
|
||||
}
|
||||
|
||||
if ($close = (string) $field->fieldparams->get('close', '')) {
|
||||
HTMLHelper::_('bootstrap.alert');
|
||||
$close = $close === 'true' ? 'alert' : $close;
|
||||
$html[] = '<button type="button" class="btn-close" data-bs-dismiss="' . $close . '"></button>';
|
||||
$class[] = 'alert-dismissible show';
|
||||
}
|
||||
|
||||
$class = $class ? ' class="' . implode(' ', $class) . '"' : '';
|
||||
$title = (string) $field->fieldparams->get('label', ($field->label ? : ''));
|
||||
$heading = (string) $field->fieldparams->get('heading', 'h4');
|
||||
$description = (string) $field->fieldparams->get('description', '');
|
||||
$html[] = !empty($title) ? '<' . $heading . '>' . Text::_($title) . '</' . $heading . '>' : '';
|
||||
$html[] = !empty($description) ? Text::_($description) : '';
|
||||
|
||||
echo '<div ' . $class . '>' . implode('', $html) . '</div>';
|
||||
Reference in New Issue
Block a user