function editor_get_attached in Editor 7
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.
2 calls to editor_get_attached()
- CKEditor::getAttachments in InPlaceEditors/
CKEditor.php - Implements QuickEditInPlaceEditorInterface::getAttachments().
- editor_process_format in ./
editor.module - A copy of filter_process_format() which adds support for editors.
File
- ./
editor.module, line 448 - Allows rich text fields to be edited using WYSIWYG client-side editors.
Code
function editor_get_attached($formats) {
$attached = array();
foreach ($formats as $format_name => $format_info) {
if (!isset($format_info->editor)) {
$format_info->editor = NULL;
}
if (isset($added[$format_name])) {
unset($formats[$format_name]);
}
else {
// Add the library associated with a format's editor if needed.
if ($format_info->editor && ($editor = editor_load($format_info->editor))) {
$attached['library'][] = $editor['library'];
}
}
}
if (!empty($formats)) {
$settings = editor_get_js_settings($formats);
$attached['js'][] = array(
'type' => 'setting',
'data' => array(
'editor' => array(
'formats' => $settings,
),
),
);
}
return $attached;
}