mirror of
https://github.com/phpbb/phpbb.git
synced 2025-05-02 22:02:07 +02:00
[ticket/16955] Use common code for path iterator generation
PHPBB3-16955
This commit is contained in:
parent
8faabb559d
commit
9a546c535c
@ -65,7 +65,7 @@ require __DIR__ . '/../phpbb/event/md_exporter.' . $phpEx;
|
||||
require __DIR__ . '/../phpbb/event/rst_exporter.' . $phpEx;
|
||||
require __DIR__ . '/../includes/functions.' . $phpEx;
|
||||
require __DIR__ . '/../phpbb/event/recursive_event_filter_iterator.' . $phpEx;
|
||||
require __DIR__ . '/../phpbb/recursive_dot_prefix_filter_iterator.' . $phpEx;
|
||||
require __DIR__ . '/../phpbb/iterator/recursive_dot_prefix_filter_iterator.' . $phpEx;
|
||||
|
||||
switch ($action)
|
||||
{
|
||||
|
@ -68,7 +68,7 @@ require __DIR__ . '/../phpbb/event/md_exporter.' . $phpEx;
|
||||
require __DIR__ . '/../phpbb/event/rst_exporter.' . $phpEx;
|
||||
require __DIR__ . '/../includes/functions.' . $phpEx;
|
||||
require __DIR__ . '/../phpbb/event/recursive_event_filter_iterator.' . $phpEx;
|
||||
require __DIR__ . '/../phpbb/recursive_dot_prefix_filter_iterator.' . $phpEx;
|
||||
require __DIR__ . '/../phpbb/iterator/recursive_dot_prefix_filter_iterator.' . $phpEx;
|
||||
|
||||
switch ($action)
|
||||
{
|
||||
|
@ -67,7 +67,7 @@ require __DIR__ . '/../phpbb/event/php_exporter.' . $phpEx;
|
||||
require __DIR__ . '/../phpbb/event/md_exporter.' . $phpEx;
|
||||
require __DIR__ . '/../includes/functions.' . $phpEx;
|
||||
require __DIR__ . '/../phpbb/event/recursive_event_filter_iterator.' . $phpEx;
|
||||
require __DIR__ . '/../phpbb/recursive_dot_prefix_filter_iterator.' . $phpEx;
|
||||
require __DIR__ . '/../phpbb/iterator/recursive_dot_prefix_filter_iterator.' . $phpEx;
|
||||
|
||||
switch ($action)
|
||||
{
|
||||
|
@ -220,15 +220,7 @@ class acp_language
|
||||
{
|
||||
try
|
||||
{
|
||||
$iterator = new \RecursiveIteratorIterator(
|
||||
new \phpbb\recursive_dot_prefix_filter_iterator(
|
||||
new \RecursiveDirectoryIterator(
|
||||
$this->phpbb_root_path . 'language/' . $this->config['default_lang'] . '/',
|
||||
\FilesystemIterator::SKIP_DOTS
|
||||
)
|
||||
),
|
||||
\RecursiveIteratorIterator::LEAVES_ONLY
|
||||
);
|
||||
$iterator = new \phpbb\iterator\recursive_path_iterator($this->phpbb_root_path . 'language/' . $this->config['default_lang'] . '/');
|
||||
}
|
||||
catch (\Exception $e)
|
||||
{
|
||||
@ -237,7 +229,6 @@ class acp_language
|
||||
|
||||
foreach ($iterator as $file_info)
|
||||
{
|
||||
/** @var \RecursiveDirectoryIterator $file_info */
|
||||
$relative_path = $iterator->getInnerIterator()->getSubPathname();
|
||||
$relative_path = str_replace(DIRECTORY_SEPARATOR, '/', $relative_path);
|
||||
|
||||
|
@ -646,14 +646,10 @@ function phpbb_email_hash($email)
|
||||
*/
|
||||
function phpbb_load_extensions_autoloaders($phpbb_root_path)
|
||||
{
|
||||
$iterator = new \RecursiveIteratorIterator(
|
||||
new \phpbb\recursive_dot_prefix_filter_iterator(
|
||||
new \RecursiveDirectoryIterator(
|
||||
$phpbb_root_path . 'ext/',
|
||||
\FilesystemIterator::SKIP_DOTS | \FilesystemIterator::FOLLOW_SYMLINKS
|
||||
)
|
||||
),
|
||||
\RecursiveIteratorIterator::SELF_FIRST
|
||||
$iterator = new \phpbb\iterator\recursive_path_iterator(
|
||||
$phpbb_root_path . 'ext/',
|
||||
\RecursiveIteratorIterator::SELF_FIRST,
|
||||
\FilesystemIterator::SKIP_DOTS | \FilesystemIterator::FOLLOW_SYMLINKS
|
||||
);
|
||||
$iterator->setMaxDepth(2);
|
||||
|
||||
|
@ -658,13 +658,8 @@ class md_exporter
|
||||
{
|
||||
try
|
||||
{
|
||||
$iterator = new \RecursiveIteratorIterator(
|
||||
new \phpbb\recursive_dot_prefix_filter_iterator(
|
||||
new \RecursiveDirectoryIterator(
|
||||
$dir,
|
||||
\FilesystemIterator::SKIP_DOTS
|
||||
)
|
||||
),
|
||||
$iterator = new \phpbb\iterator\recursive_path_iterator(
|
||||
$dir,
|
||||
\RecursiveIteratorIterator::SELF_FIRST
|
||||
);
|
||||
}
|
||||
|
@ -380,11 +380,10 @@ class manager
|
||||
return $available;
|
||||
}
|
||||
|
||||
$iterator = new \RecursiveIteratorIterator(
|
||||
new \phpbb\recursive_dot_prefix_filter_iterator(
|
||||
new \RecursiveDirectoryIterator($this->phpbb_root_path . 'ext/', \FilesystemIterator::NEW_CURRENT_AND_KEY | \FilesystemIterator::FOLLOW_SYMLINKS)
|
||||
),
|
||||
\RecursiveIteratorIterator::SELF_FIRST
|
||||
$iterator = new \phpbb\iterator\recursive_path_iterator(
|
||||
$this->phpbb_root_path . 'ext/',
|
||||
\RecursiveIteratorIterator::SELF_FIRST,
|
||||
\FilesystemIterator::NEW_CURRENT_AND_KEY | \FilesystemIterator::FOLLOW_SYMLINKS
|
||||
);
|
||||
$iterator->setMaxDepth(2);
|
||||
|
||||
|
@ -486,13 +486,8 @@ class finder
|
||||
|
||||
if (is_dir($path))
|
||||
{
|
||||
$iterator = new \RecursiveIteratorIterator(
|
||||
new \phpbb\recursive_dot_prefix_filter_iterator(
|
||||
new \RecursiveDirectoryIterator(
|
||||
$path,
|
||||
\FilesystemIterator::SKIP_DOTS
|
||||
)
|
||||
),
|
||||
$iterator = new \phpbb\iterator\recursive_path_iterator(
|
||||
$path,
|
||||
\RecursiveIteratorIterator::SELF_FIRST
|
||||
);
|
||||
|
||||
|
@ -11,7 +11,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
namespace phpbb;
|
||||
namespace phpbb\iterator;
|
||||
|
||||
/**
|
||||
* Class recursive_dot_prefix_filter_iterator
|
47
phpBB/phpbb/iterator/recursive_path_iterator.php
Normal file
47
phpBB/phpbb/iterator/recursive_path_iterator.php
Normal file
@ -0,0 +1,47 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* This file is part of the phpBB Forum Software package.
|
||||
*
|
||||
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
||||
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||
*
|
||||
* For full copyright and license information, please see
|
||||
* the docs/CREDITS.txt file.
|
||||
*
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace phpbb\iterator;
|
||||
|
||||
class recursive_path_iterator extends \RecursiveIteratorIterator
|
||||
{
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param string $path Path to iterate over
|
||||
* @param int $mode Iterator mode
|
||||
* @param int $flags Flags
|
||||
*/
|
||||
public function __construct(string $path, int $mode = self::LEAVES_ONLY, int $flags = \FilesystemIterator::SKIP_DOTS)
|
||||
{
|
||||
parent::__construct(
|
||||
new recursive_dot_prefix_filter_iterator(new \RecursiveDirectoryIterator($path, $flags)),
|
||||
\RecursiveIteratorIterator::SELF_FIRST
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get inner iterator
|
||||
*
|
||||
* @return recursive_dot_prefix_filter_iterator
|
||||
*/
|
||||
public function getInnerIterator(): \RecursiveIterator
|
||||
{
|
||||
$inner_iterator = parent::getInnerIterator();
|
||||
|
||||
assert($inner_iterator instanceof recursive_dot_prefix_filter_iterator);
|
||||
return $inner_iterator;
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user