first commit
This commit is contained in:
180
layouts/joomla/form/field/calendar.php
Normal file
180
layouts/joomla/form/field/calendar.php
Normal file
@ -0,0 +1,180 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage Layout
|
||||
*
|
||||
* @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\Factory;
|
||||
use Joomla\CMS\Language\Text;
|
||||
use Joomla\Utilities\ArrayHelper;
|
||||
|
||||
extract($displayData);
|
||||
|
||||
// Get some system objects.
|
||||
$document = Factory::getApplication()->getDocument();
|
||||
$lang = Factory::getApplication()->getLanguage();
|
||||
|
||||
/**
|
||||
* 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-*.
|
||||
*
|
||||
* Calendar Specific
|
||||
* @var string $helperPath The relative path for the helper file
|
||||
* @var string $minYear The minimum year, that will be subtracted/added to current year
|
||||
* @var string $maxYear The maximum year, that will be subtracted/added to current year
|
||||
* @var integer $todaybutton The today button
|
||||
* @var integer $weeknumbers The week numbers display
|
||||
* @var integer $showtime The time selector display
|
||||
* @var integer $filltable The previous/next month filling
|
||||
* @var integer $timeformat The time format
|
||||
* @var integer $singleheader Display different header row for month/year
|
||||
* @var string $direction The document direction
|
||||
* @var string $calendar The calendar type
|
||||
* @var array $weekend The weekends days
|
||||
* @var integer $firstday The first day of the week
|
||||
* @var string $format The format of date and time
|
||||
*/
|
||||
|
||||
$inputvalue = '';
|
||||
|
||||
// Build the attributes array.
|
||||
$attributes = [];
|
||||
|
||||
empty($size) ? null : $attributes['size'] = $size;
|
||||
empty($maxlength) ? null : $attributes['maxlength'] = $maxLength;
|
||||
empty($class) ? $attributes['class'] = 'form-control' : $attributes['class'] = 'form-control ' . $class;
|
||||
!$readonly ? null : $attributes['readonly'] = 'readonly';
|
||||
!$disabled ? null : $attributes['disabled'] = 'disabled';
|
||||
empty($onchange) ? null : $attributes['onchange'] = $onchange;
|
||||
|
||||
if ($required) {
|
||||
$attributes['required'] = '';
|
||||
}
|
||||
|
||||
// Handle the special case for "now".
|
||||
if (strtoupper($value) === 'NOW') {
|
||||
$value = Factory::getDate()->format('Y-m-d H:i:s');
|
||||
}
|
||||
|
||||
$readonly = isset($attributes['readonly']) && $attributes['readonly'] === 'readonly';
|
||||
$disabled = isset($attributes['disabled']) && $attributes['disabled'] === 'disabled';
|
||||
|
||||
if (is_array($attributes)) {
|
||||
$attributes = ArrayHelper::toString($attributes);
|
||||
}
|
||||
|
||||
$calendarAttrs = [
|
||||
'data-inputfield' => $id,
|
||||
'data-button' => $id . '_btn',
|
||||
'data-date-format' => $format,
|
||||
'data-firstday' => empty($firstday) ? '' : $firstday,
|
||||
'data-weekend' => empty($weekend) ? '' : implode(',', $weekend),
|
||||
'data-today-btn' => $todaybutton,
|
||||
'data-week-numbers' => $weeknumbers,
|
||||
'data-show-time' => $showtime,
|
||||
'data-show-others' => $filltable,
|
||||
'data-time24' => $timeformat,
|
||||
'data-only-months-nav' => $singleheader,
|
||||
'data-min-year' => $minYear,
|
||||
'data-max-year' => $maxYear,
|
||||
'data-date-type' => strtolower($calendar),
|
||||
];
|
||||
|
||||
$calendarAttrsStr = ArrayHelper::toString($calendarAttrs);
|
||||
|
||||
// Add language strings
|
||||
$strings = [
|
||||
// Days
|
||||
'SUNDAY', 'MONDAY', 'TUESDAY', 'WEDNESDAY', 'THURSDAY', 'FRIDAY', 'SATURDAY',
|
||||
// Short days
|
||||
'SUN', 'MON', 'TUE', 'WED', 'THU', 'FRI', 'SAT',
|
||||
// Months
|
||||
'JANUARY', 'FEBRUARY', 'MARCH', 'APRIL', 'MAY', 'JUNE', 'JULY', 'AUGUST', 'SEPTEMBER', 'OCTOBER', 'NOVEMBER', 'DECEMBER',
|
||||
// Short months
|
||||
'JANUARY_SHORT', 'FEBRUARY_SHORT', 'MARCH_SHORT', 'APRIL_SHORT', 'MAY_SHORT', 'JUNE_SHORT',
|
||||
'JULY_SHORT', 'AUGUST_SHORT', 'SEPTEMBER_SHORT', 'OCTOBER_SHORT', 'NOVEMBER_SHORT', 'DECEMBER_SHORT',
|
||||
// Buttons
|
||||
'JCLOSE', 'JCLEAR', 'JLIB_HTML_BEHAVIOR_TODAY',
|
||||
// Miscellaneous
|
||||
'JLIB_HTML_BEHAVIOR_WK',
|
||||
];
|
||||
|
||||
foreach ($strings as $c) {
|
||||
Text::script($c);
|
||||
}
|
||||
|
||||
// These are new strings. Make sure they exist. Can be generalised at later time: eg in 4.1 version.
|
||||
if ($lang->hasKey('JLIB_HTML_BEHAVIOR_AM')) {
|
||||
Text::script('JLIB_HTML_BEHAVIOR_AM');
|
||||
}
|
||||
|
||||
if ($lang->hasKey('JLIB_HTML_BEHAVIOR_PM')) {
|
||||
Text::script('JLIB_HTML_BEHAVIOR_PM');
|
||||
}
|
||||
|
||||
// Redefine locale/helper assets to use correct path, and load calendar assets
|
||||
$document->getWebAssetManager()
|
||||
->registerAndUseScript('field.calendar.helper', $helperPath, [], ['defer' => true])
|
||||
->useStyle('field.calendar' . ($direction === 'rtl' ? '-rtl' : ''))
|
||||
->useScript('field.calendar');
|
||||
|
||||
?>
|
||||
<div class="field-calendar">
|
||||
<?php if (!$readonly && !$disabled) : ?>
|
||||
<div class="input-group">
|
||||
<?php endif; ?>
|
||||
<input
|
||||
type="text"
|
||||
id="<?php echo $id; ?>"
|
||||
name="<?php echo $name; ?>"
|
||||
value="<?php echo htmlspecialchars(($value !== '0000-00-00 00:00:00') ? $value : '', ENT_COMPAT, 'UTF-8'); ?>"
|
||||
<?php echo !empty($description) ? ' aria-describedby="' . ($id ?: $name) . '-desc"' : ''; ?>
|
||||
<?php echo $attributes; ?>
|
||||
<?php echo $dataAttribute ?? ''; ?>
|
||||
<?php echo !empty($hint) ? 'placeholder="' . htmlspecialchars($hint, ENT_COMPAT, 'UTF-8') . '"' : ''; ?>
|
||||
data-alt-value="<?php echo htmlspecialchars($value, ENT_COMPAT, 'UTF-8'); ?>" autocomplete="off">
|
||||
<button type="button" class="<?php echo ($readonly || $disabled) ? 'hidden ' : ''; ?>btn btn-primary"
|
||||
id="<?php echo $id; ?>_btn"
|
||||
title="<?php echo Text::_('JLIB_HTML_BEHAVIOR_OPEN_CALENDAR'); ?>"
|
||||
<?php echo $calendarAttrsStr; ?>
|
||||
><span class="icon-calendar" aria-hidden="true"></span>
|
||||
<span class="visually-hidden"><?php echo Text::_('JLIB_HTML_BEHAVIOR_OPEN_CALENDAR'); ?></span>
|
||||
</button>
|
||||
<?php if (!$readonly && !$disabled) : ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
71
layouts/joomla/form/field/checkbox.php
Normal file
71
layouts/joomla/form/field/checkbox.php
Normal file
@ -0,0 +1,71 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage Layout
|
||||
*
|
||||
* @copyright (C) 2019 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\Form\Field\CheckboxField;
|
||||
|
||||
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|null $description Description of the field.
|
||||
* @var boolean $disabled Is this field disabled?
|
||||
* @var CheckboxField $field The form field object.
|
||||
* @var string|null $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 string $validationtext The validation text of invalid 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 boolean $checked Whether the checkbox should be checked.
|
||||
* @var string $dataAttribute Miscellaneous data attributes preprocessed for HTML output
|
||||
* @var array $dataAttributes Miscellaneous data attribute for eg, data-*.
|
||||
*/
|
||||
|
||||
// Initialize some field attributes.
|
||||
$class = $class ? ' ' . $class : '';
|
||||
$disabled = $disabled ? ' disabled' : '';
|
||||
$required = $required ? ' required' : '';
|
||||
$autofocus = $autofocus ? ' autofocus' : '';
|
||||
$checked = $checked ? ' checked' : '';
|
||||
|
||||
// Initialize JavaScript field attributes.
|
||||
$onclick = $onclick ? ' onclick="' . $onclick . '"' : '';
|
||||
$onchange = $onchange ? ' onchange="' . $onchange . '"' : '';
|
||||
|
||||
?>
|
||||
<div class="form-check form-check-inline">
|
||||
<input
|
||||
type="checkbox"
|
||||
name="<?php echo $name; ?>"
|
||||
id="<?php echo $id; ?>"
|
||||
class="form-check-input<?php echo $class; ?>"
|
||||
value="<?php echo htmlspecialchars($value, ENT_QUOTES, 'UTF-8'); ?>"
|
||||
<?php echo $checked . $disabled . $onclick . $onchange . $required . $autofocus . $dataAttribute; ?>
|
||||
>
|
||||
</div>
|
||||
92
layouts/joomla/form/field/checkboxes.php
Normal file
92
layouts/joomla/form/field/checkboxes.php
Normal file
@ -0,0 +1,92 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage Layout
|
||||
*
|
||||
* @copyright (C) 2015 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
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
|
||||
// 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 endforeach; ?>
|
||||
</fieldset>
|
||||
97
layouts/joomla/form/field/color/advanced.php
Normal file
97
layouts/joomla/form/field/color/advanced.php
Normal file
@ -0,0 +1,97 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage Layout
|
||||
*
|
||||
* @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\Factory;
|
||||
|
||||
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 integer $size Size attribute of the input.
|
||||
* @var boolean $spellchec 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 $checked Is this field checked?
|
||||
* @var array $position Position of input.
|
||||
* @var string $control The forms control.
|
||||
* @var string $dataAttribute Miscellaneous data attributes preprocessed for HTML output
|
||||
* @var array $dataAttributes Miscellaneous data attributes for eg, data-*.
|
||||
*/
|
||||
|
||||
if ($validate !== 'color' && in_array($format, ['rgb', 'rgba'], true)) {
|
||||
$alpha = ($format === 'rgba');
|
||||
$placeholder = $alpha ? 'rgba(0, 0, 0, 0.5)' : 'rgb(0, 0, 0)';
|
||||
} else {
|
||||
$placeholder = '#rrggbb';
|
||||
}
|
||||
|
||||
$inputclass = ($keywords && ! in_array($format, ['rgb', 'rgba'], true)) ? ' keywords' : ' ' . $format;
|
||||
$class = ' class="form-control ' . trim('minicolors ' . $class) . ($validate === 'color' ? '' : $inputclass) . '"';
|
||||
$control = $control ? ' data-control="' . $control . '"' : '';
|
||||
$format = $format ? ' data-format="' . $format . '"' : '';
|
||||
$keywords = $keywords ? ' data-keywords="' . $keywords . '"' : '';
|
||||
$colors = $colors ? ' data-colors="' . $colors . '"' : '';
|
||||
$validate = $validate ? ' data-validate="' . $validate . '"' : '';
|
||||
$disabled = $disabled ? ' disabled' : '';
|
||||
$readonly = $readonly ? ' readonly' : '';
|
||||
$hint = strlen($hint) ? ' placeholder="' . $this->escape($hint) . '"' : ' placeholder="' . $placeholder . '"';
|
||||
$onchange = $onchange ? ' onchange="' . $onchange . '"' : '';
|
||||
$required = $required ? ' required' : '';
|
||||
$autocomplete = !empty($autocomplete) ? ' autocomplete="' . $autocomplete . '"' : '';
|
||||
|
||||
// Force LTR input value in RTL, due to display issues with rgba/hex colors
|
||||
$direction = $lang->isRtl() ? ' dir="ltr" style="text-align:right"' : '';
|
||||
|
||||
/** @var Joomla\CMS\WebAsset\WebAssetManager $wa */
|
||||
$wa = Factory::getApplication()->getDocument()->getWebAssetManager();
|
||||
$wa->usePreset('minicolors')
|
||||
->useScript('field.color-adv');
|
||||
?>
|
||||
<input type="text" name="<?php echo $name; ?>" id="<?php echo $id; ?>" value="<?php echo $this->escape($color); ?>"<?php
|
||||
echo $hint,
|
||||
$class,
|
||||
$position,
|
||||
$control,
|
||||
$readonly,
|
||||
$disabled,
|
||||
$required,
|
||||
$onchange,
|
||||
$autocomplete,
|
||||
$autofocus,
|
||||
$format,
|
||||
$keywords,
|
||||
$direction,
|
||||
$validate,
|
||||
$dataAttribute;
|
||||
?>/>
|
||||
72
layouts/joomla/form/field/color/simple.php
Normal file
72
layouts/joomla/form/field/color/simple.php
Normal file
@ -0,0 +1,72 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage Layout
|
||||
*
|
||||
* @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\Factory;
|
||||
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 $spellchec 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 $checked Is this field checked?
|
||||
* @var array $position Position of input.
|
||||
* @var array $control The forms control.
|
||||
* @var array $colors The specified colors
|
||||
* @var string $dataAttribute Miscellaneous data attributes preprocessed for HTML output
|
||||
* @var array $dataAttributes Miscellaneous data attribute for eg, data-*.
|
||||
*/
|
||||
|
||||
$class = ' class="form-select ' . trim($class) . '"';
|
||||
$disabled = $disabled ? ' disabled' : '';
|
||||
$readonly = $readonly ? ' readonly' : '';
|
||||
|
||||
Factory::getDocument()->getWebAssetManager()
|
||||
->useStyle('webcomponent.field-simple-color')
|
||||
->useScript('webcomponent.field-simple-color');
|
||||
|
||||
?>
|
||||
<joomla-field-simple-color text-select="<?php echo Text::_('JFIELD_COLOR_SELECT'); ?>" text-color="<?php echo Text::_('JFIELD_COLOR_VALUE'); ?>" text-close="<?php echo Text::_('JLIB_HTML_BEHAVIOR_CLOSE'); ?>" text-transparent="<?php echo Text::_('JFIELD_COLOR_TRANSPARENT'); ?>">
|
||||
<select name="<?php echo $name; ?>" id="<?php echo $id; ?>"<?php
|
||||
echo $disabled; ?><?php echo $readonly; ?><?php echo $dataAttribute; ?><?php echo $required; ?><?php echo $class; ?><?php echo $position; ?><?php
|
||||
echo $onchange; ?><?php echo $autofocus; ?> style="visibility:hidden;width:22px;height:1px">
|
||||
<?php foreach ($colors as $i => $c) : ?>
|
||||
<option<?php echo ($c === $color ? ' selected="selected"' : ''); ?> value="<?php echo $c; ?>"></option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</joomla-field-simple-color>
|
||||
157
layouts/joomla/form/field/color/slider.php
Normal file
157
layouts/joomla/form/field/color/slider.php
Normal file
@ -0,0 +1,157 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage Layout
|
||||
*
|
||||
* @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\CMS\Factory;
|
||||
use Joomla\CMS\Language\Text;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
/**
|
||||
* @var array $displayData Data for this field collected by ColorField
|
||||
*/
|
||||
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 boolean $disabled Is this field disabled?
|
||||
* @var string $display Which kind of slider should be displayed?
|
||||
* @var string $default Default value for this field
|
||||
* @var string $format Format of color value
|
||||
* @var string $hint Text for inputs placeholder
|
||||
* @var string $id ID of field and label
|
||||
* @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 $position Position of input
|
||||
* @var boolean $preview Should the selected value be displayed separately?
|
||||
* @var boolean $readonly Is this field read only?
|
||||
* @var boolean $required Is this field required?
|
||||
* @var string $saveFormat Format to save the color
|
||||
* @var integer $size Size attribute of the input
|
||||
* @var string $validate Validation rules to apply.
|
||||
* @var string $dataAttribute Miscellaneous data attributes preprocessed for HTML output
|
||||
* @var array $dataAttributes Miscellaneous data attributes for eg, data-*.
|
||||
*/
|
||||
|
||||
if ($color === 'none' || is_null($color)) {
|
||||
$color = '';
|
||||
}
|
||||
|
||||
$alpha = $format === 'hsla' || $format === 'rgba' || $format === 'alpha';
|
||||
$autocomplete = !empty($autocomplete) ? 'autocomplete="' . $autocomplete . '"' : '';
|
||||
$autofocus = $autofocus ? ' autofocus' : '';
|
||||
$color = ' data-color="' . $color . '"';
|
||||
$class = $class ? ' class="' . $class . '"' : '';
|
||||
$default = $default ? ' data-default="' . $default . '"' : '';
|
||||
$disabled = $disabled ? ' disabled' : '';
|
||||
$format = $format ? ' data-format="' . $format . '"' : '';
|
||||
$hint = strlen($hint) ? ' placeholder="' . $this->escape($hint) . '"' : '';
|
||||
$onchange = $onchange ? ' onchange="' . $onchange . '"' : '';
|
||||
$onclick = $onclick ? ' onclick="' . $onclick . '"' : '';
|
||||
$preview = $preview ? ' data-preview="' . $preview . '"' : '';
|
||||
$readonly = $readonly ? ' readonly' : '';
|
||||
$saveFormat = $saveFormat ? ' data-format="' . $saveFormat . '"' : '';
|
||||
$size = $size ? ' size="' . $size . '"' : '';
|
||||
$validate = $validate ? ' data-validate="' . $validate . '"' : '';
|
||||
|
||||
$displayValues = explode(',', $display);
|
||||
$allSliders = $display === 'full' || empty($display);
|
||||
|
||||
/** @var Joomla\CMS\WebAsset\WebAssetManager $wa */
|
||||
$wa = Factory::getApplication()->getDocument()->getWebAssetManager();
|
||||
$wa->useScript('field.color-slider');
|
||||
|
||||
Text::script('JFIELD_COLOR_ERROR_CONVERT_HSL');
|
||||
Text::script('JFIELD_COLOR_ERROR_CONVERT_HUE');
|
||||
Text::script('JFIELD_COLOR_ERROR_NO_COLOUR');
|
||||
Text::script('JFIELD_COLOR_ERROR_WRONG_FORMAT');
|
||||
?>
|
||||
|
||||
<div class="color-slider-wrapper"
|
||||
<?php echo
|
||||
$class,
|
||||
$color,
|
||||
$default,
|
||||
$preview,
|
||||
$size,
|
||||
$dataAttribute;
|
||||
?>
|
||||
>
|
||||
<!-- The data to save at the end (label created in form by Joomla) -->
|
||||
<input type="text" class="form-control color-input" id="<?php echo $id; ?>" name="<?php echo $name; ?>"
|
||||
<?php echo
|
||||
$disabled,
|
||||
$readonly,
|
||||
$required,
|
||||
$saveFormat,
|
||||
$validate;
|
||||
?>
|
||||
>
|
||||
<!-- Shows value which is allowed to manipulate like 'hue' -->
|
||||
<label for="slider-input" class="visually-hidden"><?php echo Text::_('JFIELD_COLOR_LABEL_SLIDER_INPUT'); ?></label>
|
||||
<input type="text" class="form-control" id="slider-input"
|
||||
<?php echo
|
||||
$autocomplete,
|
||||
$disabled,
|
||||
$hint,
|
||||
$onchange,
|
||||
$onclick,
|
||||
$position,
|
||||
$readonly,
|
||||
$required,
|
||||
$format,
|
||||
$validate;
|
||||
?>
|
||||
>
|
||||
<span class="form-control-feedback"></span>
|
||||
|
||||
<?php if ($allSliders || in_array('hue', $displayValues)) : ?>
|
||||
<label for="hue-slider" class="visually-hidden"><?php echo Text::_('JFIELD_COLOR_LABEL_SLIDER_HUE'); ?></label>
|
||||
<input type="range" min="0" max="360" class="form-control color-slider" id="hue-slider" data-type="hue"
|
||||
<?php echo
|
||||
$autofocus,
|
||||
$disabled
|
||||
?>
|
||||
>
|
||||
<?php endif ?>
|
||||
<?php if ($allSliders || in_array('saturation', $displayValues)) : ?>
|
||||
<label for="saturation-slider" class="visually-hidden"><?php echo Text::_('JFIELD_COLOR_LABEL_SLIDER_SATURATION'); ?></label>
|
||||
<input type="range" min="0" max="100" class="form-control color-slider" id="saturation-slider" data-type="saturation"
|
||||
<?php echo
|
||||
$autofocus,
|
||||
$disabled
|
||||
?>
|
||||
>
|
||||
<?php endif ?>
|
||||
<?php if ($allSliders || in_array('light', $displayValues)) : ?>
|
||||
<label for="light-slider" class="visually-hidden"><?php echo Text::_('JFIELD_COLOR_LABEL_SLIDER_LIGHT'); ?></label>
|
||||
<input type="range" min="0" max="100" class="form-control color-slider" id="light-slider" data-type="light"
|
||||
<?php echo
|
||||
$autofocus,
|
||||
$disabled
|
||||
?>
|
||||
>
|
||||
<?php endif ?>
|
||||
<?php if ($alpha && ($allSliders || in_array('alpha', $displayValues))) : ?>
|
||||
<label for="alpha-slider" class="visually-hidden"><?php echo Text::_('JFIELD_COLOR_LABEL_SLIDER_ALPHA'); ?></label>
|
||||
<input type="range" min="0" max="100" class="form-control color-slider" id="alpha-slider" data-type="alpha"
|
||||
<?php echo
|
||||
$autofocus,
|
||||
$disabled
|
||||
?>
|
||||
>
|
||||
<?php endif ?>
|
||||
</div>
|
||||
77
layouts/joomla/form/field/combo.php
Normal file
77
layouts/joomla/form/field/combo.php
Normal file
@ -0,0 +1,77 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage Layout
|
||||
*
|
||||
* @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;
|
||||
|
||||
extract($displayData);
|
||||
|
||||
use Joomla\CMS\HTML\HTMLHelper;
|
||||
|
||||
/**
|
||||
* 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 $options Options available for this field.
|
||||
* @var string $dataAttribute Miscellaneous data attributes preprocessed for HTML output
|
||||
* @var array $dataAttributes Miscellaneous data attribute for eg, data-*.
|
||||
*/
|
||||
|
||||
HTMLHelper::_('behavior.combobox');
|
||||
|
||||
$attr = '';
|
||||
|
||||
// Initialize some field attributes.
|
||||
$attr .= !empty($class) ? ' class="awesomplete form-control ' . $class . '"' : ' class="awesomplete form-control"';
|
||||
$attr .= !empty($size) ? ' size="' . $size . '"' : '';
|
||||
$attr .= !empty($readonly) ? ' readonly' : '';
|
||||
$attr .= !empty($disabled) ? ' disabled' : '';
|
||||
$attr .= !empty($required) ? ' required' : '';
|
||||
$attr .= !empty($description) ? ' aria-describedby="' . ($id ?: $name) . '-desc"' : '';
|
||||
|
||||
// Initialize JavaScript field attributes.
|
||||
$attr .= !empty($onchange) ? ' onchange="' . $onchange . '"' : '';
|
||||
|
||||
$val = [];
|
||||
|
||||
foreach ($options as $option) {
|
||||
$val[] = $option->text;
|
||||
}
|
||||
?>
|
||||
<input
|
||||
type="text"
|
||||
name="<?php echo $name; ?>"
|
||||
id="<?php echo $id; ?>"
|
||||
value="<?php echo htmlspecialchars($value, ENT_COMPAT, 'UTF-8'); ?>"
|
||||
<?php echo $attr; ?>
|
||||
data-list="<?php echo implode(', ', $val); ?>"
|
||||
<?php echo $dataAttribute; ?>
|
||||
/>
|
||||
78
layouts/joomla/form/field/contenthistory.php
Normal file
78
layouts/joomla/form/field/contenthistory.php
Normal file
@ -0,0 +1,78 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage Layout
|
||||
*
|
||||
* @copyright (C) 2015 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;
|
||||
use Joomla\CMS\Router\Route;
|
||||
|
||||
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 $link The link for the content history page
|
||||
* @var string $label The label text
|
||||
* @var string $dataAttribute Miscellaneous data attributes preprocessed for HTML output
|
||||
* @var array $dataAttributes Miscellaneous data attributes for eg, data-*.
|
||||
*/
|
||||
|
||||
echo HTMLHelper::_(
|
||||
'bootstrap.renderModal',
|
||||
'versionsModal',
|
||||
[
|
||||
'url' => Route::_($link),
|
||||
'title' => $label,
|
||||
'height' => '100%',
|
||||
'width' => '100%',
|
||||
'modalWidth' => '80',
|
||||
'bodyHeight' => '60',
|
||||
'footer' => '<button type="button" class="btn btn-secondary" data-bs-dismiss="modal" aria-hidden="true">'
|
||||
. Text::_('JLIB_HTML_BEHAVIOR_CLOSE') . '</button>'
|
||||
]
|
||||
);
|
||||
|
||||
?>
|
||||
<button
|
||||
type="button"
|
||||
class="btn btn-secondary"
|
||||
data-bs-toggle="modal"
|
||||
data-bs-target="#versionsModal"
|
||||
<?php echo $dataAttribute; ?>>
|
||||
<span class="icon-code-branch" aria-hidden="true"></span>
|
||||
<?php echo $label; ?>
|
||||
</button>
|
||||
74
layouts/joomla/form/field/email.php
Normal file
74
layouts/joomla/form/field/email.php
Normal file
@ -0,0 +1,74 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage Layout
|
||||
*
|
||||
* @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\String\PunycodeHelper;
|
||||
|
||||
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.
|
||||
* @var string $dataAttribute Miscellaneous data attributes preprocessed for HTML output
|
||||
* @var array $dataAttributes Miscellaneous data attribute for eg, data-*.
|
||||
*/
|
||||
|
||||
$attributes = [
|
||||
'type="email"',
|
||||
'inputmode="email"',
|
||||
'name="' . $name . '"',
|
||||
'class="form-control validate-email' . (!empty($class) ? ' ' . $class : '') . '"',
|
||||
'id="' . $id . '"',
|
||||
'value="' . htmlspecialchars(PunycodeHelper::emailToUTF8($value), ENT_COMPAT, 'UTF-8') . '"',
|
||||
$spellcheck ? '' : 'spellcheck="false"',
|
||||
!empty($size) ? 'size="' . $size . '"' : '',
|
||||
!empty($description) ? 'aria-describedby="' . ($id ?: $name) . '-desc"' : '',
|
||||
$disabled ? 'disabled' : '',
|
||||
$readonly ? 'readonly' : '',
|
||||
$onchange ? 'onchange="' . $onchange . '"' : '',
|
||||
!empty($autocomplete) ? 'autocomplete="' . $autocomplete . '"' : '',
|
||||
$multiple ? 'multiple' : '',
|
||||
!empty($maxLength) ? 'maxlength="' . $maxLength . '"' : '',
|
||||
strlen($hint) ? 'placeholder="' . htmlspecialchars($hint, ENT_COMPAT, 'UTF-8') . '"' : '',
|
||||
$required ? 'required' : '',
|
||||
$autofocus ? 'autofocus' : '',
|
||||
$dataAttribute,
|
||||
];
|
||||
|
||||
echo '<input ' . implode(' ', array_values(array_filter($attributes))) . '>';
|
||||
69
layouts/joomla/form/field/file.php
Normal file
69
layouts/joomla/form/field/file.php
Normal file
@ -0,0 +1,69 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage Layout
|
||||
*
|
||||
* @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;
|
||||
use Joomla\CMS\Utility\Utility;
|
||||
|
||||
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.
|
||||
* @var string $dataAttribute Miscellaneous data attributes preprocessed for HTML output
|
||||
* @var array $dataAttributes Miscellaneous data attribute for eg, data-*
|
||||
*/
|
||||
|
||||
$maxSize = HTMLHelper::_('number.bytes', Utility::getMaxUploadSize());
|
||||
|
||||
?>
|
||||
<input type="file"
|
||||
name="<?php echo $name; ?>"
|
||||
id="<?php echo $id; ?>"
|
||||
<?php echo !empty($size) ? ' size="' . $size . '"' : ''; ?>
|
||||
<?php echo !empty($accept) ? ' accept="' . $accept . '"' : ''; ?>
|
||||
<?php echo !empty($class) ? ' class="form-control ' . $class . '"' : ' class="form-control"'; ?>
|
||||
<?php echo !empty($multiple) ? ' multiple' : ''; ?>
|
||||
<?php echo $disabled ? ' disabled' : ''; ?>
|
||||
<?php echo $autofocus ? ' autofocus' : ''; ?>
|
||||
<?php echo $dataAttribute; ?>
|
||||
<?php echo !empty($onchange) ? ' onchange="' . $onchange . '"' : ''; ?>
|
||||
<?php echo $required ? ' required' : ''; ?>><br>
|
||||
<?php echo Text::sprintf('JGLOBAL_MAXIMUM_UPLOAD_SIZE_LIMIT', $maxSize); ?>
|
||||
122
layouts/joomla/form/field/groupedlist-fancy-select.php
Normal file
122
layouts/joomla/form/field/groupedlist-fancy-select.php
Normal file
@ -0,0 +1,122 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage Layout
|
||||
*
|
||||
* @copyright (C) 2021 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\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 $groups Groups of options available for this field.
|
||||
* @var string $dataAttribute Miscellaneous data attributes preprocessed for HTML output
|
||||
* @var array $dataAttributes Miscellaneous data attribute for eg, data-*
|
||||
*/
|
||||
|
||||
$html = [];
|
||||
$attr = '';
|
||||
|
||||
// Initialize some field attributes.
|
||||
$attr .= !empty($size) ? ' size="' . $size . '"' : '';
|
||||
$attr .= $multiple ? ' multiple' : '';
|
||||
$attr .= $autofocus ? ' autofocus' : '';
|
||||
$attr .= $dataAttribute;
|
||||
|
||||
// To avoid user's confusion, readonly="true" should imply disabled="true".
|
||||
if ($readonly || $disabled) {
|
||||
$attr .= ' disabled="disabled"';
|
||||
}
|
||||
|
||||
// Initialize JavaScript field attributes.
|
||||
$attr .= !empty($onchange) ? ' onchange="' . $onchange . '"' : '';
|
||||
|
||||
$attr2 = '';
|
||||
$attr2 .= !empty($class) ? ' class="' . $class . '"' : '';
|
||||
$attr2 .= ' placeholder="' . $this->escape($hint ?: Text::_('JGLOBAL_TYPE_OR_SELECT_SOME_OPTIONS')) . '" ';
|
||||
|
||||
if ($required) {
|
||||
$attr .= ' required class="required"';
|
||||
$attr2 .= ' required';
|
||||
}
|
||||
|
||||
// Create a read-only list (no name) with a hidden input to store the value.
|
||||
if ($readonly) {
|
||||
$html[] = HTMLHelper::_(
|
||||
'select.groupedlist',
|
||||
$groups,
|
||||
null,
|
||||
[
|
||||
'list.attr' => $attr, 'id' => $id, 'list.select' => $value, 'group.items' => null, 'option.key.toHtml' => false,
|
||||
'option.text.toHtml' => false,
|
||||
]
|
||||
);
|
||||
|
||||
// E.g. form field type tag sends $this->value as array
|
||||
if ($multiple && \is_array($value)) {
|
||||
if (!\count($value)) {
|
||||
$value[] = '';
|
||||
}
|
||||
|
||||
foreach ($value as $val) {
|
||||
$html[] = '<input type="hidden" name="' . $name . '" value="' . htmlspecialchars($val, ENT_COMPAT, 'UTF-8') . '">';
|
||||
}
|
||||
} else {
|
||||
$html[] = '<input type="hidden" name="' . $name . '" value="' . htmlspecialchars($value, ENT_COMPAT, 'UTF-8') . '">';
|
||||
}
|
||||
} else {
|
||||
// Create a regular list.
|
||||
$html[] = HTMLHelper::_(
|
||||
'select.groupedlist',
|
||||
$groups,
|
||||
$name,
|
||||
[
|
||||
'list.attr' => $attr, 'id' => $id, 'list.select' => $value, 'group.items' => null, 'option.key.toHtml' => false,
|
||||
'option.text.toHtml' => false,
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
Text::script('JGLOBAL_SELECT_NO_RESULTS_MATCH');
|
||||
Text::script('JGLOBAL_SELECT_PRESS_TO_SELECT');
|
||||
|
||||
Factory::getApplication()->getDocument()->getWebAssetManager()
|
||||
->usePreset('choicesjs')
|
||||
->useScript('webcomponent.field-fancy-select');
|
||||
|
||||
?>
|
||||
|
||||
<joomla-field-fancy-select <?php echo $attr2; ?>><?php echo implode($html); ?></joomla-field-fancy-select>
|
||||
104
layouts/joomla/form/field/groupedlist.php
Normal file
104
layouts/joomla/form/field/groupedlist.php
Normal file
@ -0,0 +1,104 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage Layout
|
||||
*
|
||||
* @copyright (C) 2021 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;
|
||||
|
||||
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 $groups Groups of options available for this field.
|
||||
* @var string $dataAttribute Miscellaneous data attributes preprocessed for HTML output
|
||||
* @var array $dataAttributes Miscellaneous data attribute for eg, data-*
|
||||
*/
|
||||
|
||||
$html = [];
|
||||
$attr = '';
|
||||
|
||||
// Initialize some field attributes.
|
||||
$attr .= !empty($class) ? ' class="form-select ' . $class . '"' : ' class="form-select"';
|
||||
$attr .= !empty($size) ? ' size="' . $size . '"' : '';
|
||||
$attr .= $multiple ? ' multiple' : '';
|
||||
$attr .= $required ? ' required' : '';
|
||||
$attr .= $autofocus ? ' autofocus' : '';
|
||||
$attr .= $dataAttribute;
|
||||
|
||||
// To avoid user's confusion, readonly="true" should imply disabled="true".
|
||||
if ($readonly || $disabled) {
|
||||
$attr .= ' disabled="disabled"';
|
||||
}
|
||||
|
||||
// Initialize JavaScript field attributes.
|
||||
$attr .= !empty($onchange) ? ' onchange="' . $onchange . '"' : '';
|
||||
|
||||
// Create a read-only list (no name) with a hidden input to store the value.
|
||||
if ($readonly) {
|
||||
$html[] = HTMLHelper::_(
|
||||
'select.groupedlist',
|
||||
$groups,
|
||||
null,
|
||||
[
|
||||
'list.attr' => $attr, 'id' => $id, 'list.select' => $value, 'group.items' => null, 'option.key.toHtml' => false,
|
||||
'option.text.toHtml' => false,
|
||||
]
|
||||
);
|
||||
|
||||
// E.g. form field type tag sends $this->value as array
|
||||
if ($multiple && \is_array($value)) {
|
||||
if (!\count($value)) {
|
||||
$value[] = '';
|
||||
}
|
||||
|
||||
foreach ($value as $val) {
|
||||
$html[] = '<input type="hidden" name="' . $name . '" value="' . htmlspecialchars($val, ENT_COMPAT, 'UTF-8') . '">';
|
||||
}
|
||||
} else {
|
||||
$html[] = '<input type="hidden" name="' . $name . '" value="' . htmlspecialchars($value, ENT_COMPAT, 'UTF-8') . '">';
|
||||
}
|
||||
} else {
|
||||
// Create a regular list.
|
||||
$html[] = HTMLHelper::_(
|
||||
'select.groupedlist',
|
||||
$groups,
|
||||
$name,
|
||||
[
|
||||
'list.attr' => $attr, 'id' => $id, 'list.select' => $value, 'group.items' => null, 'option.key.toHtml' => false,
|
||||
'option.text.toHtml' => false,
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
echo implode($html);
|
||||
59
layouts/joomla/form/field/hidden.php
Normal file
59
layouts/joomla/form/field/hidden.php
Normal file
@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage Layout
|
||||
*
|
||||
* @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;
|
||||
|
||||
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 $dataAttribute Miscellaneous data attributes preprocessed for HTML output
|
||||
* @var array $dataAttributes Miscellaneous data attribute for eg, data-*
|
||||
*/
|
||||
|
||||
// Initialize some field attributes.
|
||||
$class = !empty($class) ? ' class="' . $class . '"' : '';
|
||||
$disabled = $disabled ? ' disabled' : '';
|
||||
$onchange = $onchange ? ' onchange="' . $onchange . '"' : '';
|
||||
?>
|
||||
<input
|
||||
type="hidden"
|
||||
name="<?php echo $name; ?>"
|
||||
id="<?php echo $id; ?>"
|
||||
value="<?php echo htmlspecialchars($value, ENT_COMPAT, 'UTF-8'); ?>"
|
||||
<?php echo $class, $disabled, $onchange, $dataAttribute; ?>>
|
||||
104
layouts/joomla/form/field/list-fancy-select.php
Normal file
104
layouts/joomla/form/field/list-fancy-select.php
Normal file
@ -0,0 +1,104 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage Layout
|
||||
*
|
||||
* @copyright (C) 2018 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\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 $options Options available for this field.
|
||||
* @var string $dataAttribute Miscellaneous data attributes preprocessed for HTML output
|
||||
* @var array $dataAttributes Miscellaneous data attribute for eg, data-*
|
||||
*/
|
||||
|
||||
$html = [];
|
||||
$attr = '';
|
||||
|
||||
// Initialize the field attributes.
|
||||
$attr .= !empty($size) ? ' size="' . $size . '"' : '';
|
||||
$attr .= $multiple ? ' multiple' : '';
|
||||
$attr .= $autofocus ? ' autofocus' : '';
|
||||
$attr .= $onchange ? ' onchange="' . $onchange . '"' : '';
|
||||
$attr .= $dataAttribute;
|
||||
|
||||
// To avoid user's confusion, readonly="readonly" should imply disabled="disabled".
|
||||
if ($readonly || $disabled) {
|
||||
$attr .= ' disabled="disabled"';
|
||||
}
|
||||
|
||||
$attr2 = '';
|
||||
$attr2 .= !empty($class) ? ' class="' . $class . '"' : '';
|
||||
$attr2 .= ' placeholder="' . $this->escape($hint ?: Text::_('JGLOBAL_TYPE_OR_SELECT_SOME_OPTIONS')) . '" ';
|
||||
|
||||
if ($required) {
|
||||
$attr .= ' required class="required"';
|
||||
$attr2 .= ' required';
|
||||
}
|
||||
|
||||
// Create a read-only list (no name) with hidden input(s) to store the value(s).
|
||||
if ($readonly) {
|
||||
$html[] = HTMLHelper::_('select.genericlist', $options, '', trim($attr), 'value', 'text', $value, $id);
|
||||
|
||||
// E.g. form field type tag sends $this->value as array
|
||||
if ($multiple && is_array($value)) {
|
||||
if (!count($value)) {
|
||||
$value[] = '';
|
||||
}
|
||||
|
||||
foreach ($value as $val) {
|
||||
$html[] = '<input type="hidden" name="' . $name . '" value="' . htmlspecialchars($val, ENT_COMPAT, 'UTF-8') . '">';
|
||||
}
|
||||
} else {
|
||||
$html[] = '<input type="hidden" name="' . $name . '" value="' . htmlspecialchars($value, ENT_COMPAT, 'UTF-8') . '">';
|
||||
}
|
||||
} else // Create a regular list.
|
||||
{
|
||||
$html[] = HTMLHelper::_('select.genericlist', $options, $name, trim($attr), 'value', 'text', $value, $id);
|
||||
}
|
||||
|
||||
Text::script('JGLOBAL_SELECT_NO_RESULTS_MATCH');
|
||||
Text::script('JGLOBAL_SELECT_PRESS_TO_SELECT');
|
||||
|
||||
Factory::getApplication()->getDocument()->getWebAssetManager()
|
||||
->usePreset('choicesjs')
|
||||
->useScript('webcomponent.field-fancy-select');
|
||||
|
||||
?>
|
||||
|
||||
<joomla-field-fancy-select <?php echo $attr2; ?>><?php echo implode($html); ?></joomla-field-fancy-select>
|
||||
95
layouts/joomla/form/field/list.php
Normal file
95
layouts/joomla/form/field/list.php
Normal file
@ -0,0 +1,95 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage Layout
|
||||
*
|
||||
* @copyright (C) 2018 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;
|
||||
|
||||
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 $options Options available for this field.
|
||||
* @var string $dataAttribute Miscellaneous data attributes preprocessed for HTML output
|
||||
* @var array $dataAttributes Miscellaneous data attribute for eg, data-*
|
||||
*/
|
||||
|
||||
$html = [];
|
||||
$attr = '';
|
||||
|
||||
// Initialize the field attributes.
|
||||
$attr .= !empty($class) ? ' class="form-select ' . $class . '"' : ' class="form-select"';
|
||||
$attr .= !empty($size) ? ' size="' . $size . '"' : '';
|
||||
$attr .= $multiple ? ' multiple' : '';
|
||||
$attr .= $required ? ' required' : '';
|
||||
$attr .= $autofocus ? ' autofocus' : '';
|
||||
$attr .= $onchange ? ' onchange="' . $onchange . '"' : '';
|
||||
$attr .= !empty($description) ? ' aria-describedby="' . ($id ?: $name) . '-desc"' : '';
|
||||
$attr .= $dataAttribute;
|
||||
|
||||
// To avoid user's confusion, readonly="readonly" should imply disabled="disabled".
|
||||
if ($readonly || $disabled) {
|
||||
$attr .= ' disabled="disabled"';
|
||||
}
|
||||
|
||||
// Create a read-only list (no name) with hidden input(s) to store the value(s).
|
||||
if ($readonly) {
|
||||
$html[] = HTMLHelper::_('select.genericlist', $options, '', trim($attr), 'value', 'text', $value, $id);
|
||||
|
||||
// E.g. form field type tag sends $this->value as array
|
||||
if ($multiple && is_array($value)) {
|
||||
if (!count($value)) {
|
||||
$value[] = '';
|
||||
}
|
||||
|
||||
foreach ($value as $val) {
|
||||
$html[] = '<input type="hidden" name="' . $name . '" value="' . htmlspecialchars($val, ENT_COMPAT, 'UTF-8') . '">';
|
||||
}
|
||||
} else {
|
||||
$html[] = '<input type="hidden" name="' . $name . '" value="' . htmlspecialchars($value, ENT_COMPAT, 'UTF-8') . '">';
|
||||
}
|
||||
} else // Create a regular list passing the arguments in an array.
|
||||
{
|
||||
$listoptions = [];
|
||||
$listoptions['option.key'] = 'value';
|
||||
$listoptions['option.text'] = 'text';
|
||||
$listoptions['list.select'] = $value;
|
||||
$listoptions['id'] = $id;
|
||||
$listoptions['list.translate'] = false;
|
||||
$listoptions['option.attr'] = 'optionattr';
|
||||
$listoptions['list.attr'] = trim($attr);
|
||||
$html[] = HTMLHelper::_('select.genericlist', $options, $name, $listoptions);
|
||||
}
|
||||
|
||||
echo implode($html);
|
||||
203
layouts/joomla/form/field/media.php
Normal file
203
layouts/joomla/form/field/media.php
Normal file
@ -0,0 +1,203 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Admin
|
||||
* @subpackage Layout
|
||||
*
|
||||
* @copyright (C) 2015 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\Component\ComponentHelper;
|
||||
use Joomla\CMS\Factory;
|
||||
use Joomla\CMS\Helper\MediaHelper;
|
||||
use Joomla\CMS\HTML\HTMLHelper;
|
||||
use Joomla\CMS\Language\Text;
|
||||
use Joomla\CMS\Router\Route;
|
||||
use Joomla\CMS\Uri\Uri;
|
||||
|
||||
extract($displayData);
|
||||
|
||||
/**
|
||||
* Layout variables
|
||||
* -----------------
|
||||
* @var string $asset The asset text
|
||||
* @var string $authorField The label text
|
||||
* @var integer $authorId The author id
|
||||
* @var string $class The class text
|
||||
* @var boolean $disabled True if field is disabled
|
||||
* @var string $folder The folder text
|
||||
* @var string $id The label text
|
||||
* @var string $link The link text
|
||||
* @var string $name The name text
|
||||
* @var string $preview The preview image relative path
|
||||
* @var integer $previewHeight The image preview height
|
||||
* @var integer $previewWidth The image preview width
|
||||
* @var string $onchange The onchange text
|
||||
* @var boolean $readonly True if field is readonly
|
||||
* @var integer $size The size text
|
||||
* @var string $value The value text
|
||||
* @var string $src The path and filename of the image
|
||||
* @var array $mediaTypes The supported media types for the Media Manager
|
||||
* @var array $imagesExt The supported extensions for images
|
||||
* @var array $audiosExt The supported extensions for audios
|
||||
* @var array $videosExt The supported extensions for videos
|
||||
* @var array $documentsExt The supported extensions for documents
|
||||
* @var string $dataAttribute Miscellaneous data attributes preprocessed for HTML output
|
||||
* @var array $dataAttributes Miscellaneous data attribute for eg, data-*
|
||||
*/
|
||||
|
||||
$attr = '';
|
||||
|
||||
// Initialize some field attributes.
|
||||
$attr .= !empty($class) ? ' class="form-control field-media-input ' . $class . '"' : ' class="form-control field-media-input"';
|
||||
$attr .= !empty($size) ? ' size="' . $size . '"' : '';
|
||||
$attr .= $dataAttribute;
|
||||
|
||||
// Initialize JavaScript field attributes.
|
||||
$attr .= !empty($onchange) ? ' onchange="' . $onchange . '"' : '';
|
||||
|
||||
switch ($preview) {
|
||||
case 'no': // Deprecated parameter value
|
||||
case 'false':
|
||||
case 'none':
|
||||
$showPreview = false;
|
||||
break;
|
||||
case 'yes': // Deprecated parameter value
|
||||
case 'true':
|
||||
case 'show':
|
||||
case 'tooltip':
|
||||
default:
|
||||
$showPreview = true;
|
||||
break;
|
||||
}
|
||||
|
||||
// Pre fill the contents of the popover
|
||||
if ($showPreview) {
|
||||
$cleanValue = MediaHelper::getCleanMediaFieldValue($value);
|
||||
|
||||
if ($cleanValue && file_exists(JPATH_ROOT . '/' . $cleanValue)) {
|
||||
$src = Uri::root() . $value;
|
||||
} else {
|
||||
$src = '';
|
||||
}
|
||||
|
||||
$width = $previewWidth;
|
||||
$height = $previewHeight;
|
||||
$style = '';
|
||||
$style .= ($width > 0) ? 'max-width:' . $width . 'px;' : '';
|
||||
$style .= ($height > 0) ? 'max-height:' . $height . 'px;' : '';
|
||||
|
||||
$imgattr = [
|
||||
'id' => $id . '_preview',
|
||||
'class' => 'media-preview',
|
||||
'style' => $style,
|
||||
];
|
||||
|
||||
$img = HTMLHelper::_('image', $src, Text::_('JLIB_FORM_MEDIA_PREVIEW_ALT'), $imgattr);
|
||||
|
||||
$previewImg = '<div id="' . $id . '_preview_img">' . $img . '</div>';
|
||||
$previewImgEmpty = '<div id="' . $id . '_preview_empty"' . ($src ? ' class="hidden"' : '') . '>'
|
||||
. Text::_('JLIB_FORM_MEDIA_PREVIEW_EMPTY') . '</div>';
|
||||
|
||||
$showPreview = 'static';
|
||||
}
|
||||
|
||||
// The url for the modal
|
||||
$url = ($readonly ? ''
|
||||
: ($link ?: 'index.php?option=com_media&view=media&tmpl=component&mediatypes=' . $mediaTypes
|
||||
. '&asset=' . $asset . '&author=' . $authorId)
|
||||
. '&fieldid={field-media-id}&path=' . $folder);
|
||||
|
||||
// Correctly route the url to ensure it's correctly using sef modes and subfolders
|
||||
$url = Route::_($url);
|
||||
$doc = Factory::getDocument();
|
||||
$wam = $doc->getWebAssetManager();
|
||||
|
||||
$wam->useScript('webcomponent.media-select');
|
||||
$doc->addScriptOptions('media-picker-api', ['apiBaseUrl' => Uri::base() . 'index.php?option=com_media&format=json']);
|
||||
|
||||
Text::script('JFIELD_MEDIA_LAZY_LABEL');
|
||||
Text::script('JFIELD_MEDIA_ALT_LABEL');
|
||||
Text::script('JFIELD_MEDIA_ALT_CHECK_LABEL');
|
||||
Text::script('JFIELD_MEDIA_ALT_CHECK_DESC_LABEL');
|
||||
Text::script('JFIELD_MEDIA_CLASS_LABEL');
|
||||
Text::script('JFIELD_MEDIA_FIGURE_CLASS_LABEL');
|
||||
Text::script('JFIELD_MEDIA_FIGURE_CAPTION_LABEL');
|
||||
Text::script('JFIELD_MEDIA_LAZY_LABEL');
|
||||
Text::script('JFIELD_MEDIA_SUMMARY_LABEL');
|
||||
Text::script('JFIELD_MEDIA_EMBED_CHECK_DESC_LABEL');
|
||||
Text::script('JFIELD_MEDIA_DOWNLOAD_CHECK_DESC_LABEL');
|
||||
Text::script('JFIELD_MEDIA_DOWNLOAD_CHECK_LABEL');
|
||||
Text::script('JFIELD_MEDIA_EMBED_CHECK_LABEL');
|
||||
Text::script('JFIELD_MEDIA_WIDTH_LABEL');
|
||||
Text::script('JFIELD_MEDIA_TITLE_LABEL');
|
||||
Text::script('JFIELD_MEDIA_HEIGHT_LABEL');
|
||||
Text::script('JFIELD_MEDIA_UNSUPPORTED');
|
||||
Text::script('JFIELD_MEDIA_DOWNLOAD_FILE');
|
||||
Text::script('JLIB_APPLICATION_ERROR_SERVER');
|
||||
Text::script('JLIB_FORM_MEDIA_PREVIEW_EMPTY', true);
|
||||
|
||||
$modalHTML = HTMLHelper::_(
|
||||
'bootstrap.renderModal',
|
||||
'imageModal_' . $id,
|
||||
[
|
||||
'url' => $url,
|
||||
'title' => Text::_('JLIB_FORM_CHANGE_IMAGE'),
|
||||
'closeButton' => true,
|
||||
'height' => '100%',
|
||||
'width' => '100%',
|
||||
'modalWidth' => '80',
|
||||
'bodyHeight' => '60',
|
||||
'footer' => '<button type="button" class="btn btn-success button-save-selected">' . Text::_('JSELECT') . '</button>'
|
||||
. '<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">' . Text::_('JCANCEL') . '</button>',
|
||||
]
|
||||
);
|
||||
|
||||
$wam->useStyle('webcomponent.field-media')
|
||||
->useScript('webcomponent.field-media');
|
||||
|
||||
if (count($doc->getScriptOptions('media-picker')) === 0) {
|
||||
$doc->addScriptOptions('media-picker', [
|
||||
'images' => $imagesExt,
|
||||
'audios' => $audiosExt,
|
||||
'videos' => $videosExt,
|
||||
'documents' => $documentsExt,
|
||||
]);
|
||||
}
|
||||
|
||||
?>
|
||||
<joomla-field-media class="field-media-wrapper" type="image" <?php // @TODO add this attribute to the field in order to use it for all media types ?>
|
||||
base-path="<?php echo Uri::root(); ?>"
|
||||
root-folder="<?php echo ComponentHelper::getParams('com_media')->get('file_path', 'images'); ?>"
|
||||
url="<?php echo $url; ?>"
|
||||
modal-container=".modal"
|
||||
modal-width="100%"
|
||||
modal-height="400px"
|
||||
input=".field-media-input"
|
||||
button-select=".button-select"
|
||||
button-clear=".button-clear"
|
||||
button-save-selected=".button-save-selected"
|
||||
preview="static"
|
||||
preview-container=".field-media-preview"
|
||||
preview-width="<?php echo $previewWidth; ?>"
|
||||
preview-height="<?php echo $previewHeight; ?>"
|
||||
supported-extensions="<?php echo str_replace('"', '"', json_encode(['images' => $imagesAllowedExt, 'audios' => $audiosAllowedExt, 'videos' => $videosAllowedExt, 'documents' => $documentsAllowedExt])); ?>
|
||||
">
|
||||
<?php echo $modalHTML; ?>
|
||||
<?php if ($showPreview) : ?>
|
||||
<div class="field-media-preview">
|
||||
<?php echo ' ' . $previewImgEmpty; ?>
|
||||
<?php echo ' ' . $previewImg; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<div class="input-group">
|
||||
<input type="text" name="<?php echo $name; ?>" id="<?php echo $id; ?>" value="<?php echo htmlspecialchars($value, ENT_COMPAT, 'UTF-8'); ?>" <?php echo $attr; ?>>
|
||||
<?php if ($disabled != true) : ?>
|
||||
<button type="button" class="btn btn-success button-select"><?php echo Text::_('JLIB_FORM_BUTTON_SELECT'); ?></button>
|
||||
<button type="button" class="btn btn-danger button-clear"><span class="icon-times" aria-hidden="true"></span><span class="visually-hidden"><?php echo Text::_('JLIB_FORM_BUTTON_CLEAR'); ?></span></button>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</joomla-field-media>
|
||||
24
layouts/joomla/form/field/media/accessiblemedia.php
Normal file
24
layouts/joomla/form/field/media/accessiblemedia.php
Normal file
@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage Layout
|
||||
*
|
||||
* @copyright (C) 2020 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
extract($displayData);
|
||||
|
||||
$form = $forms[0];
|
||||
|
||||
$formfields = $form->getGroup('');
|
||||
?>
|
||||
|
||||
<div class="subform-wrapper">
|
||||
<?php foreach ($formfields as $field) : ?>
|
||||
<?php echo $field->renderField(); ?>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
82
layouts/joomla/form/field/meter.php
Normal file
82
layouts/joomla/form/field/meter.php
Normal file
@ -0,0 +1,82 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage Layout
|
||||
*
|
||||
* @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;
|
||||
|
||||
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.
|
||||
* @var string $animated Is it animated.
|
||||
* @var string $active Is it active.
|
||||
* @var string $max The maximum value.
|
||||
* @var string $dataAttribute Miscellaneous data attributes preprocessed for HTML output
|
||||
* @var array $dataAttributes Miscellaneous data attribute for eg, data-*
|
||||
*/
|
||||
|
||||
// Initialize some field attributes.
|
||||
$class = 'progress-bar ' . $class;
|
||||
$class .= $animated ? ' progress-bar-striped progress-bar-animated' : '';
|
||||
$class .= $active ? ' active' : '';
|
||||
$class = 'class="' . $class . '"';
|
||||
|
||||
$value = (float) $value;
|
||||
$value = max($value, $min);
|
||||
$value = min($value, $max);
|
||||
|
||||
$data = '';
|
||||
$data .= 'aria-valuemax="' . $max . '"';
|
||||
$data .= ' aria-valuemin="' . $min . '"';
|
||||
$data .= ' aria-valuenow="' . $value . '"';
|
||||
|
||||
$attributes = [
|
||||
$class,
|
||||
!empty($width) ? ' style="width:' . $width . ';"' : '',
|
||||
$data,
|
||||
$dataAttribute,
|
||||
];
|
||||
|
||||
$value = ((float) ($value - $min) * 100) / ($max - $min);
|
||||
?>
|
||||
<div class="progress">
|
||||
<div
|
||||
role="progressbar"
|
||||
<?php echo implode(' ', $attributes); ?>
|
||||
style="width:<?php echo (string) $value; ?>%;<?php echo !empty($color) ? ' background-color:' . $color . ';' : ''; ?>"></div>
|
||||
</div>
|
||||
77
layouts/joomla/form/field/modal-select.php
Normal file
77
layouts/joomla/form/field/modal-select.php
Normal file
@ -0,0 +1,77 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage Layout
|
||||
*
|
||||
* @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\Factory;
|
||||
|
||||
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 string $dataAttribute Miscellaneous data attributes preprocessed for HTML output
|
||||
* @var array $dataAttributes Miscellaneous data attribute for eg, data-*
|
||||
* @var string $valueTitle
|
||||
* @var array $canDo
|
||||
* @var string[] $urls
|
||||
* @var string[] $modalTitles
|
||||
* @var string[] $buttonIcons
|
||||
*/
|
||||
|
||||
// Add the field script
|
||||
if (!$readonly && !$disabled) {
|
||||
/** @var \Joomla\CMS\WebAsset\WebAssetManager $wa */
|
||||
$wa = Factory::getApplication()->getDocument()->getWebAssetManager();
|
||||
$wa->useScript('modal-content-select-field');
|
||||
}
|
||||
|
||||
$fieldClass = $required ? 'required modal-value' : '';
|
||||
?>
|
||||
|
||||
<div class="js-modal-content-select-field <?php echo $class; ?>" <?php echo $dataAttribute; ?>>
|
||||
<div class="input-group">
|
||||
<input class="form-control js-input-title" type="text" value="<?php echo $this->escape($valueTitle ?? $value); ?>" readonly
|
||||
id="<?php echo $id; ?>" name="<?php echo $name; ?>"
|
||||
placeholder="<?php echo $this->escape($hint); ?>"/>
|
||||
|
||||
<?php if (!$readonly && !$disabled) :
|
||||
echo $this->sublayout('buttons', $displayData);
|
||||
// The "extra-buttons" layout allows to add extra control buttons to the field, example "propagate association" by com_content
|
||||
echo $this->sublayout('extra-buttons', $displayData);
|
||||
endif; ?>
|
||||
</div>
|
||||
|
||||
<input type="hidden" id="<?php echo $id; ?>_id" class="<?php echo $fieldClass; ?> js-input-value" data-required="<?php echo (int) $required; ?>"
|
||||
name="<?php echo $name; ?>" value="<?php echo $this->escape($value); ?>">
|
||||
</div>
|
||||
103
layouts/joomla/form/field/modal-select/buttons.php
Normal file
103
layouts/joomla/form/field/modal-select/buttons.php
Normal file
@ -0,0 +1,103 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage Layout
|
||||
*
|
||||
* @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\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 string $dataAttribute Miscellaneous data attributes preprocessed for HTML output
|
||||
* @var array $dataAttributes Miscellaneous data attribute for eg, data-*
|
||||
* @var string $valueTitle
|
||||
* @var array $canDo
|
||||
* @var string[] $urls
|
||||
* @var string[] $modalTitles
|
||||
* @var string[] $buttonIcons
|
||||
*/
|
||||
|
||||
// Prepare options for each Modal
|
||||
$modalSelect = [
|
||||
'popupType' => 'iframe',
|
||||
'src' => $urls['select'] ?? '',
|
||||
'textHeader' => $modalTitles['select'] ?? Text::_('JSELECT'),
|
||||
];
|
||||
$modalNew = [
|
||||
'popupType' => 'iframe',
|
||||
'src' => $urls['new'] ?? '',
|
||||
'textHeader' => $modalTitles['new'] ?? Text::_('JACTION_CREATE'),
|
||||
];
|
||||
$modalEdit = [
|
||||
'popupType' => 'iframe',
|
||||
'src' => $urls['edit'] ?? '',
|
||||
'textHeader' => $modalTitles['edit'] ?? Text::_('JACTION_EDIT'),
|
||||
];
|
||||
|
||||
// Decide when the select button always will be visible
|
||||
$isSelectAlways = !empty($canDo['select']) && empty($canDo['clear']);
|
||||
|
||||
?>
|
||||
<?php if ($modalSelect['src'] && $canDo['select'] ?? true) : ?>
|
||||
<button type="button" class="btn btn-primary" <?php echo $value && !$isSelectAlways ? 'hidden' : ''; ?>
|
||||
data-button-action="select" <?php echo !$isSelectAlways ? 'data-show-when-value=""' : ''; ?>
|
||||
data-modal-config="<?php echo $this->escape(json_encode($modalSelect)); ?>">
|
||||
<span class="<?php echo !empty($buttonIcons['select']) ? $buttonIcons['select'] : 'icon-file'; ?>" aria-hidden="true"></span> <?php echo Text::_('JSELECT'); ?>
|
||||
</button>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($modalNew['src'] && $canDo['new'] ?? false) : ?>
|
||||
<button type="button" class="btn btn-secondary" <?php echo $value ? 'hidden' : ''; ?>
|
||||
data-button-action="create" data-show-when-value=""
|
||||
data-modal-config="<?php echo $this->escape(json_encode($modalNew)); ?>">
|
||||
<span class="icon-plus" aria-hidden="true"></span> <?php echo Text::_('JACTION_CREATE'); ?>
|
||||
</button>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($modalEdit['src'] && $canDo['edit'] ?? false) : ?>
|
||||
<button type="button" class="btn btn-primary" <?php echo $value ? '' : 'hidden'; ?>
|
||||
data-button-action="edit" data-show-when-value="1"
|
||||
data-modal-config="<?php echo $this->escape(json_encode($modalEdit)); ?>"
|
||||
data-checkin-url="<?php echo $this->escape($urls['checkin'] ?? ''); ?>">
|
||||
<span class="icon-pen-square" aria-hidden="true"></span> <?php echo Text::_('JACTION_EDIT'); ?>
|
||||
</button>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($canDo['clear'] ?? true) : ?>
|
||||
<button type="button" class="btn btn-secondary" <?php echo $value ? '' : 'hidden'; ?>
|
||||
data-button-action="clear" data-show-when-value="1">
|
||||
<span class="icon-times" aria-hidden="true"></span> <?php echo Text::_('JCLEAR'); ?>
|
||||
</button>
|
||||
<?php endif; ?>
|
||||
48
layouts/joomla/form/field/modal-select/extra-buttons.php
Normal file
48
layouts/joomla/form/field/modal-select/extra-buttons.php
Normal file
@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage Layout
|
||||
*
|
||||
* @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;
|
||||
|
||||
/**
|
||||
* The layout allows to add extra control buttons to the field, example "propagate association" by com_content.
|
||||
*
|
||||
* 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 string $dataAttribute Miscellaneous data attributes preprocessed for HTML output
|
||||
* @var array $dataAttributes Miscellaneous data attribute for eg, data-*
|
||||
* @var string $valueTitle
|
||||
* @var array $canDo
|
||||
* @var string[] $urls
|
||||
* @var string[] $modalTitles
|
||||
* @var string[] $buttonIcons
|
||||
*/
|
||||
86
layouts/joomla/form/field/moduleorder.php
Normal file
86
layouts/joomla/form/field/moduleorder.php
Normal file
@ -0,0 +1,86 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage Layout
|
||||
*
|
||||
* @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\Factory;
|
||||
|
||||
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.
|
||||
* @var string $dataAttribute Miscellaneous data attributes preprocessed for HTML output
|
||||
* @var array $dataAttributes Miscellaneous data attributes for eg, data-*.
|
||||
*/
|
||||
|
||||
// Initialize some field attributes.
|
||||
$attributes['dataid'] = 'data-id="' . $id . '"';
|
||||
$attributes['data-url'] = 'data-url="index.php?option=com_modules&task=module.orderPosition&' . $token . '"';
|
||||
$attributes['data-element'] = 'data-element="parent_' . $id . '"';
|
||||
$attributes['data-ordering'] = 'data-ordering="' . $ordering . '"';
|
||||
$attributes['data-position-element'] = 'data-position-element="' . $element . '"';
|
||||
$attributes['data-client-id'] = 'data-client-id="' . $clientId . '"';
|
||||
$attributes['data-name'] = 'data-name="' . $name . '"';
|
||||
$attributes['data-module-id'] = 'data-module-id="' . $moduleId . '"';
|
||||
|
||||
if ($disabled) {
|
||||
$attributes['disabled'] = 'disabled';
|
||||
}
|
||||
|
||||
if ($class) {
|
||||
$attributes['class'] = 'class="' . $class . '"';
|
||||
}
|
||||
|
||||
if ($size) {
|
||||
$attributes['size'] = 'size="' . $size . '"';
|
||||
}
|
||||
|
||||
if ($onchange) {
|
||||
$attributes['onchange'] = 'onchange="' . $onchange . '"';
|
||||
}
|
||||
|
||||
if ($dataAttribute) {
|
||||
$attributes['dataAttribute'] = $dataAttribute;
|
||||
}
|
||||
|
||||
Factory::getDocument()->getWebAssetManager()
|
||||
->useScript('webcomponent.field-module-order');
|
||||
|
||||
?>
|
||||
<joomla-field-module-order <?php echo implode(' ', $attributes); ?>></joomla-field-module-order>
|
||||
78
layouts/joomla/form/field/number.php
Normal file
78
layouts/joomla/form/field/number.php
Normal file
@ -0,0 +1,78 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage Layout
|
||||
*
|
||||
* @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;
|
||||
|
||||
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 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-*.
|
||||
*/
|
||||
|
||||
$attributes = [
|
||||
!empty($class) ? 'class="form-control ' . $class . '"' : 'class="form-control"',
|
||||
!empty($description) ? 'aria-describedby="' . ($id ?: $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' : '',
|
||||
!empty($autocomplete) ? 'autocomplete="' . $autocomplete . '"' : '',
|
||||
$autofocus ? 'autofocus' : '',
|
||||
$dataAttribute,
|
||||
];
|
||||
|
||||
if (is_numeric($value)) {
|
||||
$value = (float) $value;
|
||||
} else {
|
||||
$value = '';
|
||||
$value = ($required && isset($min)) ? $min : $value;
|
||||
}
|
||||
?>
|
||||
<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); ?>>
|
||||
158
layouts/joomla/form/field/password.php
Normal file
158
layouts/joomla/form/field/password.php
Normal file
@ -0,0 +1,158 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage Layout
|
||||
*
|
||||
* @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\Factory;
|
||||
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 boolean $rules Are the rules to be displayed?
|
||||
* @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 boolean $lock Is this field locked.
|
||||
*/
|
||||
|
||||
$document = Factory::getApplication()->getDocument();
|
||||
|
||||
/** @var Joomla\CMS\WebAsset\WebAssetManager $wa */
|
||||
$wa = $document->getWebAssetManager();
|
||||
|
||||
if ($meter) {
|
||||
$wa->useScript('field.passwordstrength');
|
||||
|
||||
$class = 'js-password-strength ' . $class;
|
||||
|
||||
if ($forcePassword) {
|
||||
$class .= ' meteredPassword';
|
||||
}
|
||||
}
|
||||
|
||||
$wa->useScript('field.passwordview');
|
||||
|
||||
Text::script('JFIELD_PASSWORD_INDICATE_INCOMPLETE');
|
||||
Text::script('JFIELD_PASSWORD_INDICATE_COMPLETE');
|
||||
Text::script('JSHOWPASSWORD');
|
||||
Text::script('JHIDEPASSWORD');
|
||||
|
||||
if ($lock) {
|
||||
Text::script('JMODIFY');
|
||||
Text::script('JCANCEL');
|
||||
|
||||
$disabled = true;
|
||||
$hint = str_repeat('•', 10);
|
||||
$value = '';
|
||||
}
|
||||
|
||||
$ariaDescribedBy = $rules ? $name . '-rules ' : '';
|
||||
$ariaDescribedBy .= !empty($description) ? (($id ?: $name) . '-desc') : '';
|
||||
|
||||
$attributes = [
|
||||
strlen($hint) ? 'placeholder="' . htmlspecialchars($hint, ENT_COMPAT, 'UTF-8') . '"' : '',
|
||||
!empty($autocomplete) ? 'autocomplete="' . $autocomplete . '"' : '',
|
||||
!empty($class) ? 'class="form-control ' . $class . '"' : 'class="form-control"',
|
||||
!empty($ariaDescribedBy) ? 'aria-describedby="' . trim($ariaDescribedBy) . '"' : '',
|
||||
$readonly ? 'readonly' : '',
|
||||
$disabled ? 'disabled' : '',
|
||||
!empty($size) ? 'size="' . $size . '"' : '',
|
||||
!empty($maxLength) ? 'maxlength="' . $maxLength . '"' : '',
|
||||
$required ? 'required' : '',
|
||||
$autofocus ? 'autofocus' : '',
|
||||
!empty($minLength) ? 'data-min-length="' . $minLength . '"' : '',
|
||||
!empty($minIntegers) ? 'data-min-integers="' . $minIntegers . '"' : '',
|
||||
!empty($minSymbols) ? 'data-min-symbols="' . $minSymbols . '"' : '',
|
||||
!empty($minUppercase) ? 'data-min-uppercase="' . $minUppercase . '"' : '',
|
||||
!empty($minLowercase) ? 'data-min-lowercase="' . $minLowercase . '"' : '',
|
||||
!empty($forcePassword) ? 'data-min-force="' . $forcePassword . '"' : '',
|
||||
$dataAttribute,
|
||||
];
|
||||
|
||||
if ($rules) {
|
||||
$requirements = [];
|
||||
|
||||
if ($minLength) {
|
||||
$requirements[] = Text::sprintf('JFIELD_PASSWORD_RULES_CHARACTERS', $minLength);
|
||||
}
|
||||
|
||||
if ($minIntegers) {
|
||||
$requirements[] = Text::sprintf('JFIELD_PASSWORD_RULES_DIGITS', $minIntegers);
|
||||
}
|
||||
|
||||
if ($minSymbols) {
|
||||
$requirements[] = Text::sprintf('JFIELD_PASSWORD_RULES_SYMBOLS', $minSymbols);
|
||||
}
|
||||
|
||||
if ($minUppercase) {
|
||||
$requirements[] = Text::sprintf('JFIELD_PASSWORD_RULES_UPPERCASE', $minUppercase);
|
||||
}
|
||||
|
||||
if ($minLowercase) {
|
||||
$requirements[] = Text::sprintf('JFIELD_PASSWORD_RULES_LOWERCASE', $minLowercase);
|
||||
}
|
||||
}
|
||||
?>
|
||||
<?php if ($rules) : ?>
|
||||
<div id="<?php echo $name . '-rules'; ?>" class="small text-muted">
|
||||
<?php echo Text::sprintf('JFIELD_PASSWORD_RULES_MINIMUM_REQUIREMENTS', implode(', ', $requirements)); ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<div class="password-group">
|
||||
<div class="input-group">
|
||||
<input
|
||||
type="password"
|
||||
name="<?php echo $name; ?>"
|
||||
id="<?php echo $id; ?>"
|
||||
value="<?php echo htmlspecialchars($value, ENT_COMPAT, 'UTF-8'); ?>"
|
||||
<?php echo implode(' ', $attributes); ?>>
|
||||
<?php if (!$lock) : ?>
|
||||
<button type="button" class="btn btn-secondary input-password-toggle">
|
||||
<span class="icon-eye icon-fw" aria-hidden="true"></span>
|
||||
<span class="visually-hidden"><?php echo Text::_('JSHOWPASSWORD'); ?></span>
|
||||
</button>
|
||||
<?php else : ?>
|
||||
<button type="button" id="<?php echo $id; ?>_lock" class="btn btn-info input-password-modify locked">
|
||||
<?php echo Text::_('JMODIFY'); ?>
|
||||
</button>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
127
layouts/joomla/form/field/radio/buttons.php
Normal file
127
layouts/joomla/form/field/radio/buttons.php
Normal file
@ -0,0 +1,127 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage Layout
|
||||
*
|
||||
* @copyright (C) 2018 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
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 $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-*.
|
||||
*/
|
||||
|
||||
$alt = preg_replace('/[^a-zA-Z0-9_\-]/', '_', $name);
|
||||
$isBtnGroup = strpos(trim($class), 'btn-group') !== false;
|
||||
$isBtnYesNo = strpos(trim($class), 'btn-group-yesno') !== false;
|
||||
$classToggle = $isBtnGroup ? 'btn-check' : 'form-check-input';
|
||||
$btnClass = $isBtnGroup ? 'btn btn-outline-secondary' : 'form-check-label';
|
||||
$blockStart = $isBtnGroup ? '' : '<div class="form-check">';
|
||||
$blockEnd = $isBtnGroup ? '' : '</div>';
|
||||
|
||||
// Add the attributes of the fieldset in an array
|
||||
$containerClass = trim($class . ' radio' . ($readonly || $disabled ? ' disabled' : '') . ($readonly ? ' readonly' : ''));
|
||||
|
||||
$attribs = ['id="' . $id . '"'];
|
||||
|
||||
if (!empty($disabled)) {
|
||||
$attribs[] = 'disabled';
|
||||
}
|
||||
|
||||
if (!empty($autofocus)) {
|
||||
$attribs[] = 'autofocus';
|
||||
}
|
||||
|
||||
if ($required) {
|
||||
$attribs[] = 'class="required radio"';
|
||||
}
|
||||
|
||||
if ($readonly || $disabled) {
|
||||
$attribs[] = 'style="pointer-events: none"';
|
||||
}
|
||||
|
||||
if ($dataAttribute) {
|
||||
$attribs[] = $dataAttribute;
|
||||
}
|
||||
?>
|
||||
<fieldset <?php echo implode(' ', $attribs); ?>>
|
||||
<legend class="visually-hidden">
|
||||
<?php echo $label; ?>
|
||||
</legend>
|
||||
<div class="<?php echo $containerClass; ?>">
|
||||
<?php foreach ($options as $i => $option) : ?>
|
||||
<?php echo $blockStart; ?>
|
||||
<?php
|
||||
$disabled = !empty($option->disable) ? 'disabled' : '';
|
||||
$style = $disabled ? ' style="pointer-events: none"' : '';
|
||||
|
||||
// Initialize some option attributes.
|
||||
if ($isBtnYesNo) {
|
||||
// Set the button classes for the yes/no group
|
||||
switch ($option->value) {
|
||||
case '0':
|
||||
$btnClass = 'btn btn-outline-danger';
|
||||
break;
|
||||
case '1':
|
||||
$btnClass = 'btn btn-outline-success';
|
||||
break;
|
||||
default:
|
||||
$btnClass = 'btn btn-outline-secondary';
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$optionClass = !empty($option->class) ? $option->class : $btnClass;
|
||||
$optionClass = trim($optionClass . ' ' . $disabled);
|
||||
$checked = ((string) $option->value === $value) ? 'checked="checked"' : '';
|
||||
|
||||
// Initialize some JavaScript option attributes.
|
||||
$onclick = !empty($option->onclick) ? 'onclick="' . $option->onclick . '"' : '';
|
||||
$onchange = !empty($option->onchange) ? 'onchange="' . $option->onchange . '"' : '';
|
||||
$oid = $id . $i;
|
||||
$ovalue = htmlspecialchars($option->value, ENT_COMPAT, 'UTF-8');
|
||||
$attributes = array_filter([$checked, $disabled, ltrim($style), $onchange, $onclick]);
|
||||
?>
|
||||
<?php if ($required) : ?>
|
||||
<?php $attributes[] = 'required'; ?>
|
||||
<?php endif; ?>
|
||||
<input class="<?php echo $classToggle; ?>" type="radio" id="<?php echo $oid; ?>" name="<?php echo $name; ?>" value="<?php echo $ovalue; ?>" <?php echo implode(' ', $attributes); ?>>
|
||||
<label for="<?php echo $oid; ?>" class="<?php echo trim($optionClass); ?>"<?php echo $style; ?>>
|
||||
<?php echo $option->text; ?>
|
||||
</label>
|
||||
<?php echo $blockEnd; ?>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
</fieldset>
|
||||
93
layouts/joomla/form/field/radio/switcher.php
Normal file
93
layouts/joomla/form/field/radio/switcher.php
Normal file
@ -0,0 +1,93 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage Layout
|
||||
*
|
||||
* @copyright (C) 2018 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;
|
||||
|
||||
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 $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-*.
|
||||
*/
|
||||
|
||||
// If there are no options don't render anything
|
||||
if (empty($options)) {
|
||||
return '';
|
||||
}
|
||||
|
||||
// Load the css files
|
||||
Factory::getApplication()->getDocument()->getWebAssetManager()->useStyle('switcher');
|
||||
|
||||
/**
|
||||
* The format of the input tag to be filled in using sprintf.
|
||||
* %1 - id
|
||||
* %2 - name
|
||||
* %3 - value
|
||||
* %4 = any other attributes
|
||||
*/
|
||||
$input = '<input type="radio" id="%1$s" name="%2$s" value="%3$s" %4$s>';
|
||||
|
||||
$attr = 'id="' . $id . '"';
|
||||
$attr .= $onchange ? ' onchange="' . $onchange . '"' : '';
|
||||
$attr .= $dataAttribute;
|
||||
|
||||
?>
|
||||
<fieldset <?php echo $attr; ?>>
|
||||
<legend class="visually-hidden">
|
||||
<?php echo $label; ?>
|
||||
</legend>
|
||||
<div class="switcher<?php echo ($readonly || $disabled ? ' disabled' : ''); ?>">
|
||||
<?php foreach ($options as $i => $option) : ?>
|
||||
<?php
|
||||
// False value casting as string returns an empty string so assign it 0
|
||||
if (empty($value) && $option->value == '0') {
|
||||
$value = '0';
|
||||
}
|
||||
|
||||
// Initialize some option attributes.
|
||||
$optionValue = (string) $option->value;
|
||||
$optionId = $id . $i;
|
||||
$attributes = $optionValue == $value ? 'checked class="active ' . $class . '"' : ($class ? 'class="' . $class . '"' : '');
|
||||
$attributes .= $optionValue != $value && $readonly || $disabled ? ' disabled' : '';
|
||||
?>
|
||||
<?php echo sprintf($input, $optionId, $name, $this->escape($optionValue), $attributes); ?>
|
||||
<?php echo '<label for="' . $optionId . '">' . $option->text . '</label>'; ?>
|
||||
<?php endforeach; ?>
|
||||
<span class="toggle-outside"><span class="toggle-inside"></span></span>
|
||||
</div>
|
||||
</fieldset>
|
||||
90
layouts/joomla/form/field/radiobasic.php
Normal file
90
layouts/joomla/form/field/radiobasic.php
Normal file
@ -0,0 +1,90 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage Layout
|
||||
*
|
||||
* @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;
|
||||
|
||||
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 $options Options available for this field.
|
||||
* @var string $dataAttribute Miscellaneous data attributes preprocessed for HTML output
|
||||
* @var array $dataAttributes Miscellaneous data attribute 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="radio" id="%1$s" name="%2$s" value="%3$s" %4$s>';
|
||||
$alt = preg_replace('/[^a-zA-Z0-9_\-]/', '_', $name);
|
||||
?>
|
||||
<fieldset id="<?php echo $id; ?>" class="<?php echo trim($class . ' radio'); ?>"
|
||||
<?php echo $disabled ? 'disabled' : ''; ?>
|
||||
<?php echo $required ? 'required' : ''; ?>
|
||||
<?php echo $autofocus ? 'autofocus' : ''; ?>
|
||||
<?php echo $dataAttribute; ?>>
|
||||
|
||||
<?php if (!empty($options)) : ?>
|
||||
<?php foreach ($options as $i => $option) : ?>
|
||||
<?php
|
||||
// Initialize some option attributes.
|
||||
$checked = ((string) $option->value === $value) ? 'checked="checked"' : '';
|
||||
$optionClass = !empty($option->class) ? 'class="' . $option->class . '"' : '';
|
||||
$disabled = !empty($option->disable) || ($disabled && !$checked) ? 'disabled' : '';
|
||||
|
||||
// Initialize some JavaScript option attributes.
|
||||
$onclick = !empty($option->onclick) ? 'onclick="' . $option->onclick . '"' : '';
|
||||
$onchange = !empty($option->onchange) ? 'onchange="' . $option->onchange . '"' : '';
|
||||
$oid = $id . $i;
|
||||
$ovalue = htmlspecialchars($option->value, ENT_COMPAT, 'UTF-8');
|
||||
$attributes = array_filter([$checked, $optionClass, $disabled, $onchange, $onclick]);
|
||||
?>
|
||||
<?php if ($required) : ?>
|
||||
<?php $attributes[] = 'required'; ?>
|
||||
<?php endif; ?>
|
||||
<div class="radio mb-0">
|
||||
<label for="<?php echo $oid; ?>" <?php echo $optionClass; ?>>
|
||||
<?php echo sprintf($format, $oid, $name, $ovalue, implode(' ', $attributes)); ?>
|
||||
<?php echo Text::alt($option->text, $alt); ?>
|
||||
</label>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
<?php endif; ?>
|
||||
</fieldset>
|
||||
72
layouts/joomla/form/field/range.php
Normal file
72
layouts/joomla/form/field/range.php
Normal file
@ -0,0 +1,72 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage Layout
|
||||
*
|
||||
* @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;
|
||||
|
||||
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.
|
||||
* @var string $dataAttribute Miscellaneous data attributes preprocessed for HTML output
|
||||
* @var array $dataAttributes Miscellaneous data attribute for eg, data-*.
|
||||
*/
|
||||
|
||||
// Initialize some field attributes.
|
||||
$attributes = [
|
||||
$class ? 'class="form-range ' . $class . '"' : 'class="form-range"',
|
||||
!empty($description) ? 'aria-describedby="' . ($id ?: $name) . '-desc"' : '',
|
||||
$disabled ? 'disabled' : '',
|
||||
$readonly ? 'readonly' : '',
|
||||
!empty($onchange) ? 'onchange="' . $onchange . '"' : '',
|
||||
!empty($max) ? 'max="' . $max . '"' : '',
|
||||
!empty($step) ? 'step="' . $step . '"' : '',
|
||||
!empty($min) ? 'min="' . $min . '"' : '',
|
||||
$autofocus ? 'autofocus' : '',
|
||||
$dataAttribute,
|
||||
];
|
||||
|
||||
$value = is_numeric($value) ? (float) $value : $min;
|
||||
|
||||
?>
|
||||
<input
|
||||
type="range"
|
||||
name="<?php echo $name; ?>"
|
||||
id="<?php echo $id; ?>"
|
||||
value="<?php echo htmlspecialchars($value, ENT_COMPAT, 'UTF-8'); ?>"
|
||||
<?php echo implode(' ', $attributes); ?>>
|
||||
234
layouts/joomla/form/field/rules.php
Normal file
234
layouts/joomla/form/field/rules.php
Normal file
@ -0,0 +1,234 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage Layout
|
||||
*
|
||||
* @copyright (C) 2018 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\Access\Access;
|
||||
use Joomla\CMS\Factory;
|
||||
use Joomla\CMS\HTML\HTMLHelper;
|
||||
use Joomla\CMS\Language\Text;
|
||||
use Joomla\CMS\Layout\LayoutHelper;
|
||||
use Joomla\CMS\Router\Route;
|
||||
use Joomla\CMS\Session\Session;
|
||||
|
||||
extract($displayData);
|
||||
|
||||
// Get some system objects.
|
||||
$document = Factory::getDocument();
|
||||
|
||||
/**
|
||||
* 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 array $options Options available for this field.
|
||||
* @var array $groups Available user groups.
|
||||
* @var array $actions Actions for the asset.
|
||||
* @var integer $assetId Access parameters.
|
||||
* @var string $component The component.
|
||||
* @var string $section The section.
|
||||
* @var boolean $isGlobalConfig Current view is global config?
|
||||
* @var boolean $newItem The new item.
|
||||
* @var object $assetRules Rules for asset.
|
||||
* @var integer $parentAssetId To calculate permissions.
|
||||
* @var string $dataAttribute Miscellaneous data attributes preprocessed for HTML output
|
||||
* @var array $dataAttributes Miscellaneous data attributes for eg, data-*.
|
||||
*/
|
||||
|
||||
// Add Javascript for permission change
|
||||
HTMLHelper::_('form.csrf');
|
||||
Factory::getDocument()->getWebAssetManager()
|
||||
->useStyle('webcomponent.field-permissions')
|
||||
->useScript('webcomponent.field-permissions')
|
||||
->useStyle('webcomponent.joomla-tab')
|
||||
->useScript('webcomponent.joomla-tab');
|
||||
|
||||
// Load JavaScript message titles
|
||||
Text::script('ERROR');
|
||||
Text::script('WARNING');
|
||||
Text::script('NOTICE');
|
||||
Text::script('MESSAGE');
|
||||
|
||||
// Add strings for JavaScript error translations.
|
||||
Text::script('JLIB_JS_AJAX_ERROR_CONNECTION_ABORT');
|
||||
Text::script('JLIB_JS_AJAX_ERROR_NO_CONTENT');
|
||||
Text::script('JLIB_JS_AJAX_ERROR_OTHER');
|
||||
Text::script('JLIB_JS_AJAX_ERROR_PARSE');
|
||||
Text::script('JLIB_JS_AJAX_ERROR_TIMEOUT');
|
||||
|
||||
// Ajax request data.
|
||||
$ajaxUri = Route::_('index.php?option=com_config&task=application.store&format=json&' . Session::getFormToken() . '=1');
|
||||
?>
|
||||
|
||||
<?php // Description ?>
|
||||
<details>
|
||||
<summary class="rule-notes">
|
||||
<?php echo Text::_('JLIB_RULES_SETTINGS_DESC'); ?>
|
||||
</summary>
|
||||
<div class="rule-notes">
|
||||
<?php
|
||||
if ($section === 'component' || !$section) {
|
||||
echo Text::alt('JLIB_RULES_SETTING_NOTES', $component);
|
||||
} else {
|
||||
echo Text::alt('JLIB_RULES_SETTING_NOTES_ITEM', $component . '_' . $section);
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
</details>
|
||||
<?php // Begin tabs ?>
|
||||
<joomla-field-permissions class="row mb-2" data-uri="<?php echo $ajaxUri; ?>" <?php echo $dataAttribute; ?>>
|
||||
<joomla-tab orientation="vertical" id="permissions-sliders" recall breakpoint="728">
|
||||
<?php // Initial Active Pane ?>
|
||||
<?php foreach ($groups as $group) : ?>
|
||||
<?php $active = (int) $group->value === 1 ? ' active' : ''; ?>
|
||||
<joomla-tab-element class="tab-pane" <?php echo $active; ?> name="<?php echo htmlentities(LayoutHelper::render('joomla.html.treeprefix', ['level' => $group->level + 1]), ENT_COMPAT, 'utf-8') . $group->text; ?>" id="permission-<?php echo $group->value; ?>">
|
||||
<table class="table respTable">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="actions w-30" id="actions-th<?php echo $group->value; ?>">
|
||||
<span class="acl-action"><?php echo Text::_('JLIB_RULES_ACTION'); ?></span>
|
||||
</th>
|
||||
|
||||
<th class="settings w-40" id="settings-th<?php echo $group->value; ?>">
|
||||
<span class="acl-action"><?php echo Text::_('JLIB_RULES_SELECT_SETTING'); ?></span>
|
||||
</th>
|
||||
|
||||
<th class="w-30" id="aclaction-th<?php echo $group->value; ?>">
|
||||
<span class="acl-action"><?php echo Text::_('JLIB_RULES_CALCULATED_SETTING'); ?></span>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
||||
<?php // Check if this group has super user permissions ?>
|
||||
<?php $isSuperUserGroup = Access::checkGroup($group->value, 'core.admin'); ?>
|
||||
<?php foreach ($actions as $action) : ?>
|
||||
<tr>
|
||||
<td class="oddCol" data-label="<?php echo Text::_('JLIB_RULES_ACTION'); ?>" headers="actions-th<?php echo $group->value; ?>">
|
||||
<label for="<?php echo $id; ?>_<?php echo $action->name; ?>_<?php echo $group->value; ?>">
|
||||
<?php echo Text::_($action->title); ?>
|
||||
</label>
|
||||
<?php if (!empty($action->description)) : ?>
|
||||
<div role="tooltip" id="tip-<?php echo $id; ?>">
|
||||
<?php echo htmlspecialchars(Text::_($action->description)); ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
<td data-label="<?php echo Text::_('JLIB_RULES_SELECT_SETTING'); ?>" headers="settings-th<?php echo $group->value; ?>">
|
||||
<div class="d-flex align-items-center">
|
||||
<select data-onchange-task="permissions.apply"
|
||||
class="form-select novalidate"
|
||||
name="<?php echo $name; ?>[<?php echo $action->name; ?>][<?php echo $group->value; ?>]"
|
||||
id="<?php echo $id; ?>_<?php echo $action->name; ?>_<?php echo $group->value; ?>" >
|
||||
<?php
|
||||
/**
|
||||
* Possible values:
|
||||
* null = not set means inherited
|
||||
* false = denied
|
||||
* true = allowed
|
||||
*/
|
||||
|
||||
// Get the actual setting for the action for this group. ?>
|
||||
<?php $assetRule = $newItem === false ? $assetRules->allow($action->name, $group->value) : null;?>
|
||||
|
||||
<?php // Build the dropdowns for the permissions sliders
|
||||
// The parent group has "Not Set", all children can rightly "Inherit" from that.?>
|
||||
<option value="" <?php echo ($assetRule === null ? ' selected="selected"' : ''); ?>>
|
||||
<?php echo Text::_(empty($group->parent_id) && $isGlobalConfig ? 'JLIB_RULES_NOT_SET' : 'JLIB_RULES_INHERITED'); ?></option>
|
||||
<option value="1" <?php echo ($assetRule === true ? ' selected="selected"' : ''); ?>>
|
||||
<?php echo Text::_('JLIB_RULES_ALLOWED'); ?></option>
|
||||
<option value="0" <?php echo ($assetRule === false ? ' selected="selected"' : ''); ?>>
|
||||
<?php echo Text::_('JLIB_RULES_DENIED'); ?></option>
|
||||
|
||||
</select> 
|
||||
<span id="icon_<?php echo $id; ?>_<?php echo $action->name; ?>_<?php echo $group->value; ?>"></span>
|
||||
</div>
|
||||
</td>
|
||||
|
||||
<td data-label="<?php echo Text::_('JLIB_RULES_CALCULATED_SETTING'); ?>" headers="aclaction-th<?php echo $group->value; ?>">
|
||||
<?php $result = []; ?>
|
||||
<?php // Get the group, group parent id, and group global config recursive calculated permission for the chosen action. ?>
|
||||
<?php $inheritedGroupRule = Access::checkGroup((int) $group->value, $action->name, $assetId);
|
||||
$inheritedGroupParentAssetRule = !empty($parentAssetId) ? Access::checkGroup($group->value, $action->name, $parentAssetId) : null;
|
||||
$inheritedParentGroupRule = !empty($group->parent_id) ? Access::checkGroup($group->parent_id, $action->name, $assetId) : null;
|
||||
|
||||
// Current group is a Super User group, so calculated setting is "Allowed (Super User)".
|
||||
if ($isSuperUserGroup) {
|
||||
$result['class'] = 'badge bg-success';
|
||||
$result['text'] = '<span class="icon-lock icon-white" aria-hidden="true"></span>' . Text::_('JLIB_RULES_ALLOWED_ADMIN');
|
||||
} else {
|
||||
// First get the real recursive calculated setting and add (Inherited) to it.
|
||||
|
||||
// If recursive calculated setting is "Denied" or null. Calculated permission is "Not Allowed (Inherited)".
|
||||
if ($inheritedGroupRule === null || $inheritedGroupRule === false) {
|
||||
$result['class'] = 'badge bg-danger';
|
||||
$result['text'] = Text::_('JLIB_RULES_NOT_ALLOWED_INHERITED');
|
||||
} else {
|
||||
// If recursive calculated setting is "Allowed". Calculated permission is "Allowed (Inherited)".
|
||||
$result['class'] = 'badge bg-success';
|
||||
$result['text'] = Text::_('JLIB_RULES_ALLOWED_INHERITED');
|
||||
}
|
||||
|
||||
// Second part: Overwrite the calculated permissions labels if there is an explicit permission in the current group.
|
||||
|
||||
/**
|
||||
* @todo: incorrect info
|
||||
* If a component has a permission that doesn't exists in global config (ex: frontend editing in com_modules) by default
|
||||
* we get "Not Allowed (Inherited)" when we should get "Not Allowed (Default)".
|
||||
*/
|
||||
|
||||
// If there is an explicit permission "Not Allowed". Calculated permission is "Not Allowed".
|
||||
if ($assetRule === false) {
|
||||
$result['class'] = 'badge bg-danger';
|
||||
$result['text'] = Text::_('JLIB_RULES_NOT_ALLOWED');
|
||||
} elseif ($assetRule === true) {
|
||||
// If there is an explicit permission is "Allowed". Calculated permission is "Allowed".
|
||||
$result['class'] = 'badge bg-success';
|
||||
$result['text'] = Text::_('JLIB_RULES_ALLOWED');
|
||||
}
|
||||
|
||||
// Third part: Overwrite the calculated permissions labels for special cases.
|
||||
|
||||
// Global configuration with "Not Set" permission. Calculated permission is "Not Allowed (Default)".
|
||||
if (empty($group->parent_id) && $isGlobalConfig === true && $assetRule === null) {
|
||||
$result['class'] = 'badge bg-danger';
|
||||
$result['text'] = Text::_('JLIB_RULES_NOT_ALLOWED_DEFAULT');
|
||||
} elseif ($inheritedGroupParentAssetRule === false || $inheritedParentGroupRule === false) {
|
||||
/**
|
||||
* Component/Item with explicit "Denied" permission at parent Asset (Category, Component or Global config) configuration.
|
||||
* Or some parent group has an explicit "Denied".
|
||||
* Calculated permission is "Not Allowed (Locked)".
|
||||
*/
|
||||
$result['class'] = 'badge bg-danger';
|
||||
$result['text'] = '<span class="icon-lock icon-white" aria-hidden="true"></span>' . Text::_('JLIB_RULES_NOT_ALLOWED_LOCKED');
|
||||
}
|
||||
}
|
||||
?>
|
||||
<output><span class="<?php echo $result['class']; ?>"><?php echo $result['text']; ?></span></output>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</joomla-tab-element>
|
||||
<?php endforeach; ?>
|
||||
</joomla-tab>
|
||||
</joomla-field-permissions>
|
||||
41
layouts/joomla/form/field/subform/default.php
Normal file
41
layouts/joomla/form/field/subform/default.php
Normal file
@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage Layout
|
||||
*
|
||||
* @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\Form\Form;
|
||||
|
||||
extract($displayData);
|
||||
|
||||
/**
|
||||
* Layout variables
|
||||
* -----------------
|
||||
* @var Form $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 $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 array $buttons Array of the buttons that will be rendered
|
||||
* @var bool $groupByFieldset Whether group the subform fields by it`s fieldset
|
||||
*/
|
||||
$form = $forms[0];
|
||||
?>
|
||||
|
||||
<div class="subform-wrapper">
|
||||
<?php foreach ($form->getGroup('') as $field) : ?>
|
||||
<?php echo $field->renderField(); ?>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
123
layouts/joomla/form/field/subform/repeatable-table.php
Normal file
123
layouts/joomla/form/field/subform/repeatable-table.php
Normal file
@ -0,0 +1,123 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage Layout
|
||||
*
|
||||
* @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\Factory;
|
||||
use Joomla\CMS\Form\Form;
|
||||
use Joomla\CMS\Language\Text;
|
||||
|
||||
extract($displayData);
|
||||
|
||||
/**
|
||||
* Layout variables
|
||||
* -----------------
|
||||
* @var Form $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 $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
|
||||
*/
|
||||
if ($multiple) {
|
||||
// Add script
|
||||
Factory::getApplication()
|
||||
->getDocument()
|
||||
->getWebAssetManager()
|
||||
->useScript('webcomponent.field-subform');
|
||||
}
|
||||
|
||||
$class = $class ? ' ' . $class : '';
|
||||
|
||||
// Build heading
|
||||
$table_head = '';
|
||||
|
||||
if (!empty($groupByFieldset)) {
|
||||
foreach ($tmpl->getFieldsets() as $k => $fieldset) {
|
||||
$table_head .= '<th scope="col">' . Text::_($fieldset->label);
|
||||
|
||||
if ($fieldset->description) {
|
||||
$table_head .= '<span class="icon-info-circle" aria-hidden="true" tabindex="0"></span><div role="tooltip" id="tip-th-' . $fieldId . '-' . $k . '">' . Text::_($fieldset->description) . '</div>';
|
||||
}
|
||||
|
||||
$table_head .= '</th>';
|
||||
}
|
||||
|
||||
$sublayout = 'section-byfieldsets';
|
||||
} else {
|
||||
foreach ($tmpl->getGroup('') as $field) {
|
||||
$table_head .= '<th scope="col" style="width:45%">' . strip_tags($field->label);
|
||||
|
||||
if ($field->description) {
|
||||
$table_head .= '<span class="icon-info-circle" aria-hidden="true" tabindex="0"></span><div role="tooltip" id="tip-' . $field->id . '">' . Text::_($field->description) . '</div>';
|
||||
}
|
||||
|
||||
$table_head .= '</th>';
|
||||
}
|
||||
|
||||
$sublayout = 'section';
|
||||
|
||||
// Label will not be shown for sections layout, so reset the margin left
|
||||
Factory::getApplication()
|
||||
->getDocument()
|
||||
->addStyleDeclaration('.subform-table-sublayout-section .controls { margin-left: 0px }');
|
||||
}
|
||||
?>
|
||||
|
||||
<div class="subform-repeatable-wrapper subform-table-layout subform-table-sublayout-<?php echo $sublayout; ?>">
|
||||
<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"
|
||||
rows-container="tbody.subform-repeatable-container" minimum="<?php echo $min; ?>" maximum="<?php echo $max; ?>">
|
||||
<div class="table-responsive">
|
||||
<table class="table" id="subfieldList_<?php echo $fieldId; ?>">
|
||||
<caption class="visually-hidden">
|
||||
<?php echo Text::_('JGLOBAL_REPEATABLE_FIELDS_TABLE_CAPTION'); ?>
|
||||
</caption>
|
||||
<thead>
|
||||
<tr>
|
||||
<?php echo $table_head; ?>
|
||||
<?php if (!empty($buttons)) : ?>
|
||||
<td style="width:8%;">
|
||||
<?php if (!empty($buttons['add'])) : ?>
|
||||
<div class="btn-group">
|
||||
<button type="button" class="group-add btn btn-sm btn-success" aria-label="<?php echo Text::_('JGLOBAL_FIELD_ADD'); ?>">
|
||||
<span class="icon-plus" aria-hidden="true"></span>
|
||||
</button>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
<?php endif; ?>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="subform-repeatable-container">
|
||||
<?php
|
||||
foreach ($forms as $k => $form) :
|
||||
echo $this->sublayout($sublayout, ['form' => $form, 'basegroup' => $fieldname, 'group' => $fieldname . $k, 'buttons' => $buttons]);
|
||||
endforeach;
|
||||
?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<?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])); ?>
|
||||
</template>
|
||||
<?php endif; ?>
|
||||
</joomla-field-subform>
|
||||
</div>
|
||||
@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage Layout
|
||||
*
|
||||
* @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\Form\Form;
|
||||
use Joomla\CMS\Language\Text;
|
||||
|
||||
extract($displayData);
|
||||
|
||||
/**
|
||||
* Layout variables
|
||||
* -----------------
|
||||
* @var Form $form The form instance for render the section
|
||||
* @var string $basegroup The base group name
|
||||
* @var string $group Current group name
|
||||
* @var array $buttons Array of the buttons that will be rendered
|
||||
*/
|
||||
?>
|
||||
|
||||
<tr class="subform-repeatable-group" data-base-name="<?php echo $basegroup; ?>" data-group="<?php echo $group; ?>">
|
||||
<?php foreach ($form->getFieldsets() as $fieldset) : ?>
|
||||
<td class="<?php if (!empty($fieldset->class)) {
|
||||
echo $fieldset->class;
|
||||
} ?>">
|
||||
<?php foreach ($form->getFieldset($fieldset->name) as $field) : ?>
|
||||
<?php echo $field->renderField(); ?>
|
||||
<?php endforeach; ?>
|
||||
</td>
|
||||
<?php endforeach; ?>
|
||||
<?php if (!empty($buttons)) : ?>
|
||||
<td>
|
||||
<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::_('JGLOBAL_FIELD_ADD'); ?>">
|
||||
<span class="icon-plus" aria-hidden="true"></span>
|
||||
</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" 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" aria-hidden="true"></span>
|
||||
</button>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</td>
|
||||
<?php endif; ?>
|
||||
</tr>
|
||||
@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage Layout
|
||||
*
|
||||
* @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\Form\Form;
|
||||
use Joomla\CMS\Language\Text;
|
||||
|
||||
extract($displayData);
|
||||
|
||||
/**
|
||||
* Layout variables
|
||||
* -----------------
|
||||
* @var Form $form The form instance for render the section
|
||||
* @var string $basegroup The base group name
|
||||
* @var string $group Current group name
|
||||
* @var array $buttons Array of the buttons that will be rendered
|
||||
*/
|
||||
?>
|
||||
|
||||
<tr class="subform-repeatable-group" data-base-name="<?php echo $basegroup; ?>" data-group="<?php echo $group; ?>">
|
||||
<?php foreach ($form->getGroup('') as $field) : ?>
|
||||
<td data-column="<?php echo strip_tags($field->label); ?>">
|
||||
<?php echo $field->renderField(['hiddenLabel' => true, 'hiddenDescription' => true]); ?>
|
||||
</td>
|
||||
<?php endforeach; ?>
|
||||
<?php if (!empty($buttons)) : ?>
|
||||
<td>
|
||||
<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::_('JGLOBAL_FIELD_ADD'); ?>">
|
||||
<span class="icon-plus" aria-hidden="true"></span>
|
||||
</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" 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" aria-hidden="true"></span>
|
||||
</button>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</td>
|
||||
<?php endif; ?>
|
||||
</tr>
|
||||
74
layouts/joomla/form/field/subform/repeatable.php
Normal file
74
layouts/joomla/form/field/subform/repeatable.php
Normal file
@ -0,0 +1,74 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage Layout
|
||||
*
|
||||
* @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\Factory;
|
||||
use Joomla\CMS\Form\Form;
|
||||
use Joomla\CMS\Language\Text;
|
||||
|
||||
extract($displayData);
|
||||
|
||||
/**
|
||||
* Layout variables
|
||||
* -----------------
|
||||
* @var Form $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 $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
|
||||
*/
|
||||
if ($multiple) {
|
||||
// Add script
|
||||
Factory::getApplication()
|
||||
->getDocument()
|
||||
->getWebAssetManager()
|
||||
->useScript('webcomponent.field-subform');
|
||||
}
|
||||
|
||||
$class = $class ? ' ' . $class : '';
|
||||
|
||||
$sublayout = empty($groupByFieldset) ? 'section' : 'section-byfieldsets';
|
||||
?>
|
||||
|
||||
<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::_('JGLOBAL_FIELD_ADD'); ?>">
|
||||
<span class="icon-plus icon-white" aria-hidden="true"></span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php
|
||||
foreach ($forms as $k => $form) :
|
||||
echo $this->sublayout($sublayout, ['form' => $form, 'basegroup' => $fieldname, 'group' => $fieldname . $k, 'buttons' => $buttons]);
|
||||
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]));
|
||||
?></template>
|
||||
<?php endif; ?>
|
||||
</joomla-field-subform>
|
||||
</div>
|
||||
@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage Layout
|
||||
*
|
||||
* @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\Form\Form;
|
||||
use Joomla\CMS\Language\Text;
|
||||
|
||||
extract($displayData);
|
||||
|
||||
/**
|
||||
* Layout variables
|
||||
* -----------------
|
||||
* @var Form $form The form instance for render the section
|
||||
* @var string $basegroup The base group name
|
||||
* @var string $group Current group name
|
||||
* @var array $buttons Array of the buttons that will be rendered
|
||||
*/
|
||||
?>
|
||||
|
||||
<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::_('JGLOBAL_FIELD_ADD'); ?>"><span class="icon-plus icon-white" aria-hidden="true"></span> </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>
|
||||
48
layouts/joomla/form/field/subform/repeatable/section.php
Normal file
48
layouts/joomla/form/field/subform/repeatable/section.php
Normal file
@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage Layout
|
||||
*
|
||||
* @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\Form\Form;
|
||||
use Joomla\CMS\Language\Text;
|
||||
|
||||
extract($displayData);
|
||||
|
||||
/**
|
||||
* Layout variables
|
||||
* -----------------
|
||||
* @var Form $form The form instance for render the section
|
||||
* @var string $basegroup The base group name
|
||||
* @var string $group Current group name
|
||||
* @var array $buttons Array of the buttons that will be rendered
|
||||
*/
|
||||
?>
|
||||
|
||||
<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::_('JGLOBAL_FIELD_ADD'); ?>"><span class="icon-plus icon-white" aria-hidden="true"></span> </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>
|
||||
123
layouts/joomla/form/field/tag.php
Normal file
123
layouts/joomla/form/field/tag.php
Normal file
@ -0,0 +1,123 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage Layout
|
||||
*
|
||||
* @copyright (C) 2018 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\CMS\HTML\HTMLHelper;
|
||||
use Joomla\CMS\Language\Text;
|
||||
use Joomla\CMS\Uri\Uri;
|
||||
|
||||
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 boolean $allowCustom Flag, to allow add custom values
|
||||
* @var boolean $remoteSearch Flag, to enable remote search
|
||||
* @var integer $minTermLength Minimum length of the term to start searching
|
||||
* @var string $dataAttribute Miscellaneous data attributes preprocessed for HTML output
|
||||
* @var array $dataAttributes Miscellaneous data attributes for eg, data-*.
|
||||
*/
|
||||
|
||||
$html = [];
|
||||
$attr = '';
|
||||
|
||||
// Initialize some field attributes.
|
||||
$attr .= $multiple ? ' multiple' : '';
|
||||
$attr .= $autofocus ? ' autofocus' : '';
|
||||
$attr .= $onchange ? ' onchange="' . $onchange . '"' : '';
|
||||
$attr .= $dataAttribute;
|
||||
|
||||
// To avoid user's confusion, readonly="readonly" should imply disabled="disabled".
|
||||
if ($readonly || $disabled) {
|
||||
$attr .= ' disabled="disabled"';
|
||||
}
|
||||
|
||||
$attr2 = '';
|
||||
$attr2 .= !empty($class) ? ' class="' . $class . '"' : '';
|
||||
$attr2 .= ' placeholder="' . $this->escape($hint ?: Text::_('JGLOBAL_TYPE_OR_SELECT_SOME_TAGS')) . '" ';
|
||||
$attr2 .= $dataAttribute;
|
||||
|
||||
if ($allowCustom) {
|
||||
$attr2 .= $allowCustom ? ' allow-custom' : '';
|
||||
$attr2 .= $allowCustom ? ' new-item-prefix="#new#"' : '';
|
||||
}
|
||||
|
||||
if ($remoteSearch) {
|
||||
$attr2 .= ' remote-search';
|
||||
$attr2 .= ' url="' . Uri::root(true) . '/index.php?option=com_tags&task=tags.searchAjax"';
|
||||
$attr2 .= ' term-key="like"';
|
||||
$attr2 .= ' min-term-length="' . $minTermLength . '"';
|
||||
}
|
||||
|
||||
if ($required) {
|
||||
$attr .= ' required class="required"';
|
||||
$attr2 .= ' required';
|
||||
}
|
||||
|
||||
// Create a read-only list (no name) with hidden input(s) to store the value(s).
|
||||
if ($readonly) {
|
||||
$html[] = HTMLHelper::_('select.genericlist', $options, '', trim($attr), 'value', 'text', $value, $id);
|
||||
|
||||
// E.g. form field type tag sends $this->value as array
|
||||
if ($multiple && is_array($value)) {
|
||||
if (!count($value)) {
|
||||
$value[] = '';
|
||||
}
|
||||
|
||||
foreach ($value as $val) {
|
||||
$html[] = '<input type="hidden" name="' . $name . '" value="' . htmlspecialchars($val, ENT_COMPAT, 'UTF-8') . '">';
|
||||
}
|
||||
} else {
|
||||
$html[] = '<input type="hidden" name="' . $name . '" value="' . htmlspecialchars($value, ENT_COMPAT, 'UTF-8') . '">';
|
||||
}
|
||||
} else // Create a regular list.
|
||||
{
|
||||
$html[] = HTMLHelper::_('select.genericlist', $options, $name, trim($attr), 'value', 'text', $value, $id);
|
||||
}
|
||||
|
||||
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 $attr2; ?>><?php echo implode($html); ?></joomla-field-fancy-select>
|
||||
74
layouts/joomla/form/field/tel.php
Normal file
74
layouts/joomla/form/field/tel.php
Normal file
@ -0,0 +1,74 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage Layout
|
||||
*
|
||||
* @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;
|
||||
|
||||
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.
|
||||
* @var integer $maxLength The maximum length that the field shall accept.
|
||||
* @var string $dataAttribute Miscellaneous data attributes preprocessed for HTML output
|
||||
* @var array $dataAttributes Miscellaneous data attribute for eg, data-*.
|
||||
*/
|
||||
|
||||
$attributes = [
|
||||
!empty($size) ? 'size="' . $size . '"' : '',
|
||||
!empty($description) ? 'aria-describedby="' . ($id ?: $name) . '-desc"' : '',
|
||||
$disabled ? 'disabled' : '',
|
||||
$readonly ? 'readonly' : '',
|
||||
strlen($hint) ? 'placeholder="' . htmlspecialchars($hint, ENT_COMPAT, 'UTF-8') . '"' : '',
|
||||
!empty($autocomplete) ? 'autocomplete="' . $autocomplete . '"' : '',
|
||||
$autofocus ? 'autofocus' : '',
|
||||
$spellcheck ? '' : 'spellcheck="false"',
|
||||
$onchange ? 'onchange="' . $onchange . '"' : '',
|
||||
!empty($maxLength) ? $maxLength : '',
|
||||
$required ? 'required' : '',
|
||||
!empty($pattern) ? 'pattern="' . $pattern . '"' : '',
|
||||
$dataAttribute,
|
||||
];
|
||||
?>
|
||||
<input
|
||||
type="tel"
|
||||
inputmode="tel"
|
||||
name="<?php echo $name; ?>"
|
||||
<?php echo !empty($class) ? ' class="form-control ' . $class . '"' : 'class="form-control"'; ?>
|
||||
id="<?php echo $id; ?>"
|
||||
value="<?php echo htmlspecialchars($value, ENT_COMPAT, 'UTF-8'); ?>"
|
||||
<?php echo implode(' ', $attributes); ?>>
|
||||
138
layouts/joomla/form/field/text.php
Normal file
138
layouts/joomla/form/field/text.php
Normal file
@ -0,0 +1,138 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage Layout
|
||||
*
|
||||
* @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\Factory;
|
||||
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.
|
||||
* @var string $dataAttribute Miscellaneous data attributes preprocessed for HTML output
|
||||
* @var array $dataAttributes Miscellaneous data attribute for eg, data-*.
|
||||
* @var string $dirname The directory name
|
||||
* @var string $addonBefore The text to use in a bootstrap input group prepend
|
||||
* @var string $addonAfter The text to use in a bootstrap input group append
|
||||
* @var boolean $charcounter Does this field support a character counter?
|
||||
*/
|
||||
|
||||
$list = '';
|
||||
|
||||
if ($options) {
|
||||
$list = 'list="' . $id . '_datalist"';
|
||||
}
|
||||
|
||||
$charcounterclass = '';
|
||||
|
||||
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
|
||||
$charcounterclass = ' charcount';
|
||||
|
||||
// Set the text
|
||||
$counterlabel = 'data-counter-label="' . $this->escape(Text::_('JFIELD_META_DESCRIPTION_COUNTER')) . '"';
|
||||
}
|
||||
|
||||
$attributes = [
|
||||
!empty($class) ? 'class="form-control ' . $class . $charcounterclass . '"' : 'class="form-control' . $charcounterclass . '"',
|
||||
!empty($size) ? 'size="' . $size . '"' : '',
|
||||
!empty($description) ? 'aria-describedby="' . ($id ?: $name) . '-desc"' : '',
|
||||
$disabled ? 'disabled' : '',
|
||||
$readonly ? 'readonly' : '',
|
||||
$dataAttribute,
|
||||
$list,
|
||||
strlen($hint) ? 'placeholder="' . htmlspecialchars($hint, ENT_COMPAT, 'UTF-8') . '"' : '',
|
||||
$onchange ? ' onchange="' . $onchange . '"' : '',
|
||||
!empty($maxLength) ? $maxLength : '',
|
||||
$required ? 'required' : '',
|
||||
!empty($autocomplete) ? 'autocomplete="' . $autocomplete . '"' : '',
|
||||
$autofocus ? ' autofocus' : '',
|
||||
$spellcheck ? '' : 'spellcheck="false"',
|
||||
!empty($inputmode) ? $inputmode : '',
|
||||
!empty($counterlabel) ? $counterlabel : '',
|
||||
!empty($pattern) ? 'pattern="' . $pattern . '"' : '',
|
||||
|
||||
// @TODO add a proper string here!!!
|
||||
!empty($validationtext) ? 'data-validation-text="' . $validationtext . '"' : '',
|
||||
];
|
||||
|
||||
$addonBeforeHtml = '<span class="input-group-text">' . Text::_($addonBefore) . '</span>';
|
||||
$addonAfterHtml = '<span class="input-group-text">' . Text::_($addonAfter) . '</span>';
|
||||
?>
|
||||
|
||||
<?php if (!empty($addonBefore) || !empty($addonAfter)) : ?>
|
||||
<div class="input-group">
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if (!empty($addonBefore)) : ?>
|
||||
<?php echo $addonBeforeHtml; ?>
|
||||
<?php endif; ?>
|
||||
|
||||
<input
|
||||
type="text"
|
||||
name="<?php echo $name; ?>"
|
||||
id="<?php echo $id; ?>"
|
||||
value="<?php echo htmlspecialchars($value, ENT_COMPAT, 'UTF-8'); ?>"
|
||||
<?php echo $dirname; ?>
|
||||
<?php echo implode(' ', $attributes); ?>>
|
||||
|
||||
<?php if (!empty($addonAfter)) : ?>
|
||||
<?php echo $addonAfterHtml; ?>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if (!empty($addonBefore) || !empty($addonAfter)) : ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($options) : ?>
|
||||
<datalist id="<?php echo $id; ?>_datalist">
|
||||
<?php foreach ($options as $option) : ?>
|
||||
<?php if (!$option->value) : ?>
|
||||
<?php continue; ?>
|
||||
<?php endif; ?>
|
||||
<option value="<?php echo $option->value; ?>"><?php echo $option->text; ?></option>
|
||||
<?php endforeach; ?>
|
||||
</datalist>
|
||||
<?php endif; ?>
|
||||
89
layouts/joomla/form/field/textarea.php
Normal file
89
layouts/joomla/form/field/textarea.php
Normal file
@ -0,0 +1,89 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage Layout
|
||||
*
|
||||
* @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\Factory;
|
||||
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.
|
||||
* @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-*.
|
||||
*/
|
||||
|
||||
// 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="' . ($id ?: $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,
|
||||
];
|
||||
?>
|
||||
<textarea name="<?php
|
||||
echo $name; ?>" id="<?php
|
||||
echo $id; ?>" <?php
|
||||
echo implode(' ', $attributes); ?> ><?php echo htmlspecialchars($value, ENT_COMPAT, 'UTF-8'); ?></textarea>
|
||||
73
layouts/joomla/form/field/time.php
Normal file
73
layouts/joomla/form/field/time.php
Normal file
@ -0,0 +1,73 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage Layout
|
||||
*
|
||||
* @copyright (C) 2019 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
/**
|
||||
* @var array $displayData Array with values.
|
||||
*/
|
||||
extract($displayData);
|
||||
|
||||
/**
|
||||
* Layout variables
|
||||
* -----------------
|
||||
* @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 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-*.
|
||||
*/
|
||||
|
||||
$attributes = [
|
||||
!empty($class) ? 'class="form-control ' . $class . '"' : 'class="form-control"',
|
||||
!empty($description) ? 'aria-describedby="' . ($id ?: $name) . '-desc"' : '',
|
||||
$disabled ? 'disabled' : '',
|
||||
$readonly ? 'readonly' : '',
|
||||
strlen($hint) ? 'placeholder="' . htmlspecialchars($hint, ENT_COMPAT, 'UTF-8') . '"' : '',
|
||||
!empty($onchange) ? 'onchange="' . $onchange . '"' : '',
|
||||
isset($max) ? 'max="' . $max . '"' : '',
|
||||
isset($step) ? 'step="' . $step . '"' : '',
|
||||
isset($min) ? 'min="' . $min . '"' : '',
|
||||
$required ? 'required' : '',
|
||||
$autofocus ? 'autofocus' : '',
|
||||
$dataAttribute,
|
||||
];
|
||||
|
||||
?>
|
||||
<input
|
||||
type="time"
|
||||
name="<?php echo $name; ?>"
|
||||
id="<?php echo $id; ?>"
|
||||
value="<?php echo $value ?>"
|
||||
<?php echo implode(' ', $attributes); ?>>
|
||||
|
||||
75
layouts/joomla/form/field/url.php
Normal file
75
layouts/joomla/form/field/url.php
Normal file
@ -0,0 +1,75 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage Layout
|
||||
*
|
||||
* @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\String\PunycodeHelper;
|
||||
|
||||
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.
|
||||
* @var string $dataAttribute Miscellaneous data attributes preprocessed for HTML output
|
||||
* @var array $dataAttributes Miscellaneous data attribute for eg, data-*.
|
||||
*/
|
||||
|
||||
$attributes = [
|
||||
!empty($size) ? ' size="' . $size . '"' : '',
|
||||
!empty($description) ? ' aria-describedby="' . ($id ?: $name) . '-desc"' : '',
|
||||
$disabled ? ' disabled' : '',
|
||||
$readonly ? ' readonly' : '',
|
||||
strlen($hint) ? ' placeholder="' . htmlspecialchars($hint, ENT_COMPAT, 'UTF-8') . '"' : '',
|
||||
!empty($autocomplete) ? 'autocomplete="' . $autocomplete . '"' : '',
|
||||
$autofocus ? ' autofocus' : '',
|
||||
$spellcheck ? '' : ' spellcheck="false"',
|
||||
$onchange ? ' onchange="' . $onchange . '"' : '',
|
||||
!empty($maxLength) ? $maxLength : '',
|
||||
$required ? ' required' : '',
|
||||
$dataAttribute,
|
||||
];
|
||||
|
||||
/**
|
||||
* @deprecated 4.3 will be removed in 6.0
|
||||
* The unicode conversion of the URL will be moved to \Joomla\CMS\Form\Field\UrlField::getLayoutData
|
||||
*/
|
||||
if ($value !== null) {
|
||||
$value = $this->escape(PunycodeHelper::urlToUTF8($value));
|
||||
}
|
||||
?>
|
||||
<input <?php echo $inputType; ?> inputmode="url" name="<?php echo $name; ?>" <?php echo !empty($class) ? ' class="form-control ' . $class . '"' : 'class="form-control"'; ?> id="<?php echo $id; ?>" value="<?php echo $value; ?>" <?php echo implode(' ', $attributes); ?>>
|
||||
120
layouts/joomla/form/field/user.php
Normal file
120
layouts/joomla/form/field/user.php
Normal file
@ -0,0 +1,120 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage Layout
|
||||
*
|
||||
* @copyright (C) 2015 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\CMS\Language\Text;
|
||||
use Joomla\CMS\Uri\Uri;
|
||||
use Joomla\Utilities\ArrayHelper;
|
||||
|
||||
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 string $userName The user name
|
||||
* @var mixed $groups The filtering groups (null means no filtering)
|
||||
* @var mixed $excluded The users to exclude from the list of users
|
||||
* @var string $dataAttribute Miscellaneous data attributes preprocessed for HTML output
|
||||
* @var array $dataAttributes Miscellaneous data attribute for eg, data-*.
|
||||
*/
|
||||
|
||||
$uri = new Uri('index.php?option=com_users&view=users&layout=modal&tmpl=component&required=0');
|
||||
$uri->setVar('field', $this->escape($id));
|
||||
|
||||
if ($required) {
|
||||
$uri->setVar('required', 1);
|
||||
}
|
||||
|
||||
if (!empty($groups)) {
|
||||
$uri->setVar('groups', base64_encode(json_encode($groups)));
|
||||
}
|
||||
|
||||
if (!empty($excluded)) {
|
||||
$uri->setVar('excluded', base64_encode(json_encode($excluded)));
|
||||
}
|
||||
|
||||
// Invalidate the input value if no user selected
|
||||
if ($this->escape($userName) === Text::_('JLIB_FORM_SELECT_USER')) {
|
||||
$userName = '';
|
||||
}
|
||||
|
||||
$inputAttributes = [
|
||||
'type' => 'text',
|
||||
'id' => $id,
|
||||
'class' => 'form-control field-user-input-name',
|
||||
'value' => $this->escape($userName),
|
||||
];
|
||||
|
||||
if ($class) {
|
||||
$inputAttributes['class'] .= ' ' . $class;
|
||||
}
|
||||
if ($size) {
|
||||
$inputAttributes['size'] = (int) $size;
|
||||
}
|
||||
if ($required) {
|
||||
$inputAttributes['required'] = 'required';
|
||||
}
|
||||
if (!$readonly) {
|
||||
$inputAttributes['placeholder'] = Text::_('JLIB_FORM_SELECT_USER');
|
||||
}
|
||||
|
||||
if (!$readonly) {
|
||||
Factory::getApplication()->getDocument()->getWebAssetManager()
|
||||
->useScript('webcomponent.field-user');
|
||||
}
|
||||
?>
|
||||
<?php // Create a dummy text field with the user name. ?>
|
||||
<joomla-field-user class="field-user-wrapper"
|
||||
url="<?php echo (string) $uri; ?>"
|
||||
modal-title="<?php echo $this->escape(Text::_('JLIB_FORM_CHANGE_USER')); ?>"
|
||||
input=".field-user-input"
|
||||
input-name=".field-user-input-name"
|
||||
button-select=".button-select">
|
||||
<div class="input-group">
|
||||
<input <?php echo ArrayHelper::toString($inputAttributes), $dataAttribute; ?> readonly>
|
||||
<?php if (!$readonly) : ?>
|
||||
<button type="button" class="btn btn-primary button-select" title="<?php echo Text::_('JLIB_FORM_CHANGE_USER'); ?>">
|
||||
<span class="icon-user icon-white" aria-hidden="true"></span>
|
||||
<span class="visually-hidden"><?php echo Text::_('JLIB_FORM_CHANGE_USER'); ?></span>
|
||||
</button>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<?php // Create the real field, hidden, that stored the user id. ?>
|
||||
<?php if (!$readonly) : ?>
|
||||
<input type="hidden" id="<?php echo $id; ?>_id" name="<?php echo $name; ?>" value="<?php echo $this->escape($value); ?>"
|
||||
class="field-user-input <?php echo $class ? (string) $class : ''?>"
|
||||
data-onchange="<?php echo $this->escape($onchange); ?>">
|
||||
<?php endif; ?>
|
||||
</joomla-field-user>
|
||||
63
layouts/joomla/form/renderfield.php
Normal file
63
layouts/joomla/form/renderfield.php
Normal file
@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage Layout
|
||||
*
|
||||
* @copyright (C) 2014 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;
|
||||
|
||||
extract($displayData);
|
||||
|
||||
/**
|
||||
* Layout variables
|
||||
* -----------------
|
||||
* @var array $options Optional parameters
|
||||
* @var string $id The id of the input this label is for
|
||||
* @var string $name The name of the input this label is for
|
||||
* @var string $label The html code for the label
|
||||
* @var string $input The input field html code
|
||||
* @var string $description An optional description to use as in–line help text
|
||||
* @var string $descClass The class name to use for the description
|
||||
*/
|
||||
|
||||
if (!empty($options['showonEnabled'])) {
|
||||
/** @var Joomla\CMS\WebAsset\WebAssetManager $wa */
|
||||
$wa = Factory::getApplication()->getDocument()->getWebAssetManager();
|
||||
$wa->useScript('showon');
|
||||
}
|
||||
|
||||
$class = empty($options['class']) ? '' : ' ' . $options['class'];
|
||||
$rel = empty($options['rel']) ? '' : ' ' . $options['rel'];
|
||||
$id = ($id ?? $name) . '-desc';
|
||||
$hideLabel = !empty($options['hiddenLabel']);
|
||||
$hideDescription = empty($options['hiddenDescription']) ? false : $options['hiddenDescription'];
|
||||
$descClass = ($options['descClass'] ?? '') ?: (!empty($options['inlineHelp']) ? 'hide-aware-inline-help d-none' : '');
|
||||
|
||||
if (!empty($parentclass)) {
|
||||
$class .= ' ' . $parentclass;
|
||||
}
|
||||
|
||||
?>
|
||||
<div class="control-group<?php echo $class; ?>"<?php echo $rel; ?>>
|
||||
<?php if ($hideLabel) : ?>
|
||||
<div class="visually-hidden"><?php echo $label; ?></div>
|
||||
<?php else : ?>
|
||||
<div class="control-label"><?php echo $label; ?></div>
|
||||
<?php endif; ?>
|
||||
<div class="controls">
|
||||
<?php echo $input; ?>
|
||||
<?php if (!$hideDescription && !empty($description)) : ?>
|
||||
<div id="<?php echo $id; ?>" class="<?php echo $descClass ?>">
|
||||
<small class="form-text">
|
||||
<?php echo $description; ?>
|
||||
</small>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
38
layouts/joomla/form/renderlabel.php
Normal file
38
layouts/joomla/form/renderlabel.php
Normal file
@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage Layout
|
||||
*
|
||||
* @copyright (C) 2014 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
extract($displayData);
|
||||
|
||||
/**
|
||||
* Layout variables
|
||||
* -----------------
|
||||
* @var string $text The label text
|
||||
* @var string $for The id of the input this label is for
|
||||
* @var boolean $required True if a required field
|
||||
* @var array $classes A list of classes
|
||||
*/
|
||||
|
||||
$classes = array_filter((array) $classes);
|
||||
$id = $for . '-lbl';
|
||||
|
||||
if ($required) {
|
||||
$classes[] = 'required';
|
||||
}
|
||||
|
||||
?>
|
||||
<label id="<?php echo $id; ?>" for="<?php echo $for; ?>"<?php if (!empty($classes)) {
|
||||
echo ' class="' . implode(' ', $classes) . '"';
|
||||
} ?>>
|
||||
<?php echo $text; ?><?php if ($required) :
|
||||
?><span class="star" aria-hidden="true"> *</span><?php
|
||||
endif; ?>
|
||||
</label>
|
||||
Reference in New Issue
Block a user