You are here

function ckeditor_pre_render_text_format in CKEditor - WYSIWYG HTML editor 7

This function creates the HTML objects required for CKEditor.

Parameters

$element: A fully populated form element to add the editor to.

Return value

The same $element with extra CKEditor markup and initialization.

1 string reference to 'ckeditor_pre_render_text_format'
ckeditor_element_info_alter in ./ckeditor.module
Implementation of hook_element_info_alter().

File

./ckeditor.module, line 298
CKEditor - The text editor for the Internet - http://ckeditor.com Copyright (c) 2003-2013, CKSource - Frederico Knabben. All rights reserved.

Code

function 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']);
      $element['summary'] = ckeditor_load_by_field($element['summary'], $element['format']['format'], FALSE);
    }
    else {
      $element['value'] = ckeditor_load_by_field($element['value'], $element['format']['format']);
    }
  }
  else {
    $element = ckeditor_load_by_field($element, $element['#format']);
  }
  return $element;
}