Fix recursion in subfolders

This commit is contained in:
Flavio Copes 2015-10-07 19:32:06 +02:00
parent adec98c198
commit d3438f190f
1 changed files with 6 additions and 2 deletions

View File

@ -103,7 +103,11 @@ class CommentsPlugin extends Plugin
private function getFilesOrderedByModifiedDate($path = '') {
$files = [];
$dirItr = new \RecursiveDirectoryIterator(DATA_DIR . 'comments' . $path, \RecursiveDirectoryIterator::SKIP_DOTS);
if (!$path) {
$path = DATA_DIR . 'comments';
}
$dirItr = new \RecursiveDirectoryIterator($path, \RecursiveDirectoryIterator::SKIP_DOTS);
$filterItr = new RecursiveFolderFilterIterator($dirItr);
$itr = new \RecursiveIteratorIterator($filterItr, \RecursiveIteratorIterator::SELF_FIRST);
@ -121,7 +125,7 @@ class CommentsPlugin extends Plugin
foreach ($itr as $file) {
if ($file->isDir()) {
$this->getFilesOrderedByModifiedDate('/' . $file->getFilename());
$this->getFilesOrderedByModifiedDate($file->getPath() . '/' . $file->getFilename());
}
}