Commit aa61bdcc authored by Devin Carlson's avatar Devin Carlson

Fixed CKEditor buttons using embed button name instead of ID.

parent f1b615c1
......@@ -19,9 +19,7 @@ function entity_embed_ckeditor_plugin() {
);
// Add user-defined buttons.
ctools_include('export');
$embed_buttons = ctools_export_crud_load_all('entity_embed');
$embed_buttons = entity_embed_embed_button_load_all();
$buttons = array();
......
......@@ -104,6 +104,19 @@ function entity_embed_filter_format_load($format_id) {
return isset($formats[$format_id]) ? $formats[$format_id] : FALSE;
}
/**
* Load all embed button objects from the database.
*
* @return
* An array of all loaded embed button objects, keyed by the unique IDs of the
* export key.
*/
function entity_embed_embed_button_load_all() {
ctools_include('export');
return ctools_export_crud_load_all('entity_embed');
}
/**
* Loads an embed button object from the database.
*
......@@ -116,9 +129,8 @@ function entity_embed_filter_format_load($format_id) {
* has been marked as disabled, FALSE is returned.
*/
function entity_embed_embed_button_load($button_id) {
ctools_include('export');
$embed_buttons = entity_embed_embed_button_load_all();
$embed_buttons = ctools_export_crud_load_all('entity_embed');
return isset($embed_buttons[$button_id]) ? $embed_buttons[$button_id] : FALSE;
}
......@@ -154,10 +166,10 @@ function _entity_embed_preview_format_access($format) {
*/
function _entity_embed_button_is_enabled($filter_format, $embed_button) {
module_load_include('inc', 'ckeditor', 'includes/ckeditor.lib');
$button_label = $embed_button->name;
$button_name = $embed_button->name;
$profile = ckeditor_get_profile($filter_format->format);
$settings = $profile->settings;
if (strpos($settings['toolbar'], "'" . $button_label . "'")) {
if (strpos($settings['toolbar'], "'" . $button_name . "'")) {
return TRUE;
}
......@@ -567,9 +579,8 @@ function entity_embed_pre_render_text_format($element) {
return $element;
}
ctools_include('export');
$embed_buttons = ctools_export_crud_load_all('entity_embed');
// Add user-defined buttons.
$embed_buttons = entity_embed_embed_button_load_all();
$buttons = array();
......
......@@ -134,7 +134,7 @@
if (editor.ui.addButton) {
for (var key in Drupal.settings.entity_embed.DrupalEntity_buttons) {
var button = Drupal.settings.entity_embed.DrupalEntity_buttons[key];
editor.ui.addButton(button.name, {
editor.ui.addButton(button.id, {
label: button.label,
data: button,
click: function(editor) {
......
Markdown is supported
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