Version 5.0.0 beta 1
This commit is contained in:
1 parent
25ddeb65d6
commit
15c7beabc5
6736 files changed
+627902
-497943
No files matched your search
@@ -12,32 +12,39 @@
|
||||
namespace IPS\nexus\Form;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use IPS\Helpers\Form\FormAbstract;
|
||||
use IPS\Text\Encrypt;
|
||||
use IPS\Theme;
|
||||
use function defined;
|
||||
use function is_array;
|
||||
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
header( ( $_SERVER['SERVER_PROTOCOL'] ?? 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Username & Password input class for Form Builder
|
||||
*/
|
||||
class _UserPass extends \IPS\Helpers\Form\FormAbstract
|
||||
class UserPass extends FormAbstract
|
||||
{
|
||||
/**
|
||||
* Get HTML
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function html()
|
||||
public function html(): string
|
||||
{
|
||||
$value = \is_array( $this->value ) ? $this->value : json_decode( \IPS\Text\Encrypt::fromTag( $this->value )->decrypt(), TRUE );
|
||||
$defaultValue = \is_array( $this->defaultValue ) ? $this->defaultValue : json_decode( \IPS\Text\Encrypt::fromTag( $this->defaultValue )->decrypt(), TRUE );
|
||||
$value = is_array( $this->value ) ? $this->value : json_decode( Encrypt::fromTag( $this->value )->decrypt(), TRUE );
|
||||
$defaultValue = is_array( $this->defaultValue ) ? $this->defaultValue : json_decode( Encrypt::fromTag( $this->defaultValue )->decrypt(), TRUE );
|
||||
if ( isset( $value['pw'] ) and isset( $defaultValue['pw'] ) and $value['pw'] and $value['pw'] === $defaultValue['pw'] and !$this->error )
|
||||
{
|
||||
$value['pw'] = '********';
|
||||
}
|
||||
|
||||
return \IPS\Theme::i()->getTemplate( 'forms', 'nexus', 'global' )->usernamePassword( $this->name, $value );
|
||||
return Theme::i()->getTemplate( 'forms', 'nexus', 'global' )->usernamePassword( $this->name, $value );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -45,13 +52,13 @@ class _UserPass extends \IPS\Helpers\Form\FormAbstract
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function getValue()
|
||||
public function getValue(): mixed
|
||||
{
|
||||
$value = parent::getValue();
|
||||
|
||||
if ( isset( $value['pw'] ) and $value['pw'] === '********' )
|
||||
{
|
||||
$defaultValue = \is_array( $this->defaultValue ) ? $this->defaultValue : json_decode( \IPS\Text\Encrypt::fromTag( $this->defaultValue )->decrypt(), TRUE );
|
||||
$defaultValue = is_array( $this->defaultValue ) ? $this->defaultValue : json_decode( Encrypt::fromTag( $this->defaultValue )->decrypt(), TRUE );
|
||||
$value['pw'] = $defaultValue['pw'];
|
||||
}
|
||||
|
||||
@@ -62,10 +69,10 @@ class _UserPass extends \IPS\Helpers\Form\FormAbstract
|
||||
* String Value
|
||||
*
|
||||
* @param mixed $value The value
|
||||
* @return string
|
||||
* @return string|int|null
|
||||
*/
|
||||
public static function stringValue( $value )
|
||||
public static function stringValue( mixed $value ): string|int|null
|
||||
{
|
||||
return \IPS\Text\Encrypt::fromPlaintext( json_encode( $value ) )->tag();
|
||||
return Encrypt::fromPlaintext( json_encode( $value ) )->tag();
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user