You are here

function editor_format_ensure_additional_properties in Editor 7

Ensures that a text format has the additional properties added by Editor.

This is required when interacting with a format freshly loaded with filter_format_load() because filter.module does not provide a way to load additional data when a format is retrieved from the database.

@todo Remove this when we can alter filter_format_load() or filter_formats().

Parameters

object $format: An object representing the text format.

7 calls to editor_format_ensure_additional_properties()
CKEditor::isCompatible in InPlaceEditors/CKEditor.php
Implements QuickEditInPlaceEditorInterface::isCompatible().
EditorFilterCRUDTestCase::verifyTextFormat in ./editor.test
Verifies that a text format is properly stored.
editor_ckeditor_get_settings in modules/editor_ckeditor/editor_ckeditor.module
Editor JS settings callback; Add CKEditor settings to the page for a format.
editor_ckeditor_image_dialog_form in modules/editor_ckeditor/includes/editor_ckeditor.pages.inc
Form callback: Display a form for inserting/editing a link.
editor_ckeditor_link_dialog_form in modules/editor_ckeditor/includes/editor_ckeditor.pages.inc
Form callback: Display a form for inserting/editing a link.

... See full list

File

./editor.module, line 762
Allows rich text fields to be edited using WYSIWYG client-side editors.

Code

function editor_format_ensure_additional_properties($format) {
  if (empty($format->editor)) {
    $format->editor = NULL;
  }
  if (empty($format->editor_settings)) {
    $format->editor_settings = array();
  }
  else {

    // Unserialize the editor settings when necessary.
    $editor_settings = $format->editor_settings;
    if ($editor_settings == serialize(false) || @unserialize($editor_settings) !== false) {
      $format->editor_settings = unserialize($editor_settings);
    }
  }
  if (empty($format->filters)) {
    $format->filters = array();
    $filters = filter_list_format($format->format);
    foreach ($filters as $name => $filter) {
      $format->filters[$name] = $filter;
    }
  }
}