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

+42 -26
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;
@@ -37,33 +37,38 @@ class _Member extends Text
/**
* Constructor
* Adds 'confirm' to the available options
*
* @see \IPS\Helpers\Form\FormAbstract::__construct
* @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()
public function __construct( $name, $defaultValue=NULL, $required=FALSE, $options=array(), $customValidationCode=NULL, $prefix=NULL, $suffix=NULL, $id=NULL )
{
$args = func_get_args();
$this->defaultOptions['autocomplete'] = array(
'source' => 'app=core&module=system&controller=ajax&do=findMember',
'source' => 'app=core&module=system&controller=ajax&do=findMember',
'resultItemTemplate' => 'core.autocomplete.memberItem',
'commaTrigger' => false,
'unique' => true,
'minAjaxLength' => 3,
'disallowedCharacters' => array()
'disallowedCharacters' => array(),
'lang' => 'mem_optional',
);
if( isset( $args[3] ) and array_key_exists( 'multiple', $args[3] ) and $args[3]['multiple'] > 0 )
if( \count( $options ) and array_key_exists( 'multiple', $options ) and $options['multiple'] > 0 )
{
$this->defaultOptions['autocomplete']['maxItems'] = $args[3]['multiple'];
$this->defaultOptions['autocomplete']['maxItems'] = $options['multiple'];
}
elseif ( !isset( $args[3] ) or !array_key_exists( 'multiple', $args[3] ) )
elseif ( !array_key_exists( 'multiple', $options ) )
{
$this->defaultOptions['autocomplete']['maxItems'] = $this->childDefaultOptions['multiple'];
}
call_user_func_array( 'parent::__construct', $args );
parent::__construct( $name, $defaultValue, $required, $options, $customValidationCode, $prefix, $suffix, $id );
}
/**
@@ -74,7 +79,7 @@ class _Member extends Text
public function html()
{
$value = $this->value;
if ( is_array( $this->value ) )
if ( \is_array( $this->value ) )
{
$value = array();
foreach ( $this->value as $v )
@@ -89,7 +94,7 @@ class _Member extends Text
}
/* This value is decoded by the JS widget before use. */
return \IPS\Theme::i()->getTemplate( 'forms', 'core', 'global' )->text( $this->name, 'text', ( $this->options['autocomplete'] AND !is_null( $value ) ) ? htmlspecialchars( $value, ENT_QUOTES | ENT_DISALLOWED, 'UTF-8', FALSE ) : $value, $this->required, $this->options['maxLength'], $this->options['size'], $this->options['disabled'], $this->options['autocomplete'], $this->options['placeholder'], NULL, $this->options['nullLang'] );
return \IPS\Theme::i()->getTemplate( 'forms', 'core', 'global' )->text( $this->name, 'text', ( $this->options['autocomplete'] AND !\is_null( $value ) ) ? htmlspecialchars( $value, ENT_QUOTES | ENT_DISALLOWED, 'UTF-8', FALSE ) : $value, $this->required, $this->options['maxLength'], $this->options['size'], $this->options['disabled'], $this->options['autocomplete'], $this->options['placeholder'], NULL, $this->options['nullLang'] );
}
/**
@@ -103,7 +108,7 @@ class _Member extends Text
{
$return = array();
foreach ( is_array( $this->value ) ? $this->value : explode( "\n", $this->value ) as $v )
foreach ( \is_array( $this->value ) ? $this->value : explode( "\n", $this->value ) as $v )
{
if ( $v instanceof \IPS\Member )
{
@@ -127,7 +132,7 @@ class _Member extends Text
if ( !empty( $return ) )
{
return ( $this->options['multiple'] === NULL or $this->options['multiple'] == 0 ) ? $return : array_slice( $return, 0, $this->options['multiple'] );
return ( $this->options['multiple'] === NULL or $this->options['multiple'] == 0 ) ? $return : \array_slice( $return, 0, $this->options['multiple'] );
}
}
@@ -144,11 +149,11 @@ class _Member extends Text
{
parent::validate();
if ( $this->value !== '' and !( $this->value instanceof \IPS\Member ) and !is_array( $this->value ) )
if ( $this->value !== '' and !( $this->value instanceof \IPS\Member ) and !\is_array( $this->value ) )
{
throw new \InvalidArgumentException('form_member_bad');
}
else if ( is_array( $this->value ) )
else if ( \is_array( $this->value ) )
{
foreach( $this->value AS $value )
{
@@ -169,19 +174,30 @@ class _Member extends Text
*/
public static function stringValue( $value )
{
if ( is_array( $value ) )
if( !\is_array( $value ) )
{
if ( !count( $value ) )
if( $value instanceof \IPS\Member )
{
return NULL;
$value = array( $value );
}
return implode( "\n", array_map( function( $v )
elseif( $value )
{
return $v->member_id;
}, $value ) );
$value = explode( "\n", $value );
}
else
{
$value = array();
}
}
if ( !\count( $value ) )
{
return NULL;
}
return $value ? (string) $value->member_id : NULL;
return implode( "\n", array_map( function( $v )
{
return $v->member_id;
}, $value ) );
}
}