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

+16 -5
View File
@@ -11,7 +11,7 @@
namespace IPS\File;
/* 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;
@@ -41,6 +41,12 @@ class _Iterator extends \IteratorIterator implements \Countable
* @brief Used to restore 'real' names when filenames cleaned (eg adh1029_file.php back to fi^le.php)
*/
protected $replaceNameField;
/**
* @brief Used to pre-cache the filesize value if available
*/
protected $fileSizeField;
/**
* Constructor
@@ -48,15 +54,18 @@ class _Iterator extends \IteratorIterator implements \Countable
* @param Traversable $iterator The iterator
* @param string $storageExtension The storage extension
* @param string|NULL $urlField If passed a string, will look for an element with that key in the data returned from the iterator
* @param bool $fileUrlsOnly Only return the file URL instead of the file object
* @param string|NULL $replaceNameField If passed a string, it will replace the originalFilename with the data in the array. Used to restore 'real' names when filenames cleaned (eg adh1029_file.php back to fi^le.php)
* @param string $fileSizeField Field to use to pre-cache the filesize
* @return void
*/
public function __construct( \Traversable $iterator, $storageExtension, $urlField=NULL, $fileUrlsOnly=FALSE, $replaceNameField=NULL )
public function __construct( \Traversable $iterator, $storageExtension, $urlField=NULL, $fileUrlsOnly=FALSE, $replaceNameField=NULL, $fileSizeField=NULL )
{
$this->storageExtension = $storageExtension;
$this->urlField = $urlField;
$this->fileUrlsOnly = $fileUrlsOnly;
$this->replaceNameField = $replaceNameField;
$this->fileSizeField = $fileSizeField;
return parent::__construct( $iterator );
}
@@ -74,9 +83,10 @@ class _Iterator extends \IteratorIterator implements \Countable
if ( $this->urlField )
{
if ( !is_string( $this->urlField ) and is_callable( $this->urlField ) )
if ( !\is_string( $this->urlField ) and \is_callable( $this->urlField ) )
{
$urlField = call_user_func( $this->urlField, $data );
$urlFieldCallback = $this->urlField;
$urlField = $urlFieldCallback( $data );
}
else
{
@@ -84,7 +94,8 @@ class _Iterator extends \IteratorIterator implements \Countable
}
}
$obj = \IPS\File::get( $this->storageExtension, $urlField ? $data[ $urlField ] : $data );
$fileSize = ( $this->fileSizeField AND !empty( $data[ $this->fileSizeField ] ) ) ? $data[ $this->fileSizeField ] : ( $this->fileSizeField === FALSE ? FALSE : NULL );
$obj = \IPS\File::get( $this->storageExtension, $urlField ? $data[ $urlField ] : $data, $fileSize );
if ( $this->replaceNameField and ! empty( $data[ $this->replaceNameField ] ) )
{