Version 4.3.0
This commit is contained in:
1 parent
96997ddd8e
commit
fe1acf984a
1349 files changed
+116159
-67711
No files matched your search
@@ -42,7 +42,8 @@ class _Text extends TextArea
|
||||
'prefix' => TRUE, // If TRUE, user will have option to specify one tag as a prefix
|
||||
'resultItemTemplate'=> 'core.foo.bar', // Can be used to specify a custom JavaScript template to use for the result
|
||||
'minAjaxLength' => 3, // Minimum length of value before sending AJAX lookup call
|
||||
'disallowedCharacters' => array() // An array of disallowed characters (default < > ' ")
|
||||
'disallowedCharacters' => array(), // An array of disallowed characters (default < > ' ")
|
||||
'minimized' => TRUE // Whether the autocomplete shows a 'choose' link to activate. Existing values or required = true will always override this.
|
||||
),
|
||||
'placeholder' => 'e.g. ...', // A placeholder (NB: Will only work on compatible browsers)
|
||||
'regex' => '/[A-Z]+/i', // RegEx of acceptable value
|
||||
@@ -131,7 +132,7 @@ class _Text extends TextArea
|
||||
{
|
||||
foreach( $this->value as $key => $value )
|
||||
{
|
||||
$this->value[ $key ] = htmlspecialchars( $value, ENT_QUOTES | \IPS\HTMLENTITIES, 'UTF-8', FALSE );
|
||||
$this->value[ $key ] = htmlspecialchars( $value, ENT_QUOTES | ENT_DISALLOWED, 'UTF-8', FALSE );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -171,23 +172,27 @@ class _Text extends TextArea
|
||||
{
|
||||
$return = htmlspecialchars_decode( $return, ENT_QUOTES );
|
||||
|
||||
if ( !is_array( $return ) )
|
||||
if ( !is_array( $return ) and ( !isset( $this->options['autocomplete']['maxItems'] ) or $this->options['autocomplete']['maxItems'] != 1 ) )
|
||||
{
|
||||
$return = array_filter( explode( "\n", $return ) );
|
||||
$return = array_filter( array_map( 'trim', explode( "\n", $return ) ) );
|
||||
}
|
||||
}
|
||||
|
||||
/* Remove all invisible characters */
|
||||
if ( !is_array( $return ) )
|
||||
|
||||
/* Remove all invisible characters if this is a username */
|
||||
if( $this->options['accountUsername'] )
|
||||
{
|
||||
$return = preg_replace( '/\p{C}+/u', '', $return );
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach( $return as $k => $v )
|
||||
if ( !is_array( $return ) )
|
||||
{
|
||||
$return = preg_replace( '/\p{C}+/u', '', $return );
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach( $return as $k => $v )
|
||||
{
|
||||
$return = preg_replace( '/\p{C}+/u', '', $return );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( isset( $this->options['autocomplete']['prefix'] ) and $this->options['autocomplete']['prefix'] )
|
||||
@@ -229,7 +234,7 @@ class _Text extends TextArea
|
||||
* @return mixed
|
||||
*/
|
||||
public function formatValue()
|
||||
{
|
||||
{
|
||||
if ( $this->options['autocomplete'] !== NULL and ( !isset( $this->options['autocomplete']['maxItems'] ) or $this->options['autocomplete']['maxItems'] != 1 ) and !is_array( $this->value ) and $this->value !== NULL )
|
||||
{
|
||||
return array_filter( array_map( 'trim', explode( "\n", $this->value ) ) );
|
||||
@@ -249,6 +254,12 @@ class _Text extends TextArea
|
||||
{
|
||||
parent::validate();
|
||||
|
||||
/* Check it isn't just invisible characters (we don't strip them, because things like zero-width-joiners when in between other characters have a special meaning */
|
||||
if ( $this->required and is_string( $this->value ) and mb_strlen( preg_replace( '/\p{C}+/u', '', $this->value ) ) === 0 )
|
||||
{
|
||||
throw new \DomainException('form_required');
|
||||
}
|
||||
|
||||
/* skip validation if it's an username field and if the name wasn't changed */
|
||||
if ( $this->options['accountUsername'] AND $this->options['accountUsername'] instanceOf \IPS\Member AND $this->options['accountUsername']->name == $this->value )
|
||||
{
|
||||
@@ -304,21 +315,11 @@ class _Text extends TextArea
|
||||
/* Check if it exists */
|
||||
if ( !( $this->options['accountUsername'] instanceof \IPS\Member ) or mb_strtolower( $this->options['accountUsername']->name ) !== mb_strtolower( $this->value ) )
|
||||
{
|
||||
foreach( \IPS\Login::handlers( TRUE ) as $k => $handler )
|
||||
if ( $error = \IPS\Login::usernameIsInUse( $this->value, ( $this->options['accountUsername'] instanceof \IPS\Member ) ? $this->options['accountUsername'] : NULL, \IPS\Member::loggedIn()->isAdmin() ) )
|
||||
{
|
||||
if( $handler->usernameIsInUse( $this->value, $this->options['accountUsername'] ) === TRUE )
|
||||
{
|
||||
if( \IPS\Member::loggedIn()->isAdmin() )
|
||||
{
|
||||
throw new \DomainException( \IPS\Member::loggedIn()->language()->addToStack( 'member_name_exists_admin', FALSE, array('sprintf' => array($k)) ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new \DomainException( 'member_name_exists' );
|
||||
}
|
||||
}
|
||||
throw new \DomainException( $error );
|
||||
}
|
||||
|
||||
|
||||
/* Check it's not banned */
|
||||
foreach( \IPS\Db::i()->select( 'ban_content', 'core_banfilters', array("ban_type=?", 'name') ) as $bannedName )
|
||||
{
|
||||
@@ -383,7 +384,7 @@ class _Text extends TextArea
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new \DomainException( 'Profanity Filter' ); // @todo proper lang string
|
||||
throw new \DomainException( \IPS\Member::loggedIn()->language()->addToStack( 'form_tags_not_allowed', FALSE, array( 'sprintf' => array( $v ) ) ) );
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -399,7 +400,7 @@ class _Text extends TextArea
|
||||
{
|
||||
if ( mb_stristr( $value, $type ) )
|
||||
{
|
||||
throw new \DomainException( 'Profanity Filter' );
|
||||
throw new \DomainException( \IPS\Member::loggedIn()->language()->addToStack( 'form_tags_not_allowed', FALSE, array( 'sprintf' => array( $v ) ) ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -426,11 +427,11 @@ class _Text extends TextArea
|
||||
{
|
||||
if( isset( $this->options['autocomplete']['forceLower'] ) AND $this->options['autocomplete']['forceLower'] )
|
||||
{
|
||||
$this->value = array_uintersect( array_map( 'mb_strtolower', $this->value ), array_map( 'mb_strtolower', $this->options['autocomplete']['source'] ), 'strcasecmp' );
|
||||
$this->value = array_uintersect( array_map( 'mb_strtolower', $this->value ), array_map( 'mb_strtolower', array_map( 'trim', $this->options['autocomplete']['source'] ) ), 'strcasecmp' );
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->value = array_uintersect( $this->value, $this->options['autocomplete']['source'], 'strcasecmp' );
|
||||
$this->value = array_uintersect( $this->value, array_map( 'trim', $this->options['autocomplete']['source'] ), 'strcasecmp' );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user