Commit 5f8df5fe authored by Tobias Stoeckler's avatar Tobias Stoeckler

#919632 by tstoeckler, sun: Allow library information to be stored in info files.

parent 30b84515
...@@ -6,6 +6,7 @@ Libraries x.x-x.x, xxxx-xx-xx ...@@ -6,6 +6,7 @@ Libraries x.x-x.x, xxxx-xx-xx
Libraries 7.x-1.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. by sun: Fixed testbot breaks upon directory name/info file name mismatch.
#864376 by tstoeckler, sun: Code-cleanup, allow hard-coded 'version'. #864376 by tstoeckler, sun: Code-cleanup, allow hard-coded 'version'.
#939174 by sun, tstoeckler: Rename example.info to libraries_example.info. #939174 by sun, tstoeckler: Rename example.info to libraries_example.info.
......
...@@ -126,7 +126,7 @@ function libraries_get_libraries() { ...@@ -126,7 +126,7 @@ function libraries_get_libraries() {
* An array of info files, keyed by library name. The values are the paths of * An array of info files, keyed by library name. The values are the paths of
* the files. * the files.
*/ */
function libraries_info_files() { function libraries_scan_info_files() {
global $profile; global $profile;
if (!isset($profile)) { if (!isset($profile)) {
$profile = variable_get('install_profile', 'default'); $profile = variable_get('install_profile', 'default');
...@@ -136,21 +136,24 @@ function libraries_info_files() { ...@@ -136,21 +136,24 @@ function libraries_info_files() {
// Build a list of directories. // Build a list of directories.
$directories = module_invoke_all('libraries_info_file_paths'); $directories = module_invoke_all('libraries_info_file_paths');
$directories[] = 'libraries'; $directories[] = 'libraries';
$directories[] = "libraries/$profile/libraries"; $directories[] = "profiles/$profile/libraries";
$directories[] = 'sites/all/libraries'; $directories[] = 'sites/all/libraries';
$directories[] = "sites/$config/libraries"; $directories[] = "$config/libraries";
// Scan for info files. // Scan for info files.
$files = array(); $files = array();
foreach ($directories as $dir) { foreach ($directories as $dir) {
$files += file_scan_directory($dir, '/[a-z[a-z0-9_]+.info/', array( if (file_exists($dir)) {
'key' => 'name', $files = array_merge($files, file_scan_directory($dir, '@^[a-z0-9._-]+\.libraries\.info$@', array(
'recurse' => FALSE, 'key' => 'name',
)); 'recurse' => FALSE,
)));
}
} }
foreach ($files as &$file) { foreach ($files as $name => $file) {
$file = $file->uri; $files[basename($name, '.libraries')] = $file;
unset($files[$name]);
} }
return $files; return $files;
...@@ -187,9 +190,10 @@ function libraries_info($library = NULL) { ...@@ -187,9 +190,10 @@ function libraries_info($library = NULL) {
} }
} }
// Gather information from .info files. // Gather information from .info files.
foreach (libraries_info_files() as $name => $path) { foreach (libraries_scan_info_files() as $name => $file) {
$file = "$path/$name.info"; $properties = drupal_parse_info_file($file->uri);
$libraries[$name] = drupal_parse_info_file($file); $properties['info file'] = $file->uri;
$libraries[$name] = $properties;
} }
// Provide defaults. // Provide defaults.
......
; $Id$
; This is an example info file of a library used for testing purposes.
name = Example info file
; $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
<?php
// $Id$
// Testbot gets confused and breaks when encountering an .info file without
// .module file. Until the testbot is corrected, we need to resolve this by
// supplying a fake .module file for the libraries_example.info library.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment