Commit 159b78d9 authored by Henri MEDOT's avatar Henri MEDOT
Browse files

Yet another final rewrite of the attachment process.

parent 35f6be0f
......@@ -153,16 +153,31 @@ function ckeditor_link_ckeditor_link_types() {
function ckeditor_link_elements() {
$type = array();
if (user_access('access ckeditor link')) {
$type['textarea'] = array('#post_render' => array('ckeditor_link_text_format_post_render'));
$type['textarea'] = array('#pre_render' => array('ckeditor_link_textarea_pre_render'));
$type['form'] = array('#post_render' => array('ckeditor_link_form_post_render'));
}
return $type;
}
function ckeditor_link_text_format_post_render($content, $element) {
static $added = FALSE;
if (!$added && ($js = drupal_add_js()) && isset($js['setting'])) {
function ckeditor_link_textarea_pre_render($element) {
_ckeditor_link_has_textarea(TRUE);
return $element;
}
function _ckeditor_link_has_textarea($set = FALSE) {
static $has = FALSE;
if (!$set) {
return $has;
}
$has = TRUE;
}
function ckeditor_link_form_post_render($content, $element) {
static $added;
if (!isset($added) && _ckeditor_link_has_textarea() && ($js = drupal_add_js()) && isset($js['setting'])) {
$setting = call_user_func_array('array_merge_recursive', $js['setting']);
if (isset($setting['ckeditor']) || isset($setting['wysiwyg']['configs']['ckeditor'])) {
$added = TRUE;
drupal_add_css(drupal_get_path('module', 'ckeditor_link') .'/ckeditor_link.css');
drupal_add_js('misc/autocomplete.js');
drupal_add_js(array('ckeditor_link' => array(
......@@ -173,7 +188,6 @@ function ckeditor_link_text_format_post_render($content, $element) {
'type_name' => ckeditor_link_get_link_type_name(),
'type_selected' => (bool) variable_get('ckeditor_link_type_selected', 1),
)), 'setting');
$added = TRUE;
}
}
return $content;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment