Index: libraries.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/libraries/libraries.module,v retrieving revision 1.6 diff -u -p -r1.6 libraries.module --- libraries.module 23 Jul 2010 12:57:01 -0000 1.6 +++ libraries.module 7 Oct 2010 01:32:32 -0000 @@ -208,24 +208,27 @@ function libraries_detect_library(&$libr if (!isset($library['library path'])) { $library['library path'] = libraries_get_path($name); } - if (!file_exists($library['library path'])) { + + if (!libraries_file_exists($library['library path'])) { $library['error'] = t('%library could not be found.', array('%library' => $library['title'])); return; } // Determine to which supported version the installed version maps. @@ -332,8 +339,8 @@ function libraries_load_files($library, // If the value is not an array, it's a filename and passed as first // (and only) argument. if (!is_array($options)) { - // Prepend the library path to the file name. - $data = "$path/$options"; + // Prepend the library path to the file name, if it is not an external file. + $data = (url_is_external($options) ? $options : "$path/$options"); $options = NULL; } // In some cases, the first parameter ($data) is an array. Arrays can't be @@ -354,9 +361,9 @@ function libraries_load_files($library, // Load PHP files. if (!empty($library['files']['php'])) { foreach ($library['files']['php'] as $file) { - $file_path = DRUPAL_ROOT . '/' . $path . '/' . $file; - if (file_exists($file_path)) { - require_once $file_path; + $file = (url_is_external($file) ? $file : DRUPAL_ROOT . '/' . $path . '/' . $file); + if (libraries_file_exists($file)) { + include_once $file; } } } @@ -393,8 +400,8 @@ function libraries_get_version($library, 'cols' => 200, ); - $file = DRUPAL_ROOT . '/' . $library['library path'] . '/' . $options['file']; - if (empty($options['file']) || !file_exists($file)) { + $file = (url_is_external($options['file']) ? $options['file'] : DRUPAL_ROOT . '/' . $library['library path'] . '/' . $options['file']); + if (empty($options['file']) || !libraries_file_exists($file)) { return; } $file = fopen($file, 'r'); @@ -408,3 +415,12 @@ function libraries_get_version($library, fclose($file); } +/** + * Wrapper function for file_exists() with support for external files. + * + * @param $file + * The path to the file. In case of an external file the full URL. + */ +function libraries_file_exists($file) { + return (file_exists($file) || (url_is_external($file) && fopen($file, 'r'))); +}