/** * Find previous file in current chapter * * @return array */ public function findPrevious() { if (!isset($this->cache['docbook_previous'])) { $this->cache['docbook_previous'] = null; $filepath = $this->getPathname(); if ($this->isLink() || $this->isRootLink()) { $filepath = DirectoryHelper::slashDirname($this->getWebPath()) . $this->getFilename(); } $dir_realpath = dirname(realpath($filepath)); $dir_targetpath = dirname($filepath); if (empty($dir_realpath)) { $dir_realpath = $dir_targetpath; } $dir = new FilesystemIterator($dir_realpath, FilesystemIterator::CURRENT_AS_PATHNAME); $dir_table = iterator_to_array($dir, false); $i = array_search($this->getRealPath(), $dir_table); if (false !== $i) { $j = $i - 1; while ($j >= 0 && array_key_exists($j, $dir_table) && (is_dir($dir_table[$j]) && !Helper::isDirValid($dir_table[$j]) || !Helper::isFileValid($dir_table[$j]) || DirectoryHelper::isDotPath($dir_table[$j]) || Helper::isTranslationFile($dir_table[$j]))) { $j = $j - 1; } if ($j >= 0 && array_key_exists($j, $dir_table) && (is_dir($dir_table[$j]) && Helper::isDirValid($dir_table[$j]) || !is_dir($dir_table[$j]) && Helper::isFileValid($dir_table[$j]) && !Helper::isTranslationFile($dir_table[$j])) && !DirectoryHelper::isDotPath($dir_table[$j])) { $previous = new DocBookFile($dir_table[$j]); $this->cache['docbook_previous'] = $previous->getDocBookStack(); } } } return $this->cache['docbook_previous']; }
public static function dirValidation($file_path) { return Helper::isDirValid($file_path); $name = basename($file_path); return $name !== FrontController::DOCBOOK_ASSETS; }