Version 4.5.0

This commit is contained in:
Neo committed 2025-12-19 05:51:58 -08:00
1 parent 1a0c7fd3c2
commit f79dcf067a
3791 files changed
+248032 -76372

No files matched your search

+48 -8
View File
@@ -11,7 +11,7 @@
namespace IPS\Helpers\Form;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
@@ -29,6 +29,11 @@ class _DateRange extends FormAbstract
$defaultOptions = array(
'start' => array( ... ),
'end' => array( ... ),
'unlimited' => -1, // If any value other than NULL is provided, an "Unlimited" checkbox will be displayed. If checked, the value specified will be sent.
'unlimitedLang' => 'unlimited', // Language string to use for unlimited checkbox label
'unlimitedToggles' => array(...), // Names of other input fields that should show/hide when the "Unlimited" checkbox is toggled.
'unlimitedToggleOn' => TRUE, // Whether the toggles should show on unlimited TRUE or FALSE. Default is TRUE.
'unlimitedChecked' => FALSE, // Whether the unlimited checkbox should be checked by default. Default is FALSE.
);
* @endcode
*/
@@ -53,6 +58,11 @@ class _DateRange extends FormAbstract
'unlimitedToggles' => array(),
'unlimitedToggleOn' => TRUE,
),
'unlimited' => NULL,
'unlimitedLang' => 'no_date_range_restriction',
'unlimitedToggles' => array(),
'unlimitedToggleOn' => TRUE,
'unlimitedChecked' => FALSE
);
/**
@@ -64,20 +74,32 @@ class _DateRange extends FormAbstract
* @brief End Date Object
*/
public $end = NULL;
/**
* @brief Name for unlimited checkbox
*/
public $unlimitedName = '';
/**
* Constructor
* Creates the two date objects
*
* @see \IPS\Helpers\Form\FormAbstract::__construct
* @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
*/
public function __construct( $name, $defaultValue=NULL, $required=FALSE, $options=array() )
public function __construct( $name, $defaultValue=NULL, $required=FALSE, $options=array(), $customValidationCode=NULL, $prefix=NULL, $suffix=NULL, $id=NULL )
{
$this->start = new \IPS\Helpers\Form\Date( "{$name}[start]", isset( $defaultValue['start'] ) ? $defaultValue['start'] : NULL, FALSE, isset( $options['start'] ) ? $options['start'] : array() );
$this->end = new \IPS\Helpers\Form\Date( "{$name}[end]", isset( $defaultValue['end'] ) ? $defaultValue['end'] : NULL, FALSE, isset( $options['end'] ) ? $options['end'] : array() );
$this->unlimitedName = "{$name}_unlimited";
call_user_func_array( 'parent::__construct', func_get_args() );
parent::__construct( $name, $defaultValue, $required, $options, $customValidationCode, $prefix, $suffix, $id );
}
/**
@@ -93,7 +115,8 @@ class _DateRange extends FormAbstract
/**
* Format Value
*
* @return array
* @note Returns an array with keys 'start' and 'end' normally, but if using the unlimited checkbox option will return that value if checked
* @return mixed
*/
public function formatValue()
{
@@ -111,6 +134,13 @@ class _DateRange extends FormAbstract
$end->setTime( 23, 59, 59 );
}
/* Unlimited? */
$unlimitedName = $this->unlimitedName;
if ( $this->options['unlimited'] !== NULL and isset( \IPS\Request::i()->$unlimitedName ) )
{
return $this->options['unlimited'];
}
/* Return */
return array(
'start' => $start,
@@ -125,7 +155,16 @@ class _DateRange extends FormAbstract
*/
public function html()
{
return \IPS\Theme::i()->getTemplate( 'forms', 'core', 'global' )->dateRange( $this->start->html(), $this->end->html() );
return \IPS\Theme::i()->getTemplate( 'forms', 'core', 'global' )->dateRange(
$this->start->html(),
$this->end->html(),
$this->options['unlimited'],
$this->options['unlimitedLang'],
$this->unlimitedName,
$this->options['unlimitedChecked'],
$this->options['unlimitedToggles'],
$this->options['unlimitedToggleOn']
);
}
/**
@@ -147,7 +186,8 @@ class _DateRange extends FormAbstract
if( $this->customValidationCode !== NULL )
{
call_user_func( $this->customValidationCode, $this->value );
$validationFunction = $this->customValidationCode;
$validationFunction( $this->value );
}
}
}