scandir original

This commit is contained in:
fredtempez 2021-02-10 17:58:08 +01:00
parent ddb0f4f4a5
commit 8dff1cd069
3 changed files with 22 additions and 19 deletions

View File

@ -164,23 +164,6 @@ class helper {
return($modules);
}
/**
* Scanne le contenu d'un dossier et de ses sous-dossiers
* @param string $dir Dossier à scanner
* @return array liste de dossiers contenus dans le répertoire cible.
*/
public static function scanSubDir($dir) {
$dirContent = [];
$iterator = new DirectoryIterator($dir);
foreach($iterator as $fileInfos) {
if($fileInfos->isDot() === false AND $fileInfos->isDir()) {
$dirContent[] = $dir . '/' . $fileInfos->getBasename();
$dirContent = array_merge($dirContent, self::scanSubDir($dir . '/' . $fileInfos->getBasename()));
}
}
return $dirContent;
}
/**

View File

@ -44,7 +44,7 @@ class common {
const ACCESS_TIMER = 1800;
// Numéro de version
const ZWII_VERSION = '10.4.01';
const ZWII_VERSION = '10.4.02.modules';
const ZWII_UPDATE_CHANNEL = "v10";
public static $actions = [];

View File

@ -324,7 +324,7 @@ class gallery extends common {
// Valeurs en sortie
$this->addOutput([
'display' => self::DISPLAY_JSON,
'content' => helper::scanSubDir(self::FILE_DIR.'source')
'content' => galleriesHelper::scanDir(self::FILE_DIR.'source')
]);
}
@ -673,4 +673,24 @@ class gallery extends common {
]);
}
}
class galleriesHelper extends helper {
/**
* Scan le contenu d'un dossier et de ses sous-dossiers
* @param string $dir Dossier à scanner
* @return array
*/
public static function scanDir($dir) {
$dirContent = [];
$iterator = new DirectoryIterator($dir);
foreach($iterator as $fileInfos) {
if($fileInfos->isDot() === false AND $fileInfos->isDir()) {
$dirContent[] = $dir . '/' . $fileInfos->getBasename();
$dirContent = array_merge($dirContent, self::scanDir($dir . '/' . $fileInfos->getBasename()));
}
}
return $dirContent;
}
}