Version 4.7.8

This commit is contained in:
Neo committed 2025-12-19 16:10:42 -08:00
1 parent 7b7404e741
commit fd22d99e69
688 files changed
+19814 -10890

No files matched your search

+2 -1
View File
@@ -39,6 +39,7 @@ class _CheckboxSet extends Select
{
$options['multiple'] = TRUE;
$options['showAllNone'] = $options['showAllNone'] ?? TRUE;
$options['condense'] = $options['condense'] ?? TRUE;
parent::__construct( $name, $defaultValue, $required, $options, $customValidationCode, $prefix, $suffix, $id );
if ( !isset( $this->options['descriptions'] ) )
@@ -93,7 +94,7 @@ class _CheckboxSet extends Select
$value = array( $value );
}
return \IPS\Theme::i()->getTemplate( 'forms', 'core', 'global' )->checkboxset( $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'], $this->options['showAllNone'] );
return \IPS\Theme::i()->getTemplate( 'forms', 'core', 'global' )->checkboxset( $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'], $this->options['showAllNone'], $this->options['condense'] );
}
/**
+22 -2
View File
@@ -290,15 +290,35 @@ class _Date extends FormAbstract
}
/* Check minimum */
try
{
$timezone = $this->options['timezone'] ?: ( \IPS\Member::loggedIn()->timezone ? new \DateTimeZone( \IPS\Member::loggedIn()->timezone ) : NULL );
}
catch ( \Exception $e )
{
$timezone = NULL;
}
if ( $this->value and $this->options['min'] !== NULL and $this->options['min'] > $this->value )
{
throw new \LengthException( \IPS\Member::loggedIn()->language()->addToStack('form_date_min', FALSE, array( 'sprintf' => array( $this->options['min']->localeDate() ) ) ) );
$string = $this->options['min']->setTimeZone( $timezone )->localeDate( \IPS\Member::loggedIn() );
if( $this->options['time'] )
{
$string .=' ' . $this->options['min']->setTimeZone( $timezone )->localeTime( \IPS\Member::loggedIn() );
}
throw new \LengthException( \IPS\Member::loggedIn()->language()->addToStack('form_date_min', FALSE, array( 'sprintf' => array( $string ) ) ) );
}
/* Check maximum */
if ( $this->value and $this->options['max'] !== NULL and $this->options['max'] < $this->value )
{
throw new \LengthException( \IPS\Member::loggedIn()->language()->addToStack('form_date_max', FALSE, array( 'sprintf' => array( $this->options['max']->localeDate() ) ) ) );
$string = $this->options['max']->setTimeZone( $timezone )->localeDate( \IPS\Member::loggedIn() );
if( $this->options['time'] )
{
$string .=' ' . $this->options['max']->setTimeZone( $timezone )->localeTime( \IPS\Member::loggedIn() );
}
throw new \LengthException( \IPS\Member::loggedIn()->language()->addToStack('form_date_max', FALSE, array( 'sprintf' => array( $string ) ) ) );
}
return TRUE;
+5 -2
View File
@@ -95,8 +95,11 @@ class _DateRange extends FormAbstract
*/
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() );
$startOptions = isset( $options['start'] ) ? array_merge( $this->defaultOptions['start'], $options['start'] ) : $this->defaultOptions['start'];
$this->start = new \IPS\Helpers\Form\Date( "{$name}[start]", isset( $defaultValue['start'] ) ? $defaultValue['start'] : NULL, FALSE, $startOptions );
$endOptions = isset( $options['end'] ) ? array_merge( $this->defaultOptions['end'], $options['end'] ) : $this->defaultOptions['end'];
$this->end = new \IPS\Helpers\Form\Date( "{$name}[end]", isset( $defaultValue['end'] ) ? $defaultValue['end'] : NULL, FALSE, $endOptions );
$this->unlimitedName = "{$name}_unlimited";
parent::__construct( $name, $defaultValue, $required, $options, $customValidationCode, $prefix, $suffix, $id );
+7 -1
View File
@@ -27,6 +27,7 @@ class _Poll extends FormAbstract
* @code
$defaultOptions = array(
'allowPollOnly' => TRUE, // Controls if "Allow poll only" option is allowed (if the admin has enabled it)
'itemClass' => NULL, // The content item class attached to this poll
);
* @endcode
*/
@@ -103,8 +104,13 @@ EOF;
{
$poll = new \IPS\Poll;
$poll->starter_id = \IPS\Member::loggedIn()->member_id;
if( isset( $this->options['itemClass'] ) )
{
$poll->poll_item_class = $this->options['itemClass'];
}
}
/* Set values */
$data = parent::getValue();
if ( !isset( $data['questions'] ) )
+19 -29
View File
@@ -232,9 +232,7 @@ class _Upload extends FormAbstract
/* If this is the LAST chunk, finish the process */
if ( \IPS\Request::i()->chunk == \IPS\Request::i()->chunks - 1 )
{
$url = $storageClass->chunkFinish( $ref );
$fileObj = \IPS\File::get( $this->options['storageExtension'], $url );
$fileObj = $storageClass->chunkFinish( $ref, $this->options['storageExtension'] );
$fileArray = array(
'error' => NULL,
@@ -247,24 +245,21 @@ class _Upload extends FormAbstract
/* If there is an error, an exception will be thrown and will be caught below like normal */
\IPS\File::validateUpload( $fileArray, $this->options['allowedFileTypes'], $this->options['maxFileSize'] );
if ( $fileObj->isImage() AND ( $this->options['checkImage'] OR \is_array( $this->options['image'] ) ) )
if ( $fileObj->isImage() )
{
try
{
$image = \IPS\Image::create( $fileObj->contents() );
$image = \IPS\Image::create( $fileObj->contents(), $this->options['checkImage'] ?: TRUE );
if( $image::exifSupported() )
{
$image->setExifData( $fileObj->contents() );
}
$hasBeenResized = FALSE;
if( \is_array( $this->options['image'] ) )
{
$hasBeenResized = $image->resizeToMax( $this->options['image']['maxWidth'] ?: NULL, $this->options['image']['maxHeight'] ?: NULL );
}
if ( $hasBeenResized or $image->hasBeenRotated )
$hasBeenResized = $image->resizeToMax( $this->options['image']['maxWidth'] ?? NULL, $this->options['image']['maxHeight'] ?? NULL );
/* If type JPG, image handler may strip meta data on image output */
if( $hasBeenResized OR $image->hasBeenRotated OR $image->type == 'jpeg' )
{
$fileObj->replace( (string) $image );
}
@@ -487,7 +482,7 @@ class _Upload extends FormAbstract
{
/* Get the files we had already */
$return = array();
$tempFiles = iterator_to_array( \IPS\Db::i()->select( 'id,contents,filename,exif,requires_moderation', 'core_files_temp', array( 'upload_key=?', md5( $this->name . session_id() ) ) )->setKeyField('id') );
$tempFiles = iterator_to_array( \IPS\Db::i()->select( 'id,contents,filename,exif,requires_moderation,labels', 'core_files_temp', array( 'upload_key=?', md5( $this->name . session_id() ) ) )->setKeyField('id') );
if ( $this->options['storageExtension'] )
{
$existingName = $this->name . '_existing';
@@ -507,6 +502,7 @@ class _Upload extends FormAbstract
$file->originalFilename = $tempFiles[ $tempId ]['filename'];
$file->exifData = $tempFiles[ $tempId ]['exif'] ? json_decode( $tempFiles[ $tempId ]['exif'], TRUE ) : NULL;
$file->requiresModeration = (bool) $tempFiles[ $tempId ]['requires_moderation'];
$file->labels = $tempFiles[ $tempId ]['labels'];
$return[ $id ] = $file;
}
else
@@ -735,25 +731,19 @@ class _Upload extends FormAbstract
{
/* Resize */
$image = NULL;
$hasBeenResized = FALSE;
if ( \is_array( $options['image'] ) OR $options['checkImage'] )
try
{
try
$image = \IPS\Image::create( $contents, $options['checkImage'] ?: TRUE );
$hasBeenResized = $image->resizeToMax( $options['image']['maxWidth'] ?? NULL, $options['image']['maxHeight'] ?? NULL );
/* If type JPG, image handler may strip meta data on image output */
if( $hasBeenResized OR $image->hasBeenRotated OR $image->type == 'jpeg' )
{
$image = \IPS\Image::create( $contents );
if( \is_array( $options['image'] ) )
{
$hasBeenResized = $image->resizeToMax( $options['image']['maxWidth'] ?: NULL, $options['image']['maxHeight'] ?: NULL );
}
if ( $hasBeenResized or $image->hasBeenRotated )
{
$contents = (string) $image;
}
$contents = (string) $image;
}
catch ( \Exception $e ) {}
}
catch ( \Exception $e ) {}
}
return $contents;
+24
View File
@@ -253,6 +253,10 @@ class _Content extends Table
}
}
/* Make sure we initialize the default sort fields so that we can properly get the column sort direction */
$this->defaultSortBy = $this->sortBy;
$this->defaultSortDirection = $this->sortDirection;
/* Do any multi-mod */
if ( isset( \IPS\Request::i()->modaction ) )
{
@@ -1061,4 +1065,24 @@ class _Content extends Table
{
return $this->container;
}
/**
* Return the sort direction to use for links
*
* @note Abstracted so other table helper instances can adjust as needed
* @param string $column Sort by string
* @return string [asc|desc]
*/
public function getSortDirection( $column )
{
$class = $this->class;
/* ID and Title columns should be ascending */
if( $column != $this->defaultSortBy AND ( $column == $class::$databaseColumnId OR $column == $class::$databaseColumnMap[ 'title' ] ) )
{
return 'asc';
}
return parent::getSortDirection( $column );
}
}
+16
View File
@@ -65,6 +65,16 @@ abstract class _Table
* @brief Columns that are not sortable
*/
public $noSort = array();
/**
* @brief Default column to sort results by
*/
public $defaultSortBy;
/**
* @brief Default sort direction - "asc" or "desc"
*/
public $defaultSortDirection = NULL;
/**
* @brief Filters
@@ -770,6 +780,12 @@ abstract class _Table
*/
public function getSortDirection( $column )
{
/* If the column we are sorting by is the default sort, use the default sort direction */
if ( $this->defaultSortBy AND $column == $this->defaultSortBy AND $this->defaultSortDirection )
{
return $this->defaultSortDirection;
}
if( $column == 'title' )
{
return 'asc';