summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDries Buytaert2009-09-05 15:05:05 (GMT)
committerDries Buytaert2009-09-05 15:05:05 (GMT)
commita539b0e00dedddfea36d4a96b788e42923056a78 (patch)
treefcf4876cbfa5abef45c40e134b99bc30944fde14
parent2431df84a2a6afb07a5214ef748cded72ac87947 (diff)
- Patch by #565496 by dropcube, pwolanin: changed Allow dynamic attaching of other types of stuff to render() structures.
-rw-r--r--includes/ajax.inc2
-rw-r--r--includes/common.inc105
-rw-r--r--includes/form.inc4
-rw-r--r--modules/book/book.module4
-rw-r--r--modules/color/color.module34
-rw-r--r--modules/comment/comment.module12
-rw-r--r--modules/field/field.attach.inc4
-rw-r--r--modules/file/file.field.inc8
-rw-r--r--modules/file/file.module6
-rw-r--r--modules/image/image.admin.inc12
-rw-r--r--modules/menu/menu.admin.inc4
-rw-r--r--modules/menu/menu.module4
-rw-r--r--modules/node/content_types.inc4
-rw-r--r--modules/node/node.pages.inc12
-rw-r--r--modules/path/path.module4
-rw-r--r--modules/simpletest/tests/common.test8
-rw-r--r--modules/system/system.module6
-rw-r--r--modules/taxonomy/taxonomy.admin.inc4
-rw-r--r--modules/toolbar/toolbar.module14
-rw-r--r--modules/tracker/tracker.pages.inc4
-rw-r--r--modules/upload/upload.admin.inc4
-rw-r--r--modules/upload/upload.module4
-rw-r--r--modules/user/user.admin.inc2
23 files changed, 170 insertions, 95 deletions
diff --git a/includes/ajax.inc b/includes/ajax.inc
index e3e324f..478adf5 100644
--- a/includes/ajax.inc
+++ b/includes/ajax.inc
@@ -292,7 +292,7 @@ function ajax_process_form($element) {
// we avoid the problem by checking if the JavaScript has already been added.
if (!isset($js_added[$element['#id']]) && (isset($element['#ajax']['callback']) || isset($element['#ajax']['path'])) && isset($element['#ajax']['event'])) {
drupal_add_library('system', 'form');
- $element['#attached_js'] = array('misc/ajax.js');
+ $element['#attached']['js'][] = 'misc/ajax.js';
$ajax_binding = array(
'url' => isset($element['#ajax']['callback']) ? url('system/ajax') : url($element['#ajax']['path']),
diff --git a/includes/common.inc b/includes/common.inc
index 28897bd..295a435 100644
--- a/includes/common.inc
+++ b/includes/common.inc
@@ -3203,14 +3203,31 @@ function drupal_get_js($scope = 'header', $javascript = NULL) {
}
/**
- * Adds all the attached libraries, JavaScript and CSS to the page.
+ * Add to the page all structures attached to a render() structure.
*
- * @param $libraries
- * An array of depending libraries to be added.
- * @param $js
- * An array of JavaScript components to add.
- * @param $css
- * An array of cascading stylesheets to add.
+ * Libraries, JavaScript, CSS and other types of custom structures are attached
+ * to elements using the #attached property. The #attached property contains an
+ * associative array, where the keys are the the types of the structure, and
+ * the value the attached data. For example:
+ * @code
+ * $build['#attached'] = array(
+ * 'js' => array(drupal_get_path('module', 'taxonomy') . '/taxonomy.js'),
+ * 'css' => array(drupal_get_path('module', 'taxonomy') . '/taxonomy.css'),
+ * );
+ * @endcode
+ *
+ * 'js', 'css', and 'library' are types that get special handling. For any
+ * other kind of attached data, the array key must be the full name of the
+ * callback function and each value an array of arguments. For example:
+ *
+ * @code
+ * $build['#attached']['drupal_set_header'] = array(
+ * array('Content-Type', 'application/rss+xml; charset=utf-8'),
+ * );
+ * @endcode
+ *
+ * @param $elements
+ * The structured array describing the data being rendered.
* @param $weight
* The default weight of JavaScript and CSS being added. This is only applied
* to the stylesheets and JavaScript items that don't have an explicit weight
@@ -3223,12 +3240,26 @@ function drupal_get_js($scope = 'header', $javascript = NULL) {
* Will return FALSE if there were any missing library dependencies. TRUE will
* be returned if all library dependencies were met.
*
- * @see drupal_add_library(), drupal_render()
+ * @see drupal_add_library().
+ * @see drupal_add_js().
+ * @see drupal_add_css().
+ * @see drupal_render().
*/
-function drupal_process_attached(array $libraries = array(), array $js = array(), array $css = array(), $weight = JS_DEFAULT, $dependency_check = FALSE) {
+function drupal_process_attached($elements, $weight = JS_DEFAULT, $dependency_check = FALSE) {
+ // If there is nothing to process then return.
+ if (empty($elements['#attached'])) {
+ return;
+ }
+ // Add defaults to the special attached structures that should be processed differently.
+ $elements['#attached'] += array(
+ 'library' => array(),
+ 'js' => array(),
+ 'css' => array(),
+ );
+
// Add the libraries first.
$success = TRUE;
- foreach ($libraries as $library) {
+ foreach ($elements['#attached']['library'] as $library) {
if (drupal_add_library($library[0], $library[1]) === FALSE) {
$success = FALSE;
// Exit if the dependency is missing.
@@ -3237,10 +3268,13 @@ function drupal_process_attached(array $libraries = array(), array $js = array()
}
}
}
+ unset($elements['#attached']['library']);
// Add both the JavaScript and the CSS.
- foreach (array('js' => $js, 'css' => $css) as $type => $items) {
- foreach ($items as $data => $options) {
+ // The parameters for drupal_add_js() and drupal_add_css() require special
+ // handling.
+ foreach (array('js', 'css') as $type) {
+ foreach ($elements['#attached'][$type] as $data => $options) {
// If the value is not an array, it's a filename and passed as first
// (and only) argument.
if (!is_array($options)) {
@@ -3259,7 +3293,20 @@ function drupal_process_attached(array $libraries = array(), array $js = array()
}
call_user_func('drupal_add_' . $type, $data, $options);
}
+ unset($elements['#attached'][$type]);
+ }
+
+ // Add additional types of attachments specified in the render() structure.
+ // Libraries, Javascript and CSS have been added already, as they require
+ // special handling.
+ foreach ($elements['#attached'] as $callback => $options) {
+ if (function_exists($callback)) {
+ foreach ($elements['#attached'][$callback] as $args) {
+ call_user_func_array($callback, $args);
+ }
+ }
}
+
return $success;
}
@@ -3292,7 +3339,12 @@ function drupal_add_library($module, $name) {
if (!isset($added[$module][$name])) {
if ($library = drupal_get_library($module, $name)) {
// Add all components within the library.
- $added[$module][$name] = drupal_process_attached($library['dependencies'], $library['js'], $library['css'], JS_LIBRARY, TRUE);
+ $elements['#attached'] = array(
+ 'library' => $library['dependencies'],
+ 'js' => $library['js'],
+ 'css' => $library['css'],
+ );
+ $added[$module][$name] = drupal_process_attached($elements, JS_LIBRARY, TRUE);
}
else {
// Requested library does not exist.
@@ -4141,12 +4193,9 @@ function drupal_render(&$elements) {
}
}
- // Add additional libraries, CSS and JavaScript associated with this element.
- drupal_process_attached(
- isset($elements['#attached_library']) ? $elements['#attached_library'] : array(),
- isset($elements['#attached_js']) ? $elements['#attached_js'] : array(),
- isset($elements['#attached_css']) ? $elements['#attached_css'] : array()
- );
+ // Add additional libraries, CSS, JavaScript an other custom
+ // attached data associated with this element.
+ drupal_process_attached($elements);
$prefix = isset($elements['#prefix']) ? $elements['#prefix'] : '';
$suffix = isset($elements['#suffix']) ? $elements['#suffix'] : '';
@@ -4252,12 +4301,9 @@ function drupal_render_cache_get($elements) {
$bin = isset($elements['#cache']['bin']) ? $elements['#cache']['bin'] : 'cache';
if (!empty($cid) && $cache = cache_get($cid, $bin)) {
- // Add additional libraries, CSS and JavaScript associated with this element.
- drupal_process_attached(
- isset($cache->data['#attached_library']) ? $cache->data['#attached_library'] : array(),
- isset($cache->data['#attached_js']) ? $cache->data['#attached_js'] : array(),
- isset($cache->data['#attached_css']) ? $cache->data['#attached_css'] : array()
- );
+ // Add additional libraries, JavaScript, CSS and other data attached
+ // to this element.
+ drupal_process_attached($cache->data);
// Return the rendered output.
return $cache->data['#markup'];;
}
@@ -4284,12 +4330,8 @@ function drupal_render_cache_set($markup, $elements) {
}
$data['#markup'] = $markup;
- // Persist additional CSS and JavaScript files associated with this element.
- foreach (array('css', 'js', 'library') as $kind) {
- if (!empty($elements['#attached_' . $kind])) {
- $data['#attached_' . $kind] = $elements['#attached_' . $kind];
- }
- }
+ // Persist attached data associated with this element.
+ $data['#attached'] = $elements['#attached'];
$bin = isset($elements['#cache']['bin']) ? $elements['#cache']['bin'] : 'cache';
$expire = isset($elements['#cache']['expire']) ? $elements['#cache']['expire'] : CACHE_PERMANENT;
cache_set($cid, $data, $bin, $expire);
@@ -4412,6 +4454,7 @@ function element_basic_defaults() {
'#title' => '',
'#attributes' => array(),
'#required' => FALSE,
+ '#attached' => array(),
);
}
diff --git a/includes/form.inc b/includes/form.inc
index 55eb5e5..198f77a 100644
--- a/includes/form.inc
+++ b/includes/form.inc
@@ -2253,9 +2253,9 @@ function form_process_fieldset(&$element, &$form_state) {
$element['#group_members'] = &$form_state['groups'][$parents];
// Contains form element summary functionalities.
- $element['#attached_js']['misc/form.js'] = array('weight' => JS_LIBRARY + 1);
+ $element['#attached']['js']['misc/form.js'] = array('weight' => JS_LIBRARY + 1);
if (!empty($element['#collapsible'])) {
- $element['#attached_js']['misc/collapse.js'] = array();
+ $element['#attached']['js'][] = 'misc/collapse.js';
}
return $element;
diff --git a/modules/book/book.module b/modules/book/book.module
index ca49a98..1ac28bc 100644
--- a/modules/book/book.module
+++ b/modules/book/book.module
@@ -445,7 +445,9 @@ function _book_add_form_elements(&$form, $node) {
'#collapsible' => TRUE,
'#collapsed' => TRUE,
'#group' => 'additional_settings',
- '#attached_js' => array(drupal_get_path('module', 'book') . '/book.js'),
+ '#attached' => array(
+ 'js' => array(drupal_get_path('module', 'book') . '/book.js'),
+ ),
'#tree' => TRUE,
'#attributes' => array('class' => array('book-outline-form')),
);
diff --git a/modules/color/color.module b/modules/color/color.module
index a08114f..fe62dc0 100644
--- a/modules/color/color.module
+++ b/modules/color/color.module
@@ -148,22 +148,24 @@ function color_scheme_form(&$form_state, $theme) {
'#title' => t('Color set'),
'#options' => $info['schemes'],
'#default_value' => $current,
- // Add Farbtastic color picker.
- '#attached_library' => array(
- array('system', 'farbtastic'),
- ),
- // Add custom CSS.
- '#attached_css' => array(
- $base . '/color.css' => array('preprocess' => FALSE),
- ),
- // Add custom JavaScript.
- '#attached_js' => array(
- $base . '/color.js',
- array(
- 'data' => array('color' => array(
- 'reference' => color_get_palette($theme, TRUE),
- )),
- 'type' => 'setting',
+ '#attached' => array(
+ // Add Farbtastic color picker.
+ 'library' => array(
+ array('system', 'farbtastic'),
+ ),
+ // Add custom CSS.
+ 'css' => array(
+ $base . '/color.css' => array('preprocess' => FALSE),
+ ),
+ // Add custom JavaScript.
+ 'js' => array(
+ $base . '/color.js',
+ array(
+ 'data' => array(
+ 'color' => array('reference' => color_get_palette($theme, TRUE)),
+ ),
+ 'type' => 'setting',
+ ),
),
),
);
diff --git a/modules/comment/comment.module b/modules/comment/comment.module
index b17d3c7..3decfdc 100644
--- a/modules/comment/comment.module
+++ b/modules/comment/comment.module
@@ -590,7 +590,7 @@ function comment_node_page_additions($node) {
$comments = comment_load_multiple($cids);
comment_prepare_thread($comments);
$build = comment_build_multiple($comments);
- $build['#attached_css'][] = drupal_get_path('module', 'comment') . '/comment.css';
+ $build['#attached']['css'][] = drupal_get_path('module', 'comment') . '/comment.css';
$build['pager']['#theme'] = 'pager';
$additions['comments'] = $build;
}
@@ -940,7 +940,9 @@ function comment_form_node_type_form_alter(&$form, $form_state) {
'#collapsible' => TRUE,
'#collapsed' => TRUE,
'#group' => 'additional_settings',
- '#attached_js' => array(drupal_get_path('module', 'comment') . '/comment-node-form.js'),
+ '#attached' => array(
+ 'js' => array(drupal_get_path('module', 'comment') . '/comment-node-form.js'),
+ ),
);
$form['comment']['comment_default_mode'] = array(
'#type' => 'checkbox',
@@ -1006,7 +1008,9 @@ function comment_form_alter(&$form, $form_state, $form_id) {
'#collapsible' => TRUE,
'#collapsed' => TRUE,
'#group' => 'additional_settings',
- '#attached_js' => array(drupal_get_path('module', 'comment') . '/comment-node-form.js'),
+ '#attached' => array(
+ 'js' => array(drupal_get_path('module', 'comment') . '/comment-node-form.js'),
+ ),
'#weight' => 30,
);
$comment_count = isset($node->nid) ? db_query('SELECT comment_count FROM {node_comment_statistics} WHERE nid = :nid', array(':nid' => $node->nid))->fetchField() : 0;
@@ -1614,7 +1618,7 @@ function comment_form(&$form_state, $comment) {
$node = node_load($comment->nid);
if (!$user->uid && variable_get('comment_anonymous_' . $node->type, COMMENT_ANONYMOUS_MAYNOT_CONTACT) != COMMENT_ANONYMOUS_MAYNOT_CONTACT) {
- $form_state['#attached_js'][] = drupal_get_path('module', 'comment') . '/comment.js';
+ $form_state['#attached']['js'][] = drupal_get_path('module', 'comment') . '/comment.js';
}
$comment = (array) $comment;
diff --git a/modules/field/field.attach.inc b/modules/field/field.attach.inc
index 1cdd3b0..4cf57c4 100644
--- a/modules/field/field.attach.inc
+++ b/modules/field/field.attach.inc
@@ -490,7 +490,7 @@ function field_attach_form($obj_type, $object, &$form, &$form_state, $langcode =
// Add custom weight handling.
list($id, $vid, $bundle) = field_attach_extract_ids($obj_type, $object);
- $form['#attached_css'][] = drupal_get_path('module', 'field') . '/theme/field.css';
+ $form['#attached']['css'][] = drupal_get_path('module', 'field') . '/theme/field.css';
$form['#pre_render'][] = '_field_extra_weights_pre_render';
$form['#extra_fields'] = field_extra_fields($bundle);
@@ -1090,7 +1090,7 @@ function field_attach_view($obj_type, $object, $build_mode = 'full', $langcode =
// Add custom weight handling.
list($id, $vid, $bundle) = field_attach_extract_ids($obj_type, $object);
- $output['#attached_css'][] = drupal_get_path('module', 'field') . '/theme/field.css';
+ $output['#attached']['css'][] = drupal_get_path('module', 'field') . '/theme/field.css';
$output['#pre_render'][] = '_field_extra_weights_pre_render';
$output['#extra_fields'] = field_extra_fields($bundle);
diff --git a/modules/file/file.field.inc b/modules/file/file.field.inc
index 48a9247..12c1b60 100644
--- a/modules/file/file.field.inc
+++ b/modules/file/file.field.inc
@@ -71,9 +71,7 @@ function file_field_settings_form($field, $instance) {
$defaults = field_info_field_settings($field['type']);
$settings = array_merge($defaults, $field['settings']);
- $form = array(
- '#attached_js' => array(drupal_get_path('module', 'file') . '/file.js'),
- );
+ $form['#attached']['js'][] = drupal_get_path('module', 'file') . '/file.js';
$form['display_field'] = array(
'#type' => 'checkbox',
@@ -119,9 +117,7 @@ function file_field_settings_form($field, $instance) {
function file_field_instance_settings_form($field, $instance) {
$settings = $instance['settings'];
- $form = array(
- '#attached_js' => array(drupal_get_path('module', 'file') . '/file.js'),
- );
+ $form['#attached']['js'][] = drupal_get_path('module', 'file') . '/file.js';
$form['max_filesize'] = array(
'#type' => 'textfield',
diff --git a/modules/file/file.module b/modules/file/file.module
index 21b1478..4af5bae 100644
--- a/modules/file/file.module
+++ b/modules/file/file.module
@@ -50,8 +50,10 @@ function file_elements() {
'#upload_validators' => array(),
'#upload_location' => NULL,
'#extended' => FALSE,
- '#attached_css' => array($file_path . '/file.css'),
- '#attached_js' => array($file_path . '/file.js'),
+ '#attached' => array(
+ 'css' => array($file_path . '/file.css'),
+ 'js' => array($file_path . '/file.js'),
+ ),
);
return $elements;
diff --git a/modules/image/image.admin.inc b/modules/image/image.admin.inc
index 5f96f50..10faf67 100644
--- a/modules/image/image.admin.inc
+++ b/modules/image/image.admin.inc
@@ -15,7 +15,9 @@ function image_style_list() {
$styles = image_styles();
$page['image_style_list'] = array(
'#markup' => theme('image_style_list', $styles),
- '#attached_css' => array(drupal_get_path('module', 'image') . '/image.admin.css' => array('preprocess' => FALSE)),
+ '#attached' => array(
+ 'css' => array(drupal_get_path('module', 'image') . '/image.admin.css' => array('preprocess' => FALSE)),
+ ),
);
return $page;
@@ -40,7 +42,9 @@ function image_style_form(&$form_state, $style) {
$form_state['image_style'] = $style;
$form = array(
'#tree' => TRUE,
- '#attached_css' => array(drupal_get_path('module', 'image') . '/image.admin.css' => array('preprocess' => FALSE)),
+ '#attached' => array(
+ 'css' => array(drupal_get_path('module', 'image') . '/image.admin.css' => array('preprocess' => FALSE)),
+ ),
);
// Allow the name of the style to be changed.
@@ -313,7 +317,9 @@ function image_effect_form(&$form_state, $style, $effect) {
$form = array(
'#tree' => TRUE,
- '#attached_css' => array(drupal_get_path('module', 'image') . '/image.admin.css' => array('preprocess' => FALSE)),
+ '#attached' => array(
+ 'css' => array(drupal_get_path('module', 'image') . '/image.admin.css' => array('preprocess' => FALSE)),
+ ),
);
if (function_exists($effect['form callback'])) {
$form['data'] = call_user_func($effect['form callback'], $effect['data']);
diff --git a/modules/menu/menu.admin.inc b/modules/menu/menu.admin.inc
index f116a16..48818e7 100644
--- a/modules/menu/menu.admin.inc
+++ b/modules/menu/menu.admin.inc
@@ -448,7 +448,9 @@ function menu_edit_menu(&$form_state, $type, $menu = array()) {
'#maxsize' => MENU_MAX_MENU_NAME_LENGTH_UI,
'#description' => t('This text will be used to construct the URL for the menu. The name must contain only lowercase letters, numbers and hyphens, and must be unique.'),
'#required' => TRUE,
- '#attached_js' => array(drupal_get_path('module', 'system') . '/system.js', $js_settings),
+ '#attached' => array(
+ 'js' => array(drupal_get_path('module', 'system') . '/system.js', $js_settings),
+ ),
);
}
diff --git a/modules/menu/menu.module b/modules/menu/menu.module
index b27217b..cef7433 100644
--- a/modules/menu/menu.module
+++ b/modules/menu/menu.module
@@ -412,7 +412,9 @@ function menu_form_alter(&$form, $form_state, $form_id) {
'#collapsible' => TRUE,
'#collapsed' => FALSE,
'#group' => 'additional_settings',
- '#attached_js' => array(drupal_get_path('module', 'menu') . '/menu.js'),
+ '#attached' => array(
+ 'js' => array(drupal_get_path('module', 'menu') . '/menu.js'),
+ ),
'#tree' => TRUE,
'#weight' => -2,
'#attributes' => array('class' => array('menu-item-form')),
diff --git a/modules/node/content_types.inc b/modules/node/content_types.inc
index c6e9d6d..2236090 100644
--- a/modules/node/content_types.inc
+++ b/modules/node/content_types.inc
@@ -101,7 +101,9 @@ function node_type_form(&$form_state, $type = NULL) {
'#maxlength' => 32,
'#required' => TRUE,
'#description' => t('The machine-readable name of this content type. This text will be used for constructing the URL of the <em>add new content</em> page for this content type. This name must contain only lowercase letters, numbers, and underscores. Underscores will be converted into hyphens when constructing the URL of the <em>add new content</em> page. This name must be unique.'),
- '#attached_js' => array(drupal_get_path('module', 'system') . '/system.js', $js_settings),
+ '#attached' => array(
+ 'js' => array(drupal_get_path('module', 'system') . '/system.js', $js_settings),
+ ),
);
}
else {
diff --git a/modules/node/node.pages.inc b/modules/node/node.pages.inc
index af5f2ff..6016801 100644
--- a/modules/node/node.pages.inc
+++ b/modules/node/node.pages.inc
@@ -172,7 +172,9 @@ function node_form(&$form_state, $node) {
// Collapsed by default when "Create new revision" is unchecked
'#collapsed' => !$node->revision,
'#group' => 'additional_settings',
- '#attached_js' => array(drupal_get_path('module', 'node') . '/node.js'),
+ '#attached' => array(
+ 'js' => array(drupal_get_path('module', 'node') . '/node.js'),
+ ),
'#weight' => 20,
);
$form['revision_information']['revision'] = array(
@@ -198,7 +200,9 @@ function node_form(&$form_state, $node) {
'#collapsible' => TRUE,
'#collapsed' => TRUE,
'#group' => 'additional_settings',
- '#attached_js' => array(drupal_get_path('module', 'node') . '/node.js'),
+ '#attached' => array(
+ 'js' => array(drupal_get_path('module', 'node') . '/node.js'),
+ ),
'#weight' => 90,
);
$form['author']['name'] = array(
@@ -229,7 +233,9 @@ function node_form(&$form_state, $node) {
'#collapsible' => TRUE,
'#collapsed' => TRUE,
'#group' => 'additional_settings',
- '#attached_js' => array(drupal_get_path('module', 'node') . '/node.js'),
+ '#attached' => array(
+ 'js' => array(drupal_get_path('module', 'node') . '/node.js'),
+ ),
'#weight' => 95,
);
$form['options']['status'] = array(
diff --git a/modules/path/path.module b/modules/path/path.module
index 0d811b2..81ae6f4 100644
--- a/modules/path/path.module
+++ b/modules/path/path.module
@@ -234,7 +234,9 @@ function path_form_alter(&$form, $form_state, $form_id) {
'#collapsible' => TRUE,
'#collapsed' => empty($path),
'#group' => 'additional_settings',
- '#attached_js' => array(drupal_get_path('module', 'path') . '/path.js'),
+ '#attached' => array(
+ 'js' => array(drupal_get_path('module', 'path') . '/path.js'),
+ ),
'#access' => user_access('create url aliases'),
'#weight' => 30,
);
diff --git a/modules/simpletest/tests/common.test b/modules/simpletest/tests/common.test
index dc6b0c7..d58a0ec 100644
--- a/modules/simpletest/tests/common.test
+++ b/modules/simpletest/tests/common.test
@@ -896,14 +896,10 @@ class JavaScriptTestCase extends DrupalWebTestCase {
}
/**
- * Tests the addition of libraries through the #attached_library property.
+ * Tests the addition of libraries through the #attached['library'] property.
*/
function testAttachedLibrary() {
- $element = array(
- '#attached_library' => array(
- array('system', 'farbtastic'),
- )
- );
+ $element['#attached']['library'][] = array('system', 'farbtastic');
drupal_render($element);
$scripts = drupal_get_js();
$this->assertTrue(strpos($scripts, 'misc/farbtastic/farbtastic.js'), t('The attached_library property adds the additional libraries.'));
diff --git a/modules/system/system.module b/modules/system/system.module
index 70026bc..4c395d9 100644
--- a/modules/system/system.module
+++ b/modules/system/system.module
@@ -3101,8 +3101,10 @@ function system_page_build(&$page) {
if (system_run_cron_image_access()) {
$page['page_bottom']['run_cron'] = array(
// Trigger cron run via AJAX.
- '#attached_js' => array(
- '(function($){ $.get(' . drupal_to_js(url('system/run-cron-image')) . '); })(jQuery);' => array('type' => 'inline', 'scope' => 'header'),
+ '#attached' => array(
+ 'js' => array(
+ '(function($){ $.get(' . drupal_to_js(url('system/run-cron-image')) . '); })(jQuery);' => array('type' => 'inline', 'scope' => 'header'),
+ ),
),
// Trigger cron run for clients not supporting JavaScript (fall-back).
'#markup' => theme('system_run_cron_image', 'system/run-cron-image'),
diff --git a/modules/taxonomy/taxonomy.admin.inc b/modules/taxonomy/taxonomy.admin.inc
index a95409e..ab011aa 100644
--- a/modules/taxonomy/taxonomy.admin.inc
+++ b/modules/taxonomy/taxonomy.admin.inc
@@ -151,7 +151,9 @@ function taxonomy_form_vocabulary(&$form_state, $edit = array()) {
'#maxlength' => 255,
'#description' => t('The unique machine readable name for this vocabulary, used for theme templates, can only contain lowercase letters, numbers and underscores.'),
'#required' => TRUE,
- '#attached_js' => array(drupal_get_path('module', 'system') . '/system.js', $js_settings),
+ '#attached' => array(
+ 'js' => array(drupal_get_path('module', 'system') . '/system.js', $js_settings),
+ ),
);
$form['help'] = array(
'#type' => 'textfield',
diff --git a/modules/toolbar/toolbar.module b/modules/toolbar/toolbar.module
index b17107c..cbebf75 100644
--- a/modules/toolbar/toolbar.module
+++ b/modules/toolbar/toolbar.module
@@ -61,12 +61,14 @@ function toolbar_build() {
$module_path = drupal_get_path('module', 'toolbar');
$build = array(
'#theme' => 'toolbar',
- '#attached_js' => array(
- $module_path . '/toolbar.js',
- array('data' => 'misc/jquery.cookie.js', 'weight' => JS_LIBRARY + 2),
- ),
- '#attached_css' => array(
- $module_path . '/toolbar.css',
+ '#attached'=> array(
+ 'js' => array(
+ $module_path . '/toolbar.js',
+ array('data' => 'misc/jquery.cookie.js', 'weight' => JS_LIBRARY + 2),
+ ),
+ 'css' => array(
+ $module_path . '/toolbar.css',
+ ),
),
);
diff --git a/modules/tracker/tracker.pages.inc b/modules/tracker/tracker.pages.inc
index b39b415..1466848 100644
--- a/modules/tracker/tracker.pages.inc
+++ b/modules/tracker/tracker.pages.inc
@@ -76,7 +76,9 @@ function tracker_page($account = NULL, $set_title = FALSE) {
'#rows' => $rows,
'#header' => array(t('Type'), t('Post'), t('Author'), t('Replies'), t('Last updated')),
'#theme' => 'table',
- '#attached_css' => array(drupal_get_path('module', 'tracker') . '/tracker.css' => array('preprocess' => FALSE)),
+ '#attached' => array(
+ 'css' => array(drupal_get_path('module', 'tracker') . '/tracker.css' => array('preprocess' => FALSE)),
+ ),
);
$page['pager'] = array(
'#theme' => 'pager',
diff --git a/modules/upload/upload.admin.inc b/modules/upload/upload.admin.inc
index 7d9d147..759cde4 100644
--- a/modules/upload/upload.admin.inc
+++ b/modules/upload/upload.admin.inc
@@ -69,8 +69,8 @@ function upload_admin_settings() {
'#type' => 'fieldset',
'#title' => t('General settings'),
'#collapsible' => TRUE,
- '#attached_css' => array(
- drupal_get_path('module', 'upload') . '/upload.admin.css',
+ '#attached'=> array(
+ 'css' => array(drupal_get_path('module', 'upload') . '/upload.admin.css'),
),
);
$form['settings_general']['upload_max_resolution'] = array(
diff --git a/modules/upload/upload.module b/modules/upload/upload.module
index 26a2844..76bc7b2 100644
--- a/modules/upload/upload.module
+++ b/modules/upload/upload.module
@@ -231,7 +231,9 @@ function upload_form_alter(&$form, $form_state, $form_id) {
'#collapsible' => TRUE,
'#collapsed' => empty($node->files),
'#group' => 'additional_settings',
- '#attached_js' => array(drupal_get_path('module', 'upload') . '/upload.js'),
+ '#attached' => array(
+ 'js' => array(drupal_get_path('module', 'upload') . '/upload.js'),
+ ),
'#description' => t('Changes made to the attachments are not permanent until you save this post. The first "listed" file will be included in RSS feeds.'),
'#weight' => 30,
);
diff --git a/modules/user/user.admin.inc b/modules/user/user.admin.inc
index 99948a3..d68da24 100644
--- a/modules/user/user.admin.inc
+++ b/modules/user/user.admin.inc
@@ -651,7 +651,7 @@ function user_admin_permissions($form_state, $rid = NULL) {
}
$form['submit'] = array('#type' => 'submit', '#value' => t('Save permissions'));
- $form['#attached_js'] = array(drupal_get_path('module', 'user') . '/user.permissions.js');
+ $form['#attached']['js'][] = drupal_get_path('module', 'user') . '/user.permissions.js';
return $form;
}