1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-11 00:54:49 +02:00

Fixes related to Gallery image import, watermarks and thumbnails.

This commit is contained in:
CaMer0n
2012-07-14 10:40:40 +00:00
parent 8c497fcee1
commit 4cfe5c4387
12 changed files with 133 additions and 41 deletions

View File

@@ -122,6 +122,31 @@ class e_file
$this->fileFilter = $filter;
return $this;
}
/**
* Clean and rename file name
* @param $f array as returned by get_files();
* @param $rename boolean - set to true to rename file.
*/
public function cleanFileName($f,$rename=false)
{
$fullpath = $f['path'].$f['fname'];
$newfile = preg_replace("/[^a-z0-9-\.]/", "-", strtolower($f['fname']));
$newpath = $f['path'].$newfile;
if($rename == true)
{
if(!rename($fullpath,$newpath))
{
$f['error'] = "Couldn't rename $fullpath to $newpath";
}
}
$f['fname'] = $newfile;
return $f;
}
/**
* Read files from given path