-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathckeditor_settings.module
47 lines (42 loc) · 1.5 KB
/
ckeditor_settings.module
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<?php
function ckeditor_settings_element_info_alter(&$types) {
if (!empty($types['text_format']['#pre_render'])) {
$types['text_format']['#pre_render'] = array_diff($types['text_format']['#pre_render'], array('ckeditor_pre_render_text_format'));
}
$types['text_format']['#pre_render'][] = 'ckeditor_settings_ckeditor_pre_render_text_format';
}
/**
* This function creates the HTML objects required for CKEditor.
*
* @param $element
* A fully populated form element to add the editor to.
* @return
* The same $element with extra CKEditor markup and initialization.
*/
function ckeditor_settings_ckeditor_pre_render_text_format($element) {
static $init = FALSE;
if (!isset($element['#format'])) {
return $element;
}
module_load_include('inc', 'ckeditor', 'includes/ckeditor.lib');
if ($init === FALSE) {
$input_formats = ckeditor_profiles_compile();
drupal_add_js(array('ckeditor' => array('input_formats' => $input_formats, 'plugins' => array())), 'setting');
$init = TRUE;
}
if (isset($element['value'])) {
if (!isset($element['format'])) {
return $element;
}
if (isset($element['summary'])) {
$element['value'] = ckeditor_load_by_field($element['value'], $element['format']['format'], TRUE, $element['summary']['#id']);
}
else {
$element['value'] = ckeditor_load_by_field($element['value'], $element['format']['format']);
}
}
else {
$element = ckeditor_load_by_field($element, $element['#format']);
}
return $element;
}