1 filter.module | filter_get_attached($formats) |
Adds filter configuration information to the page for access by JavaScript.
Parameters
array $formats: An array of formats as returned by filter_formats(), whose settings should be added to the page.
Return value
array: An array of attached libraries, CSS, and JS that can be set to an element's #attached property.
File
- core/
modules/ filter/ filter.module, line 1463 - Framework for handling the filtering of content.
Code
function filter_get_attached($formats) {
$attached = array();
$attached['library'][] = array('filter', 'filter');
foreach ($formats as $format) {
// Add the library associated with a format's editor if exists.
if ($format->editor && ($editor = filter_editor_load($format->editor)) && isset($editor['library'])) {
$attached['library'][] = $editor['library'];
}
}
if (!empty($formats)) {
$settings = filter_get_js_settings($formats);
$attached['js'][] = array(
'type' => 'setting',
'key' => 'filter_formats',
'data' => array('filter' => array('formats' => $settings)),
);
}
return $attached;
}