### Eclipse Workspace Patch 1.0
#P drupal
Index: includes/common.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/common.inc,v
retrieving revision 1.756
diff -u -r1.756 common.inc
--- includes/common.inc	30 Jan 2008 23:07:41 -0000	1.756
+++ includes/common.inc	5 Feb 2008 20:58:47 -0000
@@ -1925,6 +1925,7 @@
  * @param $data
  *   (optional) If given, the value depends on the $type parameter:
  *   - 'core', 'module' or 'theme': Path to the file relative to base_path().
+ *   - 'external': Path to the file without any relative path added.
  *   - 'inline': The JavaScript code that should be placed in the given scope.
  *   - 'setting': An array with configuration options as associative array. The
  *       array is directly placed in Drupal.settings. You might want to wrap your
@@ -1963,37 +1964,22 @@
     // first time a Javascript file is added.
     if (empty($javascript)) {
       $javascript['header'] = array(
-        'core' => array(
-          'misc/jquery.js' => array('cache' => TRUE, 'defer' => FALSE, 'preprocess' => TRUE),
-          'misc/drupal.js' => array('cache' => TRUE, 'defer' => FALSE, 'preprocess' => TRUE),
-        ),
-        'module' => array(),
-        'theme' => array(),
-        'setting' => array(
-          array('basePath' => base_path()),
-        ),
-        'inline' => array(),
+        array('type' => 'core', 'path' => 'misc/jquery.js', 'cache' => TRUE, 'defer' => FALSE, 'preprocess' => TRUE),
+        array('type' => 'core', 'path' => 'misc/drupal.js', 'cache' => TRUE, 'defer' => FALSE, 'preprocess' => TRUE),
+        array('type' => 'setting', 'data' => array('basePath' => base_path()))
       );
     }
 
-    if (isset($scope) && !isset($javascript[$scope])) {
-      $javascript[$scope] = array('core' => array(), 'module' => array(), 'theme' => array(), 'setting' => array(), 'inline' => array());
-    }
-
-    if (isset($type) && isset($scope) && !isset($javascript[$scope][$type])) {
-      $javascript[$scope][$type] = array();
-    }
-
     switch ($type) {
       case 'setting':
-        $javascript[$scope][$type][] = $data;
+        $javascript[$scope][] = array('type' => $type, 'data' => $data);
         break;
       case 'inline':
-        $javascript[$scope][$type][] = array('code' => $data, 'defer' => $defer);
+        $javascript[$scope][] = array('type' => $type, 'code' => $data, 'defer' => $defer);
         break;
       default:
         // If cache is FALSE, don't preprocess the JS file.
-        $javascript[$scope][$type][$data] = array('cache' => $cache, 'defer' => $defer, 'preprocess' => (!$cache ? FALSE : $preprocess));
+        $javascript[$scope][] = array('type' => $type, 'path' => $data, 'cache' => $cache, 'defer' => $defer, 'preprocess' => (!$cache ? FALSE : $preprocess));
     }
   }
 
@@ -2057,29 +2043,22 @@
   // page request.
   $query_string = '?'. substr(variable_get('css_js_query_string', '0'), 0, 1);
 
-  foreach ($javascript as $type => $data) {
-
-    if (!$data) continue;
-
-    switch ($type) {
+  foreach ($javascript as $item) {
+    switch ($item['type']) {
       case 'setting':
-        $output .= '<script type="text/javascript">jQuery.extend(Drupal.settings, '. drupal_to_js(call_user_func_array('array_merge_recursive', $data)) .");</script>\n";
+        $output .= '<script type="text/javascript">jQuery.extend(Drupal.settings, '. drupal_to_js($item['data']) .");</script>\n";
         break;
       case 'inline':
-        foreach ($data as $info) {
-          $output .= '<script type="text/javascript"'. ($info['defer'] ? ' defer="defer"' : '') .'>'. $info['code'] ."</script>\n";
-        }
+        $output .= '<script type="text/javascript"'. ($item['defer'] ? ' defer="defer"' : '') .'>'. $item['code'] ."</script>\n";
         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.
-        foreach ($data as $path => $info) {
-          if (!$info['preprocess'] || !$is_writable || !$preprocess_js) {
-            $no_preprocess[$type] .= '<script type="text/javascript"'. ($info['defer'] ? ' defer="defer"' : '') .' src="'. base_path() . $path . ($info['cache'] ? $query_string : '?'. time()) ."\"></script>\n";
-          }
-          else {
-            $files[$path] = $info;
-          }
+        if (!$item['preprocess'] || !$is_writable || !$preprocess_js) {
+          $no_preprocess[] .= '<script type="text/javascript"'. ($item['defer'] ? ' defer="defer"' : '') .' src="'. ($item['type'] == 'external' ? '' : base_path()) . $item['path'] . ($item['cache'] ? $query_string : '?'. time()) ."\"></script>\n";
+        }
+        else {
+          $files[] = $item;
         }
     }
   }
@@ -2088,7 +2067,7 @@
   if ($is_writable && $preprocess_js && count($files) > 0) {
     $filename = md5(serialize($files) . $query_string) .'.js';
     $preprocess_file = drupal_build_js_cache($files, $filename);
-    $preprocessed .= '<script type="text/javascript" src="'. base_path() . $preprocess_file .'"></script>'."\n";
+    $preprocessed .= '<script type="text/javascript" src="'. ($item['type'] == 'external' ? '' : base_path()) . $preprocess_file .'"></script>'."\n";
   }
 
   // Keep the order of JS files consistent as some are preprocessed and others are not.
@@ -2245,10 +2224,10 @@
 
   if (!file_exists($jspath .'/'. $filename)) {
     // Build aggregate JS file.
-    foreach ($files as $path => $info) {
+    foreach ($files as $info) {
       if ($info['preprocess']) {
         // Append a ';' after each JS file to prevent them from running together.
-        $contents .= file_get_contents($path) .';';
+        $contents .= file_get_contents($info['path']) .';';
       }
     }
 
