/** * Reads from the filesystem with extra options * @param zibo\library\filesystem\File $path The path of the directory to read * @param array $filters Array with filters * @param boolean $recursive Set to true to read recursivly * @return array Array with the directories and files of the provided path */ public function readDirectory(File $path = null, array $filters = array(), $recursive = false) { $path = new File($this->root, $path); if (!$path->exists()) { throw new FileSystemException($path->getPath() . ' does not exist'); } if (!$path->isDirectory()) { throw new FileSystemException($path->getPath() . ' is not a directory'); } if (!$path->isReadable()) { throw new FileSystemException($path->getPath() . ' is not readable'); } $paths = array(); $files = $path->read($recursive); foreach ($files as $file) { $path = $this->getPath($file, false); $paths[$path->getPath()] = $path; } if ($filters) { $paths = $this->applyFilters($paths, $filters); } return $paths; }
/** * Read models from a path in the Zibo file system structure. * @param zibo\library\filesystem\File $path path in the Zibo file system structure (eg. ./modules/zibo.orm.country or ./application) * @return array Array with Model instances */ public function readModelsFromPath(File $path) { $file = new File($path, self::FILE_MODELS); if (!$file->exists() || !$file->isReadable()) { return array(); } return $this->readModelsFromFile($file); }
/** * Get the available themes based on the existance of the theme directory * @param string $themesDirectory name of the theme directory in the view directory (optional) * @return array Array with the names of the available themes */ public static function getThemes($themesDirectory = null) { if ($themesDirectory === null) { $themesDirectory = self::DEFAULT_THEMES_DIRECTORY; } $themes = array(); $includePaths = Zibo::getInstance()->getIncludePaths(); $viewPath = new File(Zibo::DIRECTORY_VIEW, $themesDirectory); foreach ($includePaths as $includePath) { $themesPath = new File($includePath, $viewPath); if ($themesPath->exists() && $themesPath->isDirectory() && $themesPath->isReadable()) { $themesFiles = $themesPath->read(); foreach ($themesFiles as $themesFile) { if ($themesFile->isDirectory() && $themesFile->isReadable()) { $name = $themesFile->getName(); $themes[$name] = $name; } } } } return $themes; }