mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-06-30 16:39:38 +02:00
Merge pull request #848 from chillu/pulls/4754
BUG Exclude framework/dev from text collection (fixes #4754)
This commit is contained in:
commit
6dec0592e8
|
@ -170,7 +170,7 @@ class i18nTextCollector extends Object {
|
||||||
$fileList = $this->getFilesRecursive("$this->basePath/$module/code");
|
$fileList = $this->getFilesRecursive("$this->basePath/$module/code");
|
||||||
} else if($module == FRAMEWORK_DIR || substr($module, 0, 7) == 'themes/') {
|
} else if($module == FRAMEWORK_DIR || substr($module, 0, 7) == 'themes/') {
|
||||||
// framework doesn't have the usual module structure, so we'll scan all subfolders
|
// framework doesn't have the usual module structure, so we'll scan all subfolders
|
||||||
$fileList = $this->getFilesRecursive("$this->basePath/$module");
|
$fileList = $this->getFilesRecursive("$this->basePath/$module", null, null, '/\/(tests|dev)$/');
|
||||||
}
|
}
|
||||||
foreach($fileList as $filePath) {
|
foreach($fileList as $filePath) {
|
||||||
// exclude ss-templates, they're scanned separately
|
// exclude ss-templates, they're scanned separately
|
||||||
|
@ -183,8 +183,7 @@ class i18nTextCollector extends Object {
|
||||||
|
|
||||||
// Search for calls in template files if these exists
|
// Search for calls in template files if these exists
|
||||||
if(is_dir("$this->basePath/$module/")) {
|
if(is_dir("$this->basePath/$module/")) {
|
||||||
$dummy = array();
|
$fileList = $this->getFilesRecursive("$this->basePath/$module/", null, 'ss');
|
||||||
$fileList = $this->getFilesRecursive("$this->basePath/$module/", $dummy, 'ss');
|
|
||||||
foreach($fileList as $index => $filePath) {
|
foreach($fileList as $index => $filePath) {
|
||||||
$content = file_get_contents($filePath);
|
$content = file_get_contents($filePath);
|
||||||
// templates use their filename as a namespace
|
// templates use their filename as a namespace
|
||||||
|
@ -401,25 +400,30 @@ class i18nTextCollector extends Object {
|
||||||
* @param string $folder base directory to scan (will scan recursively)
|
* @param string $folder base directory to scan (will scan recursively)
|
||||||
* @param array $fileList Array to which potential files will be appended
|
* @param array $fileList Array to which potential files will be appended
|
||||||
* @param string $type Optional, "php" or "ss"
|
* @param string $type Optional, "php" or "ss"
|
||||||
|
* @param string $folderExclude Regular expression matching folder names to exclude
|
||||||
* @return array $fileList An array of files
|
* @return array $fileList An array of files
|
||||||
*/
|
*/
|
||||||
protected function getFilesRecursive($folder, &$fileList = null, $type = null) {
|
protected function getFilesRecursive($folder, $fileList = null, $type = null, $folderExclude = null) {
|
||||||
|
if(!$folderExclude) $folderExclude = '/\/(tests)$/';
|
||||||
if(!$fileList) $fileList = array();
|
if(!$fileList) $fileList = array();
|
||||||
$items = scandir($folder);
|
$items = scandir($folder);
|
||||||
$isValidFolder = (
|
$isValidFolder = (
|
||||||
!in_array('_manifest_exclude', $items)
|
!in_array('_manifest_exclude', $items)
|
||||||
&& !preg_match('/\/tests$/', $folder)
|
&& !preg_match($folderExclude, $folder)
|
||||||
);
|
);
|
||||||
|
|
||||||
if($items && $isValidFolder) foreach($items as $item) {
|
if($items && $isValidFolder) foreach($items as $item) {
|
||||||
if(substr($item,0,1) == '.') continue;
|
if(substr($item,0,1) == '.') continue;
|
||||||
if(substr($item,-4) == '.php' && (!$type || $type == 'php')) {
|
if(substr($item,-4) == '.php' && (!$type || $type == 'php')) {
|
||||||
$fileList[substr($item,0,-4)] = "$folder/$item";
|
$fileList[substr($item,0,-4)] = "$folder/$item";
|
||||||
}
|
} else if(substr($item,-3) == '.ss' && (!$type || $type == 'ss')) {
|
||||||
else if(substr($item,-3) == '.ss' && (!$type || $type == 'ss')) {
|
|
||||||
$fileList[$item] = "$folder/$item";
|
$fileList[$item] = "$folder/$item";
|
||||||
|
} else if(is_dir("$folder/$item")) {
|
||||||
|
$fileList = array_merge(
|
||||||
|
$fileList,
|
||||||
|
$this->getFilesRecursive("$folder/$item", $fileList, $type, $folderExclude)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
else if(is_dir("$folder/$item")) $this->getFilesRecursive("$folder/$item", $fileList, $type);
|
|
||||||
}
|
}
|
||||||
return $fileList;
|
return $fileList;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user