Mercurial > defr > drupal > core
comparison includes/common.inc @ 11:589fb7c02327 6.5
Drupal 6.5
author | Franck Deroche <webmaster@defr.org> |
---|---|
date | Tue, 23 Dec 2008 14:32:19 +0100 |
parents | acef7ccb09b5 |
children | 8b6c45761e01 |
comparison
equal
deleted
inserted
replaced
10:6f15c9d74937 | 11:589fb7c02327 |
---|---|
1 <?php | 1 <?php |
2 // $Id: common.inc,v 1.756.2.24 2008/08/13 23:59:12 drumm Exp $ | 2 // $Id: common.inc,v 1.756.2.27 2008/10/08 20:12:17 goba Exp $ |
3 | 3 |
4 /** | 4 /** |
5 * @file | 5 * @file |
6 * Common functions that many Drupal modules will need to reference. | 6 * Common functions that many Drupal modules will need to reference. |
7 * | 7 * |
2059 // URL changed. Files that should not be cached (see drupal_add_js()) | 2059 // URL changed. Files that should not be cached (see drupal_add_js()) |
2060 // get time() as query-string instead, to enforce reload on every | 2060 // get time() as query-string instead, to enforce reload on every |
2061 // page request. | 2061 // page request. |
2062 $query_string = '?'. substr(variable_get('css_js_query_string', '0'), 0, 1); | 2062 $query_string = '?'. substr(variable_get('css_js_query_string', '0'), 0, 1); |
2063 | 2063 |
2064 // For inline Javascript to validate as XHTML, all Javascript containing | |
2065 // XHTML needs to be wrapped in CDATA. To make that backwards compatible | |
2066 // with HTML 4, we need to comment out the CDATA-tag. | |
2067 $embed_prefix = "\n<!--//--><![CDATA[//><!--\n"; | |
2068 $embed_suffix = "\n//--><!]]>\n"; | |
2069 | |
2064 foreach ($javascript as $type => $data) { | 2070 foreach ($javascript as $type => $data) { |
2065 | 2071 |
2066 if (!$data) continue; | 2072 if (!$data) continue; |
2067 | 2073 |
2068 switch ($type) { | 2074 switch ($type) { |
2069 case 'setting': | 2075 case 'setting': |
2070 $output .= '<script type="text/javascript">jQuery.extend(Drupal.settings, '. drupal_to_js(call_user_func_array('array_merge_recursive', $data)) .");</script>\n"; | 2076 $output .= '<script type="text/javascript">' . $embed_prefix . 'jQuery.extend(Drupal.settings, ' . drupal_to_js(call_user_func_array('array_merge_recursive', $data)) . ");" . $embed_suffix . "</script>\n"; |
2071 break; | 2077 break; |
2072 case 'inline': | 2078 case 'inline': |
2073 foreach ($data as $info) { | 2079 foreach ($data as $info) { |
2074 $output .= '<script type="text/javascript"'. ($info['defer'] ? ' defer="defer"' : '') .'>'. $info['code'] ."</script>\n"; | 2080 $output .= '<script type="text/javascript"' . ($info['defer'] ? ' defer="defer"' : '') . '>' . $embed_prefix . $info['code'] . $embed_suffix . "</script>\n"; |
2075 } | 2081 } |
2076 break; | 2082 break; |
2077 default: | 2083 default: |
2078 // If JS preprocessing is off, we still need to output the scripts. | 2084 // If JS preprocessing is off, we still need to output the scripts. |
2079 // Additionally, go through any remaining scripts if JS preprocessing is on and output the non-cached ones. | 2085 // Additionally, go through any remaining scripts if JS preprocessing is on and output the non-cached ones. |