class CKEditor in Editor 7
Defines the CKEditor in-place editor.
Hierarchy
- class \CKEditor implements QuickEditInPlaceEditorInterface
Expanded class hierarchy of CKEditor
3 string references to 'CKEditor'
- EditorTestCase::testLibrary in ./
editor.test - Test the addition of the library to the page when configured.
- editor_ckeditor_editor_info in modules/
editor_ckeditor/ editor_ckeditor.editor.inc - Implements hook_editor_info().
- editor_quickedit_editor_info in ./
editor.quickedit.inc - Implements hook_quickedit_editor_info().
File
- InPlaceEditors/
CKEditor.php, line 15
View source
class CKEditor implements QuickEditInPlaceEditorInterface {
/**
* Implements QuickEditInPlaceEditorInterface::isCompatible().
*
* @see Drupal 8's \Drupal\editor\Plugin\quickedit\editor\Editor::isCompatible().
*/
public function isCompatible(array $instance, array $items) {
$field = field_info_field($instance['field_name']);
// This editor is incompatible with multivalued fields.
if ($field['cardinality'] != 1) {
return FALSE;
}
elseif (!empty($instance['settings']['text_processing'])) {
$format_id = $items[0]['format'];
if ($format = filter_format_load($format_id)) {
editor_format_ensure_additional_properties($format);
if ($format->editor == 'ckeditor') {
return TRUE;
}
}
return FALSE;
}
}
/**
* Implements QuickEditInPlaceEditorInterface::getMetadata().
*
* @see Drupal 8's \Drupal\editor\Plugin\quickedit\editor\Editor::getMetadata().
*/
public function getMetadata(array $instance, array $items) {
$format_id = $items[0]['format'];
$metadata['format'] = $format_id;
$metadata['formatHasTransformations'] = (bool) count(array_intersect(array(
FILTER_TYPE_TRANSFORM_REVERSIBLE,
FILTER_TYPE_TRANSFORM_IRREVERSIBLE,
), filter_get_filter_types_by_format($format_id)));
return $metadata;
}
/**
* Implements QuickEditInPlaceEditorInterface::getAttachments().
*
* @see Drupal 8's \Drupal\editor\Plugin\quickedit\editor\Editor::getAttachments().
*/
public function getAttachments() {
global $user;
// Get a list of formats to which the current user has access.
$formats = filter_formats($user);
// Get filter configuration information for the available formats.
$settings = editor_get_attached($formats);
// Also include editor.module's formatted text editor.
$settings['library'][] = array(
'editor',
'quickedit.inPlaceEditor.formattedText',
);
$settings['js'][] = array(
'type' => 'setting',
'data' => array(
'quickedit' => array(
'ckeditor' => array(
'basePath' => base_path() . drupal_get_path('module', 'editor_ckeditor') . '/lib/ckeditor/',
),
),
),
);
return $settings;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
CKEditor:: |
public | function |
Implements QuickEditInPlaceEditorInterface::getAttachments(). Overrides QuickEditInPlaceEditorInterface:: |
|
CKEditor:: |
public | function |
Implements QuickEditInPlaceEditorInterface::getMetadata(). Overrides QuickEditInPlaceEditorInterface:: |
|
CKEditor:: |
public | function |
Implements QuickEditInPlaceEditorInterface::isCompatible(). Overrides QuickEditInPlaceEditorInterface:: |