Projet

Général

Profil

Révision 5721e759

Ajouté par Assos Assos il y a presque 10 ans

Weekly update of contrib modules

Voir les différences:

drupal7/sites/all/modules/token_insert/token_insert_wysiwyg/token_insert_wysiwyg.module
11 11
  }
12 12
}
13 13

  
14
function token_insert_wysiwyg_form_alter(&$form, $form_state, $form_id) {
15
  if (strpos($form_id, 'node_form') !== FALSE || strpos($form_id, 'comment') !== FALSE) {
16
    drupal_add_library('system', 'ui.dialog');
17
    drupal_add_library('system', 'ui.draggable');
18
    drupal_add_js(array('token_insert_wysiwyg' => array('current_form' => $form['form_build_id']['#value'])), 'setting');
14
/**
15
 * Implements hook_element_info_alter().
16
 */
17
function token_insert_wysiwyg_element_info_alter(&$types) {
18
  $types['text_format']['#pre_render'][] = 'token_insert_wysiwyg_pre_render_text_format';
19
}
20

  
21
function token_insert_wysiwyg_pre_render_text_format($element) {
22
  // filter_process_format() copies properties to the expanded 'value' child
23
  // element. Skip this text format widget, if it contains no 'format' or when
24
  // the current user does not have access to edit the value.
25
  if (!isset($element['format']) || !empty($element['value']['#disabled'])) {
26
    return $element;
19 27
  }
28
  // WYSIWYG module allows modules to programmatically enforce no client-side
29
  // editor by setting the #wysiwyg property to FALSE.
30
  if (isset($element['#wysiwyg']) && !$element['#wysiwyg']) {
31
    return $element;
32
  }
33
  $element['#attached']['library'][] = array('system', 'ui.dialog');
34
  $element['#attached']['library'][] = array('system', 'ui.draggable');
35
  $element['#attached']['library'][] = array('system', 'drupal.ajax');
36
  return $element;
20 37
}
21 38

  
22 39
function token_insert_wysiwyg_menu() {
23 40

  
24 41
  $items = array();
25 42
  $items['token_insert_wysiwyg/insert/%'] = array(
26
    'page callback' => 'drupal_get_form',
27
    'page arguments' => array('token_insert_wysiwyg_form', 3),
43
    'page callback' => 'token_insert_wysiwyg_page',
44
    'page arguments' => array(2),
28 45
    'access callback' => TRUE,
46
    'delivery callback' => 'ajax_deliver',
29 47
    'type' => MENU_CALLBACK,
30 48
  );
31 49

  
32 50
  return $items;
33 51
}
34 52

  
35
function token_insert_wysiwyg_form($form_state, $form_id) {
36
  module_load_include('inc', 'token_insert', 'token_insert');
37
  drupal_set_title(t('Insert token'));
38
  $options = token_insert_get_tokens();
39

  
40
  $form = array();
41
  $form['insert'] = array(
42
    '#type' => 'select',
43
    '#title' => t('Choose the token you want to insert.'),
44
    '#options' => $options,
45
    '#description' => t('This token will be inserted in your textfield')
53
function token_insert_wysiwyg_page($wysiwyg_instance_id) {
54
  $commands = array();
55
  $id = '#token-insert-dialog-' . $wysiwyg_instance_id;
56
  $commands[] = ajax_command_insert($id, theme('token_insert_tree'));
57
  $commands[] = array(
58
    'command' => 'tokenInsertTable',
59
    'selector' => $id,
60
    'instance_id' => $wysiwyg_instance_id,
46 61
  );
62
  return array('#type' => 'ajax', '#commands' => $commands);
63
}
47 64

  
48
  return $form;
65
function token_insert_wysiwyg_custom_theme() {
66
  if (strpos(current_path(), 'token_insert_wysiwyg/insert') === 0) {
67
    return 'seven';
68
  }
49 69
}

Formats disponibles : Unified diff