1
|
<?php
|
2
|
|
3
|
/**
|
4
|
* @file
|
5
|
* This module provides wysiwyg support for token insert.
|
6
|
*/
|
7
|
function token_insert_wysiwyg_wysiwyg_include_directory($type) {
|
8
|
switch ($type) {
|
9
|
case 'plugins':
|
10
|
return $type;
|
11
|
}
|
12
|
}
|
13
|
|
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;
|
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;
|
37
|
}
|
38
|
|
39
|
function token_insert_wysiwyg_menu() {
|
40
|
|
41
|
$items = array();
|
42
|
$items['token_insert_wysiwyg/insert/%'] = array(
|
43
|
'page callback' => 'token_insert_wysiwyg_page',
|
44
|
'page arguments' => array(2),
|
45
|
'access callback' => TRUE,
|
46
|
'delivery callback' => 'ajax_deliver',
|
47
|
'type' => MENU_CALLBACK,
|
48
|
);
|
49
|
|
50
|
return $items;
|
51
|
}
|
52
|
|
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,
|
61
|
);
|
62
|
return array('#type' => 'ajax', '#commands' => $commands);
|
63
|
}
|
64
|
|
65
|
function token_insert_wysiwyg_custom_theme() {
|
66
|
if (strpos(current_path(), 'token_insert_wysiwyg/insert') === 0) {
|
67
|
return 'seven';
|
68
|
}
|
69
|
}
|