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
@@ -11,16 +11,22 @@
|
||||
namespace IPS\Helpers\Form;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use IPS\Request;
|
||||
use IPS\Theme;
|
||||
use function defined;
|
||||
use function intval;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checkbox class for Form Builder
|
||||
*/
|
||||
class _Checkbox extends FormAbstract
|
||||
class Checkbox extends FormAbstract
|
||||
{
|
||||
/**
|
||||
* @brief Default Options
|
||||
@@ -33,7 +39,7 @@ class _Checkbox extends FormAbstract
|
||||
);
|
||||
* @endcode
|
||||
*/
|
||||
protected $defaultOptions = array(
|
||||
protected array $defaultOptions = array(
|
||||
'disabled' => FALSE,
|
||||
'togglesOn' => array(),
|
||||
'togglesOff' => array(),
|
||||
@@ -45,7 +51,7 @@ class _Checkbox extends FormAbstract
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function html()
|
||||
public function html(): string
|
||||
{
|
||||
if ( !$this->htmlId )
|
||||
{
|
||||
@@ -53,15 +59,15 @@ class _Checkbox extends FormAbstract
|
||||
}
|
||||
|
||||
$checkboxName = preg_replace( '/^(.+?\[?.+?)(\])?$/', '$1_checkbox$2', $this->name );
|
||||
return \IPS\Theme::i()->getTemplate( 'forms', 'core', 'global' )->checkbox( $checkboxName, $this->value, $this->options['disabled'], $this->options['togglesOn'], $this->options['togglesOff'], $this->options['label'], $this->name, $this->htmlId );
|
||||
return Theme::i()->getTemplate( 'forms', 'core', 'global' )->checkbox( $checkboxName, $this->value, $this->options['disabled'], $this->options['togglesOn'], $this->options['togglesOff'], $this->options['label'], $this->name, $this->htmlId );
|
||||
}
|
||||
|
||||
/**
|
||||
* Format Value
|
||||
*
|
||||
* @return bool
|
||||
* @return bool
|
||||
*/
|
||||
public function formatValue()
|
||||
public function formatValue(): bool
|
||||
{
|
||||
return (bool) $this->value;
|
||||
}
|
||||
@@ -71,16 +77,16 @@ class _Checkbox extends FormAbstract
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function getValue()
|
||||
public function getValue(): mixed
|
||||
{
|
||||
$checkboxName = preg_replace( '/^(.+?\[?.+?)(\])?$/', '$1_checkbox$2', $this->name );
|
||||
if ( mb_strpos( $checkboxName, '[' ) === FALSE )
|
||||
{
|
||||
return \IPS\Request::i()->$checkboxName;
|
||||
return Request::i()->$checkboxName;
|
||||
}
|
||||
else
|
||||
{
|
||||
return \IPS\Request::i()->valueFromArray( $checkboxName );
|
||||
return Request::i()->valueFromArray( $checkboxName );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -88,10 +94,10 @@ class _Checkbox extends FormAbstract
|
||||
* String Value
|
||||
*
|
||||
* @param mixed $value The value
|
||||
* @return int
|
||||
* @return string|int|null
|
||||
*/
|
||||
public static function stringValue( $value )
|
||||
public static function stringValue( mixed $value ): string|int|null
|
||||
{
|
||||
return \intval( $value );
|
||||
return intval( $value );
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user