You are here

function panopoly_wysiwyg_wysiwyg_editor_settings_alter in Panopoly WYSIWYG 7

Implementation of hook_wysiwyg_editor_settings_alter()

See also

panopoly_wysiwyg_alter_wysiwyg_editor_settings().

File

./panopoly_wysiwyg.module, line 318

Code

function panopoly_wysiwyg_wysiwyg_editor_settings_alter(&$settings, $context) {

  // Only work the magic on the Panopoly profiles
  if (strpos($context['profile']->format, 'panopoly_') === 0) {
    panopoly_wysiwyg_alter_wysiwyg_editor_settings($settings, $context);
  }
  elseif ($context['profile']->editor == 'tinymce') {

    // However, the 'pdw' or 'Kitchen Sink' plugin (which we've made available)
    // requires some extra configuration or it'll break. So, we'll set this up
    // to prevent user text formats from breaking (see issue #1846322).
    if (!isset($settings['pdw_toggle_on'])) {
      $settings['pdw_toggle_on'] = '1';
    }
    if (!isset($settings['pdw_toggle_toolbars'])) {
      $toolbars = array();
      if (!empty($settings['theme_advanced_buttons2'])) {
        $toolbars[] = '2';
      }
      if (!empty($settings['theme_advanced_buttons3'])) {
        $toolbars[] = '3';
      }
      if (empty($toolbars)) {

        // Issue #2058917: If we have no toolbars then we need to disable 'pdw'
        // all together, otherwise there'll be Javascript errors.
        $settings['plugins'] = implode(',', array_diff(explode(',', $settings['plugins']), array(
          '-pdw',
        )));
      }
      else {
        $settings['pdw_toggle_toolbars'] = implode(',', $toolbars);
      }
    }
  }
}