t('jWYSIWYG settings'), 'description' => t('Allows administrators to configure several options of this module'), 'page callback' => 'drupal_get_form', 'page arguments' => array('jwysiwyg_settings'), 'access arguments' => array(array('access administration pages', JWYSIWYG_PERM)), 'type' => MENU_NORMAL_ITEM, 'weight' => 0, ); return $items; } /////////////////////////////////////////////////////////////////////////////////////// // Implementation of hook_elements /////////////////////////////////////////////////////////////////////////////////////// function jwysiwyg_elements() { $types = array(); $types['textarea'] = array('#process' => array('jwysiwyg_process_textarea')); return $types; } /////////////////////////////////////////////////////////////////////////////////////// // Our own function for textarea fields processing /////////////////////////////////////////////////////////////////////////////////////// function jwysiwyg_process_textarea($element) { //_debug($element, 'pre jwysiwyg_process_textarea'); // Set the new description, and include a
if a previous description existed. $element['#description'] .= isset($element['#description']) ? '
' : ''; $element['#description'] .= t('jwysiwyg note: The id of this field is @field', array('@field'=>$element['#id'])); // Add our own class for jQuery activation $element['#attributes'] = array('class'=>'jwysiwyg_class'); //_debug($element, 'post jwysiwyg_process_textarea'); return $element; } /////////////////////////////////////////////////////////////////////////////////////// // This module's settings form /////////////////////////////////////////////////////////////////////////////////////// function jwysiwyg_settings() { $form = array(); // Get the current settings $visibility = variable_get(JWYSIWYG_VISIBILITY, array()); $form[JWYSIWYG_VISIBILITY] = array( '#type' => 'fieldset', '#title' => t('Visibility settings'), '#tree' => TRUE, '#collapsible' => TRUE, '#collapsed' => FALSE, ); $form[JWYSIWYG_VISIBILITY][JWYSIWYG_ACTION] = array( '#type' => 'radios', '#title' => t('Where to show the rich text editor?'), '#default_value' => isset($visibility[JWYSIWYG_ACTION]) ? $visibility[JWYSIWYG_ACTION] : JWYSIWYG_ACTION_DEFAULT, '#options' => array(0 => t('Show in each textarea'), 1 => t('Show in all text areas, except in the fields listed bellow'), 2 => t('Show only in the fields listed bellow')), '#description' => t("Choose where to include the jWYSIWYG rich text editor."), '#required' => TRUE, '#weight' => -4, ); $form[JWYSIWYG_VISIBILITY][JWYSIWYG_FIELDS] = array( '#type' => 'textarea', '#title' => t('Field names'), '#default_value' => isset($visibility[JWYSIWYG_FIELDS]) ? $visibility[JWYSIWYG_FIELDS] : '', '#description' => t("Type the name of a field by line, separating them with an enter."), '#required' => FALSE, '#weight' => -3, ); return system_settings_form($form); } /////////////////////////////////////////////////////////////////////////////////////// // Implementation of hook_help(). /////////////////////////////////////////////////////////////////////////////////////// function jwysiwyg_help($path, $arg) { return 'Help is under construction...'; } /////////////////////////////////////////////////////////////////////////////////////// // Implementation of hook_help(). /////////////////////////////////////////////////////////////////////////////////////// function jwysiwyg_perm() { return array(JWYSIWYG_PERM); } /////////////////////////////////////////////////////////////////////////////////////// // Implementation of hook_init(). /////////////////////////////////////////////////////////////////////////////////////// function jwysiwyg_init() { drupal_add_css(drupal_get_path('module', 'jwysiwyg') .'/jquery.wysiwyg.css'); drupal_add_js(drupal_get_path('module', 'jwysiwyg') .'/js/jquery.wysiwyg.js'); $js = <<