/** * Create a new documentation parser for the given path * * @param string $path Path to the documentation * * @throws DocException If the documentation directory does not exist * @throws NotReadableError If the documentation directory is not readable */ public function __construct($path) { if (!DirectoryIterator::isReadable($path)) { throw new DocException(mt('doc', 'Documentation directory \'%s\' is not readable'), $path); } $this->path = $path; $this->docIterator = new DirectoryIterator($path, 'md', DirectoryIterator::FILES_FIRST); }
/** * Get themes provided by Web 2 and all enabled modules * * @return string[] Array of theme names as keys and values */ public function getThemes() { $themes = array(StyleSheet::DEFAULT_THEME); $applicationThemePath = $this->getBaseDir('public/css/themes'); if (DirectoryIterator::isReadable($applicationThemePath)) { foreach (new DirectoryIterator($applicationThemePath, 'less') as $name => $theme) { $themes[] = substr($name, 0, -5); } } $mm = $this->getModuleManager(); foreach ($mm->listEnabledModules() as $moduleName) { $moduleThemePath = $mm->getModule($moduleName)->getCssDir() . '/themes'; if (!DirectoryIterator::isReadable($moduleThemePath)) { continue; } foreach (new DirectoryIterator($moduleThemePath, 'less') as $name => $theme) { $themes[] = $moduleName . '/' . substr($name, 0, -5); } } return array_combine($themes, $themes); }