Merge pull request #848 from chillu/pulls/4754

BUG Exclude framework/dev from text collection (fixes #4754)
This commit is contained in:
Sam Minnée 2013-04-08 16:06:52 -07:00
commit 6dec0592e8

View File

@ -170,7 +170,7 @@ class i18nTextCollector extends Object {
$fileList = $this->getFilesRecursive("$this->basePath/$module/code");
} else if($module == FRAMEWORK_DIR || substr($module, 0, 7) == 'themes/') {
// 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) {
// exclude ss-templates, they're scanned separately
@ -183,8 +183,7 @@ class i18nTextCollector extends Object {
// Search for calls in template files if these exists
if(is_dir("$this->basePath/$module/")) {
$dummy = array();
$fileList = $this->getFilesRecursive("$this->basePath/$module/", $dummy, 'ss');
$fileList = $this->getFilesRecursive("$this->basePath/$module/", null, 'ss');
foreach($fileList as $index => $filePath) {
$content = file_get_contents($filePath);
// 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 array $fileList Array to which potential files will be appended
* @param string $type Optional, "php" or "ss"
* @param string $folderExclude Regular expression matching folder names to exclude
* @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();
$items = scandir($folder);
$isValidFolder = (
!in_array('_manifest_exclude', $items)
&& !preg_match('/\/tests$/', $folder)
&& !preg_match($folderExclude, $folder)
);
if($items && $isValidFolder) foreach($items as $item) {
if(substr($item,0,1) == '.') continue;
if(substr($item,-4) == '.php' && (!$type || $type == 'php')) {
$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";
} 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;
}