Spade
Mini Shell
url.xml000064400000003205151170300120006056 0ustar00<?xml
version="1.0" encoding="utf-8" ?>
<extension type="plugin" version="3.7.0"
group="fields" method="upgrade">
<name>plg_fields_url</name>
<author>Joomla! Project</author>
<creationDate>March 2016</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>
<files>
<filename plugin="url">url.php</filename>
<folder>params</folder>
<folder>tmpl</folder>
</files>
<languages>
<language
tag="en-GB">en-GB.plg_fields_url.ini</language>
<language
tag="en-GB">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"
description="PLG_FIELDS_URL_PARAMS_SCHEMES_DESC"
multiple="true"
>
<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"
description="PLG_FIELDS_URL_PARAMS_RELATIVE_DESC"
class="btn-group btn-group-yesno"
default="1"
filter="integer"
>
<option value="1">JYES</option>
<option value="0">JNO</option>
</field>
</fieldset>
</fields>
</config>
</extension>
services/provider.php000064400000002346151170300120010725 0ustar00<?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;
}
);
}
};
tmpl/url.php000064400000001042151170300120007016 0ustar00<?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;
$value = $field->value;
if ($value == '')
{
return;
}
$attributes = '';
if (!JUri::isInternal($value))
{
$attributes = ' rel="nofollow noopener noreferrer"
target="_blank"';
}
echo sprintf('<a href="%s"%s>%s</a>',
htmlspecialchars($value),
$attributes,
htmlspecialchars($value)
);
params/url.xml000064400000001560151170300120007343 0ustar00<?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"
description="PLG_FIELDS_URL_PARAMS_SCHEMES_DESC"
multiple="true"
>
<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"
description="PLG_FIELDS_URL_PARAMS_RELATIVE_DESC"
filter="integer"
>
<option
value="">COM_FIELDS_FIELD_USE_GLOBAL</option>
<option value="1">JYES</option>
<option value="0">JNO</option>
</field>
</fieldset>
</fields>
</form>
src/Extension/Url.php000064400000002620151170300120010550 0ustar00<?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;
}
}
url.php000064400000002144151171347400006063 0ustar00<?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
*/
defined('_JEXEC') or die;
JLoader::import('components.com_fields.libraries.fieldsplugin',
JPATH_ADMINISTRATOR);
/**
* Fields URL Plugin
*
* @since 3.7.0
*/
class PlgFieldsUrl 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 JForm $form The form.
*
* @return DOMElement
*
* @since 3.7.0
*/
public function onCustomFieldsPrepareDom($field, DOMElement $parent, JForm
$form)
{
$fieldNode = parent::onCustomFieldsPrepareDom($field, $parent, $form);
if (!$fieldNode)
{
return $fieldNode;
}
$fieldNode->setAttribute('validate', 'url');
if (! $fieldNode->getAttribute('relative'))
{
$fieldNode->removeAttribute('relative');
}
return $fieldNode;
}
}