Added Video

This commit is contained in:
Deon George
2016-07-04 16:00:33 +10:00
parent ec4c7ae3d1
commit 3012004901
25 changed files with 1356 additions and 143 deletions

View File

@@ -10,41 +10,42 @@ trait Files
/**
* Get a list of files
*/
public function getFiles(array $option)
public function getFiles(array $option,$type)
{
// Make sure we got a directory or a file to import
if (is_null($option['file']) AND is_null($option['dir']))
abort(500,'Missing filename, please use --file= OR --dir=');
// Make sure we got a directory or a file to import
if (is_null($option['file']) AND is_null($option['dir']))
abort(500,'Missing filename, please use --file= OR --dir=');
Log::info(sprintf('%s: Processing: %s',__METHOD__,($option['file'] ? $option['file'] : $option['dir'])));
Log::info(sprintf('%s: Processing: %s',__METHOD__,($option['file'] ? $option['file'] : $option['dir'])));
$files = [];
$files = [];
$dir = '';
if ($option['dir'])
{
// Remove our trailing slash from the directory.
$dir = preg_replace('/\/$/','',$option['dir']);
if ($option['dir'])
{
// Remove our trailing slash from the directory.
$dir = preg_replace('/\/$/','',$option['dir']);
// Exclude . & .. from the path.
$files = array_diff(scandir($dir),array('.','..'));
// Exclude . & .. from the path.
$files = array_diff(scandir($dir),array('.','..'));
}
elseif ($option['file'])
{
$dir = dirname($option['file']);
$files = array(basename($option['file']));
}
}
elseif ($option['file'] AND file_exists($option['file']))
{
$dir = dirname($option['file']);
$files = array(basename($option['file']));
}
// Determine if our dir is releative to where we store data
$dir = Photo::path($dir);
// Determine if our dir is releative to where we store data
$dir = static::path($dir,$type);
// Add our path
if ($dir)
array_walk($files,function(&$value,$key,$path='') {
if ($path) {
$value = sprintf('%s/%s',$path,$value);
}
},$dir);
// Add our path
if ($dir)
array_walk($files,function(&$value,$key,$path='') {
if ($path) {
$value = sprintf('%s/%s',$path,$value);
}
},$dir);
return $files;
}
@@ -58,5 +59,10 @@ trait Files
return FALSE;
else
return is_writable(dirname($dir)) AND mkdir($dir);
}
}
public static function path($path,$type)
{
return (strpos($path,config($type.'.dir').'/') === 0) ? str_replace(config($type.'.dir').'/','',$path) : $path;
}
}