public function getAvailableFiles($seek, $limit, $filter, $filterExtensions, $secure = false, $subdir = null)
{
$answer = array();
if ($subdir && substr($subdir, -1) != '/') {
$subdir .= '/';
}
$repositoryDir = $this->getPath($secure, $subdir);
$iterator = new \DirectoryIterator($repositoryDir);
$iterator->seek($seek);
while ($iterator->valid() && count($answer) < $limit) {
if ($iterator->isFile()) {
$fileData = $this->getFileData($iterator->getFilename(), $secure, $subdir);
$append = null;
switch ($filter) {
case 'image':
if (in_array($fileData['ext'], $this->supportedImageExtensions)) {
$append = $fileData;
}
break;
default:
$append = $fileData;
break;
}
if ($filterExtensions && !in_array($fileData['ext'], $filterExtensions)) {
$append = null;
}
if ($append) {
$answer[] = $append;
}
}
$iterator->next();
}
return $answer;
}