Version 4.1.19
This commit is contained in:
1 parent
28bd025b35
commit
2bd5025018
2674 files changed
+233518
-77766
No files matched your search
@@ -2,9 +2,9 @@
|
||||
/**
|
||||
* @brief File IteratorIterator
|
||||
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
|
||||
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/legal/standards/
|
||||
* @package IPS Social Suite
|
||||
* @package IPS Community Suite
|
||||
* @since 10 Oct 2013
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
@@ -38,19 +38,26 @@ class _Iterator extends \IteratorIterator implements \Countable
|
||||
*/
|
||||
protected $fileUrlsOnly;
|
||||
|
||||
/**
|
||||
* @brief Used to restore 'real' names when filenames cleaned (eg adh1029_file.php back to fi^le.php)
|
||||
*/
|
||||
protected $replaceNameField;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @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 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)
|
||||
* @return void
|
||||
*/
|
||||
public function __construct( \Traversable $iterator, $storageExtension, $urlField=NULL, $fileUrlsOnly=FALSE )
|
||||
public function __construct( \Traversable $iterator, $storageExtension, $urlField=NULL, $fileUrlsOnly=FALSE, $replaceNameField=NULL )
|
||||
{
|
||||
$this->storageExtension = $storageExtension;
|
||||
$this->urlField = $urlField;
|
||||
$this->fileUrlsOnly = $fileUrlsOnly;
|
||||
$this->replaceNameField = $replaceNameField;
|
||||
return parent::__construct( $iterator );
|
||||
}
|
||||
|
||||
@@ -64,7 +71,27 @@ class _Iterator extends \IteratorIterator implements \Countable
|
||||
try
|
||||
{
|
||||
$data = $this->data();
|
||||
$obj = \IPS\File::get( $this->storageExtension, $this->urlField ? $data[ $this->urlField ] : $data );
|
||||
$urlField = NULL;
|
||||
|
||||
if ( $this->urlField )
|
||||
{
|
||||
if ( !is_string( $this->urlField ) and is_callable( $this->urlField ) )
|
||||
{
|
||||
$urlField = call_user_func( $this->urlField, $data );
|
||||
}
|
||||
else
|
||||
{
|
||||
$urlField = $this->urlField;
|
||||
}
|
||||
}
|
||||
|
||||
$obj = \IPS\File::get( $this->storageExtension, $urlField ? $data[ $urlField ] : $data );
|
||||
|
||||
if ( $this->replaceNameField and ! empty( $data[ $this->replaceNameField ] ) )
|
||||
{
|
||||
$obj->originalFilename = $data[ $this->replaceNameField ];
|
||||
}
|
||||
|
||||
return ( $this->fileUrlsOnly ) ? (string) $obj->url : $obj;
|
||||
}
|
||||
catch ( \Exception $e )
|
||||
|
||||
Reference in new issue
Block a user