1 |
85ad3d82
|
Assos Assos
|
<?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 |
5721e759
|
Assos Assos
|
/**
|
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 |
85ad3d82
|
Assos Assos
|
}
|
28 |
5721e759
|
Assos Assos
|
// 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 |
85ad3d82
|
Assos Assos
|
}
|
38 |
|
|
|
39 |
|
|
function token_insert_wysiwyg_menu() {
|
40 |
|
|
|
41 |
|
|
$items = array();
|
42 |
|
|
$items['token_insert_wysiwyg/insert/%'] = array(
|
43 |
5721e759
|
Assos Assos
|
'page callback' => 'token_insert_wysiwyg_page',
|
44 |
|
|
'page arguments' => array(2),
|
45 |
85ad3d82
|
Assos Assos
|
'access callback' => TRUE,
|
46 |
5721e759
|
Assos Assos
|
'delivery callback' => 'ajax_deliver',
|
47 |
85ad3d82
|
Assos Assos
|
'type' => MENU_CALLBACK,
|
48 |
|
|
);
|
49 |
|
|
|
50 |
|
|
return $items;
|
51 |
|
|
}
|
52 |
|
|
|
53 |
5721e759
|
Assos Assos
|
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 |
85ad3d82
|
Assos Assos
|
);
|
62 |
5721e759
|
Assos Assos
|
return array('#type' => 'ajax', '#commands' => $commands);
|
63 |
|
|
}
|
64 |
85ad3d82
|
Assos Assos
|
|
65 |
5721e759
|
Assos Assos
|
function token_insert_wysiwyg_custom_theme() {
|
66 |
|
|
if (strpos(current_path(), 'token_insert_wysiwyg/insert') === 0) {
|
67 |
|
|
return 'seven';
|
68 |
|
|
}
|
69 |
85ad3d82
|
Assos Assos
|
} |