diff --git a/setup/modelfactory.class.inc.php b/setup/modelfactory.class.inc.php index 2bc507c99..38dcd8919 100644 --- a/setup/modelfactory.class.inc.php +++ b/setup/modelfactory.class.inc.php @@ -464,25 +464,29 @@ class MFDictModule extends MFModule } /** + * Scan for dictionary files recursively in $sDir + * * @inheritDoc */ - public function GetDictionaryFiles() + public function GetDictionaryFiles($sDir = null) { $aDictionaries = array(); - foreach (array($this->sRootDir, $this->sRootDir.'/dictionaries') as $sRootDir) + $sDictionaryFilePattern = '*dictionary.itop.*.php'; + + if($sDir === null) { - if ($hDir = @opendir($sRootDir)) + $sDir = $this->sRootDir; + } + + if ($hDir = opendir($sDir)) + { + // Matching files + $aDictionaries = glob($sDir.'/'.$sDictionaryFilePattern); + + // Directories to scan + foreach(glob($sDir.'/*', GLOB_ONLYDIR|GLOB_NOSORT) as $sSubDir) { - while (($sFile = readdir($hDir)) !== false) - { - $aMatches = array(); - if (preg_match("/^.*dictionary\\.itop.*.php$/i", $sFile, - $aMatches)) // Dictionary files are named like .dict..php - { - $aDictionaries[] = $sRootDir.'/'.$sFile; - } - } - closedir($hDir); + $aDictionaries = array_merge($aDictionaries, $this->GetDictionaryFiles($sSubDir)); } }