Révision 5721e759
Ajouté par Assos Assos il y a presque 10 ans
drupal7/sites/all/modules/token_insert/token_insert_ckeditor/token_insert_ckeditor.module | ||
---|---|---|
10 | 10 |
*/ |
11 | 11 |
function token_insert_ckeditor_menu() { |
12 | 12 |
$items = array(); |
13 |
$items['token_insert_ckeditor/insert'] = array( |
|
13 |
$items['token_insert_ckeditor/insert/%'] = array(
|
|
14 | 14 |
'page callback' => '_token_insert_ckeditor_tokens_output', |
15 |
'page arguments' => array(2), |
|
15 | 16 |
'access arguments' => array('access content'), |
16 | 17 |
'type' => MENU_CALLBACK, |
18 |
'delivery callback' => 'ajax_deliver', |
|
17 | 19 |
); |
18 | 20 |
|
19 | 21 |
return $items; |
... | ... | |
39 | 41 |
/** |
40 | 42 |
* Print out the tokens in a CKEditor-readable format. |
41 | 43 |
*/ |
42 |
function _token_insert_ckeditor_tokens_output() { |
|
43 |
module_load_include('inc', 'token_insert', 'token_insert'); |
|
44 |
$options = token_insert_get_tokens(); |
|
44 |
function _token_insert_ckeditor_tokens_output($id) { |
|
45 |
$html = theme('token_insert_tree'); |
|
46 |
$commands = array(); |
|
47 |
$commands[] = array( |
|
48 |
'command' => 'insert', |
|
49 |
'method' => 'html', |
|
50 |
'selector' => '#' . $id, |
|
51 |
'data' => $html, |
|
52 |
'settings' => NULL, |
|
53 |
); |
|
54 |
$commands[] = ajax_command_invoke('#' . $id, 'trigger', array('token-insert-table-loaded')); |
|
55 |
return array('#type' => 'ajax', '#commands' => $commands); |
|
56 |
} |
|
57 |
|
|
58 |
/** |
|
59 |
* Implements hook_element_info_alter(). |
|
60 |
*/ |
|
61 |
function token_insert_ckeditor_element_info_alter(&$types) { |
|
62 |
$types['text_format']['#pre_render'][] = 'token_insert_ckeditor_pre_render_text_format'; |
|
63 |
} |
|
45 | 64 |
|
46 |
$tokens = array(); |
|
65 |
function token_insert_ckeditor_pre_render_text_format($element) { |
|
66 |
$element['#attached']['library'][] = array('system', 'drupal.ajax'); |
|
67 |
return $element; |
|
68 |
} |
|
47 | 69 |
|
48 |
foreach ($options as $token_key => $description) { |
|
49 |
$tokens[] = array($description, $token_key); |
|
70 |
function token_insert_ckeditor_custom_theme() { |
|
71 |
if (strpos(current_path(), 'token_insert_ckeditor/insert') === 0) { |
|
72 |
return 'seven'; |
|
50 | 73 |
} |
51 |
|
|
52 |
print json_encode($tokens); |
|
53 | 74 |
} |
Formats disponibles : Unified diff
Weekly update of contrib modules