Ip\Internal\Repository\BrowserModel::getAvailableFiles PHP Метод

getAvailableFiles() публичный Метод

Get list of files for file browser
public getAvailableFiles ( integer $seek, integer $limit, string $filter, $filterExtensions, boolean $secure = false, $subdir = null ) : array
$seek integer
$limit integer
$filter string
$secure boolean use secure folder instead of repository root
Результат array
    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;
    }