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 InvalidArgumentException;
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Rating input class for Form Builder
|
||||
*/
|
||||
class _Rating extends FormAbstract
|
||||
class Rating extends FormAbstract
|
||||
{
|
||||
/**
|
||||
* @brief Default Options
|
||||
@@ -32,7 +38,7 @@ class _Rating extends FormAbstract
|
||||
);
|
||||
* @endcode
|
||||
*/
|
||||
protected $defaultOptions = array(
|
||||
protected array $defaultOptions = array(
|
||||
'max' => 5,
|
||||
'display' => NULL,
|
||||
'userRated' => NULL,
|
||||
@@ -43,32 +49,32 @@ class _Rating extends FormAbstract
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function html()
|
||||
public function html(): string
|
||||
{
|
||||
return \IPS\Theme::i()->getTemplate( 'forms', 'core', 'global' )->rating( $this->name, $this->value, $this->required, $this->options['max'], $this->options['display'], $this->options['userRated'] );
|
||||
return Theme::i()->getTemplate( 'forms', 'core', 'global' )->rating( $this->name, $this->value, $this->required, $this->options['max'], $this->options['display'], $this->options['userRated'] );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Format Value
|
||||
*
|
||||
* @return int|NULL
|
||||
* @return mixed
|
||||
*/
|
||||
public function formatValue()
|
||||
public function formatValue(): mixed
|
||||
{
|
||||
return $this->value ? \intval( $this->value ) : NULL;
|
||||
return $this->value ? intval( $this->value ) : NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
* @throws InvalidArgumentException
|
||||
* @return TRUE
|
||||
*/
|
||||
public function validate()
|
||||
public function validate(): bool
|
||||
{
|
||||
if( $this->value === NULL and $this->required )
|
||||
{
|
||||
throw new \InvalidArgumentException('form_required');
|
||||
throw new InvalidArgumentException('form_required');
|
||||
}
|
||||
|
||||
return parent::validate();
|
||||
|
||||
Reference in new issue
Block a user