diff --git a/CHANGELOG.txt b/CHANGELOG.txt index c889636baf2c95eb754812c8b0f42d3a34613a44..0ec4d1ca900543d2ce1bd638dc3e9c51c9531aac 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -6,6 +6,7 @@ Libraries x.x-x.x, xxxx-xx-xx Libraries 7.x-1.x, xxxx-xx-xx ----------------------------- +#919632 by tstoeckler, sun: Allow library information to be stored in info files. by sun: Fixed testbot breaks upon directory name/info file name mismatch. #864376 by tstoeckler, sun: Code-cleanup, allow hard-coded 'version'. #939174 by sun, tstoeckler: Rename example.info to libraries_example.info. diff --git a/libraries.module b/libraries.module index 73593eaa3acf56c67d4578b22616077dfa6099bb..35262463b661b0129dfc28555628c7aa54cd1be9 100644 --- a/libraries.module +++ b/libraries.module @@ -126,7 +126,7 @@ function libraries_get_libraries() { * An array of info files, keyed by library name. The values are the paths of * the files. */ -function libraries_info_files() { +function libraries_scan_info_files() { global $profile; if (!isset($profile)) { $profile = variable_get('install_profile', 'default'); @@ -136,21 +136,24 @@ function libraries_info_files() { // Build a list of directories. $directories = module_invoke_all('libraries_info_file_paths'); $directories[] = 'libraries'; - $directories[] = "libraries/$profile/libraries"; + $directories[] = "profiles/$profile/libraries"; $directories[] = 'sites/all/libraries'; - $directories[] = "sites/$config/libraries"; + $directories[] = "$config/libraries"; // Scan for info files. $files = array(); foreach ($directories as $dir) { - $files += file_scan_directory($dir, '/[a-z[a-z0-9_]+.info/', array( - 'key' => 'name', - 'recurse' => FALSE, - )); + if (file_exists($dir)) { + $files = array_merge($files, file_scan_directory($dir, '@^[a-z0-9._-]+\.libraries\.info$@', array( + 'key' => 'name', + 'recurse' => FALSE, + ))); + } } - foreach ($files as &$file) { - $file = $file->uri; + foreach ($files as $name => $file) { + $files[basename($name, '.libraries')] = $file; + unset($files[$name]); } return $files; @@ -187,9 +190,10 @@ function libraries_info($library = NULL) { } } // Gather information from .info files. - foreach (libraries_info_files() as $name => $path) { - $file = "$path/$name.info"; - $libraries[$name] = drupal_parse_info_file($file); + foreach (libraries_scan_info_files() as $name => $file) { + $properties = drupal_parse_info_file($file->uri); + $properties['info file'] = $file->uri; + $libraries[$name] = $properties; } // Provide defaults. diff --git a/tests/example/example_info_file.libraries.info b/tests/example/example_info_file.libraries.info new file mode 100644 index 0000000000000000000000000000000000000000..a5abb4c5b16c612215e54a4f24abf1866f3ec83a --- /dev/null +++ b/tests/example/example_info_file.libraries.info @@ -0,0 +1,5 @@ +; $Id$ + +; This is an example info file of a library used for testing purposes. +name = Example info file + diff --git a/tests/libraries_info_example/libraries_info_example.info b/tests/libraries_info_example/libraries_info_example.info deleted file mode 100644 index 2508802ae7002f5e2cbe399d1ee72ef9ebf22924..0000000000000000000000000000000000000000 --- a/tests/libraries_info_example/libraries_info_example.info +++ /dev/null @@ -1,12 +0,0 @@ -; $Id$ - -; This is an example info file of a library used for testing purposes. -; Do not declare name manually. It is set automatically. -name = example_info_file -title = Example info file - -; Because Drupal thinks this is a module's .info file, it is in the 'libraries' -; namespace, in order to not cause problems with other modules named 'example'. -; Also, we need to hide this "module" from the modules page. -hidden = TRUE - diff --git a/tests/libraries_info_example/libraries_info_example.module b/tests/libraries_info_example/libraries_info_example.module deleted file mode 100644 index 9fefe95206d08553c621afcb5317ef4076c15f42..0000000000000000000000000000000000000000 --- a/tests/libraries_info_example/libraries_info_example.module +++ /dev/null @@ -1,6 +0,0 @@ -