mirror of
https://github.com/e107inc/e107.git
synced 2025-08-07 23:26:41 +02:00
file handler improvement - mode/finfo changes, getimagesize now optional, pathinfo added to info array - no more need of parsing fname for e.g. file extension (generic php pathinfo much more faster than anything we are currently using).
This commit is contained in:
@@ -9,8 +9,8 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* $Source: /cvs_backup/e107_0.8/e107_handlers/file_class.php,v $
|
* $Source: /cvs_backup/e107_0.8/e107_handlers/file_class.php,v $
|
||||||
* $Revision: 1.9 $
|
* $Revision: 1.10 $
|
||||||
* $Date: 2010-01-16 14:17:10 $
|
* $Date: 2010-02-05 11:13:38 $
|
||||||
* $Author: secretr $
|
* $Author: secretr $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -51,10 +51,26 @@ Note:
|
|||||||
|
|
||||||
class e_file
|
class e_file
|
||||||
{
|
{
|
||||||
var $dirFilter; // Array of directory names to ignore (in addition to any set by caller)
|
public $dirFilter; // Array of directory names to ignore (in addition to any set by caller)
|
||||||
var $fileFilter; // Array of file names to ignore (in addition to any set by caller)
|
public $fileFilter; // Array of file names to ignore (in addition to any set by caller)
|
||||||
var $mode = 'default';
|
|
||||||
var $finfo = 'default';
|
/**
|
||||||
|
* Defines what array format should return get_files() method
|
||||||
|
* If one of 'fname', 'path', 'full' - numerical array.
|
||||||
|
* If default - associative array (depends on $finfo value).
|
||||||
|
*
|
||||||
|
* @see get_files()
|
||||||
|
* @var string one of the following: default (BC) | fname | path | full
|
||||||
|
*/
|
||||||
|
public $mode = 'default';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Defines what info should gatter get_files method.
|
||||||
|
* Works only in 'default' mode.
|
||||||
|
*
|
||||||
|
* @var string default (BC) | image | file | all
|
||||||
|
*/
|
||||||
|
public $finfo = 'default';
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
function __construct()
|
function __construct()
|
||||||
@@ -146,7 +162,7 @@ class e_file
|
|||||||
}
|
}
|
||||||
if($rejected == FALSE)
|
if($rejected == FALSE)
|
||||||
{
|
{
|
||||||
switch($this->mode) //TODO remove this check from the loop.
|
switch($this->mode)
|
||||||
{
|
{
|
||||||
case 'fname':
|
case 'fname':
|
||||||
$ret[] = $file;
|
$ret[] = $file;
|
||||||
@@ -160,11 +176,11 @@ class e_file
|
|||||||
$ret[] = $path."/".$file;
|
$ret[] = $path."/".$file;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 'all':
|
||||||
default:
|
default:
|
||||||
|
if('default' != $this->finfo)
|
||||||
if($this->finfo == 'all')
|
|
||||||
{
|
{
|
||||||
$finfo = $this->get_file_info($path."/".$file);
|
$finfo = $this->get_file_info($path."/".$file, ('file' != $this->finfo)); // -> 'all' & 'image'
|
||||||
}
|
}
|
||||||
$finfo['path'] = $path."/"; // important: leave this slash here and update other file instead.
|
$finfo['path'] = $path."/"; // important: leave this slash here and update other file instead.
|
||||||
$finfo['fname'] = $file;
|
$finfo['fname'] = $file;
|
||||||
@@ -174,27 +190,31 @@ class e_file
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $ret;
|
return $ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_file_info($path_to_file)
|
function get_file_info($path_to_file, $imgcheck = true)
|
||||||
{
|
{
|
||||||
$finfo = array();
|
$finfo = array();
|
||||||
|
|
||||||
$tmp = getimagesize($path_to_file);
|
if($imgcheck && ($tmp = getimagesize($path_to_file)))
|
||||||
|
{
|
||||||
$finfo['img-width'] = $tmp[0];
|
$finfo['img-width'] = $tmp[0];
|
||||||
$finfo['img-height'] = $tmp[1];
|
$finfo['img-height'] = $tmp[1];
|
||||||
$finfo['mime'] = $tmp['mime'];
|
$finfo['mime'] = $tmp['mime'];
|
||||||
|
}
|
||||||
|
|
||||||
|
$tmp = stat($path_to_file);
|
||||||
|
if($tmp)
|
||||||
|
{
|
||||||
|
$finfo['fsize'] = $tmp['size'];
|
||||||
|
$finfo['modified'] = $tmp['mtime'];
|
||||||
|
}
|
||||||
|
|
||||||
$tmp2 = stat($path_to_file);
|
// associative array elements: dirname, basename, extension, filename
|
||||||
$finfo['fsize'] = $tmp2['size'];
|
$finfo['pathinfo'] = pathinfo($path_to_file);
|
||||||
$finfo['modified'] = $tmp2['mtime'];
|
|
||||||
|
|
||||||
return $finfo;
|
return $finfo;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user