Browse Source

scandir original

branche_v10
fredtempez 1 year ago
parent
commit
8dff1cd069
  1. 17
      core/class/helper.class.php
  2. 2
      core/core.php
  3. 22
      module/gallery/gallery.php

17
core/class/helper.class.php

@ -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;
}
/**

2
core/core.php

@ -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 = [];

22
module/gallery/gallery.php

@ -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;
}
}
Loading…
Cancel
Save