0byt3m1n1-V2
Path:
/
home
/
a
/
c
/
a
/
academiac
/
www
/
[
Home
]
File: color.php.tar
home/academiac/www/libraries/joomla/form/rules/color.php 0000644 00000004021 15137270104 0017365 0 ustar 00 <?php /** * @package Joomla.Platform * @subpackage Form * * @copyright Copyright (C) 2005 - 2014 Open Source Matters, Inc. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE */ defined('JPATH_PLATFORM') or die; /** * Form Rule class for the Joomla Platform. * * @package Joomla.Platform * @subpackage Form * @since 11.2 */ class JFormRuleColor extends JFormRule { /** * Method to test for a valid color in hexadecimal. * * @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 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]". * @param object &$input An optional JRegistry object with the entire data set to validate against the entire form. * @param object &$form The form object for which the field is being tested. * * @return boolean True if the value is valid, false otherwise. * * @since 11.2 * @throws JException on invalid rule. */ public function test(&$element, $value, $group = null, &$input = null, &$form = null) { $value = trim($value); if (empty($value)) { // A color field can't be empty, we default to black. This is the same as the HTML5 spec. $value = '#000000'; return true; } if ($value[0] != '#') { return false; } // Remove the leading # if present to validate the numeric part $value = ltrim($value, '#'); // The value must be 6 or 3 characters long if (!((strlen($value) == 6 || strlen($value) == 3) && ctype_xdigit($value))) { return false; } // Prepend the # again $value = '#' . $value; return true; } } home/academiac/www/libraries/joomla/form/fields/color.php 0000644 00000003427 15137513645 0017524 0 ustar 00 <?php /** * @package Joomla.Platform * @subpackage Form * * @copyright Copyright (C) 2005 - 2014 Open Source Matters, Inc. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE */ defined('JPATH_PLATFORM') or die; /** * Color Form Field class for the Joomla Platform. * This implementation is designed to be compatible with HTML5's <input type="color"> * * @package Joomla.Platform * @subpackage Form * @link http://www.w3.org/TR/html-markup/input.color.html * @since 11.3 */ class JFormFieldColor extends JFormField { /** * The form field type. * * @var string * @since 11.3 */ protected $type = 'Color'; /** * Method to get the field input markup. * * @return string The field input markup. * * @since 11.3 */ protected function getInput() { // Initialize some field attributes. $size = $this->element['size'] ? ' size="' . (int) $this->element['size'] . '"' : ''; $classes = (string) $this->element['class']; $disabled = ((string) $this->element['disabled'] == 'true') ? ' disabled="disabled"' : ''; if (!$disabled) { JHtml::_('behavior.colorpicker'); $classes .= ' input-colorpicker'; } if (empty($this->value)) { // A color field can't be empty, we default to black. This is the same as the HTML5 spec. $this->value = '#000000'; } // Initialize JavaScript field attributes. $onchange = $this->element['onchange'] ? ' onchange="' . (string) $this->element['onchange'] . '"' : ''; $class = $classes ? ' class="' . trim($classes) . '"' : ''; return '<input type="text" name="' . $this->name . '" id="' . $this->id . '"' . ' value="' . htmlspecialchars($this->value, ENT_COMPAT, 'UTF-8') . '"' . $class . $size . $disabled . $onchange . '/>'; } }
©
2018.