[ticket/12273] Add root path to recursive_event_filter_iterator

PHPBB3-12273
This commit is contained in:
Joas Schilling 2014-04-27 23:51:06 +02:00
parent e934cefe80
commit dbac4bb5c0
2 changed files with 35 additions and 11 deletions

View file

@ -112,7 +112,8 @@ class php_exporter
new \RecursiveDirectoryIterator( new \RecursiveDirectoryIterator(
$dir, $dir,
\FilesystemIterator::SKIP_DOTS \FilesystemIterator::SKIP_DOTS
) ),
$dir
), ),
\RecursiveIteratorIterator::LEAVES_ONLY \RecursiveIteratorIterator::LEAVES_ONLY
); );

View file

@ -20,6 +20,29 @@ namespace phpbb\event;
*/ */
class recursive_event_filter_iterator extends \RecursiveFilterIterator class recursive_event_filter_iterator extends \RecursiveFilterIterator
{ {
protected $root_path;
/**
* Construct
*
* @param \RecursiveIterator $iterator
* @param string $root_path
*/
public function __construct(\RecursiveIterator $iterator, $root_path)
{
$this->root_path = str_replace(DIRECTORY_SEPARATOR, '/', $root_path);
parent::__construct($iterator);
}
/**
* Return the inner iterator's children contained in a recursive_event_filter_iterator
*
* @return recursive_event_filter_iterator
*/
public function getChildren() {
return new self($this->getInnerIterator()->getChildren(), $this->root_path);
}
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@ -30,16 +53,16 @@ class recursive_event_filter_iterator extends \RecursiveFilterIterator
return (substr($relative_path, -4) === '.php' || $this->current()->isDir()) return (substr($relative_path, -4) === '.php' || $this->current()->isDir())
&& $filename[0] !== '.' && $filename[0] !== '.'
&& strpos($relative_path, 'phpBB/cache/') !== 0 && strpos($relative_path, $this->root_path . 'cache/') !== 0
&& strpos($relative_path, 'phpBB/develop/') !== 0 && strpos($relative_path, $this->root_path . 'develop/') !== 0
&& strpos($relative_path, 'phpBB/ext/') !== 0 && strpos($relative_path, $this->root_path . 'ext/') !== 0
&& strpos($relative_path, 'phpBB/files/') !== 0 && strpos($relative_path, $this->root_path . 'files/') !== 0
&& strpos($relative_path, 'phpBB/includes/utf/') !== 0 && strpos($relative_path, $this->root_path . 'includes/utf/') !== 0
&& strpos($relative_path, 'phpBB/language/') !== 0 && strpos($relative_path, $this->root_path . 'language/') !== 0
&& strpos($relative_path, 'phpBB/phpbb/db/migration/data/') !== 0 && strpos($relative_path, $this->root_path . 'phpbb/db/migration/data/') !== 0
&& strpos($relative_path, 'phpBB/phpbb/event/') !== 0 && strpos($relative_path, $this->root_path . 'phpbb/event/') !== 0
&& strpos($relative_path, 'phpBB/store/') !== 0 && strpos($relative_path, $this->root_path . 'store/') !== 0
&& strpos($relative_path, 'phpBB/vendor/') !== 0 && strpos($relative_path, $this->root_path . 'vendor/') !== 0
; ;
} }
} }