Version 4.5.0

This commit is contained in:
Neo committed 2025-12-19 05:51:58 -08:00
1 parent 1a0c7fd3c2
commit f79dcf067a
3791 files changed
+248032 -76372

No files matched your search

+24 -22
View File
@@ -11,7 +11,7 @@
namespace IPS\Helpers\Form;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
@@ -32,6 +32,7 @@ class _Select extends FormAbstract
'class' => '', // CSS class
'disabled' => FALSE, // Disables input. Default is FALSE.
'parse' => 'lang', // Sets how the values for options should be parsed. Acceptable values are "lang" (language keys), "normal" (htmlentities), "raw" (no parsing) or "image" (image URLs, only for Radio fields). Default is "lang".
'gridspan' => 3, // If 'parse' is set to 'image', this controls the gridspan to use when creating the option layout
'unlimited' => -1, // If any value other than NULL is provided, an "Unlimited" checkbox will be displayed. If checked, the value specified will be sent.
'unlimitedLang' => 'unlimited', // Language string to use for unlimited checkbox label
'unlimitedToggles' => array(...), // Names of other input fields that should show/hide when the "Unlimited" checkbox is toggled.
@@ -50,6 +51,7 @@ class _Select extends FormAbstract
'class' => '',
'disabled' => FALSE,
'parse' => 'lang',
'gridspan' => 3,
'unlimited' => NULL,
'unlimitedLang' => 'all',
'unlimitedToggles' => array(),
@@ -63,28 +65,28 @@ class _Select extends FormAbstract
/**
* Constructor
*
* @param string $name Name
* @param mixed $defaultValue Default value
* @param bool $required Required?
* @param array $options Type-specific options
* @param callback $customValidationCode Custom validation code
* @param string $prefix HTML to show before input field
* @param string $suffix HTML to show after input field
* @param string $id The ID to add to the row
* @param string $name Name
* @param mixed $defaultValue Default value
* @param bool|NULL $required Required? (NULL for not required, but appears to be so)
* @param array $options Type-specific options
* @param callback $customValidationCode Custom validation code
* @param string $prefix HTML to show before input field
* @param string $suffix HTML to show after input field
* @param string $id The ID to add to the row
* @return void
*/
public function __construct( $name, $defaultValue=NULL, $required=FALSE, $options=array(), $customValidationCode=NULL, $prefix=NULL, $suffix=NULL, $id=NULL )
{
/* Set the default value to the first option if one isn't provided */
if ( $defaultValue === NULL and ( !isset( $options['noDefault'] ) OR !$options['noDefault'] ) and is_array( $options['options'] ) )
if ( $defaultValue === NULL and ( !isset( $options['noDefault'] ) OR !$options['noDefault'] ) and \is_array( $options['options'] ) )
{
foreach ( $options['options'] as $k => $v )
{
if ( is_array( $v ) )
if ( \is_array( $v ) )
{
foreach ( $v as $_k => $_v )
{
if ( !isset( $options['disabled'] ) OR ( is_array( $options['disabled'] ) AND !in_array( $_k, $options['disabled'] ) ) )
if ( !isset( $options['disabled'] ) OR ( \is_array( $options['disabled'] ) AND !\in_array( $_k, $options['disabled'] ) ) )
{
$defaultValue = $_k;
break;
@@ -93,7 +95,7 @@ class _Select extends FormAbstract
}
else
{
if ( !isset( $options['disabled'] ) OR ( is_array( $options['disabled'] ) AND !in_array( $k, $options['disabled'] ) ) )
if ( !isset( $options['disabled'] ) OR ( \is_array( $options['disabled'] ) AND !\in_array( $k, $options['disabled'] ) ) )
{
$defaultValue = $k;
break;
@@ -108,7 +110,7 @@ class _Select extends FormAbstract
}
/* Call parent constructor */
call_user_func( 'parent::__construct', $name, $defaultValue, $required, $options, $customValidationCode, $prefix, $suffix, $id );
parent::__construct( $name, $defaultValue, $required, $options, $customValidationCode, $prefix, $suffix, $id );
}
/**
@@ -129,7 +131,7 @@ class _Select extends FormAbstract
if ( $this->options['returnLabels'] and ( $this->options['unlimited'] === NULL or $this->value !== $this->options['unlimited'] ) )
{
$value = array();
if ( is_array( $this->value ) )
if ( \is_array( $this->value ) )
{
foreach ( $this->value as $v )
{
@@ -162,7 +164,7 @@ class _Select extends FormAbstract
case 'lang':
foreach ( $this->options['options'] as $k => $v )
{
if ( is_array( $v ) )
if ( \is_array( $v ) )
{
foreach ( $v as $x => $y )
{
@@ -179,7 +181,7 @@ class _Select extends FormAbstract
case 'normal':
foreach ( $this->options['options'] as $k => $v )
{
if ( is_array( $v ) )
if ( \is_array( $v ) )
{
foreach ( $v as $x => $y )
{
@@ -223,14 +225,14 @@ class _Select extends FormAbstract
}
}
if ( isset( $value ) AND is_array( $value ) AND $this->options['multiple'] AND array_search( '__EMPTY', $value ) !== FALSE )
if ( isset( $value ) AND \is_array( $value ) AND $this->options['multiple'] AND array_search( '__EMPTY', $value ) !== FALSE )
{
unset( $value[ array_search( '__EMPTY', $value ) ] );
}
if ( $this->options['returnLabels'] )
{
if ( is_array( $value ) )
if ( \is_array( $value ) )
{
$return = array();
foreach ( $value as $k => $v )
@@ -276,7 +278,7 @@ class _Select extends FormAbstract
}
foreach ( $this->options['options'] as $k => $v )
{
if ( is_array( $v ) )
if ( \is_array( $v ) )
{
$acceptableValues = array_merge( $acceptableValues, $this->options['returnLabels'] ? $v : array_keys( $v ) );
}
@@ -286,10 +288,10 @@ class _Select extends FormAbstract
}
}
$disabledValues = ( is_array( $this->options['disabled'] ) ) ? $this->options['disabled'] : array( $this->options['disabled'] );
$disabledValues = ( \is_array( $this->options['disabled'] ) ) ? $this->options['disabled'] : ( $this->options['disabled'] ? array( $this->options['disabled'] ) : array() );
$acceptableValues = array_diff( $acceptableValues, $disabledValues );
$diff = array_diff( ( is_array( $this->value ) ? $this->value : array( $this->value ) ), $acceptableValues );
$diff = array_diff( ( \is_array( $this->value ) ? $this->value : array( $this->value ) ), $acceptableValues );
if ( !empty( $diff ) )
{
/* Is the entire thing disabled? If so, just return any default value set (if one has been set)*/