You are here

function _wysiwyg_tinymce_plugins in Wysiwyg 6.2

Same name and namespace in other branches
  1. 7.2 editors/tinymce.inc \_wysiwyg_tinymce_plugins()

Return internal plugins for this editor; semi-implementation of hook_wysiwyg_plugin().

1 string reference to '_wysiwyg_tinymce_plugins'
wysiwyg_tinymce_editor in editors/tinymce.inc
Plugin implementation of hook_editor().

File

editors/tinymce.inc, line 1156
Editor integration functions for TinyMCE.

Code

function _wysiwyg_tinymce_plugins($editor) {

  // Buttons which have no icons and only work as menu items. (TinyMCE 4)
  // visualaid - Visual aid
  // selectall - Select All https://github.com/tinymce/tinymce/issues/634
  // Start with a list matching 3.x and modify to match the installed version.
  $plugins = array(
    'default' => array(
      'path' => $editor['library path'] . '/themes/advanced',
      'buttons' => array(
        'bold' => t('Bold'),
        'italic' => t('Italic'),
        'underline' => t('Underline'),
        'strikethrough' => t('Strikethrough'),
        'justifyleft' => t('Align left'),
        'justifycenter' => t('Align center'),
        'justifyright' => t('Align right'),
        'justifyfull' => t('Align full'),
        'bullist' => t('Unordered list'),
        'numlist' => t('Ordered list'),
        'outdent' => t('Outdent'),
        'indent' => t('Indent'),
        'undo' => t('Undo'),
        'redo' => t('Redo'),
        'link' => t('Link'),
        'unlink' => t('Unlink'),
        'anchor' => t('Anchor'),
        'image' => t('Image'),
        'cleanup' => t('Cleanup messy code'),
        'forecolor' => t('Select text color'),
        'backcolor' => t('Select background color'),
        'formatselect' => t('Block format'),
        'styleselect' => t('Styles'),
        'fontselect' => t('Font'),
        'fontsizeselect' => t('Font size'),
        'sup' => t('Superscript'),
        'sub' => t('Subscript'),
        'blockquote' => t('Blockquote'),
        'code' => t('Edit HTML Source'),
        'hr' => t('Insert horizontal ruler'),
        'cut' => t('Cut'),
        'copy' => t('Copy'),
        'paste' => t('Paste'),
        'visualaid' => t('Toggle guidelines/invisible elements'),
        'removeformat' => t('Remove formatting'),
        'charmap' => t('Insert custom character'),
        'help' => t('Help'),
      ),
    ),
    'advhr' => array(
      'buttons' => array(
        'advhr' => t('Advanced horizontal rule'),
      ),
      'extended_valid_elements' => array(
        'hr[class|width|size|noshade]',
      ),
      'url' => _wysiwyg_tinymce_get_plugin_url('advhr'),
    ),
    'advimage' => array(
      'extensions' => array(
        'advimage' => t('Advanced image'),
      ),
      'extended_valid_elements' => array(
        'img[src|alt|title|align|width|height|usemap|hspace|vspace|border|style|class|onmouseover|onmouseout|id|name|longdesc]',
      ),
      'url' => _wysiwyg_tinymce_get_plugin_url('advimage'),
    ),
    'advlink' => array(
      'extensions' => array(
        'advlink' => t('Advanced link'),
      ),
      'extended_valid_elements' => array(
        'a[name|href|target|title|class|onfocus|onblur|onclick|ondlbclick|onmousedown|onmouseup|onmouseover|onmouseout|onkeypress|onkeydown|onkeyup|id|style|rel]',
      ),
      'url' => _wysiwyg_tinymce_get_plugin_url('advlink'),
    ),
    'autosave' => array(
      'extensions' => array(
        'autosave' => t('Auto save'),
      ),
      'url' => _wysiwyg_tinymce_get_plugin_url('autosave'),
    ),
    'bbcode' => array(
      'extensions' => array(
        'bbcode' => t('BBCode'),
      ),
      'url' => _wysiwyg_tinymce_get_plugin_url('bbcode'),
    ),
    'contextmenu' => array(
      'extensions' => array(
        'contextmenu' => t('Context menu'),
      ),
      'url' => _wysiwyg_tinymce_get_plugin_url('contextmenu'),
    ),
    'directionality' => array(
      'buttons' => array(
        'ltr' => t('Left-to-right'),
        'rtl' => t('Right-to-left'),
      ),
      'url' => _wysiwyg_tinymce_get_plugin_url('directionality'),
    ),
    'emotions' => array(
      'buttons' => array(
        'emotions' => t('Emotions'),
      ),
      'url' => _wysiwyg_tinymce_get_plugin_url('emotions'),
    ),
    'fullscreen' => array(
      'buttons' => array(
        'fullscreen' => t('Fullscreen'),
      ),
      'url' => _wysiwyg_tinymce_get_plugin_url('fullscreen'),
    ),
    'inlinepopups' => array(
      'extensions' => array(
        'inlinepopups' => t('Inline popups'),
      ),
      'options' => array(
        'dialog_type' => array(
          'modal',
        ),
      ),
      'url' => _wysiwyg_tinymce_get_plugin_url('inlinepopups'),
    ),
    'insertdatetime' => array(
      'buttons' => array(
        'insertdate' => t('Insert date'),
        'inserttime' => t('Insert time'),
      ),
      'options' => array(
        'plugin_insertdate_dateFormat' => '%Y-%m-%d',
        'plugin_insertdate_timeFormat' => '%H:%M:%S',
      ),
      'url' => _wysiwyg_tinymce_get_plugin_url('insertdatetime'),
    ),
    'media' => array(
      'buttons' => array(
        'media' => t('Media'),
      ),
      'url' => _wysiwyg_tinymce_get_plugin_url('media'),
    ),
    'nonbreaking' => array(
      'buttons' => array(
        'nonbreaking' => t('Insert nonbreaking space'),
      ),
      'url' => _wysiwyg_tinymce_get_plugin_url('nonbreaking'),
    ),
    'paste' => array(
      'buttons' => array(
        'pastetext' => t('Paste text'),
        'pasteword' => t('Paste from Word'),
        'selectall' => t('Select all'),
      ),
      'url' => _wysiwyg_tinymce_get_plugin_url('paste'),
    ),
    'preview' => array(
      'buttons' => array(
        'preview' => t('Preview'),
      ),
      'url' => _wysiwyg_tinymce_get_plugin_url('preview'),
    ),
    'print' => array(
      'buttons' => array(
        'print' => t('Print'),
      ),
      'url' => _wysiwyg_tinymce_get_plugin_url('print'),
    ),
    'safari' => array(
      'path' => $editor['library path'] . '/plugins/safari',
      'extensions' => array(
        'safari' => t('Safari compatibility'),
      ),
    ),
    'searchreplace' => array(
      'buttons' => array(
        'search' => t('Search'),
        'replace' => t('Replace'),
      ),
      'url' => _wysiwyg_tinymce_get_plugin_url('searchreplace'),
    ),
    'style' => array(
      'buttons' => array(
        'styleprops' => t('Advanced CSS styles'),
      ),
      'url' => _wysiwyg_tinymce_get_plugin_url('style'),
    ),
    'table' => array(
      'buttons' => array(
        'tablecontrols' => t('Table'),
      ),
      'url' => _wysiwyg_tinymce_get_plugin_url('table'),
    ),
    'visualchars' => array(
      'buttons' => array(
        'visualchars' => t('Show invisible characters'),
      ),
      'url' => _wysiwyg_tinymce_get_plugin_url('visualchars'),
    ),
  );
  if (version_compare($editor['installed version'], '2.0.6', '>')) {
    $plugins['media'] = array(
      'path' => $editor['library path'] . '/plugins/media',
      'buttons' => array(
        'media' => t('Media'),
      ),
      'url' => 'http://www.tinymce.com/wiki.php/Plugin:media',
      'internal' => TRUE,
      'load' => TRUE,
    );
    $plugins['xhtmlxtras'] = array(
      'path' => $editor['library path'] . '/plugins/xhtmlxtras',
      'buttons' => array(
        'cite' => t('Citation'),
        'del' => t('Deleted'),
        'abbr' => t('Abbreviation'),
        'acronym' => t('Acronym'),
        'ins' => t('Inserted'),
        'attribs' => t('HTML attributes'),
      ),
      'url' => _wysiwyg_tinymce_get_plugin_url('xhtmlxtras'),
    );
  }
  if (version_compare($editor['installed version'], '3.2.5', '>=')) {
    $plugins['autoresize'] = array(
      'extensions' => array(
        'autoresize' => t('Auto resize'),
      ),
      'url' => _wysiwyg_tinymce_get_plugin_url('autoresize'),
    );
    if (version_compare($editor['installed version'], '3.2.6', '>=')) {
      $plugins['wordcount'] = array(
        'extensions' => array(
          'wordcount' => t('Word count'),
        ),
        'url' => _wysiwyg_tinymce_get_plugin_url('wordcount'),
      );
      if (version_compare($editor['installed version'], '3.3', '>=')) {
        unset($plugins['safari']);
        $plugins['advlist'] = array(
          'extensions' => array(
            'advlist' => t('Advanced list'),
          ),
          'url' => _wysiwyg_tinymce_get_plugin_url('advlist'),
        );
        if (version_compare($editor['installed version'], '3.4.1', '>=')) {
          $plugins['lists'] = array(
            'extensions' => array(
              'lists' => t('List normalizer'),
            ),
            'url' => 'http://www.tinymce.com/wiki.php/Plugin:lists',
            'extended_valid_elements' => array(
              'li[class|dir|id|lang|onclick|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style|title|type|value]',
              'ol[class|compact|dir|id|lang|onclick|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|start|style|title|type]',
              'ul[class|compact|dir|id|lang|onclick|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style|title|type]',
            ),
          );
          if (version_compare($editor['installed version'], '3.5.b1', '>=')) {
            $plugins['visualblocks'] = array(
              'buttons' => array(
                'visualblocks' => t('Show blocks'),
              ),
              'url' => version_compare($editor['installed version'], '4.0', '>') ? _wysiwyg_tinymce_get_plugin_url('visualblocks') : NULL,
            );
          }
        }
      }
    }
  }
  if (version_compare($editor['installed version'], '4', '>=')) {
    $removed_plugins = array(
      'advhr',
      'advimage',
      'advlink',
      'inlinepopups',
      'style',
      'emotions',
      'xhtmlxtras',
    );
    foreach ($removed_plugins as $plugin) {
      unset($plugins[$plugin]);
    }
    $removed_default_buttons = array(
      'link',
      'unlink',
      'anchor',
      'image',
      'justifyleft',
      'justifycenter',
      'justifyright',
      'justifyfull',
      'forecolor',
      'backcolor',
      'sup',
      'sub',
      'code',
      'charmap',
      'cleanup',
      'hr',
    );
    foreach ($removed_default_buttons as $button) {
      unset($plugins['default']['buttons'][$button]);
    }
    unset($plugins['insertdatetime']['buttons']['insertdate']);
    $plugins['paste']['buttons'] = array(
      'pastetext' => t('Paste text'),
    );
    unset($plugins['paste']['buttons']['pasteword']);
    $plugins['searchreplace']['buttons'] = array(
      'searchreplace' => t('Search & Replace'),
    );
    $plugins['table']['buttons'] = array(
      'table' => t('table'),
    );
    $plugins['hr'] = array(
      'buttons' => array(
        'hr' => t('Insert horizontal rule'),
      ),
      'extended_valid_elements' => array(
        'hr[class|width|size|noshade]',
      ),
      'url' => _wysiwyg_tinymce_get_plugin_url('hr'),
    );
    $plugins['charmap'] = array(
      'buttons' => array(
        'charmap' => t('Insert special character'),
      ),
      'url' => _wysiwyg_tinymce_get_plugin_url('charmap'),
    );
    $plugins['anchor'] = array(
      'buttons' => array(
        'anchor' => t('Insert anchor/bookmark'),
      ),
      'url' => _wysiwyg_tinymce_get_plugin_url('anchor'),
    );
    $plugins['image'] = array(
      'buttons' => array(
        'image' => t('Insert image'),
      ),
      'url' => _wysiwyg_tinymce_get_plugin_url('image'),
    );
    $plugins['link'] = array(
      'buttons' => array(
        'link' => t('Insert link'),
        'unlink' => t('Remove link'),
      ),
      'url' => _wysiwyg_tinymce_get_plugin_url('link'),
    );
    $plugins['emoticons'] = array(
      'buttons' => array(
        'emoticons' => t('Insert emoticons'),
      ),
      'url' => _wysiwyg_tinymce_get_plugin_url('emoticons'),
    );
    $plugins['code'] = array(
      'buttons' => array(
        'code' => t('Source code'),
      ),
      'url' => _wysiwyg_tinymce_get_plugin_url('code'),
    );
    $plugins['textcolor'] = array(
      'buttons' => array(
        'forecolor' => t('Text color'),
        'backcolor' => t('Background color'),
      ),
      'url' => _wysiwyg_tinymce_get_plugin_url('textcolor'),
    );
    $plugins['default']['buttons'] += array(
      'subscript' => t('Subscript'),
      'superscript' => t('Superscript'),
      'alignleft' => t('Align left'),
      'aligncenter' => t('Align center'),
      'alignright' => t('Align right'),
      'alignjustify' => t('Justify'),
      'selectall' => t('Select all'),
    );
    if (version_compare($editor['installed version'], '4.3.0', '>=')) {
      $plugins['codesample'] = array(
        'buttons' => array(
          'codesample' => t('Insert/edit code sample'),
        ),
        'url' => _wysiwyg_tinymce_get_plugin_url('codesample'),
      );
    }
    if (version_compare($editor['installed version'], '4.5.0', '>=')) {
      $plugins['toc'] = array(
        'buttons' => array(
          'toc' => t('Table of Contents'),
        ),
        'url' => _wysiwyg_tinymce_get_plugin_url('toc'),
      );

      // The list buttons now require the lists plugin.
      $plugins['lists']['buttons'] = array(
        'bullist' => t('Unordered list'),
        'numlist' => t('Ordered list'),
      );
      unset($plugins['default']['buttons']['bullist'], $plugins['default']['buttons']['numlist']);
    }
  }
  foreach ($plugins as &$plugin) {

    // All the plugins are internal and need explicit loading.
    $plugin['internal'] = TRUE;
    $plugin['load'] = TRUE;
  }
  $plugins['default']['load'] = FALSE;
  return $plugins;
}