<?php /** * @file * Documentation for Editor module APIs. */ /** * @addtogroup hooks * @{ */ /** * Define text editors, such as WYSIWYGs or toolbars to assist with text input. * * Text editors are bound to an individual text format. When a format is * activated in a 'text_format' element, the text editor associated with the * format should be activated on the text area. * * @return array * An associative array of editors, whose keys are internal editor names, * which should be unique and therefore prefixed with the name of the module. * Each value is an associative array describing the editor, with the * following elements (all are optional except as noted): * - label: The human-readable name of the text editor, translated. * - supports_content_filtering: Whether the editor supports "allowed content * only" filtering. * - supports_inline_editing: Whether the editor supports the inline editing * provided by the Quick Edit module. * - is_xss_safe: Whether this text editor is not vulnerable to XSS attacks. * - supported_element_types: On which form element #types this text editor is * capable of working. * - default settings: An associative array containing default settings for * the editor, to be applied when the editor has not been configured yet. * - libraries callback: The name of a function that returns an array of * libraries which will be attached to the text_format element on which the * editor is being loaded. * - validate callback: The name of a function that validates editor settings. * - submit callback: The name of a function that submits editor settings. * - settings callback: The name of a function that returns configuration * form elements for the editor. See hook_editor_EDITOR_settings() for * details. * - js settings callback: The name of a function that returns configuration * options that should be added to the page via JavaScript for use on the * client side. * * @see filter_example.module * @see hook_filter_info_alter() */ function hook_editor_info() { $editors['myeditor'] = array( 'label' => t('My Editor'), 'supports_content_filtering' => TRUE, 'supports_inline_editing' => TRUE, 'is_xss_safe' => FALSE, 'supported_element_types' => array( "textarea" ), 'default settings' => array( 'enable_toolbar' => TRUE, 'toolbar_buttons' => array('bold', 'italic', 'underline', 'link', 'image'), 'resizeable' => TRUE, ), 'file' => 'includes/myeditor.admin.inc', 'libraries callback' => 'myeditor_get_libraries', 'validate callback' => 'myeditor_settings_form_validate', 'submit callback' => 'myeditor_settings_form_submit', 'settings callback' => 'myeditor_settings_form', 'js settings callback' => 'myeditor_get_js_settings', ); return $editors; } /** * Perform alterations on editor definitions. * * @param array $editors * Array of information on editors exposed by hook_editor_info() * implementations. */ function hook_editor_info_alter(&$editors) { $editors['some_other_editor']['title'] = t('A different name'); } /** * Modifies JavaScript settings that are added for text editors. * * @param array $settings * All the settings that will be added to the page for the text formats to * which a user has access. */ function hook_editor_js_settings_alter(array &$settings) { if (isset($settings['editor']['formats']['basic_html'])) { $settings['editor']['formats']['basic_html']['editor'] = 'MyDifferentEditor'; $settings['editor']['formats']['basic_html']['editorSettings']['buttons'] = array('strong', 'italic', 'underline'); } } /** * Modifies the text editor XSS filter that will be used for the given text format. * * It is only called when an EditorXssFilter will effectively be used; this hook * does not allow one to alter that decision. * * @param string &$editor_xss_filter_class * The text editor XSS filter class that will be used. * @param object $format * The text format configuration entity. Provides context based upon which * one may want to adjust the filtering. * @param object|null $original_format * (optional) The original text format configuration entity (when switching * text formats/editors). Also provides context based upon which one may want * to adjust the filtering. */ function hook_editor_xss_filter_alter(&$editor_xss_filter_class, $format, $original_format = NULL) { $filters = filter_list_format($format); if (isset($filters['filter_wysiwyg']) && $filters['filter_wysiwyg']->status) { $editor_xss_filter_class = 'WysiwygFilter'; } } /** * Modify the language mappings between browser and Drupal language codes. * * @param array $language_mappings * The array of language mappings. */ function hook_editor_browser_drupal_langcode_mappings_alter(array &$language_mappings) { // Remove the Norwegian no|nb language mapping. unset($language_mappings['no']); } /** * @} End of "addtogroup hooks". */