CKEditor.php in Quick Edit 7
File
InPlaceEditors/CKEditor.php
View source
<?php
module_load_include('php', 'quickedit', 'includes/QuickEditInPlaceEditorInterface');
class CKEditor implements QuickEditInPlaceEditorInterface {
public function isCompatible(array $instance, array $items) {
$field = field_info_field($instance['field_name']);
if ($field['cardinality'] != 1) {
return FALSE;
}
elseif (!empty($instance['settings']['text_processing'])) {
$format_id = $items[0]['format'];
module_load_include('inc', 'ckeditor', 'includes/ckeditor.lib');
if ($ckeditor_profile = ckeditor_get_profile($format_id)) {
if ($settings = ckeditor_profiles_compile($format_id)) {
return $ckeditor_profile->settings['default'] === 't';
}
}
return FALSE;
}
}
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)));
module_load_include('inc', 'ckeditor', 'includes/ckeditor.lib');
if ($settings = ckeditor_profiles_compile($format_id)) {
if (is_string($settings['toolbar'])) {
$toolbar = $settings['toolbar'];
$toolbar = str_replace("'", '"', $toolbar);
$toolbar = preg_replace('/(\\w*)\\s*\\:/', '"${1}":', $toolbar);
$settings['toolbar'] = json_decode($toolbar);
}
if ($settings['skin'] == 'kama') {
$settings['skin'] = 'moono';
}
$field = field_info_field($instance['field_name']);
if (isset($settings['scayt_sLang'])) {
$settings['scayt_language'] = $settings['scayt_sLang'];
unset($settings['scayt_sLang']);
}
elseif (!empty($field["#language"]) && $field["#language"] != LANGUAGE_NONE) {
$settings['scayt_language'] = ckeditor_scayt_langcode($field["#language"]);
}
$metadata['ckeditorSettings'] = $settings;
}
return $metadata;
}
public function getAttachments() {
return array(
'library' => array(
array(
'quickedit',
'quickedit.inPlaceEditor.ckeditor',
),
),
'js' => array(
array(
'type' => 'setting',
'data' => array(
'quickedit' => array(
'ckeditor' => array(
'basePath' => ckeditor_library_path('relative') . '/ckeditor/',
),
),
),
),
),
);
}
}
Classes
Name |
Description |
CKEditor |
Defines the CKEditor in-place editor. |