function _potx_explore_dir in Translation template extractor 6
Same name and namespace in other branches
- 8 potx.inc \_potx_explore_dir()
- 5.2 potx.inc \_potx_explore_dir()
- 5 potx.inc \_potx_explore_dir()
- 6.3 potx.inc \_potx_explore_dir()
- 6.2 potx.inc \_potx_explore_dir()
- 7.3 potx.inc \_potx_explore_dir()
- 7 potx.inc \_potx_explore_dir()
- 7.2 potx.inc \_potx_explore_dir()
Collect a list of file names relevant for extraction, starting from the given path.
@todo Add folder exceptions for other version control systems.
Parameters
$path: Where to start searching for files recursively. Provide non-empty path values with a trailing slash.
$basename: Allows the restriction of search to a specific basename (ie. to collect files for a specific module).
$api_version: Drupal API version to work with.
2 calls to _potx_explore_dir()
- potx-cli.php in ./
potx-cli.php - potx_select_form_submit in ./
potx.module - Generate translation template or translation file for the requested module.
File
- ./
potx.inc, line 1081 - Extraction API used by the web and command line interface.
Code
function _potx_explore_dir($path = '', $basename = '*', $api_version = POTX_API_6) {
// It would be so nice to just use GLOB_BRACE, but it is not available on all
// operarting systems, so we are working around the missing functionality.
$extensions = array(
'php',
'inc',
'module',
'engine',
'theme',
'install',
'info',
'profile',
);
if ($api_version > POTX_API_5) {
$extensions[] = 'js';
}
$files = array();
foreach ($extensions as $extension) {
$files_here = glob($path . $basename . '.' . $extension);
if (is_array($files_here)) {
$files = array_merge($files, $files_here);
}
}
// Grab subdirectories.
$dirs = glob($path . '*', GLOB_ONLYDIR);
if (is_array($dirs)) {
foreach ($dirs as $dir) {
if (!preg_match("!(^|.+/)(CVS|.svn|.git)\$!", $dir)) {
$files = array_merge($files, _potx_explore_dir("{$dir}/", $basename));
}
}
}
// Skip our own files, because we don't want to get strings from them
// to appear in the output, especially with the command line interface.
// TODO: fix this to be able to autogenerate templates for potx itself.
foreach ($files as $id => $file_name) {
if (preg_match('!(potx-cli.php|potx.inc)$!', $file_name)) {
unset($files[$id]);
}
}
return $files;
}