diff --git a/resources/DirectoryLister.php b/resources/DirectoryLister.php index 20306ab..2d21823 100644 --- a/resources/DirectoryLister.php +++ b/resources/DirectoryLister.php @@ -233,17 +233,23 @@ class DirectoryLister { */ public function containsIndex($dirPath) { - // Check if directory contains an index file - foreach ($this->_config['index_files'] as $indexFile) { + // Check if links_dirs_with_index is enabled + if ($this->linksDirsWithIndex()) { - if (file_exists($dirPath . '/' . $indexFile)) { + // Check if directory contains an index file + foreach ($this->_config['index_files'] as $indexFile) { - return true; + if (file_exists($dirPath . '/' . $indexFile)) { + + return true; + + } } } + return false; } @@ -290,19 +296,19 @@ class DirectoryLister { public function externalLinksNewWindow() { return $this->_config['external_links_new_window']; } - - + + /** * Returns use real url for indexed directories * * @return boolean Returns true if in config is enabled links for directories with index, false if not * @access public */ - public function linksForDirsWithIndex() + public function linksDirsWithIndex() { - return $this->_config['links_for_dirs_with_index']; + return $this->_config['links_dirs_with_index']; } - + /** * Returns the path to the chosen theme directory @@ -620,15 +626,7 @@ class DirectoryLister { $urlPath = implode('/', array_map('rawurlencode', explode('/', $relativePath))); if (is_dir($relativePath)) { - $urlPath = '?dir=' . $urlPath; - } else { - $urlPath = $urlPath; - } - - if ($this->linksForDirsWithIndex()) { - if ($this->containsIndex($relativePath)) { - $urlPath = $relativePath; - } + $urlPath = $this->containsIndex($relativePath) ? $relativePath : '?dir=' . $urlPath; } // Add the info to the main array diff --git a/resources/default.config.php b/resources/default.config.php index 9dcaa01..ec48964 100644 --- a/resources/default.config.php +++ b/resources/default.config.php @@ -8,8 +8,6 @@ return array( 'list_folders_first' => true, 'list_sort_order' => 'natcasesort', 'theme_name' => 'bootstrap', - 'external_links_new_window' => true, - 'links_for_dirs_with_index' => false, 'date_format' => 'Y-m-d H:i:s', // See: http://php.net/manual/en/function.date.php // Hidden files @@ -23,6 +21,13 @@ return array( 'footer.php' ), + // If set to 'true' an directory with an index file (as defined below) will + // become a direct link to the index page instead of a browsable directory + 'links_dirs_with_index' => false, + + // Make linked directories open in a new (_blank) tab + 'external_links_new_window' => true, + // Files that, if present in a directory, make the directory // a direct link rather than a browse link. 'index_files' => array( diff --git a/resources/themes/bootstrap/index.php b/resources/themes/bootstrap/index.php index b9ac018..bac2969 100644 --- a/resources/themes/bootstrap/index.php +++ b/resources/themes/bootstrap/index.php @@ -122,20 +122,6 @@ - - - linksForDirsWithIndex()): ?> - - containsIndex($fileInfo['file_path'])): ?> - - externalLinksNewWindow()): ?>target="_blank"> - - - - - - -