### Eclipse Workspace Patch 1.0
#P Drupal Head
Index: includes/common.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/common.inc,v
retrieving revision 1.765
diff -u -r1.765 common.inc
--- includes/common.inc 6 May 2008 12:18:45 -0000 1.765
+++ includes/common.inc 12 May 2008 15:15:59 -0000
@@ -1900,6 +1900,9 @@
* 'theme' so that files, that are added later, can override previously added
* files with ease.
*
+ * - Add an external file ('external'):
+ * Adds a reference to an external Javascript file to the page.
+ *
* - Add inline JavaScript code ('inline'):
* Executes a piece of JavaScript code on the current page by placing the code
* directly in the page. This can, for example, be useful to tell the user that
@@ -1914,13 +1917,14 @@
* (optional) If given, the value depends on the $type parameter:
* - 'core', 'module' or 'theme': Path to the file relative to base_path().
* - 'inline': The JavaScript code that should be placed in the given scope.
+ * - 'external': The absolute URL of a JavaScript resource.
* - 'setting': An array with configuration options as associative array. The
* array is directly placed in Drupal.settings. You might want to wrap your
* actual configuration settings in another variable to prevent the pollution
* of the Drupal.settings namespace.
* @param $type
* (optional) The type of JavaScript that should be added to the page. Allowed
- * values are 'core', 'module', 'theme', 'inline' and 'setting'. You
+ * values are 'core', 'module', 'theme', 'inline', 'external' and 'setting'. You
* can, however, specify any value. It is treated as a reference to a JavaScript
* file. Defaults to 'module'.
* @param $scope
@@ -1957,6 +1961,7 @@
),
'module' => array(),
'theme' => array(),
+ 'external' => array(),
'setting' => array(
array('basePath' => base_path()),
),
@@ -1965,7 +1970,7 @@
}
if (isset($scope) && !isset($javascript[$scope])) {
- $javascript[$scope] = array('core' => array(), 'module' => array(), 'theme' => array(), 'setting' => array(), 'inline' => array());
+ $javascript[$scope] = array('core' => array(), 'module' => array(), 'theme' => array(), 'external' => array(), 'setting' => array(), 'inline' => array());
}
if (isset($type) && isset($scope) && !isset($javascript[$scope][$type])) {
@@ -2058,6 +2063,17 @@
$output .= '\n";
}
break;
+ case 'external':
+ foreach ($data as $path => $info) {
+ if (!$info['preprocess'] || !$is_writable || !$preprocess_js) {
+ $output .= '\n";
+ }
+ else {
+ $info['external'] = TRUE;
+ $files[$path] = $info;
+ }
+ }
+ break;
default:
// If JS preprocessing is off, we still need to output the scripts.
// Additionally, go through any remaining scripts if JS preprocessing is on and output the non-cached ones.
@@ -2235,8 +2251,15 @@
// Build aggregate JS file.
foreach ($files as $path => $info) {
if ($info['preprocess']) {
- // Append a ';' after each JS file to prevent them from running together.
- $contents .= file_get_contents($path) . ';';
+ if ($info['external']) {
+ // Request the external Javascript resource if it's from an external source.
+ $request = drupal_http_request($path);
+ $contents .= $request->data . ';';
+ }
+ else {
+ // Append a ';' after each JS file to prevent them from running together.
+ $contents .= file_get_contents($path) . ';';
+ }
}
}