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
|
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');
|
19
|
}
|
20
|
}
|
21
|
|
22
|
function token_insert_wysiwyg_menu() {
|
23
|
|
24
|
$items = array();
|
25
|
$items['token_insert_wysiwyg/insert/%'] = array(
|
26
|
'page callback' => 'drupal_get_form',
|
27
|
'page arguments' => array('token_insert_wysiwyg_form', 3),
|
28
|
'access callback' => TRUE,
|
29
|
'type' => MENU_CALLBACK,
|
30
|
);
|
31
|
|
32
|
return $items;
|
33
|
}
|
34
|
|
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')
|
46
|
);
|
47
|
|
48
|
return $form;
|
49
|
}
|