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;
}
}
@@ -11,16 +11,24 @@
namespace IPS\core\Form;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
use IPS\Helpers\Form\CheckboxSet;
use IPS\Member;
use IPS\Output;
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;
}
/**
* Checkbox Set for Webhooks
*/
class _WebhookSelector extends \IPS\Helpers\Form\CheckboxSet
class WebhookSelector extends CheckboxSet
{
/**
@@ -28,18 +36,18 @@ class _WebhookSelector extends \IPS\Helpers\Form\CheckboxSet
*
* @return string
*/
public function html()
public function html(): string
{
\IPS\Output::i()->cssFiles = array_merge( \IPS\Output::i()->cssFiles, \IPS\Theme::i()->css( 'system/webhooks.css' ) );
Output::i()->cssFiles = array_merge( Output::i()->cssFiles, Theme::i()->css( 'system/webhooks.css' ) );
/* Get descriptions */
$descriptions = $this->options['descriptions'];
foreach ( $this->options['options'] as $k => $v )
{
if ( \IPS\Member::loggedIn()->language()->checkKeyExists( $v ) )
if ( Member::loggedIn()->language()->checkKeyExists( $v ) )
{
$descriptions[ $k ] = \IPS\Member::loggedIn()->language()->addToStack( $v );
$descriptions[ $k ] = Member::loggedIn()->language()->addToStack( $v );
}
}
@@ -47,11 +55,11 @@ class _WebhookSelector extends \IPS\Helpers\Form\CheckboxSet
/* If the value is NULL or an empty string, i.e. from a custom field, then we should not convert it into an array because the
value will evaluate to 0 with an == check and the first option in the checkbox set will always be selected erroneously */
if ( $this->options['unlimited'] === NULL and !\is_array( $value ) AND $value !== NULL AND $value !== '' )
if ( $this->options['unlimited'] === NULL and !is_array( $value ) AND $value !== NULL AND $value !== '' )
{
$value = array( $value );
}
return \IPS\Theme::i()->getTemplate( 'forms', 'core', 'admin' )->webhookselector( $this->name, $value, $this->required, $this->parseOptions(), $this->options['multiple'], $this->options['class'], $this->options['disabled'], $this->options['toggles'], NULL, $this->options['unlimited'], $this->options['unlimitedLang'], $this->options['unlimitedToggles'], $this->options['unlimitedToggleOn'], $descriptions, $this->options['impliedUnlimited'] );
return Theme::i()->getTemplate( 'forms', 'core', 'admin' )->webhookselector( $this->name, $value, $this->required, $this->parseOptions(), $this->options['multiple'], $this->options['class'], $this->options['disabled'], $this->options['toggles'], NULL, $this->options['unlimited'], $this->options['unlimitedLang'], $this->options['unlimitedToggles'], $this->options['unlimitedToggleOn'], $descriptions, $this->options['impliedUnlimited'] );
}
}