libraries.module | 27 +++++++++++++++++----- tests/libraries.test | 12 ++++++---- .../libraries_test_module.module | 17 +++++++++----- .../libraries_test_theme/libraries_test_theme.css | 12 ++++++++++ .../libraries_test_theme/libraries_test_theme.inc | 11 +++++++++ .../libraries_test_theme/libraries_test_theme.js | 18 +++++++++++++++ tests/themes/libraries_test_theme/template.php | 12 ++++++++++ 7 files changed, 93 insertions(+), 16 deletions(-) diff --git a/libraries.module b/libraries.module index db2946a..b278455 100644 --- a/libraries.module +++ b/libraries.module @@ -737,12 +737,27 @@ function libraries_load_files($library) { // Load integration files. if (!empty($library['integration files'])) { - foreach ($library['integration files'] as $module => $files) { - libraries_load_files(array( - 'files' => $files, - 'path' => '', - 'library path' => drupal_get_path('module', $module), - )); + $enabled_themes = array(); + foreach (list_themes() as $theme_name => $theme) { + if ($theme->status) { + $enabled_themes[] = $theme_name; + } + } + foreach ($library['integration files'] as $provider => $files) { + if (module_exists($provider)) { + libraries_load_files(array( + 'files' => $files, + 'path' => '', + 'library path' => drupal_get_path('module', $provider), + )); + } + elseif (in_array($provider, $enabled_themes)) { + libraries_load_files(array( + 'files' => $files, + 'path' => '', + 'library path' => drupal_get_path('theme', $provider), + )); + } } } diff --git a/tests/libraries.test b/tests/libraries.test index ab1d9b8..75c8a9a 100644 --- a/tests/libraries.test +++ b/tests/libraries.test @@ -459,10 +459,14 @@ class LibrariesTestCase extends DrupalWebTestCase { $this->assertLibraryFiles('example_1', 'File loading'); // Test loading of integration files. - $this->drupalGet('libraries-test-module/integration-files'); - $this->assertRaw('libraries_test_module.js', 'Integration file loading: libraries_test.js found'); - $this->assertRaw('libraries_test_module.css', 'Integration file loading: libraries_test.css found'); - $this->assertRaw('libraries_test_module.inc', 'Integration file loading: libraries_test.inc found'); + $this->drupalGet('libraries-test-module/module-integration-files'); + $this->assertRaw('libraries_test_module.js', 'Integration file loading: libraries_test_module.js found'); + $this->assertRaw('libraries_test_module.css', 'Integration file loading: libraries_test_module.css found'); + $this->assertRaw('libraries_test_module.inc', 'Integration file loading: libraries_test_module.inc found'); + $this->drupalGet('libraries-test-module/theme-integration-files'); + $this->assertRaw('libraries_test_theme.js', 'Integration file loading: libraries_test_theme.js found'); + $this->assertRaw('libraries_test_theme.css', 'Integration file loading: libraries_test_theme.css found'); + $this->assertRaw('libraries_test_theme.inc', 'Integration file loading: libraries_test_theme.inc found'); // Test version overloading. $this->drupalGet('libraries-test-module/versions'); diff --git a/tests/modules/libraries_test_module/libraries_test_module.module b/tests/modules/libraries_test_module/libraries_test_module.module index 614e30e..045d71c 100644 --- a/tests/modules/libraries_test_module/libraries_test_module.module +++ b/tests/modules/libraries_test_module/libraries_test_module.module @@ -81,8 +81,8 @@ function libraries_test_module_libraries_info() { // Test loading of integration files. // Normally added by the corresponding module via hook_libraries_info_alter(), // these files should be automatically loaded when the library is loaded. - $libraries['example_integration_files'] = array( - 'name' => 'Example integration files', + $libraries['example_module_integration_files'] = array( + 'name' => 'Example module integration files', 'library path' => drupal_get_path('module', 'libraries') . '/tests/libraries/example', 'version' => '1', 'integration files' => array( @@ -513,9 +513,13 @@ function libraries_test_module_menu() { 'title' => 'Test files', 'page arguments' => array('example_files'), ); - $items['libraries-test-module/integration-files'] = $base + array( - 'title' => 'Test integration files', - 'page arguments' => array('example_integration_files'), + $items['libraries-test-module/module-integration-files'] = $base + array( + 'title' => 'Test module integration files', + 'page arguments' => array('example_module_integration_files'), + ); + $items['libraries-test-module/theme-integration-files'] = $base + array( + 'title' => 'Test theme integration files', + 'page arguments' => array('example_theme_integration_files'), ); $items['libraries-test-module/versions'] = $base + array( 'title' => 'Test version loading', @@ -570,6 +574,7 @@ function _libraries_test_module_load($library, $variant = NULL) { $output .= '
  • example_3: orange
  • '; $output .= '
  • example_4: blue
  • '; $output .= '
  • libraries_test_module: purple
  • '; + $output .= '
  • libraries_test_theme: turquoise
  • '; $output .= ''; $output .= ''; @@ -579,7 +584,7 @@ function _libraries_test_module_load($library, $variant = NULL) { $output .= '