Commit eb40966a authored by gifad's avatar gifad Committed by Bálint Nagy
Browse files

Issue #2571791 by gifad, DeFr, nagy.balint: Wysiwyg related plugins and...

Issue #2571791 by gifad, DeFr, nagy.balint: Wysiwyg related plugins and functions should be in the mee module
parent 580a52aa
Loading
Loading
Loading
Loading
+2 −0
Changes for modules/fields/mee/mee.info: 2 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -6,3 +6,5 @@ dependencies[] = text
dependencies[] = dnd
dependencies[] = scald
core = 7.x

stylesheets[all][] = css/editor-global.css
+30 −0
Changes for modules/fields/mee/mee.install: 30 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -175,3 +175,33 @@ function mee_update_7002() {
    variable_set('mee_store_format', 'sas');
  }
}

/**
 * Update plugins paths in CKEditor profiles.
 */
function mee_update_7003() {
  if(module_exists('ckeditor')) {
    module_load_include('inc', 'ckeditor', 'includes/ckeditor.lib');
    $profiles_list = ckeditor_profile_input_formats();
    $plugins_list = ckeditor_load_plugins();
    foreach ($profiles_list AS $_profile => $_inputs) {
      $changed = FALSE;
      $profile = ckeditor_profile_load($_profile);
      if (!isset($profile->settings['loadPlugins'])) continue;
      foreach (array_keys((array) $profile->settings['loadPlugins']) as $plugin_name) {
        if (in_array($plugin_name, array('dnd', 'dndck4'))) {
          $profile->settings['loadPlugins'][$plugin_name] = $plugins_list[$plugin_name];
          $changed = TRUE;
        }
      }
      if ($changed === TRUE) {
        db_update('ckeditor_settings')
            ->fields(array(
              'settings' => serialize($profile->settings)
            ))
            ->condition('name', $profile->name, '=')
            ->execute();
      }
    }
  }
}
+66 −0
Changes for modules/fields/mee/mee.module: 66 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -64,9 +64,75 @@ function mee_library() {
    ),
  );

  // This file is included automatically if the CKEditor plugin is enabled.
  // However we need to load it directly in Drupal so that strings can be
  // translated.
  $plugin = mee_store_format() !== 'embed_div' ? 'ckeditor' : 'dndck4';
  $libraries['library']['js'][$path . '/plugins/' . $plugin . '/lang/en.js'] = array();

  return $libraries;
}

/**
 * Implements hook_wywiwyg_plugin().
 */
function mee_wysiwyg_plugin($editor, $version) {
  $plugins = array();
  $mee_store_format = mee_store_format();
  switch ($editor) {
    case 'ckeditor':
      if ($mee_store_format == 'sas') {
        $plugins['dnd'] = array(
          'path' => drupal_get_path('module', 'mee') . '/plugins/ckeditor',
          'filename' => 'plugin.js',
          'buttons' => array(
            'dnd' => t('Scald DnD integration'),
          ),
          'load' => TRUE,
        );
      }
      elseif ($mee_store_format == 'embed_div') {
        $plugins['dndck4'] = array(
          'path' =>  drupal_get_path('module', 'mee') . '/plugins/dndck4',
          'filename' => 'plugin.js',
          'buttons' => array(
            'dndck4' => t('Scald DnD integration - CKEditor 4 widgets'),
          ),
          'load' => TRUE,
        );
      }
      break;
  }

  return $plugins;
}

/**
 * Implements hook_ckeditor_plugin().
 */
function mee_ckeditor_plugin() {
  $plugins = array();
  $mee_store_format = mee_store_format();
  if ($mee_store_format == 'sas') {
    $plugins['dnd'] = array(
      'name' => 'dnd',
      'desc' => t('Scald Drag and Drop integration'),
      'path' =>  drupal_get_path('module', 'mee') . '/plugins/ckeditor/',
      'buttons' => array(),
    );
  }
  elseif ($mee_store_format == 'embed_div' && version_compare(ckeditor_get_version(), '4.3.0') >= 0) {
    $plugins['dndck4'] = array(
      'name' => 'dndck4',
      'desc' => t('Scald Drag and Drop integration - CKEditor 4 widgets'),
      'path' =>  drupal_get_path('module', 'mee') . '/plugins/dndck4/',
      'buttons' => array(),
    );
  }

  return $plugins;
}

/**
 * Implements hook_views_api().
 */
Loading