function __construct($path = '', $parents = array()) { if (!isset($path) || $path == '' || !file_exists($path)) { return; } $this->local_path = $path; $this->parents = $parents; $this->last_modified = filemtime($path); $this->name = DauxHelper::pathinfo($path); $this->name = $this->name['filename']; $this->title = DauxHelper::get_title_from_file($this->name); $this->uri = DauxHelper::get_url_from_filename($this->name); $this->index_page = false; if (is_dir($path)) { $this->type = Directory_Entry::DIRECTORY_TYPE; $this->value = array(); } else { $this->type = Directory_Entry::FILE_TYPE; $this->value = $this->uri; } }
private function get_page_params($mode = '') { $params = array(); $params['local_base'] = $this->local_base; if ($mode === '') { $mode = $this->mode; } $params['mode'] = $mode; switch ($mode) { case ErrorPage::FATAL_ERROR_TYPE: $params['error_type'] = ErrorPage::FATAL_ERROR_TYPE; break; case ErrorPage::NORMAL_ERROR_TYPE: $params['error_type'] = ErrorPage::NORMAL_ERROR_TYPE; $params['index_key'] = 'index'; $params['docs_path'] = $this->docs_path; $protocol = !empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' || $_SERVER['SERVER_PORT'] == 443 ? 'https://' : 'http://'; $params['base_url'] = $protocol . $this->base_url . '/'; $params['base_page'] = $params['base_url']; $params['host'] = $this->host; $params['tree'] = $this->tree; $params['index'] = $this->tree->index_page !== false ? $this->tree->index_page : $this->tree->first_page; $params['tagline'] = $this->options['tagline']; $params['title'] = $this->options['title']; $params['author'] = $this->options['author']; $params['image'] = $this->options['image']; if ($params['image'] !== '') { $params['image'] = str_replace('<base_url>', $params['base_url'], $params['image']); } $params['repo'] = $this->options['repo']; $params['links'] = $this->options['links']; $params['twitter'] = $this->options['twitter']; $params['google_analytics'] = ($g = $this->options['google_analytics']) ? DauxHelper::google_analytics($g, $this->host) : ''; $params['piwik_analytics'] = ($p = $this->options['piwik_analytics']) ? DauxHelper::piwik_analytics($p, $this->options['piwik_analytics_id']) : ''; $params['theme'] = DauxHelper::configure_theme($this->local_base . DIRECTORY_SEPARATOR . 'themes' . DIRECTORY_SEPARATOR . $this->options['theme'] . '.thm', $params['base_url'], $params['local_base']); break; case Daux::LIVE_MODE: $params['docs_path'] = $this->docs_path; $params['index_key'] = 'index'; $protocol = !empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' || $_SERVER['SERVER_PORT'] == 443 ? 'https://' : 'http://'; $params['base_url'] = $protocol . $this->base_url . '/'; $params['base_page'] = $params['base_url']; $params['host'] = $this->host; $params['tree'] = $this->tree; $params['index'] = $this->tree->index_page !== false ? $this->tree->index_page : $this->tree->first_page; $params['tagline'] = $this->options['tagline']; $params['title'] = $this->options['title']; $params['author'] = $this->options['author']; $params['image'] = $this->options['image']; if ($params['image'] !== '') { $params['image'] = str_replace('<base_url>', $params['base_url'], $params['image']); } $params['repo'] = $this->options['repo']; $params['links'] = $this->options['links']; $params['twitter'] = $this->options['twitter']; $params['google_analytics'] = ($g = $this->options['google_analytics']) ? DauxHelper::google_analytics($g, $this->host) : ''; $params['piwik_analytics'] = ($p = $this->options['piwik_analytics']) ? DauxHelper::piwik_analytics($p, $this->options['piwik_analytics_id']) : ''; $params['theme'] = DauxHelper::configure_theme($this->local_base . DIRECTORY_SEPARATOR . 'themes' . DIRECTORY_SEPARATOR . $this->options['theme'] . '.thm', $params['base_url'], $params['local_base'], $mode); if ($params['breadcrumbs'] = $this->options['breadcrumbs']) { $params['breadcrumb_separator'] = $this->options['breadcrumb_separator']; } $params['multilanguage'] = !empty($this->options['languages']); $params['languages'] = $this->options['languages']; if (empty($this->options['languages'])) { $params['entry_page'] = $this->tree->first_page; } else { foreach ($this->options['languages'] as $key => $name) { $params['entry_page'][$key] = $this->tree->value[$key]->first_page; } } $params['toggle_code'] = $this->options['toggle_code']; $params['float'] = $this->options['float']; $params['date_modified'] = $this->options['date_modified']; $params['file_editor'] = $this->options['file_editor']; break; case Daux::STATIC_MODE: $params['docs_path'] = $this->docs_path; $params['index_key'] = 'index.html'; $params['base_url'] = ''; $params['base_page'] = $params['base_url']; $params['tree'] = $this->tree; $params['index'] = $this->tree->index_page !== false ? $this->tree->index_page : $this->tree->first_page; $params['tagline'] = $this->options['tagline']; $params['title'] = $this->options['title']; $params['author'] = $this->options['author']; $params['image'] = $this->options['image']; $params['repo'] = $this->options['repo']; $params['links'] = $this->options['links']; $params['twitter'] = $this->options['twitter']; $params['google_analytics'] = ($g = $this->options['google_analytics']) ? DauxHelper::google_analytics($g, $this->host) : ''; $params['piwik_analytics'] = ($p = $this->options['piwik_analytics']) ? DauxHelper::piwik_analytics($p, $this->options['piwik_analytics_id']) : ''; $params['theme'] = DauxHelper::configure_theme($this->local_base . DIRECTORY_SEPARATOR . 'themes' . DIRECTORY_SEPARATOR . $this->options['theme'] . '.thm', $params['base_url'], $params['local_base'], $mode); if ($params['breadcrumbs'] = $this->options['breadcrumbs']) { $params['breadcrumb_separator'] = $this->options['breadcrumb_separator']; } $params['multilanguage'] = !empty($this->options['languages']); $params['languages'] = $this->options['languages']; if (empty($this->options['languages'])) { $params['entry_page'] = $this->tree->first_page; } else { foreach ($this->options['languages'] as $key => $name) { $params['entry_page'][$key] = $this->tree->value[$key]->first_page; } } $params['toggle_code'] = $this->options['toggle_code']; $params['float'] = $this->options['float']; $params['date_modified'] = $this->options['date_modified']; $params['file_editor'] = false; break; } return $params; }
/** * @dataProvider providerGetFilenames */ public function testGetFilenames($expected, $node) { $config = new Config(); $config['valid_content_extensions'] = ['md']; $this->assertEquals($expected, DauxHelper::getFilenames($config, $node)); }