Fix for Code

Rob Loach's picture
  1.   // Add additional CSS and JavaScript files associated with this element.
  2.   foreach (array('css', 'js') as $kind) {
  3.     if (!empty($elements['#attached_' . $kind]) && is_array($elements['#attached_' . $kind])) {
  4.       foreach ($elements['#attached_' . $kind] as $data => $options) {
  5.         // If the value is not an array, it's a filename and passed as first
  6.         // (and only) argument.
  7.         if (!is_array($options)) {
  8.           $data = $options;
  9.           $options = NULL;
  10.         }
  11.         // When drupal_add_js with 'type' => 'setting' is called, the first
  12.         // parameter ($data) is an array. Arrays can't be keys in PHP, so we
  13.         // have to get $data from the value array.
  14.         if (is_numeric($data)) {
  15.           $data = $options['data'];
  16.           unset($options['data']);
  17.         }
  18.         call_user_func('drupal_add_' . $kind, $data, $options);
  19.       }
  20.     }
  21.   }

Submit Fix

Any tags you'd like to associate with your code, delimitered by commas (example: Views, CCK, Module, etc).
Select the syntax highlighting mode to use.