Index: includes/common.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/common.inc,v retrieving revision 1.766 diff -u -r1.766 common.inc --- includes/common.inc 14 May 2008 13:15:09 -0000 1.766 +++ includes/common.inc 15 May 2008 00:41:25 -0000 @@ -1913,6 +1913,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 @@ -1951,37 +1952,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)); } } @@ -2045,29 +2031,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 .= '\n"; + $output .= '\n"; break; case 'inline': - foreach ($data as $info) { - $output .= '\n"; - } + $output .= '\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] .= '\n"; - } - else { - $files[$path] = $info; - } + if (!$item['preprocess'] || !$is_writable || !$preprocess_js) { + $no_preprocess[] .= '\n"; + } + else { + $files[] = $item; } } } @@ -2076,7 +2055,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 .= '' . "\n"; + $preprocessed .= '' . "\n"; } // Keep the order of JS files consistent as some are preprocessed and others are not. @@ -2233,10 +2212,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']) . ';'; } }