diff --git a/potx.inc b/potx.inc index 4e3c630..d7053bc 100644 --- a/potx.inc +++ b/potx.inc @@ -2109,7 +2109,7 @@ function _potx_parse_yaml_file($code, $file_name, $file_path, $save_callback) { elseif (preg_match('~[^/]+\.info\.yml~', $file_name)) { $module_path = dirname($file_path); $module_qualified_name = array_search($module_path, $_potx_found_modules, TRUE); - + if (isset($yaml['dependencies'])) { $_potx_module_metadata[$module_qualified_name]['dependencies'] = $yaml['dependencies']; } @@ -2597,7 +2597,7 @@ function _potx_parse_shipped_configuration($save_callback = '_potx_save_string', */ function _potx_load_matching_qualified_modules($module_names) { global $potx_callbacks; - + $qualified_modules = array(); foreach ($module_names as $module_name) { $qualified_name = $potx_callbacks['find_matching_qualified_module']($module_name); @@ -2605,7 +2605,7 @@ function _potx_load_matching_qualified_modules($module_names) { $qualified_modules[] = $qualified_name; } } - + return $qualified_modules; } diff --git a/potx.local.inc b/potx.local.inc index 7872d55..3c500dc 100644 --- a/potx.local.inc +++ b/potx.local.inc @@ -45,7 +45,7 @@ function _potx_find_all_modules($module_path) { global $_potx_found_modules; $module_path = realpath($module_path); - + // Find the drupal root directory. $search_path = $module_path; do { @@ -55,33 +55,33 @@ function _potx_find_all_modules($module_path) { } $search_path = dirname($search_path); } while($search_path != '/'); - + if (!isset($root_dir)) { return; } - + // The Drupal core directory contains a config/schema subdirectory, which // is not part of any module or theme. $_potx_found_modules['drupal:core']['path'] = $root_dir . '/core'; - + // The list of paths that contain drupal core modules or themes. $core_paths = array( $root_dir . '/core/profiles', $root_dir . '/core/modules', $root_dir . '/core/themes', ); - + foreach ($core_paths as $core_path) { _potx_find_modules($core_path, 'drupal'); } - + // The list of paths that could contain drupal modules or themes. $search_paths = array( $root_dir . '/profiles', $root_dir . '/modules', $root_dir . '/themes', ); - + $sites = glob($root_dir . '/sites/*', GLOB_ONLYDIR); foreach ($sites as $site) { @@ -91,7 +91,7 @@ function _potx_find_all_modules($module_path) { } } } - + foreach ($search_paths as $search_path) { _potx_find_modules($search_path); } @@ -116,18 +116,9 @@ function _potx_find_modules($path, $project = NULL) { $module_info_paths = glob($dir . '/*.info.yml', GLOB_MARK); if (!empty($module_info_paths)) { foreach($module_info_paths as $module_info_path) { - $parts = explode('/', $module_info_path); - - $info_file = end($parts); - // If the .info.yml file is actually a directory, skip. - if ($info_file == '') { - continue; - } - - // Split the '.info.yml' part. - $module_name = explode('.', $info_file)[0]; - + $module_name = basename($module_info_path, '.info.yml'); + if ($project != NULL) { $module_project = $project; } else { @@ -136,11 +127,12 @@ function _potx_find_modules($path, $project = NULL) { // running potx locally (e.g. custom or dev modules); so, we use // the directory name as the project name for this module and any // submodules in the same directory - $module_project = $parts[count($parts) - 2]; + $module_dir = dirname($module_info_path); + $module_project = basename($module_dir); } - + $_potx_found_modules["$module_project:$module_name"]['path'] = $dir; - + _potx_find_modules($dir, $module_project); } } else { @@ -328,7 +320,7 @@ function _potx_schema_store($module_qualified_name) { */ function _potx_schema_load($module_qualified_name) { global $_potx_schema_cache; - + if ($module_qualified_name !== FALSE && isset($_potx_schema_cache[$module_qualified_name])) { return $_potx_schema_cache[$module_qualified_name]; } @@ -346,7 +338,7 @@ function _potx_schema_load($module_qualified_name) { */ function _potx_find_matching_qualified_module($module_name) { global $_potx_found_modules; - + if (strpos($module_name, ':') !== FALSE) { return isset($_potx_found_modules[$module_name]) ? $module_name : FALSE; } else {