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,21 +11,29 @@
namespace IPS\Helpers\Form;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
use DomainException;
use InvalidArgumentException;
use IPS\Output;
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;
}
/**
* Sort items input class for Form Builder
*/
class _Sort extends FormAbstract
class Sort extends FormAbstract
{
/**
* @brief Default Options
*/
protected $defaultOptions = array(
protected array $defaultOptions = array(
'checkboxes' => NULL
);
@@ -34,29 +42,29 @@ class _Sort extends FormAbstract
*
* @return string
*/
public function html()
public function html(): string
{
\IPS\Output::i()->jsFiles = array_merge( \IPS\Output::i()->jsFiles, \IPS\Output::i()->js( 'jquery/jquery-ui.js', 'core', 'interface' ) );
\IPS\Output::i()->jsFiles = array_merge( \IPS\Output::i()->jsFiles, \IPS\Output::i()->js( 'jquery/jquery-touchpunch.js', 'core', 'interface' ) );
\IPS\Output::i()->jsFiles = array_merge( \IPS\Output::i()->jsFiles, \IPS\Output::i()->js( 'jquery/jquery.menuaim.js', 'core', 'interface' ) );
Output::i()->jsFiles = array_merge( Output::i()->jsFiles, Output::i()->js( 'jquery/jquery-ui.js', 'core', 'interface' ) );
Output::i()->jsFiles = array_merge( Output::i()->jsFiles, Output::i()->js( 'jquery/jquery-touchpunch.js', 'core', 'interface' ) );
Output::i()->jsFiles = array_merge( Output::i()->jsFiles, Output::i()->js( 'jquery/jquery.menuaim.js', 'core', 'interface' ) );
return \IPS\Theme::i()->getTemplate( 'forms', 'core', 'global' )->sort( $this->name, $this->value, $this->options );
return Theme::i()->getTemplate( 'forms', 'core', 'global' )->sort( $this->name, $this->value, $this->options );
}
/**
* Validate
*
* @throws \InvalidArgumentException
* @throws InvalidArgumentException
* @return TRUE
*/
public function validate()
public function validate(): bool
{
if ( array_diff( array_keys( $this->value ), array_keys( $this->defaultValue ) ) or array_diff( array_keys( $this->defaultValue ), array_keys( $this->value ) ) )
{
throw new \DomainException('form_bad_value');
throw new DomainException('form_bad_value');
}
parent::validate();
return parent::validate();
}
/**
@@ -64,21 +72,18 @@ class _Sort extends FormAbstract
*
* @return mixed
*/
public function getValue()
public function getValue(): mixed
{
$value = parent::getValue();
$checkboxName = preg_replace( '/^(.+?\[?.+?)(\])?$/', '$1_checkboxes$2', $this->name );
if ( $this->options['checkboxes'] and \IPS\Request::i()->$checkboxName )
if ( $this->options['checkboxes'] and Request::i()->$checkboxName )
{
foreach ( $value as $k => $v )
{
$value[ $k ] = isset( \IPS\Request::i()->$checkboxName[ $k ] );
$value[ $k ] = isset( Request::i()->$checkboxName[ $k ] );
}
return $value;
}
else
{
return $value;
}
return $value;
}
}