Version 5.0.0 beta 1

This commit is contained in:
Neo committed 2025-12-19 16:27:35 -08:00
1 parent 25ddeb65d6
commit 15c7beabc5
6736 files changed
+627902 -497943

No files matched your search

+26 -21
View File
@@ -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\Image;
use IPS\Request;
use IPS\Theme;
use function defined;
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;
}
/**
* Width/Height input class for Form Builder
*/
class _WidthHeight extends FormAbstract
class WidthHeight extends FormAbstract
{
/**
* @brief Default Options
@@ -33,27 +39,26 @@ class _WidthHeight extends FormAbstract
);
* @endcode
*/
protected $defaultOptions = array(
protected array $defaultOptions = array(
'unlimited' => NULL,
'unlimitedLang' => 'unlimited',
'image' => NULL,
'resizableDiv' => TRUE,
);
/**
* Constructor
*
* @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
* @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 callable|null $customValidationCode Custom validation code
* @param string|null $prefix HTML to show before input field
* @param string|null $suffix HTML to show after input field
* @param string|null $id The ID to add to the row
*/
public function __construct( $name, $defaultValue=NULL, $required=FALSE, $options=array(), $customValidationCode=NULL, $prefix=NULL, $suffix=NULL, $id=NULL )
public function __construct( string $name, mixed $defaultValue=NULL, ?bool $required=FALSE, array $options=array(), callable $customValidationCode=NULL, string $prefix=NULL, string $suffix=NULL, string $id=NULL )
{
parent::__construct( $name, $defaultValue, $required, $options, $customValidationCode, $prefix, $suffix, $id );
@@ -61,7 +66,7 @@ class _WidthHeight extends FormAbstract
{
if ( $this->options['image'] !== NULL )
{
$image = \IPS\Image::create( $this->options['image']->contents() );
$image = Image::create( $this->options['image']->contents() );
$this->value = array( $image->width, $image->height );
}
else
@@ -76,9 +81,9 @@ class _WidthHeight extends FormAbstract
*
* @return string
*/
public function html()
public function html(): string
{
return \IPS\Theme::i()->getTemplate( 'forms', 'core', 'global' )->widthheight( $this->name, $this->value[0], $this->value[1], $this->options['unlimited'], $this->options['unlimitedLang'], $this->options['image'] ? $this->options['image'] : NULL, $this->options['resizableDiv'] );
return Theme::i()->getTemplate( 'forms', 'core', 'global' )->widthheight( $this->name, $this->value[0], $this->value[1], $this->options['unlimited'], $this->options['unlimitedLang'], $this->options['image'] ?: NULL, $this->options['resizableDiv'] );
}
/**
@@ -86,14 +91,14 @@ class _WidthHeight extends FormAbstract
*
* @return mixed
*/
public function getValue()
public function getValue(): mixed
{
$name = $this->name;
$value = \IPS\Request::i()->$name;
$value = Request::i()->$name;
if ( $this->options['unlimited'] !== NULL and isset( $value['unlimited'] ) )
{
return $this->options['unlimited'];
}
return \IPS\Request::i()->$name;
return Request::i()->$name;
}
}