Option to allow all hidden files/folders #306

This commit is contained in:
Andy Miller
2015-10-23 10:23:01 -06:00
parent f03921690c
commit 98d0538868
3 changed files with 21 additions and 0 deletions

View File

@@ -175,6 +175,17 @@ form:
validate:
type: bool
pages.ignore_hidden:
type: toggle
label: PLUGIN_ADMIN.IGNORE_HIDDEN
help: PLUGIN_ADMIN.IGNORE_HIDDEN_HELP
highlight: 1
options:
1: PLUGIN_ADMIN.YES
0: PLUGIN_ADMIN.NO
validate:
type: bool
pages.ignore_files:
type: selectize
size: large

View File

@@ -51,6 +51,7 @@ pages:
redirect_trailing_slash: true # Handle automatically or 301 redirect a trailing / URL
ignore_files: [.DS_Store] # Files to ignore in Pages
ignore_folders: [.git, .idea] # Folders to ignore in Pages
ignore_hidden: true # Ignore all Hidden files and folders
url_taxonomy_filters: true # Enable auto-magic URL-based taxonomy filters for page collections
cache:

View File

@@ -65,6 +65,7 @@ class Pages
protected $ignore_files;
protected $ignore_folders;
protected $ignore_hidden;
/**
* @var Types
@@ -108,6 +109,7 @@ class Pages
$config = $this->grav['config'];
$this->ignore_files = $config->get('system.pages.ignore_files');
$this->ignore_folders = $config->get('system.pages.ignore_folders');
$this->ignore_hidden = $config->get('system.pages.ignore_hidden');
$this->buildPages();
}
@@ -702,6 +704,13 @@ class Pages
foreach (new \FilesystemIterator($directory) as $file) {
$name = $file->getFilename();
// Ignore all hidden files if set.
if ($this->ignore_hidden) {
if ($name && $name[0] == '.') {
continue;
}
}
if ($file->isFile()) {
// Update the last modified if it's newer than already found
if (!in_array($file->getBasename(), $this->ignore_files) && ($modified = $file->getMTime()) > $last_modified) {