primo commit
This commit is contained in:
43
libraries/regularlabs/layouts/regularlabs/buttons/button.php
Normal file
43
libraries/regularlabs/layouts/regularlabs/buttons/button.php
Normal file
@ -0,0 +1,43 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Regular Labs Library
|
||||
* @version 24.11.1459
|
||||
*
|
||||
* @author Peter van Westen <info@regularlabs.com>
|
||||
* @link https://regularlabs.com
|
||||
* @copyright Copyright © 2024 Regular Labs All Rights Reserved
|
||||
* @license GNU General Public License version 2 or later
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
use Joomla\CMS\Object\CMSObject as JCMSObject;
|
||||
|
||||
/**
|
||||
* @var JCMSObject $displayData
|
||||
*/
|
||||
|
||||
$button = $displayData;
|
||||
|
||||
if ( ! $button->get('name'))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
$is_modal = $button->get('modal');
|
||||
|
||||
$class = 'btn';
|
||||
$class .= $button->get('class') ? ' ' . $button->get('class') : ' btn-secondary';
|
||||
$class .= $is_modal ? ' modal-button' : null;
|
||||
$onclick = $button->get('onclick') ? ' onclick="' . str_replace('"', '"', $button->get('onclick')) . '"' : '';
|
||||
$title = $button->get('title') ? $button->get('title') : $button->get('text');
|
||||
$icon = $button->get('icon') ? $button->get('icon') : $button->get('name');
|
||||
|
||||
$href = $is_modal
|
||||
? 'data-bs-target="#' . strtolower($button->get('name')) . '_modal"'
|
||||
: 'href="' . $button->get('link', '#') . '"';
|
||||
?>
|
||||
<button type="button" <?php echo $href; ?> class="<?php echo $class; ?>" <?php echo $button->get('modal') ? 'data-bs-toggle="modal"' : '' ?> title="<?php echo $title; ?>" <?php echo $onclick; ?>>
|
||||
<span class="icon-<?php echo $icon; ?>" aria-hidden="true"></span>
|
||||
<?php echo $button->get('text'); ?>
|
||||
</button>
|
||||
85
libraries/regularlabs/layouts/regularlabs/buttons/modal.php
Normal file
85
libraries/regularlabs/layouts/regularlabs/buttons/modal.php
Normal file
@ -0,0 +1,85 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Regular Labs Library
|
||||
* @version 24.11.1459
|
||||
*
|
||||
* @author Peter van Westen <info@regularlabs.com>
|
||||
* @link https://regularlabs.com
|
||||
* @copyright Copyright © 2024 Regular Labs All Rights Reserved
|
||||
* @license GNU General Public License version 2 or later
|
||||
*/
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
use Joomla\CMS\HTML\HTMLHelper as JHtml;
|
||||
use Joomla\CMS\Language\Text as JText;
|
||||
use Joomla\CMS\Object\CMSObject as JCMSObject;
|
||||
use Joomla\CMS\Uri\Uri as JUri;
|
||||
|
||||
/**
|
||||
* @var JCMSObject $displayData
|
||||
*/
|
||||
|
||||
if ( ! function_exists('RegularLabsModalRenderButton'))
|
||||
{
|
||||
function RegularLabsModalRenderButton($options, $prefix = 'close', $default_text = 'JLIB_HTML_BEHAVIOR_CLOSE')
|
||||
{
|
||||
$class = $options[$prefix . 'Class'] ?? ($prefix == 'close' ? 'btn btn-secondary' : 'btn btn-success');
|
||||
$text = $options[$prefix . 'Text'] ?? JText::_($default_text);
|
||||
$onclick = $options[$prefix . 'Callback'] ?? '';
|
||||
$dismiss = $prefix == 'close' || ! empty($options[$prefix . 'Close']) ? 'data-bs-dismiss="modal"' : '';
|
||||
$icon = ! empty($options[$prefix . 'Icon']) ? '<span class="icon-' . $options[$prefix . 'Icon'] . '" aria-hidden="true"></span>' : '';
|
||||
|
||||
return '<button type="button" class="' . $class . '" ' . $dismiss . ' onclick="' . $onclick . '">'
|
||||
. $icon . $text . ' </button>';
|
||||
}
|
||||
}
|
||||
|
||||
$button = $displayData;
|
||||
|
||||
if ( ! $button->get('modal'))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if ( ! $button->get('name'))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
$link = ($button->get('link')) ? JUri::base() . $button->get('link') : null;
|
||||
$title = ($button->get('title')) ? $button->get('title') : $button->get('text');
|
||||
$options = is_array($button->get('options')) ? $button->get('options') : [];
|
||||
|
||||
$buttons = [];
|
||||
|
||||
if (isset($options['confirmCallback'])
|
||||
)
|
||||
{
|
||||
$buttons[] = RegularLabsModalRenderButton($options, 'confirm', 'JSAVE');
|
||||
}
|
||||
|
||||
if (isset($options['confirm2Callback'])
|
||||
)
|
||||
{
|
||||
$buttons[] = RegularLabsModalRenderButton($options, 'confirm2', 'JSAVE');
|
||||
}
|
||||
|
||||
$buttons[] = RegularLabsModalRenderButton($options, 'close', 'JLIB_HTML_BEHAVIOR_CLOSE');
|
||||
|
||||
$id = str_replace(' ', '', $button->get('id', strtolower($button->get('name')) . '_modal'));
|
||||
|
||||
echo JHtml::_(
|
||||
'bootstrap.renderModal',
|
||||
$id,
|
||||
[
|
||||
'url' => $link,
|
||||
'title' => $title,
|
||||
'height' => array_key_exists('height', $options) ? $options['height'] : '400px',
|
||||
'width' => array_key_exists('width', $options) ? $options['width'] : '800px',
|
||||
'bodyHeight' => array_key_exists('bodyHeight', $options) ? $options['bodyHeight'] : '70',
|
||||
'modalWidth' => array_key_exists('modalWidth', $options) ? $options['modalWidth'] : '80',
|
||||
'keyboard' => array_key_exists('keyboard', $options) ? $options['keyboard'] : true,
|
||||
'backdrop' => array_key_exists('backdrop', $options) ? $options['backdrop'] : true,
|
||||
'footer' => implode('', $buttons),
|
||||
]
|
||||
);
|
||||
@ -0,0 +1,98 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Regular Labs Library
|
||||
* @version 24.11.1459
|
||||
*
|
||||
* @author Peter van Westen <info@regularlabs.com>
|
||||
* @link https://regularlabs.com
|
||||
* @copyright Copyright © 2024 Regular Labs All Rights Reserved
|
||||
* @license GNU General Public License version 2 or later
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
extract($displayData);
|
||||
|
||||
/**
|
||||
* Layout variables
|
||||
* -----------------
|
||||
*
|
||||
* @var string $autocomplete Autocomplete attribute for the field.
|
||||
* @var boolean $autofocus Is autofocus enabled?
|
||||
* @var string $class Classes for the input.
|
||||
* @var string $description Description of the field.
|
||||
* @var boolean $disabled Is this field disabled?
|
||||
* @var string $group Group the field belongs to. <fields> section in form XML.
|
||||
* @var boolean $hidden Is this field hidden in the form?
|
||||
* @var string $hint Placeholder for the field.
|
||||
* @var string $id DOM id of the field.
|
||||
* @var string $label Label of the field.
|
||||
* @var string $labelclass Classes to apply to the label.
|
||||
* @var boolean $multiple Does this field support multiple values?
|
||||
* @var string $name Name of the input field.
|
||||
* @var string $onchange Onchange attribute for the field.
|
||||
* @var string $onclick Onclick attribute for the field.
|
||||
* @var string $pattern Pattern (Reg Ex) of value of the form field.
|
||||
* @var boolean $readonly Is this field read only?
|
||||
* @var boolean $repeat Allows extensions to duplicate elements.
|
||||
* @var boolean $required Is this field required?
|
||||
* @var integer $size Size attribute of the input.
|
||||
* @var boolean $spellcheck Spellcheck state for the form field.
|
||||
* @var string $validate Validation rules to apply.
|
||||
* @var string $value Value attribute of the field.
|
||||
* @var array $checkedOptions Options that will be set as checked.
|
||||
* @var boolean $hasValue Has this field a value assigned?
|
||||
* @var array $options Options available for this field.
|
||||
* @var string $dataAttribute Miscellaneous data attributes preprocessed for HTML output
|
||||
* @var array $dataAttributes Miscellaneous data attributes for eg, data-*.
|
||||
*/
|
||||
|
||||
/**
|
||||
* The format of the input tag to be filled in using sprintf.
|
||||
* %1 - id
|
||||
* %2 - name
|
||||
* %3 - value
|
||||
* %4 = any other attributes
|
||||
*/
|
||||
$format = '<input type="checkbox" id="%1$s" name="%2$s" value="%3$s" %4$s>';
|
||||
|
||||
// The alt option for Text::alt
|
||||
$alt = preg_replace('/[^a-zA-Z0-9_\-]/', '_', $name);
|
||||
?>
|
||||
|
||||
<fieldset id="<?php echo $id; ?>" class="<?php echo trim($class . ' checkboxes'); ?>"
|
||||
<?php echo $required ? 'required' : ''; ?>
|
||||
<?php echo $autofocus ? 'autofocus' : ''; ?>
|
||||
<?php echo $dataAttribute; ?>>
|
||||
<legend class="visually-hidden"><?php echo $label; ?></legend>
|
||||
|
||||
<?php foreach ($options as $i => $option) : ?>
|
||||
<?php if (is_string($option)) : ?>
|
||||
<h4 class="mt-2 mb-0"><?php echo $option; ?></h4>
|
||||
<?php else: ?>
|
||||
<?php
|
||||
// Initialize some option attributes.
|
||||
$checked = in_array((string) $option->value, $checkedOptions, true) ? 'checked' : '';
|
||||
|
||||
// In case there is no stored value, use the option's default state.
|
||||
$checked = ( ! $hasValue && $option->checked) ? 'checked' : $checked;
|
||||
$optionClass = ! empty($option->class) ? 'class="form-check-input ' . $option->class . '"' : ' class="form-check-input"';
|
||||
$optionDisabled = ! empty($option->disable) || $disabled ? 'disabled' : '';
|
||||
|
||||
// Initialize some JavaScript option attributes.
|
||||
$onclick = ! empty($option->onclick) ? 'onclick="' . $option->onclick . '"' : '';
|
||||
$onchange = ! empty($option->onchange) ? 'onchange="' . $option->onchange . '"' : '';
|
||||
|
||||
$oid = $id . $i;
|
||||
$value = htmlspecialchars($option->value, ENT_COMPAT, 'UTF-8');
|
||||
$attributes = array_filter([$checked, $optionClass, $optionDisabled, $onchange, $onclick]);
|
||||
?>
|
||||
<div class="form-check form-check-inline">
|
||||
<?php echo sprintf($format, $oid, $name, $value, implode(' ', $attributes)); ?>
|
||||
<label for="<?php echo $oid; ?>" class="form-check-label">
|
||||
<?php echo $option->text; ?>
|
||||
</label>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php endforeach; ?>
|
||||
</fieldset>
|
||||
@ -0,0 +1,88 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Regular Labs Library
|
||||
* @version 24.11.1459
|
||||
*
|
||||
* @author Peter van Westen <info@regularlabs.com>
|
||||
* @link https://regularlabs.com
|
||||
* @copyright Copyright © 2024 Regular Labs All Rights Reserved
|
||||
* @license GNU General Public License version 2 or later
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
use Joomla\CMS\Factory;
|
||||
use Joomla\CMS\HTML\HTMLHelper;
|
||||
use Joomla\CMS\Language\Text;
|
||||
|
||||
extract($displayData);
|
||||
|
||||
/**
|
||||
* Layout variables
|
||||
* -----------------
|
||||
*
|
||||
* @var string $autocomplete Autocomplete attribute for the field.
|
||||
* @var boolean $autofocus Is autofocus enabled?
|
||||
* @var string $class Classes for the input.
|
||||
* @var string $description Description of the field.
|
||||
* @var boolean $disabled Is this field disabled?
|
||||
* @var string $group Group the field belongs to. <fields> section in form XML.
|
||||
* @var boolean $hidden Is this field hidden in the form?
|
||||
* @var string $hint Placeholder for the field.
|
||||
* @var string $id DOM id of the field.
|
||||
* @var string $label Label of the field.
|
||||
* @var string $labelclass Classes to apply to the label.
|
||||
* @var boolean $multiple Does this field support multiple values?
|
||||
* @var string $name Name of the input field.
|
||||
* @var string $onchange Onchange attribute for the field.
|
||||
* @var string $onclick Onclick attribute for the field.
|
||||
* @var string $pattern Pattern (Reg Ex) of value of the form field.
|
||||
* @var boolean $readonly Is this field read only?
|
||||
* @var boolean $repeat Allows extensions to duplicate elements.
|
||||
* @var boolean $required Is this field required?
|
||||
* @var integer $size Size attribute of the input.
|
||||
* @var boolean $spellcheck Spellcheck state for the form field.
|
||||
* @var string $validate Validation rules to apply.
|
||||
* @var string $value Value attribute of the field.
|
||||
* @var array $checkedOptions Options that will be set as checked.
|
||||
* @var boolean $hasValue Has this field a value assigned?
|
||||
* @var array $options Options available for this field.
|
||||
* @var array $inputType Options available for this field.
|
||||
* @var string $accept File types that are accepted.
|
||||
*/
|
||||
|
||||
$attributes = [
|
||||
'class="' . $class . '"',
|
||||
'allow-custom',
|
||||
'search-placeholder="' . $this->escape(Text::_('RL_ENTER_NEW_VALUES')) . '" ',
|
||||
];
|
||||
|
||||
$selectAttr = [
|
||||
$disabled ? 'disabled' : '',
|
||||
$readonly ? 'readonly' : '',
|
||||
strlen($hint) ? 'placeholder="' . $this->escape(Text::_('RL_ENTER_NEW_VALUES')) . '"' : '',
|
||||
$onchange ? 'onchange="' . $onchange . '"' : '',
|
||||
$autofocus ? 'autofocus' : '',
|
||||
'multiple',
|
||||
];
|
||||
|
||||
if ($required)
|
||||
{
|
||||
$selectAttr[] = 'required class="required"';
|
||||
$attributes[] = 'required';
|
||||
}
|
||||
|
||||
Text::script('JGLOBAL_SELECT_NO_RESULTS_MATCH');
|
||||
Text::script('JGLOBAL_SELECT_PRESS_TO_SELECT');
|
||||
|
||||
Factory::getDocument()->getWebAssetManager()
|
||||
->usePreset('choicesjs')
|
||||
->useScript('webcomponent.field-fancy-select');
|
||||
|
||||
?>
|
||||
<joomla-field-fancy-select <?php echo implode(' ', $attributes); ?>><?php
|
||||
echo HTMLHelper::_('select.genericlist', $options, $name,
|
||||
implode(' ', $selectAttr),
|
||||
'value', 'text', $value, $id
|
||||
);
|
||||
?></joomla-field-fancy-select>
|
||||
@ -0,0 +1,89 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Regular Labs Library
|
||||
* @version 24.11.1459
|
||||
*
|
||||
* @author Peter van Westen <info@regularlabs.com>
|
||||
* @link https://regularlabs.com
|
||||
* @copyright Copyright © 2024 Regular Labs All Rights Reserved
|
||||
* @license GNU General Public License version 2 or later
|
||||
*/
|
||||
|
||||
use Joomla\CMS\Language\Text as JText;
|
||||
use Joomla\CMS\Layout\FileLayout as JFileLayout;
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
/**
|
||||
* @var array $displayData
|
||||
* @var int $id
|
||||
* @var string $extension
|
||||
* @var int $cloak_length
|
||||
* @var bool $use_modal
|
||||
* @var bool $show_label
|
||||
* @var bool $hidden
|
||||
* @var string $callback
|
||||
*/
|
||||
|
||||
extract($displayData);
|
||||
|
||||
$extension ??= 'all';
|
||||
$cloak_length ??= 4;
|
||||
$use_modal ??= false;
|
||||
$hidden ??= false;
|
||||
$show_label ??= false;
|
||||
$callback = htmlspecialchars($callback ?? '', ENT_QUOTES, 'UTF-8');
|
||||
?>
|
||||
<div id="downloadKeyWrapper_<?php echo $id; ?>" class="rl-download-key" data-callback="<?php echo $callback; ?>">
|
||||
<div class="rl-download-key-wrapper mb-4<?php echo $hidden ? ' hidden' : ''; ?>">
|
||||
<div class="<?php echo ! $show_label ? ' hidden' : ''; ?>">
|
||||
<label for="<?php echo $id; ?>">
|
||||
<span class="initialism text-muted">
|
||||
<?php echo JText::_('RL_DOWNLOAD_KEY'); ?>
|
||||
</span>
|
||||
<span class="rl-popover rl-popover-full">
|
||||
<small class="form-text">
|
||||
<?php echo JText::_('RL_DOWNLOAD_KEY_DESC'); ?>
|
||||
</small>
|
||||
</span>
|
||||
</label>
|
||||
</div>
|
||||
<span class="rl-spinner"></span>
|
||||
<div class="input-group">
|
||||
<input type="text" id="<?php echo $id; ?>" data-key-extension="<?php echo $extension; ?>" data-key-cloak-length="<?php echo $cloak_length; ?>"
|
||||
class="form-control rl-download-key-field form-control inactive rl-code-field hidden">
|
||||
<button type="button" class="btn btn-primary button-edit hidden">
|
||||
<span class="icon-edit" aria-hidden="true"></span><span class="visually-hidden"><?php echo JText::_('JEDIT'); ?></span>
|
||||
</button>
|
||||
<button type="button" class="btn btn-success button-apply hidden">
|
||||
<span class="icon-checkmark" aria-hidden="true"></span><span class="visually-hidden"><?php echo JText::_('JAPPLY'); ?></span>
|
||||
</button>
|
||||
<button type="button" class="btn btn-danger button-cancel hidden">
|
||||
<span class="icon-times" aria-hidden="true"></span><span class="visually-hidden"><?php echo JText::_('JCANCEL'); ?></span>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
echo (new JFileLayout(
|
||||
'regularlabs.form.field.downloadkey_errors',
|
||||
JPATH_SITE . '/libraries/regularlabs/layouts'
|
||||
))->render([
|
||||
'id' => $id,
|
||||
'extension' => $extension,
|
||||
]);
|
||||
?>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
if ($use_modal)
|
||||
{
|
||||
echo (new JFileLayout(
|
||||
'regularlabs.form.field.downloadkey_modal',
|
||||
JPATH_SITE . '/libraries/regularlabs/layouts'
|
||||
))->render([
|
||||
'id' => $id,
|
||||
'extension' => $extension,
|
||||
]);
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
@ -0,0 +1,48 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Regular Labs Library
|
||||
* @version 24.11.1459
|
||||
*
|
||||
* @author Peter van Westen <info@regularlabs.com>
|
||||
* @link https://regularlabs.com
|
||||
* @copyright Copyright © 2024 Regular Labs All Rights Reserved
|
||||
* @license GNU General Public License version 2 or later
|
||||
*/
|
||||
|
||||
use Joomla\CMS\Language\Text as JText;
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
/**
|
||||
* @var array $displayData
|
||||
* @var int $id
|
||||
* @var string $extension
|
||||
*/
|
||||
|
||||
extract($displayData);
|
||||
|
||||
$extension = $extension ?: 'all';
|
||||
|
||||
$extension_name = $extension == 'all'
|
||||
? JText::_('RL_REGULAR_LABS_EXTENSIONS')
|
||||
: JText::_(strtoupper($extension));
|
||||
|
||||
?>
|
||||
|
||||
<div class="key-errors">
|
||||
<div class="key-error-empty alert alert-danger hidden">
|
||||
<?php echo JText::sprintf('RL_DOWNLOAD_KEY_ERROR_EMPTY', $extension_name, '<a href="https://regularlabs.com/download-keys" target="_blank">', '</a>'); ?>
|
||||
</div>
|
||||
<div class="key-error-invalid alert alert-danger hidden">
|
||||
<?php echo JText::sprintf('RL_DOWNLOAD_KEY_ERROR_INVALID', '<a href="https://regularlabs.com/download-keys" target="_blank">', '</a>'); ?>
|
||||
</div>
|
||||
<div class="key-error-expired alert alert-danger hidden">
|
||||
<?php echo JText::sprintf('RL_DOWNLOAD_KEY_ERROR_EXPIRED', '<a href="https://regularlabs.com/purchase" target="_blank">', '</a>'); ?>
|
||||
</div>
|
||||
<div class="key-error-local alert alert-danger hidden">
|
||||
<?php echo JText::_('RL_DOWNLOAD_KEY_ERROR_LOCAL'); ?>
|
||||
</div>
|
||||
<div class="key-error-external alert alert-danger hidden">
|
||||
<?php echo JText::sprintf('RL_DOWNLOAD_KEY_ERROR_EXTERNAL', '<a href="https://regularlabs.com/forum" target="_blank">', '</a>'); ?>
|
||||
</div>
|
||||
</div>
|
||||
@ -0,0 +1,50 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Regular Labs Library
|
||||
* @version 24.11.1459
|
||||
*
|
||||
* @author Peter van Westen <info@regularlabs.com>
|
||||
* @link https://regularlabs.com
|
||||
* @copyright Copyright © 2024 Regular Labs All Rights Reserved
|
||||
* @license GNU General Public License version 2 or later
|
||||
*/
|
||||
|
||||
use Joomla\CMS\HTML\HTMLHelper as JHtml;
|
||||
use Joomla\CMS\Language\Text as JText;
|
||||
use Joomla\CMS\Layout\FileLayout as JFileLayout;
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
/**
|
||||
* @var array $displayData
|
||||
* @var int $id
|
||||
* @var string $extension
|
||||
*/
|
||||
|
||||
extract($displayData);
|
||||
|
||||
$body = (new JFileLayout(
|
||||
'regularlabs.form.field.downloadkey_modal_body',
|
||||
JPATH_SITE . '/libraries/regularlabs/layouts'
|
||||
))->render([
|
||||
'id' => $id,
|
||||
'extension' => $extension,
|
||||
]);
|
||||
|
||||
$onclick = 'RegularLabs.DownloadKey.save(\'' . $extension . '\', document.querySelector(\'#' . $id . '_modal\').value, document.querySelector(\'#downloadKeyModal_' . $id . '\'));';
|
||||
|
||||
echo JHtml::_(
|
||||
'bootstrap.renderModal',
|
||||
'downloadKeyModal_' . $id,
|
||||
[
|
||||
'title' => JText::_('RL_REGULAR_LABS_DOWNLOAD_KEY'),
|
||||
'modalWidth' => '60',
|
||||
'footer' => '<button type="button" class="btn btn-success" onclick="' . $onclick . '">'
|
||||
. JText::_('JAPPLY')
|
||||
. '</button>'
|
||||
. '<button type="button" class="btn btn-secondary" data-bs-dismiss="modal" aria-hidden="true">'
|
||||
. JText::_('JLIB_HTML_BEHAVIOR_CLOSE')
|
||||
. '</button>',
|
||||
],
|
||||
$body
|
||||
);
|
||||
@ -0,0 +1,45 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Regular Labs Library
|
||||
* @version 24.11.1459
|
||||
*
|
||||
* @author Peter van Westen <info@regularlabs.com>
|
||||
* @link https://regularlabs.com
|
||||
* @copyright Copyright © 2024 Regular Labs All Rights Reserved
|
||||
* @license GNU General Public License version 2 or later
|
||||
*/
|
||||
|
||||
use Joomla\CMS\Language\Text as JText;
|
||||
use Joomla\CMS\Layout\FileLayout as JFileLayout;
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
/**
|
||||
* @var array $displayData
|
||||
* @var int $id
|
||||
* @var string $extension
|
||||
*/
|
||||
|
||||
extract($displayData);
|
||||
|
||||
$extension = $extension ?: 'all';
|
||||
|
||||
?>
|
||||
|
||||
<div class="content p-3">
|
||||
<?php
|
||||
echo (new JFileLayout(
|
||||
'regularlabs.form.field.downloadkey_errors',
|
||||
JPATH_SITE . '/libraries/regularlabs/layouts'
|
||||
))->render([
|
||||
'id' => $id,
|
||||
'extension' => $extension,
|
||||
]);
|
||||
?>
|
||||
<p>
|
||||
<?php echo html_entity_decode(JText::_('RL_DOWNLOAD_KEY_ENTER')); ?>:
|
||||
</p>
|
||||
<div class="input-group">
|
||||
<input type="text" id="<?php echo $id; ?>_modal" placeholder="ABC123..." class="rl-download-key-field form-control rl-code-field">
|
||||
</div>
|
||||
</div>
|
||||
@ -0,0 +1,54 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Regular Labs Library
|
||||
* @version 24.11.1459
|
||||
*
|
||||
* @author Peter van Westen <info@regularlabs.com>
|
||||
* @link https://regularlabs.com
|
||||
* @copyright Copyright © 2024 Regular Labs All Rights Reserved
|
||||
* @license GNU General Public License version 2 or later
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
use Joomla\CMS\Language\Text as JText;
|
||||
use RegularLabs\Library\Document as RL_Document;
|
||||
|
||||
extract($displayData);
|
||||
|
||||
/**
|
||||
* Layout variables
|
||||
* -----------------
|
||||
*
|
||||
* @var string $id DOM id of the field.
|
||||
* @var string $icon1 Icon to show when the field is off.
|
||||
* @var string $icon2 Icon to show when the field is on.
|
||||
* @var string $text1 Text to show when the field is off.
|
||||
* @var string $text2 Text to show when the field is on.
|
||||
* @var string $class1 Class to add to the field when it is off.
|
||||
* @var string $class2 Class to add to the field when it is on.
|
||||
* @var string $name Name of the input field.
|
||||
*/
|
||||
|
||||
$text1 = JText::_($text1);
|
||||
$text2 = JText::_($text2);
|
||||
|
||||
RL_Document::useScript('showon');
|
||||
?>
|
||||
|
||||
<fieldset>
|
||||
<input type="hidden" name="<?php echo $name; ?>" id="<?php echo $id; ?>" value="0">
|
||||
<div data-showon='[{"field":"<?php echo $name; ?>","values":["0"],"sign":"=","op":""}]' class="hidden">
|
||||
<span class="<?php echo $class1; ?>" role="button" onclick="el=document.getElementById('<?php echo $id; ?>');el.value = 1;el.dispatchEvent(new Event('change'));">
|
||||
<span class="icon-<?php echo $icon1; ?>" aria-label="<?php echo $text1 ?: JText::_('JSHOW'); ?>"></span>
|
||||
<?php echo $text1; ?>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div data-showon='[{"field":"<?php echo $name; ?>","values":["1"],"sign":"=","op":""}]' class="hidden">
|
||||
<span class="<?php echo $class2; ?>" role="button" onclick="el=document.getElementById('<?php echo $id; ?>');el.value = 0;el.dispatchEvent(new Event('change'));">
|
||||
<span class="icon-<?php echo $icon2; ?>" aria-label="<?php echo $text2 ?: JText::_('JHIDE'); ?>"></span>
|
||||
<?php echo $text2; ?>
|
||||
</span>
|
||||
</div>
|
||||
</fieldset>
|
||||
146
libraries/regularlabs/layouts/regularlabs/form/field/range.php
Normal file
146
libraries/regularlabs/layouts/regularlabs/form/field/range.php
Normal file
@ -0,0 +1,146 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Regular Labs Library
|
||||
* @version 24.11.1459
|
||||
*
|
||||
* @author Peter van Westen <info@regularlabs.com>
|
||||
* @link https://regularlabs.com
|
||||
* @copyright Copyright © 2024 Regular Labs All Rights Reserved
|
||||
* @license GNU General Public License version 2 or later
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
use Joomla\CMS\Language\Text;
|
||||
|
||||
/**
|
||||
* @var array $displayData
|
||||
* @var string $autocomplete Autocomplete attribute for the field.
|
||||
* @var boolean $autofocus Is autofocus enabled?
|
||||
* @var string $class Classes for the input.
|
||||
* @var string $description Description of the field.
|
||||
* @var boolean $disabled Is this field disabled?
|
||||
* @var string $group Group the field belongs to. <fields> section in form XML.
|
||||
* @var boolean $hidden Is this field hidden in the form?
|
||||
* @var string $hint Placeholder for the field.
|
||||
* @var string $id DOM id of the field.
|
||||
* @var string $label Label of the field.
|
||||
* @var string $labelclass Classes to apply to the label.
|
||||
* @var boolean $multiple Does this field support multiple values?
|
||||
* @var string $name Name of the input field.
|
||||
* @var string $onchange Onchange attribute for the field.
|
||||
* @var string $onclick Onclick attribute for the field.
|
||||
* @var string $pattern Pattern (Reg Ex) of value of the form field.
|
||||
* @var boolean $readonly Is this field read only?
|
||||
* @var boolean $repeat Allows extensions to duplicate elements.
|
||||
* @var boolean $required Is this field required?
|
||||
* @var integer $size Size attribute of the input.
|
||||
* @var boolean $spellcheck Spellcheck state for the form field.
|
||||
* @var string $validate Validation rules to apply.
|
||||
* @var string $value Value attribute of the field.
|
||||
* @var array $checkedOptions Options that will be set as checked.
|
||||
* @var boolean $hasValue Has this field a value assigned?
|
||||
* @var array $options Options available for this field.
|
||||
* @var array $inputType Options available for this field.
|
||||
* @var string $accept File types that are accepted.
|
||||
* @var string $dataAttribute Miscellaneous data attributes preprocessed for HTML output
|
||||
* @var array $dataAttributes Miscellaneous data attribute for eg, data-*.
|
||||
* @var int $min
|
||||
* @var int $max
|
||||
* @var string $prepend
|
||||
* @var string $append
|
||||
* @var string $class_range
|
||||
*/
|
||||
|
||||
extract($displayData);
|
||||
|
||||
$value = is_numeric($value) ? (float) $value : $min;
|
||||
|
||||
$class = $class ?: 'rl-w-6em font-monospace text-right';
|
||||
$class_range = $class_range ?: 'rl-w-16em';
|
||||
|
||||
// Initialize some field attributes.
|
||||
$attributes_range = [
|
||||
$class ? 'class="' . $class_range . '"' : '',
|
||||
$disabled ? 'disabled' : '',
|
||||
$readonly ? 'readonly' : '',
|
||||
! empty($onchange) ? 'onchange="' . $onchange . '"' : '',
|
||||
! empty($max) ? 'max="' . $max . '"' : '',
|
||||
! empty($step) ? 'step="' . $step . '"' : '',
|
||||
! empty($min) ? 'min="' . $min . '"' : '',
|
||||
$autofocus ? 'autofocus' : '',
|
||||
'oninput="document.querySelector(\'input[name=\\\'' . $name . '\\\']\').value=this.value;document.querySelector(\'input[name=\\\'' . $name . '\\\']\').dispatchEvent(new Event(\'change\'));"',
|
||||
];
|
||||
|
||||
$attributes_number = [
|
||||
$class ? 'class="form-control ' . $class . '"' : 'class="form-control"',
|
||||
! empty($description) ? 'aria-describedby="' . $name . '-desc"' : '',
|
||||
$disabled ? 'disabled' : '',
|
||||
$readonly ? 'readonly' : '',
|
||||
strlen($hint) ? 'placeholder="' . htmlspecialchars($hint, ENT_COMPAT, 'UTF-8') . '"' : '',
|
||||
! empty($onchange) ? 'onchange="' . $onchange . '"' : '',
|
||||
isset($max) ? 'max="' . $max . '"' : '',
|
||||
! empty($step) ? 'step="' . $step . '"' : '',
|
||||
isset($min) ? 'min="' . $min . '"' : '',
|
||||
$required ? 'required aria-required="true"' : '',
|
||||
$autocomplete,
|
||||
$autofocus ? 'autofocus' : '',
|
||||
$dataAttribute,
|
||||
'oninput="document.querySelector(\'input[data-for=\\\'' . $name . '\\\']\').value=this.value;"',
|
||||
];
|
||||
|
||||
$chars = (strlen($max) ?: $size) ?: 4;
|
||||
$width = $chars * 8;
|
||||
|
||||
$classes = [];
|
||||
|
||||
if ($prepend)
|
||||
{
|
||||
$classes[] = 'input-prepend';
|
||||
}
|
||||
|
||||
if ($append)
|
||||
{
|
||||
$classes[] = 'input-append';
|
||||
}
|
||||
|
||||
if (str_starts_with($prepend, 'icon-'))
|
||||
{
|
||||
$prepend = '<span class="' . $prepend . '"></span>';
|
||||
}
|
||||
|
||||
if (str_starts_with($append, 'icon-'))
|
||||
{
|
||||
$append = '<span class="' . $append . '"></span>';
|
||||
}
|
||||
|
||||
if ($prepend && preg_match('#^[A-Z][A-Z0-9_]+$#', $prepend))
|
||||
{
|
||||
$prepend = Text::_($prepend);
|
||||
}
|
||||
|
||||
if ($append && preg_match('#^[A-Z][A-Z0-9_]+$#', $append))
|
||||
{
|
||||
$append = Text::_($append);
|
||||
}
|
||||
?>
|
||||
<div class="rl-flex">
|
||||
|
||||
<span class="rl-mr-1 <?php echo implode(' ', $classes); ?>">
|
||||
<?php if ($prepend): ?>
|
||||
<span class="add-on"><?php echo $prepend; ?></span>
|
||||
<?php endif; ?>
|
||||
|
||||
<input type="number" inputmode="numeric" name="<?php echo $name; ?>" id="<?php echo $id; ?>"
|
||||
value="<?php echo htmlspecialchars($value, ENT_COMPAT, 'UTF-8'); ?>"
|
||||
<?php echo implode(' ', $attributes_number); ?>>
|
||||
|
||||
<?php if ($append): ?>
|
||||
<span class="add-on"><?php echo $append; ?></span>
|
||||
<?php endif; ?>
|
||||
</span>
|
||||
|
||||
<input type="range" data-for="<?php echo $name; ?>" value="<?php echo $value; ?>"
|
||||
<?php echo implode(' ', $attributes_range); ?> />
|
||||
|
||||
</div>
|
||||
@ -0,0 +1,98 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Regular Labs Library
|
||||
* @version 24.11.1459
|
||||
*
|
||||
* @author Peter van Westen <info@regularlabs.com>
|
||||
* @link https://regularlabs.com
|
||||
* @copyright Copyright © 2024 Regular Labs All Rights Reserved
|
||||
* @license GNU General Public License version 2 or later
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
use Joomla\CMS\Factory;
|
||||
use Joomla\CMS\HTML\HTMLHelper;
|
||||
use Joomla\CMS\Language\Text;
|
||||
use RegularLabs\Library\Document as RL_Document;
|
||||
|
||||
extract($displayData);
|
||||
|
||||
/**
|
||||
* Layout variables
|
||||
* -----------------
|
||||
*
|
||||
* @var string $autocomplete Autocomplete attribute for the field.
|
||||
* @var boolean $autofocus Is autofocus enabled?
|
||||
* @var string $class Classes for the input.
|
||||
* @var string $description Description of the field.
|
||||
* @var boolean $disabled Is this field disabled?
|
||||
* @var string $group Group the field belongs to. <fields> section in form XML.
|
||||
* @var boolean $hidden Is this field hidden in the form?
|
||||
* @var string $hint Placeholder for the field.
|
||||
* @var string $id DOM id of the field.
|
||||
* @var string $label Label of the field.
|
||||
* @var string $labelclass Classes to apply to the label.
|
||||
* @var boolean $multiple Does this field support multiple values?
|
||||
* @var string $name Name of the input field.
|
||||
* @var string $onchange Onchange attribute for the field.
|
||||
* @var string $onclick Onclick attribute for the field.
|
||||
* @var string $pattern Pattern (Reg Ex) of value of the form field.
|
||||
* @var boolean $readonly Is this field read only?
|
||||
* @var boolean $repeat Allows extensions to duplicate elements.
|
||||
* @var boolean $required Is this field required?
|
||||
* @var integer $size Size attribute of the input.
|
||||
* @var boolean $spellcheck Spellcheck state for the form field.
|
||||
* @var string $validate Validation rules to apply.
|
||||
* @var string $value Value attribute of the field.
|
||||
* @var array $checkedOptions Options that will be set as checked.
|
||||
* @var boolean $hasValue Has this field a value assigned?
|
||||
* @var boolean $allowCustom Allow custom values.
|
||||
* @var array $options Options available for this field.
|
||||
* @var array $inputType Options available for this field.
|
||||
* @var string $accept File types that are accepted.
|
||||
*/
|
||||
|
||||
$attributes = [
|
||||
'class="' . $class . '"',
|
||||
'search-placeholder="' . $this->escape($hint) . '" ',
|
||||
];
|
||||
|
||||
if ($allowCustom)
|
||||
{
|
||||
$attributes[] = 'allow-custom';
|
||||
}
|
||||
|
||||
$selectAttr = [
|
||||
$disabled ? 'disabled' : '',
|
||||
$readonly ? 'readonly' : '',
|
||||
strlen($hint) ? 'placeholder="' . $this->escape($hint) . '"' : '',
|
||||
$onchange ? 'onchange="' . $onchange . '"' : '',
|
||||
$autofocus ? 'autofocus' : '',
|
||||
];
|
||||
|
||||
if ($required)
|
||||
{
|
||||
$selectAttr[] = 'required class="required"';
|
||||
$attributes[] = 'required';
|
||||
}
|
||||
|
||||
Text::script('JGLOBAL_SELECT_NO_RESULTS_MATCH');
|
||||
Text::script('JGLOBAL_SELECT_PRESS_TO_SELECT');
|
||||
|
||||
Factory::getDocument()->getWebAssetManager()
|
||||
->usePreset('choicesjs')
|
||||
->useScript('webcomponent.field-fancy-select');
|
||||
|
||||
RL_Document::script('regularlabs.simplecategory');
|
||||
?>
|
||||
<rl-field-simple-category>
|
||||
<joomla-field-fancy-select <?php echo implode(' ', $attributes); ?>><?php
|
||||
echo HTMLHelper::_('select.genericlist', $options, $name, [
|
||||
'id' => $id,
|
||||
'list.select' => $value,
|
||||
'list.attr' => implode(' ', $selectAttr),
|
||||
]
|
||||
);
|
||||
?></joomla-field-fancy-select>
|
||||
</rl-field-simple-category>
|
||||
@ -0,0 +1,82 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Regular Labs Library
|
||||
* @version 24.11.1459
|
||||
*
|
||||
* @author Peter van Westen <info@regularlabs.com>
|
||||
* @link https://regularlabs.com
|
||||
* @copyright Copyright © 2024 Regular Labs All Rights Reserved
|
||||
* @license GNU General Public License version 2 or later
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
use Joomla\CMS\Factory;
|
||||
use Joomla\CMS\Language\Text;
|
||||
|
||||
extract($displayData);
|
||||
|
||||
/**
|
||||
* Layout variables
|
||||
* -----------------
|
||||
*
|
||||
* @var JForm $tmpl The Empty form for template
|
||||
* @var array $forms Array of JForm instances for render the rows
|
||||
* @var bool $multiple The multiple state for the form field
|
||||
* @var int $min Count of minimum repeating in multiple mode
|
||||
* @var int $max Count of maximum repeating in multiple mode
|
||||
* @var string $name Name of the input field.
|
||||
* @var string $field The field
|
||||
* @var string $fieldname The field name
|
||||
* @var string $fieldId The field ID
|
||||
* @var string $control The forms control
|
||||
* @var string $label The field label
|
||||
* @var string $description The field description
|
||||
* @var string $class Classes for the container
|
||||
* @var array $buttons Array of the buttons that will be rendered
|
||||
* @var bool $groupByFieldset Whether group the subform fields by it`s fieldset
|
||||
*/
|
||||
|
||||
// Add script
|
||||
if ($multiple)
|
||||
{
|
||||
Factory::getDocument()->getWebAssetManager()
|
||||
->useScript('webcomponent.field-subform');
|
||||
}
|
||||
|
||||
$class = $class ? ' ' . $class : '';
|
||||
$sublayout = (empty($groupByFieldset) ? 'section' : 'section-byfieldsets');
|
||||
$add_button_text = $field->getAttribute('add_button_text');
|
||||
?>
|
||||
|
||||
<div class="subform-repeatable-wrapper subform-layout">
|
||||
<joomla-field-subform class="subform-repeatable<?php echo $class; ?>" name="<?php echo $name; ?>"
|
||||
button-add=".group-add" button-remove=".group-remove" button-move="<?php echo empty($buttons['move']) ? '' : '.group-move' ?>"
|
||||
repeatable-element=".subform-repeatable-group" minimum="<?php echo $min; ?>" maximum="<?php echo $max; ?>">
|
||||
<?php if ( ! empty($buttons['add'])) : ?>
|
||||
<div class="btn-toolbar">
|
||||
<div class="btn-group">
|
||||
<button type="button" class="group-add btn btn-sm button btn-success" aria-label="<?php echo Text::_($add_button_text ?: 'JGLOBAL_FIELD_ADD'); ?>">
|
||||
<span class="icon-plus icon-white" aria-hidden="true"></span>
|
||||
<?php echo Text::_($add_button_text ?: ''); ?>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php
|
||||
foreach ($forms as $k => $form) :
|
||||
echo $this->sublayout($sublayout, [
|
||||
'form' => $form, 'basegroup' => $fieldname, 'group' => $fieldname . $k, 'buttons' => $buttons, 'field' => $field,
|
||||
]);
|
||||
endforeach;
|
||||
?>
|
||||
<?php if ($multiple) : ?>
|
||||
<template class="subform-repeatable-template-section hidden"><?php
|
||||
echo trim($this->sublayout($sublayout, [
|
||||
'form' => $tmpl, 'basegroup' => $fieldname, 'group' => $fieldname . 'X', 'buttons' => $buttons,
|
||||
'field' => $field,
|
||||
]));
|
||||
?></template>
|
||||
<?php endif; ?>
|
||||
</joomla-field-subform>
|
||||
</div>
|
||||
@ -0,0 +1,70 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Regular Labs Library
|
||||
* @version 24.11.1459
|
||||
*
|
||||
* @author Peter van Westen <info@regularlabs.com>
|
||||
* @link https://regularlabs.com
|
||||
* @copyright Copyright © 2024 Regular Labs All Rights Reserved
|
||||
* @license GNU General Public License version 2 or later
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
use Joomla\CMS\Language\Text;
|
||||
|
||||
extract($displayData);
|
||||
|
||||
/**
|
||||
* Layout variables
|
||||
* -----------------
|
||||
*
|
||||
* @var JForm $form The form instance for render the section
|
||||
* @var JForm $field The field
|
||||
* @var string $basegroup The base group name
|
||||
* @var string $group Current group name
|
||||
* @var array $buttons Array of the buttons that will be rendered
|
||||
*/
|
||||
|
||||
$add_button_text = $field->getAttribute('add_button_text');
|
||||
?>
|
||||
|
||||
<div class="subform-repeatable-group" data-base-name="<?php echo $basegroup; ?>" data-group="<?php echo $group; ?>">
|
||||
<?php if ( ! empty($buttons)) : ?>
|
||||
<div class="btn-toolbar text-end">
|
||||
<div class="btn-group">
|
||||
<?php if ( ! empty($buttons['add'])): ?>
|
||||
<button type="button" class="group-add btn btn-sm btn-success" aria-label="<?php echo Text::_($add_button_text ?: 'JGLOBAL_FIELD_ADD'); ?>">
|
||||
<span class="icon-plus icon-white" aria-hidden="true"></span>
|
||||
<?php echo Text::_($add_button_text ?: ''); ?>
|
||||
</button>
|
||||
<?php endif; ?>
|
||||
<?php if ( ! empty($buttons['remove'])): ?>
|
||||
<button type="button" class="group-remove btn btn-sm btn-danger" aria-label="<?php echo Text::_('JGLOBAL_FIELD_REMOVE'); ?>">
|
||||
<span class="icon-minus icon-white" aria-hidden="true"></span>
|
||||
</button>
|
||||
<?php endif; ?>
|
||||
<?php if ( ! empty($buttons['move'])): ?>
|
||||
<button type="button" class="group-move btn btn-sm btn-primary" aria-label="<?php echo Text::_('JGLOBAL_FIELD_MOVE'); ?>">
|
||||
<span class="icon-arrows-alt icon-white" aria-hidden="true"></span>
|
||||
</button>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<div class="row">
|
||||
<?php foreach ($form->getFieldsets() as $fieldset) : ?>
|
||||
<fieldset class="<?php if ( ! empty($fieldset->class))
|
||||
{
|
||||
echo $fieldset->class;
|
||||
} ?>">
|
||||
<?php if ( ! empty($fieldset->label)) : ?>
|
||||
<legend><?php echo Text::_($fieldset->label); ?></legend>
|
||||
<?php endif; ?>
|
||||
<?php foreach ($form->getFieldset($fieldset->name) as $field) : ?>
|
||||
<?php echo $field->renderField(); ?>
|
||||
<?php endforeach; ?>
|
||||
</fieldset>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
</div>
|
||||
@ -0,0 +1,59 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Regular Labs Library
|
||||
* @version 24.11.1459
|
||||
*
|
||||
* @author Peter van Westen <info@regularlabs.com>
|
||||
* @link https://regularlabs.com
|
||||
* @copyright Copyright © 2024 Regular Labs All Rights Reserved
|
||||
* @license GNU General Public License version 2 or later
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
use Joomla\CMS\Language\Text;
|
||||
|
||||
extract($displayData);
|
||||
|
||||
/**
|
||||
* Layout variables
|
||||
* -----------------
|
||||
*
|
||||
* @var JForm $form The form instance for render the section
|
||||
* @var JForm $field The field
|
||||
* @var string $basegroup The base group name
|
||||
* @var string $group Current group name
|
||||
* @var array $buttons Array of the buttons that will be rendered
|
||||
*/
|
||||
|
||||
$add_button_text = $field->getAttribute('add_button_text');
|
||||
?>
|
||||
|
||||
<div class="subform-repeatable-group" data-base-name="<?php echo $basegroup; ?>" data-group="<?php echo $group; ?>">
|
||||
<?php if ( ! empty($buttons)) : ?>
|
||||
<div class="btn-toolbar text-end">
|
||||
<div class="btn-group">
|
||||
<?php if ( ! empty($buttons['add'])): ?>
|
||||
<button type="button" class="group-add btn btn-sm btn-success" aria-label="<?php echo Text::_($add_button_text ?: 'JGLOBAL_FIELD_ADD'); ?>">
|
||||
<span class="icon-plus icon-white" aria-hidden="true"></span>
|
||||
<?php echo Text::_($add_button_text ?: ''); ?>
|
||||
</button>
|
||||
<?php endif; ?>
|
||||
<?php if ( ! empty($buttons['remove'])): ?>
|
||||
<button type="button" class="group-remove btn btn-sm btn-danger" aria-label="<?php echo Text::_('JGLOBAL_FIELD_REMOVE'); ?>">
|
||||
<span class="icon-minus icon-white" aria-hidden="true"></span>
|
||||
</button>
|
||||
<?php endif; ?>
|
||||
<?php if ( ! empty($buttons['move'])): ?>
|
||||
<button type="button" class="group-move btn btn-sm btn-primary" aria-label="<?php echo Text::_('JGLOBAL_FIELD_MOVE'); ?>">
|
||||
<span class="icon-arrows-alt icon-white" aria-hidden="true"></span>
|
||||
</button>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php foreach ($form->getGroup('') as $field) : ?>
|
||||
<?php echo $field->renderField(); ?>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
@ -0,0 +1,117 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Regular Labs Library
|
||||
* @version 24.11.1459
|
||||
*
|
||||
* @author Peter van Westen <info@regularlabs.com>
|
||||
* @link https://regularlabs.com
|
||||
* @copyright Copyright © 2024 Regular Labs All Rights Reserved
|
||||
* @license GNU General Public License version 2 or later
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
use Joomla\CMS\Date\Date as JDate;
|
||||
use Joomla\CMS\Factory;
|
||||
use Joomla\CMS\Factory as JFactory;
|
||||
use Joomla\CMS\Language\Text;
|
||||
use Joomla\CMS\Language\Text as JText;
|
||||
|
||||
extract($displayData);
|
||||
|
||||
/**
|
||||
* Layout variables
|
||||
* -----------------
|
||||
*
|
||||
* @var object $field
|
||||
* @var string $autocomplete Autocomplete attribute for the field.
|
||||
* @var boolean $autofocus Is autofocus enabled?
|
||||
* @var string $class Classes for the input.
|
||||
* @var string $description Description of the field.
|
||||
* @var boolean $disabled Is this field disabled?
|
||||
* @var string $group Group the field belongs to. <fields> section in form XML.
|
||||
* @var boolean $hidden Is this field hidden in the form?
|
||||
* @var string $hint Placeholder for the field.
|
||||
* @var string $id DOM id of the field.
|
||||
* @var string $label Label of the field.
|
||||
* @var string $labelclass Classes to apply to the label.
|
||||
* @var boolean $multiple Does this field support multiple values?
|
||||
* @var string $name Name of the input field.
|
||||
* @var string $onchange Onchange attribute for the field.
|
||||
* @var string $onclick Onclick attribute for the field.
|
||||
* @var string $pattern Pattern (Reg Ex) of value of the form field.
|
||||
* @var boolean $readonly Is this field read only?
|
||||
* @var boolean $repeat Allows extensions to duplicate elements.
|
||||
* @var boolean $required Is this field required?
|
||||
* @var integer $size Size attribute of the input.
|
||||
* @var boolean $spellcheck Spellcheck state for the form field.
|
||||
* @var string $validate Validation rules to apply.
|
||||
* @var string $value Value attribute of the field.
|
||||
* @var array $checkedOptions Options that will be set as checked.
|
||||
* @var boolean $hasValue Has this field a value assigned?
|
||||
* @var array $options Options available for this field.
|
||||
* @var array $inputType Options available for this field.
|
||||
* @var string $accept File types that are accepted.
|
||||
* @var boolean $charcounter Does this field support a character counter?
|
||||
* @var string $dataAttribute Miscellaneous data attributes preprocessed for HTML output
|
||||
* @var array $dataAttributes Miscellaneous data attribute for eg, data-*.
|
||||
* @var string $columns
|
||||
* @var string $rows
|
||||
* @var string $maxlength
|
||||
* @var boolean $show_insert_date_name
|
||||
* @var boolean $add_separator
|
||||
*/
|
||||
|
||||
// Initialize some field attributes.
|
||||
if ($charcounter)
|
||||
{
|
||||
// Load the js file
|
||||
/** @var Joomla\CMS\WebAsset\WebAssetManager $wa */
|
||||
$wa = Factory::getApplication()->getDocument()->getWebAssetManager();
|
||||
$wa->useScript('short-and-sweet');
|
||||
|
||||
// Set the css class to be used as the trigger
|
||||
$charcounter = ' charcount';
|
||||
// Set the text
|
||||
$counterlabel = 'data-counter-label="' . $this->escape(Text::_('JFIELD_META_DESCRIPTION_COUNTER')) . '"';
|
||||
}
|
||||
|
||||
$attributes = [
|
||||
$columns ?: '',
|
||||
$rows ?: '',
|
||||
! empty($class) ? 'class="form-control ' . $class . $charcounter . '"' : 'class="form-control' . $charcounter . '"',
|
||||
! empty($description) ? 'aria-describedby="' . $name . '-desc"' : '',
|
||||
strlen($hint) ? 'placeholder="' . htmlspecialchars($hint, ENT_COMPAT, 'UTF-8') . '"' : '',
|
||||
$disabled ? 'disabled' : '',
|
||||
$readonly ? 'readonly' : '',
|
||||
$onchange ? 'onchange="' . $onchange . '"' : '',
|
||||
$onclick ? 'onclick="' . $onclick . '"' : '',
|
||||
$required ? 'required' : '',
|
||||
! empty($autocomplete) ? 'autocomplete="' . $autocomplete . '"' : '',
|
||||
$autofocus ? 'autofocus' : '',
|
||||
$spellcheck ? '' : 'spellcheck="false"',
|
||||
$maxlength ?: '',
|
||||
! empty($counterlabel) ? $counterlabel : '',
|
||||
$dataAttribute,
|
||||
];
|
||||
|
||||
if ($show_insert_date_name)
|
||||
{
|
||||
$user = JFactory::getApplication()->getIdentity() ?: JFactory::getUser();
|
||||
|
||||
$date_name = JDate::getInstance()->format('[Y-m-d]') . ' ' . $user->name . ' : ';
|
||||
$separator = $add_separator ? '---' : 'none';
|
||||
$onclick = "RegularLabs.TextArea.prependTextarea('" . $id . "', '" . addslashes($date_name) . "', '" . $separator . "');";
|
||||
}
|
||||
?>
|
||||
<?php if ($show_insert_date_name) : ?>
|
||||
<span role="button" class="btn btn-sm btn-primary text-bg-primary" onclick="<?php echo $onclick; ?>">
|
||||
<span class="icon-pencil" aria-hidden="true"></span>
|
||||
<?php echo JText::_('RL_INSERT_DATE_NAME'); ?>
|
||||
</span>
|
||||
<?php endif; ?>
|
||||
|
||||
<textarea name="<?php
|
||||
echo $name; ?>" id="<?php
|
||||
echo $id; ?>" <?php
|
||||
echo implode(' ', $attributes); ?> ><?php echo htmlspecialchars($value, ENT_COMPAT, 'UTF-8'); ?></textarea>
|
||||
@ -0,0 +1,168 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Regular Labs Library
|
||||
* @version 24.11.1459
|
||||
*
|
||||
* @author Peter van Westen <info@regularlabs.com>
|
||||
* @link https://regularlabs.com
|
||||
* @copyright Copyright © 2024 Regular Labs All Rights Reserved
|
||||
* @license GNU General Public License version 2 or later
|
||||
*/
|
||||
|
||||
use Joomla\CMS\Language\Text;
|
||||
use RegularLabs\Library\Document as RL_Document;
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
/**
|
||||
* @var array $displayData
|
||||
* @var int $id
|
||||
* @var string $name
|
||||
* @var array $value
|
||||
* @var array $options
|
||||
* @var bool $collapse_children
|
||||
*/
|
||||
|
||||
extract($displayData);
|
||||
|
||||
if (empty($options))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
RL_Document::script('regularlabs.treeselect');
|
||||
RL_Document::scriptDeclaration("
|
||||
document.addEventListener('DOMContentLoaded', () => {RegularLabs.TreeSelect.init('" . $id . "')});
|
||||
");
|
||||
|
||||
if ( ! is_array($value))
|
||||
{
|
||||
$value = [$value];
|
||||
}
|
||||
?>
|
||||
|
||||
<div class="card rl-treeselect" id="rl-treeselect-<?php echo $id; ?>">
|
||||
<div class="card-header">
|
||||
<section class="d-flex align-items-center flex-wrap w-100">
|
||||
<div class="d-flex align-items-center flex-fill mb-1" role="group"
|
||||
aria-label="<?php echo Text::_('JSELECT'); ?>">
|
||||
<?php echo Text::_('JSELECT'); ?>
|
||||
<button data-action="checkAll" class="btn btn-secondary btn-sm mx-1" type="button">
|
||||
<?php echo Text::_('JALL'); ?>
|
||||
</button>
|
||||
<button data-action="uncheckAll" class="btn btn-secondary btn-sm mx-1" type="button">
|
||||
<?php echo Text::_('JNONE'); ?>
|
||||
</button>
|
||||
<button data-action="toggleAll" class="btn btn-secondary btn-sm mx-1" type="button">
|
||||
<?php echo Text::_('RL_TOGGLE'); ?>
|
||||
</button>
|
||||
</div>
|
||||
<div class="d-flex align-items-center mb-1 flex-fill" role="group"
|
||||
aria-label="<?php echo Text::_('RL_EXPAND'); ?>">
|
||||
<?php echo Text::_('RL_EXPAND'); ?>
|
||||
<button data-action="expandAll" class="btn btn-secondary btn-sm mx-1" type="button">
|
||||
<?php echo Text::_('JALL'); ?>
|
||||
</button>
|
||||
<button data-action="collapseAll" class="btn btn-secondary btn-sm mx-1" type="button">
|
||||
<?php echo Text::_('JNONE'); ?>
|
||||
</button>
|
||||
</div>
|
||||
<div class="d-flex align-items-center mb-1 flex-fill" role="group"
|
||||
aria-label="<?php echo Text::_('JSHOW'); ?>">
|
||||
<?php echo Text::_('JSHOW'); ?>
|
||||
<button data-action="showAll" class="btn btn-secondary btn-sm mx-1" type="button">
|
||||
<?php echo Text::_('JALL'); ?>
|
||||
</button>
|
||||
<button data-action="showSelected" class="btn btn-secondary btn-sm mx-1" type="button">
|
||||
<?php echo Text::_('RL_SELECTED'); ?>
|
||||
</button>
|
||||
</div>
|
||||
<div role="search" class="flex-grow-1">
|
||||
<label for="treeselectfilter" class="visually-hidden">
|
||||
<?php echo Text::_('JSEARCH_FILTER'); ?>
|
||||
</label>
|
||||
<input type="text" name="treeselectfilter" class="form-control search-query" autocomplete="off"
|
||||
placeholder="<?php echo Text::_('JSEARCH_FILTER'); ?>">
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<ul class="treeselect">
|
||||
<?php $previous_level = 0; ?>
|
||||
<?php foreach ($options
|
||||
|
||||
as $i => $option) : ?>
|
||||
<?php
|
||||
$option->level ??= 0;
|
||||
|
||||
if ($previous_level < $option->level)
|
||||
{
|
||||
echo '<ul class="treeselect-sub">';
|
||||
}
|
||||
|
||||
if ($previous_level > $option->level)
|
||||
{
|
||||
for ($i = 0; $i < $previous_level - $option->level; $i++)
|
||||
{
|
||||
echo '</ul></li>';
|
||||
}
|
||||
}
|
||||
|
||||
$selected = in_array($option->value, $value);
|
||||
?>
|
||||
<li>
|
||||
<div class="treeselect-item">
|
||||
<?php if (empty($option->no_checkbox)) : ?>
|
||||
<input type="checkbox" class="novalidate"
|
||||
name="<?php echo $name; ?>" id="<?php echo $id . $option->value; ?>" value="<?php echo $option->value; ?>"
|
||||
<?php echo $selected ? ' checked="checked"' : ''; ?>
|
||||
<?php echo ! empty($option->disable) ? ' disabled="disabled"' : ''; ?>
|
||||
<?php echo $collapse_children && ! $option->level ? ' data-rl-treeselect-collapse-children="true"' : ''; ?>>
|
||||
<?php endif; ?>
|
||||
<label for="<?php echo $id . $option->value; ?>" class="">
|
||||
<span class="<?php echo ! empty($option->disable) ? ' disabled' : ''; ?><?php echo ! empty($option->heading) ? ' text-uppercase fw-bold' : ''; ?>">
|
||||
<?php echo $option->text; ?>
|
||||
</span>
|
||||
<?php if (isset($option->published) && $option->published == 0) : ?>
|
||||
<?php echo ' <span class="badge bg-secondary">' . Text::_('JUNPUBLISHED') . '</span>'; ?>
|
||||
<?php endif; ?>
|
||||
</label>
|
||||
</div>
|
||||
<?php
|
||||
$previous_level = $option->level;
|
||||
?>
|
||||
<?php endforeach; ?>
|
||||
<?php
|
||||
for ($i = 0; $i < $previous_level; $i++)
|
||||
{
|
||||
echo '</ul></li>';
|
||||
}
|
||||
?>
|
||||
</ul>
|
||||
<joomla-alert type="warning" style="display:none"><?php echo Text::_('JGLOBAL_NO_MATCHING_RESULTS'); ?></joomla-alert>
|
||||
<div class="sub-tree-select hidden">
|
||||
<div class="nav-hover treeselect-menu">
|
||||
<div class="dropdown">
|
||||
<button type="button" data-bs-toggle="dropdown" class="dropdown-toggle btn btn-sm btn-light">
|
||||
<span class="visually-hidden"><?php echo Text::sprintf('JGLOBAL_TOGGLE_DROPDOWN'); ?></span>
|
||||
</button>
|
||||
<div class="dropdown-menu">
|
||||
<h1 class="dropdown-header"><?php echo Text::_('RL_SUBITEMS'); ?></h1>
|
||||
<button type="button" data-action="checkNested" class="dropdown-item">
|
||||
<span class="icon-check-square" aria-hidden="true"></span>
|
||||
<?php echo Text::_('RL_SELECT_ALL'); ?>
|
||||
</button>
|
||||
<button type="button" data-action="uncheckNested" class="dropdown-item">
|
||||
<span class="icon-square" aria-hidden="true"></span>
|
||||
<?php echo Text::_('RL_UNSELECT_ALL'); ?>
|
||||
</button>
|
||||
<button type="button" data-action="toggleNested" class="dropdown-item">
|
||||
<span class="icon-question-circle" aria-hidden="true"></span>
|
||||
<?php echo Text::_('RL_TOGGLE_SELECTION'); ?>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
Reference in New Issue
Block a user