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
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.
......
......@@ -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.
......
; $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