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

@@ -11,16 +11,25 @@
namespace IPS\core\Form;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
use InvalidArgumentException;
use IPS\Helpers\Form\KeyValue;
use IPS\Helpers\Form\Select;
use IPS\Helpers\Form\Url;
use IPS\Theme;
use LengthException;
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;
}
/**
* Key/Value input class for social profile links
*/
class _SocialProfiles extends \IPS\Helpers\Form\KeyValue
class SocialProfiles extends KeyValue
{
/**
* @brief Default Options
@@ -32,7 +41,7 @@ class _SocialProfiles extends \IPS\Helpers\Form\KeyValue
);
* @endcode
*/
protected $defaultOptions = array(
protected array $defaultOptions = array(
'key' => array(
),
'value' => array(
@@ -42,25 +51,25 @@ class _SocialProfiles extends \IPS\Helpers\Form\KeyValue
/**
* @brief Key Object
*/
public $keyField = NULL;
public mixed $keyField = NULL;
/**
* @brief Value Object
*/
public $valueField = NULL;
public mixed $valueField = NULL;
/**
* Constructor
* Creates the two date objects
*
* @param string $name Form helper name
* @param mixed $defaultValue Default value for the helper
* @param bool $required Helper is required (TRUE) or not (FALSE)
* @param array $options Options for the helper instance
* @see \IPS\Helpers\Form\Abstract::__construct
* @param string $name Form helper name
* @param mixed|null $defaultValue Default value for the helper
* @param bool $required Helper is required (TRUE) or not (FALSE)
* @param array $options Options for the helper instance
* @return void
*@see \IPS\Helpers\Form\Abstract::__construct
*/
public function __construct( $name, $defaultValue=NULL, $required=FALSE, $options=array() )
public function __construct(string $name, mixed $defaultValue=NULL, bool $required=FALSE, array $options=array() )
{
$options = array_merge( $this->defaultOptions, $options );
@@ -68,20 +77,20 @@ class _SocialProfiles extends \IPS\Helpers\Form\KeyValue
parent::__construct( $name, $defaultValue, $required, $options );
$this->keyField = new \IPS\Helpers\Form\Url( "{$name}[key]", isset( $defaultValue['key'] ) ? $defaultValue['key'] : NULL, FALSE, isset( $options['key'] ) ? $options['key'] : array() );
$this->valueField = new \IPS\Helpers\Form\Select( "{$name}[value]", isset( $defaultValue['value'] ) ? $defaultValue['value'] : NULL, FALSE, isset( $options['value'] ) ? $options['value'] : array() );
$this->keyField = new Url( "{$name}[key]", $defaultValue['key'] ?? NULL, FALSE, $options['key'] ?? array() );
$this->valueField = new Select( "{$name}[value]", $defaultValue['value'] ?? NULL, FALSE, $options['value'] ?? array() );
}
/**
* Add social networks to the options array
*
* @note Abstracted so third parties can extend as needed
* @param array $options Options array
* @param array $options Options array
* @return array
*/
protected function addSocialNetworks( $options )
protected function addSocialNetworks( array $options ): array
{
$values = array(
$options['value']['options'] = array(
'facebook' => "siteprofilelink_facebook",
'youtube' => "siteprofilelink_youtube",
'x' => "siteprofilelink_x",
@@ -100,22 +109,17 @@ class _SocialProfiles extends \IPS\Helpers\Form\KeyValue
'vk' => "siteprofilelink_vk",
'discord' => "siteprofilelink_discord",
'twitch' => "siteprofilelink_twitch",
'bluesky' => "siteprofilelink_bluesky",
'tiktok' => "siteprofilelink_tiktok",
);
asort( $values );
$options['value']['options'] = $values;
return $options;
}
/**
* Format Value
*
* @return array
* @return array
*/
public function formatValue()
public function formatValue(): array
{
return array(
'key' => $this->keyField->formatValue(),
@@ -128,19 +132,19 @@ class _SocialProfiles extends \IPS\Helpers\Form\KeyValue
*
* @return string
*/
public function html()
public function html(): string
{
return \IPS\Theme::i()->getTemplate( 'forms', 'core', 'admin' )->socialProfiles( $this->keyField->html(), $this->valueField->html() );
return Theme::i()->getTemplate( 'forms', 'core', 'admin' )->socialProfiles( $this->keyField->html(), $this->valueField->html() );
}
/**
* Validate
*
* @throws \InvalidArgumentException
* @throws \LengthException
* @throws InvalidArgumentException
* @throws LengthException
* @return TRUE
*/
public function validate()
public function validate(): bool
{
$this->keyField->validate();
$this->valueField->validate();
@@ -150,5 +154,7 @@ class _SocialProfiles extends \IPS\Helpers\Form\KeyValue
$validationCode = $this->customValidationCode;
$validationCode( $this->value );
}
return TRUE;
}
}