-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
442 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
<?php | ||
/** | ||
* @package Joomla.Site | ||
* @subpackage Layout | ||
* | ||
* @copyright Copyright (C) 2005 - 2019 Open Source Matters, Inc. All rights reserved. | ||
* @license GNU General Public License version 2 or later; see LICENSE.txt | ||
*/ | ||
|
||
defined('JPATH_BASE') 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 array $spellcheck Options available for this field. | ||
* @var string $accept File types that are accepted. | ||
*/ | ||
|
||
$attributes = [ | ||
!empty($class) ? 'class="form-control ' . $class . '"' : 'class="form-control"', | ||
!empty($description) ? 'aria-describedby="' . $name . '-desc"' : '', | ||
$disabled ? 'disabled' : '', | ||
$readonly ? 'readonly' : '', | ||
strlen($hint) ? 'placeholder="' . htmlspecialchars($hint, ENT_COMPAT, 'UTF-8') . '"' : '', | ||
!empty($onchange) ? 'onchange="' . $onchange . '"' : '', | ||
isset($max) ? 'max="' . $max . '"' : '', | ||
isset($step) ? 'step="' . $step . '"' : '', | ||
isset($min) ? 'min="' . $min . '"' : '', | ||
$required ? 'required' : '', | ||
$autofocus ? 'autofocus' : '' | ||
]; | ||
|
||
?> | ||
<input | ||
type="time" | ||
name="<?php echo $name; ?>" | ||
id="<?php echo $id; ?>" | ||
value="<?php echo $value ?>" | ||
<?php echo implode(' ', $attributes); ?>> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,181 @@ | ||
<?php | ||
/** | ||
* Joomla! Content Management System | ||
* | ||
* @copyright Copyright (C) 2005 - 2019 Open Source Matters, Inc. All rights reserved. | ||
* @license GNU General Public License version 2 or later; see LICENSE.txt | ||
*/ | ||
|
||
namespace Joomla\CMS\Form\Field; | ||
|
||
defined('JPATH_PLATFORM') or die; | ||
|
||
use Joomla\CMS\Component\ComponentHelper; | ||
use Joomla\CMS\Factory; | ||
use Joomla\CMS\Form\FormField; | ||
use Joomla\CMS\HTML\HTMLHelper; | ||
use Joomla\CMS\Language\Text; | ||
use Joomla\CMS\Uri\Uri; | ||
|
||
/** | ||
* Form Field class for the Joomla Platform. | ||
* Provides a select list of integers with specified first, last and step values. | ||
* | ||
* @since 4.0.0 | ||
*/ | ||
class TimeField extends FormField | ||
{ | ||
/** | ||
* The form field type. | ||
* | ||
* @var string | ||
* @since 4.0.0 | ||
*/ | ||
protected $type = 'Time'; | ||
|
||
/** | ||
* The allowable minimal value of the field. | ||
* | ||
* @var integer | ||
* @since 4.0.0 | ||
*/ | ||
protected $min; | ||
|
||
/** | ||
* The allowable maximal value of the field. | ||
* | ||
* @var integer | ||
* @since 4.0.0 | ||
*/ | ||
protected $max; | ||
|
||
/** | ||
* Steps between different values | ||
* | ||
* @var integer | ||
* @since 4.0.0 | ||
*/ | ||
protected $step; | ||
|
||
/** | ||
* Name of the layout being used to render the field | ||
* | ||
* @var string | ||
* @since 4.0.0 | ||
*/ | ||
protected $layout = 'joomla.form.field.time'; | ||
|
||
/** | ||
* Method to set certain otherwise inaccessible properties of the form field object. | ||
* | ||
* @param string $name The property name for which to set the value. | ||
* @param mixed $value The value of the property. | ||
* | ||
* @return void | ||
* | ||
* @since 4.0.0 | ||
*/ | ||
public function __set($name, $value) | ||
{ | ||
switch ($name) | ||
{ | ||
case 'min': | ||
$this->min = (string) $value; | ||
break; | ||
|
||
case 'max': | ||
$this->max = (string) $value; | ||
break; | ||
|
||
case 'step': | ||
$this->step = (string) $value; | ||
break; | ||
|
||
default: | ||
parent::__set($name, $value); | ||
} | ||
} | ||
|
||
/** | ||
* Method to attach a Form object to the field. | ||
* | ||
* @param \SimpleXMLElement $element The SimpleXMLElement object representing the `<field>` tag for the form field object. | ||
* @param mixed $value The form field value to validate. | ||
* @param string $group The field name group control value. This acts as an array container for the field. | ||
* For example if the field has name="foo" and the group value is set to "bar" then the | ||
* full field name would end up being "bar[foo]". | ||
* | ||
* @see FormField::setup() | ||
* @return boolean True on success. | ||
* | ||
* @since 4.0.0 | ||
*/ | ||
public function setup(\SimpleXMLElement $element, $value, $group = null) | ||
{ | ||
$return = parent::setup($element, $value, $group); | ||
|
||
if ($return) | ||
{ | ||
// It is better not to force any default limits if none is specified | ||
$this->max = isset($this->element['max']) ? (string) $this->element['max'] : null; | ||
$this->min = isset($this->element['min']) ? (string) $this->element['min'] : null; | ||
$this->step = isset($this->element['step']) ? (float) $this->element['step'] : null; | ||
} | ||
|
||
return $return; | ||
} | ||
|
||
/** | ||
* Method to get certain otherwise inaccessible properties from the form field object. | ||
* | ||
* @param string $name The property name for which to get the value. | ||
* | ||
* @return mixed The property value or null. | ||
* | ||
* @since 4.0.0 | ||
*/ | ||
public function __get($name) | ||
{ | ||
switch ($name) | ||
{ | ||
case 'min': | ||
case 'max': | ||
case 'step': | ||
return $this->$name; | ||
} | ||
|
||
return parent::__get($name); | ||
} | ||
|
||
/** | ||
* Method to get the field input markup. | ||
* | ||
* @return string The field input markup. | ||
* | ||
* @since 4.0.0 | ||
*/ | ||
protected function getInput() | ||
{ | ||
return $this->getRenderer($this->layout)->render($this->getLayoutData()); | ||
} | ||
|
||
/** | ||
* Method to get the data to be passed to the layout for rendering. | ||
* | ||
* @return array | ||
* | ||
* @since 4.0.0 | ||
*/ | ||
protected function getLayoutData() | ||
{ | ||
$data = parent::getLayoutData(); | ||
|
||
$extraData = [ | ||
'min' => $this->min, | ||
'max' => $this->max, | ||
'step' => $this->step, | ||
]; | ||
|
||
return array_merge($data, $extraData); | ||
} | ||
} |
Oops, something went wrong.