Projet

Général

Profil

Paste
Télécharger (1,23 ko) Statistiques
| Branche: | Révision:

root / drupal7 / sites / all / modules / token_insert / token_insert_ckeditor / token_insert_ckeditor.module @ 74f6bef0

1
<?php
2

    
3
/**
4
 * @file
5
 * This module provides CKEditor module support for token insert.
6
 */
7

    
8
/**
9
 * Implements hook_menu().
10
 */
11
function token_insert_ckeditor_menu() {
12
  $items = array();
13
  $items['token_insert_ckeditor/insert'] = array(
14
    'page callback' => '_token_insert_ckeditor_tokens_output',
15
    'access arguments' => array('access content'),
16
    'type' => MENU_CALLBACK,
17
  );
18

    
19
  return $items;
20
}
21

    
22
/**
23
 * Implements hook_ckeditor_plugin().
24
 */
25
function token_insert_ckeditor_ckeditor_plugin() {
26
  return array(
27
    'token_insert_ckeditor' => array(
28
      'name' => 'token_insert_ckeditor',
29
      'desc' => t('Token insert'),
30
      'path' => drupal_get_path('module', 'token_insert_ckeditor') . '/plugins/token_insert_ckeditor/',
31
      'buttons' => array('TokenInsert' => array(
32
        'icon' => 'images/insert.png',
33
        'label' => 'Token insert',
34
      )),
35
    )
36
  );
37
}
38

    
39
/**
40
 * Print out the tokens in a CKEditor-readable format.
41
 */
42
function _token_insert_ckeditor_tokens_output() {
43
  module_load_include('inc', 'token_insert', 'token_insert');
44
  $options = token_insert_get_tokens();
45

    
46
  $tokens = array();
47

    
48
  foreach ($options as $token_key => $description) {
49
    $tokens[] = array($description, $token_key);
50
  }
51

    
52
  print json_encode($tokens);
53
}