Version 4.1.19
This commit is contained in:
1 parent
28bd025b35
commit
2bd5025018
2674 files changed
+233518
-77766
No files matched your search
@@ -2,9 +2,9 @@
|
||||
/**
|
||||
* @brief Number input class for Form Builder
|
||||
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
|
||||
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/legal/standards/
|
||||
* @package IPS Social Suite
|
||||
* @package IPS Community Suite
|
||||
* @since 18 Feb 2013
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
@@ -79,7 +79,7 @@ class _Number extends FormAbstract
|
||||
|
||||
/* Work out the step */
|
||||
$args = func_get_args();
|
||||
if ( !isset( $options['base'] ) and isset( $options['decimals'] ) )
|
||||
if ( !isset( $options['step'] ) and isset( $options['decimals'] ) )
|
||||
{
|
||||
if ( $options['decimals'] === TRUE )
|
||||
{
|
||||
@@ -95,6 +95,11 @@ class _Number extends FormAbstract
|
||||
call_user_func_array( 'parent::__construct', $args );
|
||||
}
|
||||
|
||||
/**
|
||||
* Generated HTML store
|
||||
*/
|
||||
protected static $generatedHtml = array();
|
||||
|
||||
/**
|
||||
* Get HTML
|
||||
*
|
||||
@@ -103,7 +108,13 @@ class _Number extends FormAbstract
|
||||
public function html()
|
||||
{
|
||||
/* Display */
|
||||
return \IPS\Theme::i()->getTemplate( 'forms', 'core', 'global' )->number( $this->name, $this->value, $this->required, $this->options['unlimited'], $this->options['range'], $this->options['min'], $this->options['max'], $this->options['step'], $this->options['decimals'], $this->options['unlimitedLang'], $this->options['disabled'], $this->suffix, $this->options['unlimitedToggles'], $this->options['unlimitedToggleOn'], $this->options['valueToggles'] );
|
||||
if ( ! isset( static::$generatedHtml[ $this->_name ] ) )
|
||||
{
|
||||
static::$generatedHtml[ $this->_name ] = \IPS\Theme::i()->getTemplate( 'forms', 'core', 'global' )->number( $this->name, $this->value, $this->required, $this->options['unlimited'], $this->options['range'], $this->options['min'], $this->options['max'], $this->options['step'], $this->options['decimals'], $this->options['unlimitedLang'], $this->options['disabled'], $this->suffix, $this->options['unlimitedToggles'], $this->options['unlimitedToggleOn'], $this->options['valueToggles'] );
|
||||
}
|
||||
|
||||
/* Because we mess around with suffixes in the Number field, we store the HTML here otherwise when it is regenerated, the suffix is missing */
|
||||
return static::$generatedHtml[ $this->_name ];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -167,10 +178,13 @@ class _Number extends FormAbstract
|
||||
return $value;
|
||||
}
|
||||
|
||||
/* Convert decimal point and thousand separators to a way PHP understand */
|
||||
$value = str_replace( trim( \IPS\Member::loggedIn()->language()->locale['thousands_sep'] ), '', $value );
|
||||
/* Browsers *might* send in a normal "10.00" format, or because they like to keep us on our
|
||||
toes, they might send in a locale-specific "10,00" format. We convert the decimal point
|
||||
of the locale to . in an attempt to get us to the former from the latter, but we don't
|
||||
do the thousand seperator in case what we received was the former alredy, which would turn
|
||||
for example "10,00" into "1000" */
|
||||
$value = str_replace( trim( \IPS\Member::loggedIn()->language()->locale['decimal_point'] ), '.', $value );
|
||||
|
||||
|
||||
/* If it's not numeric, throw an exception */
|
||||
if ( ( !is_numeric( $value ) and $value !== '' and $this->required === FALSE ) or ( !is_numeric( $value ) and $this->required === TRUE ) )
|
||||
{
|
||||
@@ -204,7 +218,7 @@ class _Number extends FormAbstract
|
||||
public function validate()
|
||||
{
|
||||
parent::validate();
|
||||
|
||||
|
||||
if ( $this->options['unlimited'] === NULL or $this->value !== $this->options['unlimited'] )
|
||||
{
|
||||
if ( $this->options['min'] !== NULL and $this->value < $this->options['min'] )
|
||||
|
||||
Reference in new issue
Block a user