Mediamanager\Controller\Mediamanager::ls PHP Метод

ls() защищенный Метод

protected ls ( )
    protected function ls()
    {
        $data = array("folders" => array(), "files" => array());
        $toignore = ['.svn', '_svn', 'cvs', '_darcs', '.arch-params', '.monotone', '.bzr', '.git', '.hg', '.ds_store', '.thumb'];
        if ($path = $this->param("path", false)) {
            $dir = $this->root . '/' . trim($path, '/');
            $data["path"] = $dir;
            if (file_exists($dir)) {
                foreach (new \DirectoryIterator($dir) as $file) {
                    if ($file->isDot()) {
                        continue;
                    }
                    $filename = $file->getFilename();
                    if ($filename[0] == '.' && in_array(strtolower($filename), $toignore)) {
                        continue;
                    }
                    $isDir = $file->isDir();
                    $data[$file->isDir() ? "folders" : "files"][] = array("is_file" => !$isDir, "is_dir" => $isDir, "is_writable" => is_writable($file->getPathname()), "name" => $filename, "path" => trim($path . '/' . $file->getFilename(), '/'), "url" => $this->app->pathToUrl($file->getPathname()), "size" => $isDir ? "" : $this->app->helper("utils")->formatSize($file->getSize()), "ext" => $isDir ? "" : strtolower($file->getExtension()), "lastmodified" => $file->isDir() ? "" : date("d.m.y H:i", $file->getMTime()));
                }
            }
        }
        return json_encode($data);
    }