Projet

Général

Profil

Révision 5721e759

Ajouté par Assos Assos il y a presque 10 ans

Weekly update of contrib modules

Voir les différences:

drupal7/sites/all/modules/highlightjs/contrib/highlight_js_filter/highlight_js_filter.info
4 4
dependencies[] = filter
5 5
core = 7.x
6 6

  
7
; Information added by drupal.org packaging script on 2012-12-29
8
version = "7.x-1.0"
7
; Information added by Drupal.org packaging script on 2014-06-26
8
version = "7.x-1.1"
9 9
core = "7.x"
10 10
project = "highlightjs"
11
datestamp = "1356797547"
11
datestamp = "1403806728"
12 12

  
drupal7/sites/all/modules/highlightjs/contrib/highlight_js_filter/highlight_js_filter.module
117 117
  $text = preg_replace("/^\n/", '', preg_replace('@</?(br|p)\s*/?>@', '', str_replace('\"', '"', $text)));
118 118
  // Trim leading and trailing linebreaks
119 119
  $text = trim($text, "\n");
120
  // Escape newlines
121
  $text = nl2br($text);
122 120
  $class = empty($lang) ? '' : ' class="' . $lang . '"';
123 121
  $text = '<pre><code' . $class . '>' . highlight_js_filter_fix_spaces(str_replace(' ', '&nbsp;', $text)) . '</code></pre>';
124 122
  return $text;
drupal7/sites/all/modules/highlightjs/highlight_js.info
4 4
core = 7.x
5 5
dependencies[] = libraries
6 6

  
7
; Information added by drupal.org packaging script on 2012-12-29
8
version = "7.x-1.0"
7
; Information added by Drupal.org packaging script on 2014-06-26
8
version = "7.x-1.1"
9 9
core = "7.x"
10 10
project = "highlightjs"
11
datestamp = "1356797547"
11
datestamp = "1403806728"
12 12

  
drupal7/sites/all/modules/token_insert/README.txt
10 10
- Token insert (text): Add a fieldset under each textarea, works for both plain text fields and wysiwyg fields.
11 11
- Token insert (wysiwyg): Adds an extra button to wysiwyg editors and opens a popup to select the token to insert.
12 12

  
13
Instructions
14
============
15
1. Install the module
16
2. Configure available tokens at admin/config/content/token_insert
17
3. Enable Token Insert for each field that requires it
18
   a. Go to admin/structure/types/manage/
19
   b. Select "Manage Fields" for content type you would like to add Token Insert to
20
   c. Select "Edit" for the field you would like to add Token Insert to
21
   d. Find the "Token Insert" fieldset and check "Use Token Insert for this field"
22
   e. Configure permissions for "use token insert" at admin/people/permissions
23

  
13 24
Dependencies
14 25
============
15 26
-Token
drupal7/sites/all/modules/token_insert/token_insert.inc
1 1
<?php
2 2
/**
3 3
 * @file
4
 * wysiwyg plugin hook.
4
 * Helper functions for token_insert.module.
5 5
 */
6 6

  
7 7
function token_insert_get_tokens() {
8 8
  global $user;
9 9
  $roles['global'] = 'global';
10
  if(variable_get('token_insert_use_tokens_per_role', 0)){
10
  if (variable_get('token_insert_use_tokens_per_role', 0)) {
11 11
    $roles += $user->roles;
12 12
  }
13 13
  $all_tokens = token_get_info();
14
  foreach($roles as $rid => $role){
14
  foreach ($roles as $rid => $role) {
15 15
    foreach ($all_tokens['tokens'] as $category => $tokens) {
16
      $allowed_options = variable_get('token_insert_' . $rid . '_used_tokens_' . $category, array());
16
      // Check to see if all tokens are enabled for this category.
17
      $allow_all = variable_get('token_insert_' . $rid . '_all_tokens_' . $category, FALSE);
18
      if (!$allow_all) {
19
        $allowed_options = variable_get('token_insert_' . $rid . '_used_tokens_' . $category, array());
20
      }
17 21
      foreach ($tokens as $token => $description) {
18
        if (!empty ($allowed_options)) {
19
          if (isset($allowed_options[$token]) && $allowed_options[$token] === $token) {
20
            $options[$category . ':' . $token] = $category . ' : [' . $token . '] : ' . truncate_utf8($description['description'], 60, TRUE, TRUE);
22
        $full_token = '[' . $category . ':' . $token . ']';
23
        if ($allow_all) {
24
          $options[$full_token] = $category . ' : [' . $token . '] : ' . truncate_utf8($description['description'], 60, TRUE, TRUE);
25
        }
26
        else {
27
          if (!empty ($allowed_options)) {
28
            if (isset($allowed_options[$full_token]) && $allowed_options[$full_token]) {
29
              $options[$full_token] = $category . ' : [' . $token . '] : ' . truncate_utf8($description['description'], 60, TRUE, TRUE);
30
            }
31
            else {
32
              $all_options[$full_token] = $category . ' : [' . $token . '] : ' . truncate_utf8($description['description'], 60, TRUE, TRUE);
33
            }
21 34
          }
22 35
          else {
23
            $all_options[$category . ':' . $token] = $category . ' : [' . $token . '] : ' . truncate_utf8($description['description'], 60, TRUE, TRUE);
36
            $all_options[$full_token] = $category . ' : [' . $token . '] : ' . truncate_utf8($description['description'], 60, TRUE, TRUE);
24 37
          }
25 38
        }
26
        else{
27
          $all_options[$category . ':' . $token] = $category . ' : [' . $token . '] : ' . truncate_utf8($description['description'], 60, TRUE, TRUE);
28
        }
29 39
      }
30 40
    }
31 41
  }
......
33 43
    $options = $all_options;
34 44
  }
35 45
  return $options;
36

  
37
  
38 46
}
39 47

  
48
function token_insert_get_allowed_token_types() {
49
  global $user;
50
  $roles['global'] = 'global';
51
  if (variable_get('token_insert_use_tokens_per_role', 0)) {
52
    $roles += $user->roles;
53
  }
54
  $all_tokens = token_get_info();
55
  foreach ($roles as $rid => $role) {
56
    foreach ($all_tokens['tokens'] as $category => $tokens) {
57
      // Check to see if all tokens are enabled for this category.
58
      $allow_all = variable_get('token_insert_' . $rid . '_all_tokens_' . $category, FALSE);
59
      if (!$allow_all) {
60
        $allowed_options = variable_get('token_insert_' . $rid . '_used_tokens_' . $category, array());
61
      }
62
      foreach ($tokens as $token => $description) {
63
        $full_token = '[' . $category . ':' . $token . ']';
64
        if ($allow_all) {
65
          $options[$category] = $category;
66
          break;
67
        }
68
        else {
69
          if (!empty ($allowed_options)) {
70
            if (isset($allowed_options[$full_token]) && $allowed_options[$full_token]) {
71
              $options[$category] = $category;
72
              break;
73
            }
74
            else {
75
              $all_options[$category] = $category;
76
              break;
77
            }
78
          }
79
          else {
80
            $all_options[$category] = $category;
81
              break;
82
          }
83
        }
84
      }
85
    }
86
  }
87
  if (empty($options)) {
88
    $options = $all_options;
89
  }
90
  return $options;
91
}
drupal7/sites/all/modules/token_insert/token_insert.info
6 6
files[] = token_insert.inc
7 7
files[] = token_insert.module
8 8
files[] = token_insert.js
9
configure = admin/config/content/formats
9 10

  
10
; Information added by drupal.org packaging script on 2012-08-09
11
version = "7.x-2.1"
11
; Information added by Drupal.org packaging script on 2014-07-02
12
version = "7.x-2.4"
12 13
core = "7.x"
13 14
project = "token_insert"
14
datestamp = "1344501143"
15
datestamp = "1404308328"
15 16

  
drupal7/sites/all/modules/token_insert/token_insert.install
1
<?php
2
/**
3
 * @file
4
 * Install and update hooks for the Token Insert module.
5
 */
6

  
7
/**
8
 * Update variable keys to support list tokens.
9
 */
10
function token_insert_update_7001() {
11
  $roles = user_roles();
12
  $roles['global'] = 'global';
13
  $all_tokens = token_get_info();
14
  foreach ($roles as $rid => $role) {
15
    foreach ($all_tokens['tokens'] as $category => $tokens) {
16
      // Check to see if all tokens are enabled for this category.
17
      $allow_all = variable_get('token_insert_' . $rid . '_all_tokens_' . $category, FALSE);
18
      if (!$allow_all) {
19
        $allowed_options = variable_get('token_insert_' . $rid . '_used_tokens_' . $category, array());
20
      }
21
      else {
22
        variable_set('token_insert_' . $rid . '_used_tokens_' . $category, array());
23
        continue;
24
      }
25
      foreach ($tokens as $token => $description) {
26
        $full_token = '[' . $category . ':' . $token . ']';
27
        if (!empty ($allowed_options)) {
28
          if (isset($allowed_options[$token]) ) {
29
            $allowed_options[$full_token] = $allowed_options[$token] ? $full_token : 0;
30
            unset($allowed_options[$token]);
31
          }
32
        }
33
      }
34
      variable_set('token_insert_' . $rid . '_used_tokens_' . $category, $allowed_options);
35
    }
36
  }
37
}
drupal7/sites/all/modules/token_insert/token_insert.js
1

  
1
/*jshint strict:true, browser:true, curly:true, eqeqeq:true, expr:true, forin:true, latedef:true, newcap:true, noarg:true, trailing: true, undef:true, unused:true */
2
/*global jQuery: true*/
2 3
// General Insert API functions.
3 4
(function ($) {
5
  "use strict";
4 6
  $.fn.insertAtCursor = function (tagName) {
5 7
    return this.each(function(){
6 8
      if (document.selection) {
7 9
        //IE support
8 10
        this.focus();
9
        sel = document.selection.createRange();
11
        var sel = document.selection.createRange();
10 12
        sel.text = tagName;
11 13
        this.focus();
12
      }else if (this.selectionStart || this.selectionStart == '0') {
14
      }
15
      else if (this.selectionStart || this.selectionStart === 0) {
13 16
        //MOZILLA/NETSCAPE support
14
        startPos = this.selectionStart;
15
        endPos = this.selectionEnd;
16
        scrollTop = this.scrollTop;
17
        var startPos = this.selectionStart;
18
        var endPos = this.selectionEnd;
19
        var scrollTop = this.scrollTop;
17 20
        this.value = this.value.substring(0, startPos) + tagName + this.value.substring(endPos,this.value.length);
18 21
        this.focus();
19 22
        this.selectionStart = startPos + tagName.length;
......
26 29
    });
27 30
  };
28 31
})(jQuery);
32

  
drupal7/sites/all/modules/token_insert/token_insert.module
16 16
}
17 17

  
18 18
function token_insert_menu() {
19
  
19

  
20 20
  $items['admin/config/content/token_insert'] = array(
21 21
    'title' => 'Token insert',
22 22
    'description' => 'Change the token users can insert.',
......
25 25
    'page arguments' => array('token_insert_settings_form'),
26 26
    'access arguments' => array('administer token insert settings'),
27 27
  );
28
  
28

  
29 29
  return $items;
30 30
}
31 31

  
32
/**
33
 * Implements hook_theme().
34
 */
35
function token_insert_theme() {
36
  $info['token_insert_tree'] = array(
37
    'variables' => array(
38
    ),
39
  );
40

  
41
  return $info;
42
}
43

  
32 44
function token_insert_settings_form($form_state) {
33 45
  $form = array();
34
  $form['tokens'] = array(
35
      '#type' => 'vertical_tabs',
46
  $form['general'] = array(
47
    '#type' => 'fieldset',
48
    '#title' => t('General settings'),
49
    '#description' => t('Configure general token insert settings'),
50
    '#collapsible' => FALSE,
36 51
  );
37
  $form['tokens_per_role'] = array(
38
      '#type' => 'fieldset',
39
      '#title' => t('Token Insert per role'),
40
      '#description' => t('Configure available tokens per user role'),
41
      '#collapsible' => FALSE,
52

  
53
  $form['general']['token_insert_use_tokens_per_role'] = array(
54
    '#type' => 'checkbox',
55
    '#title' => t('Use tokens per role'),
56
    '#default_value' => variable_get('token_insert_use_tokens_per_role', 0),
42 57
  );
43 58

  
44
  $form['tokens_per_role']['token_insert_use_tokens_per_role'] = array(
45
      '#type' => 'checkbox',
46
      '#title' => t('Use tokens per role'),
47
      '#default_value' => variable_get('token_insert_use_tokens_per_role', 0),
59
  $form['general']['token_insert_max_depth'] = array(
60
    '#type' => 'textfield',
61
    '#title' => t('Maximum depth'),
62
    '#default_value' => variable_get('token_insert_max_depth', 1),
63
    '#description' => t('An integer with the maximum number of token levels to recurse'),
64
    '#element_validate' => array('element_validate_integer_positive'),
48 65
  );
49 66

  
50 67
  $roles ['global'] = 'global';
51
  if(variable_get('token_insert_use_tokens_per_role', 0)){
68
  if (variable_get('token_insert_use_tokens_per_role', 0)) {
52 69
    $roles += user_roles(TRUE, 'use token insert');
53 70
  }
54 71
  $all_tokens = token_get_info();
55 72

  
56
  foreach($roles as $rid => $role){
57
    $title = t("Available tokens for $role");
58
    $description = t("Available tokens for users with the '$role' role");
59
    if($rid == 'global'){
73
  foreach ($roles as $rid => $role) {
74
    $title = t("Available tokens for @role", array('@role' => $role));
75
    $description = t("Available tokens for users with the '@role' role", array('@role' => $role));
76
    if ($rid == 'global') {
60 77
      $title = t('Globally available tokens');
61 78
      $description = t('Tokens available for every user');
62 79
    }
......
67 84
      '#collapsible' => TRUE,
68 85
      '#collapsed' => TRUE,
69 86
    );
87
    $form[$rid . '_available_tokens'][$rid . '_tokens'] = array(
88
      '#type' => 'vertical_tabs',
89
    );
70 90
    foreach ($all_tokens['tokens'] as $category => $tokens) {
71

  
72
      $form[$rid . '_available_tokens'][$category] = array(
91
      $form[$rid . '_available_tokens']['tokens'][$category] = array(
73 92
        '#type' => 'fieldset',
74
        '#title' => t($category),
93
        '#title' => t($all_tokens['types'][$category]['name']),
75 94
        '#collapsible' => TRUE,
76 95
        '#collapsed' => TRUE,
96
        '#group' => $rid . '_tokens',
97
        '#description' => t('Select ' . $all_tokens['types'][$category]['name'] . ' tokens available for insertion.'),
77 98
      );
78 99

  
79 100
      $options = array();
80 101
      $defaults = array();
81 102

  
82 103
      foreach ($tokens as $token => $description) {
83
        $options[$token] = $category . ' : [' . $token . '] : ' . t($description['description']);
84
        $defaults[$token] = 0;
104
        $full_token = '[' . $category . ':' . $token . ']';
105
        $options[$full_token] = $category . ' : [' . $token . '] : ' . t($description['description']);
106
        $defaults[$full_token] = 0;
85 107
      }
86 108

  
109
      $form[$rid . '_available_tokens']['tokens'][$category]['token_insert_' . $rid . '_all_tokens_' . $category] = array(
110
        '#type' => 'checkbox',
111
        '#title' => t('All tokens'),
112
        '#default_value' => variable_get('token_insert_' . $rid . '_all_tokens_' . $category, FALSE),
113
        '#description' => t('Make all ' . $all_tokens['types'][$category]['name'] . ' tokens available for insertion.'),
114
      );
87 115

  
88
      $form[$rid . '_available_tokens'][$category]['token_insert_' . $rid . '_used_tokens_' . $category] = array(
116
      $form[$rid . '_available_tokens']['tokens'][$category]['token_insert_' . $rid . '_used_tokens_' . $category] = array(
89 117
        '#type' => 'checkboxes',
90 118
        '#title' => t('Select tokens'),
91 119
        '#default_value' => variable_get('token_insert_' . $rid . '_used_tokens_' . $category, array()),
92 120
        '#options' => $options,
93
        '#description' => t('Select ' . $category . ' tokens available for insert.')
121
        '#states' => array(
122
          'visible' => array(   // action to take.
123
            ':input[name=token_insert_' . $rid . '_all_tokens_' . $category . ']' => array('checked' => FALSE),
124
          ),
125
        ),
126

  
94 127
      );
95 128
    }
96 129
  }
97
  
130

  
98 131
  return system_settings_form($form);
99 132
}
100 133

  
101
function token_insert_help($path, $arg){
102
  if($path == 'admin/help#token_insert'){
134
function token_insert_help($path, $arg) {
135
  if ($path == 'admin/help#token_insert') {
103 136
    $output = <<<EOT
104 137
    <h3>Description</h3>
105 138
    <p>This module allows you to insert tokens into a textarea. It supports both plain text and wysiwyg textareas. The format used for the insert is compatible with Token filter.</p>
......
126 159
  return $output;
127 160
  }
128 161

  
129
}
162
}
163

  
164
function theme_token_insert_tree() {
165
  module_load_include('pages.inc', 'token');
166
  module_load_include('inc', 'token_insert');
167
  $info = token_get_info();
168

  
169
  $options = array(
170
    'flat' => FALSE,
171
    'restricted' => FALSE,
172
    'depth' => variable_get('token_insert_max_depth', 1) <= 0 ? 1 : variable_get('token_insert_max_depth', 1),
173
  );
174
  $tokens = token_insert_get_tokens(TRUE);
175
  foreach (token_insert_get_allowed_token_types() as $token_type) {
176
    $row = _token_token_tree_format_row($token_type, $info['types'][$token_type], TRUE);
177
    unset($row['data']['value']);
178
    $rows[] = $row;
179
    $tree = token_flatten_tree(array_intersect_key(token_build_tree($token_type, $options), $tokens));
180
    foreach ($tree as $token => $token_info) {
181
      if (!isset($token_info['parent'])) {
182
        $token_info['parent'] = $token_type;
183
      }
184
      $row = _token_token_tree_format_row($token, $token_info);
185
      unset($row['data']['value']);
186
      $rows[] = $row;
187
    }
188
  }
189
  $element = array(
190
    '#theme' => 'tree_table',
191
    '#header' => array(
192
      t('Name'),
193
      t('Token'),
194
      t('Description'),
195
    ),
196
    '#rows' => $rows,
197
    '#attributes' => array('class' => array('token-tree', 'token-insert-table')),
198
    '#empty' => t('No tokens available'),
199
    '#attached' => array(
200
      'js' => array(drupal_get_path('module', 'token') . '/token.js'),
201
      'css' => array(drupal_get_path('module', 'token') . '/token.css'),
202
      'library' => array(array('token', 'treeTable')),
203
    ),
204
    '#caption' => t('Click a token to insert it into the field.'),
205
    '#click_insert' => FALSE,
206
  );
207
  $output = drupal_render($element);
208
  return $output;
209
}
drupal7/sites/all/modules/token_insert/token_insert_ckeditor/plugins/token_insert_ckeditor/plugin.js
1
/*jshint strict:true, browser:true, curly:true, eqeqeq:true, expr:true, forin:true, latedef:true, newcap:true, noarg:true, trailing: true, undef:true, unused:true */
2
/*global Drupal:true, jQuery: true, CKEDITOR:true*/
1 3
(function($) {
4
  "use strict";
2 5
  CKEDITOR.plugins.add('token_insert_ckeditor', {
3
    init: function(editor, pluginPath) {
4
      var tokens = [];
5

  
6
      // Ajax call to get the tokens.
7
      $.getJSON(Drupal.settings.basePath + 'token_insert_ckeditor/insert', function(data) {
8
        tokens = data;
9
      });
6
    init: function(editor) {
7
      var id = 'token-insert-' + editor.id + '-dialog-container';
8
      var dialogcontent = {
9
        id: 'token_insert_ckeditor',
10
        type: 'html',
11
        html: '<div id="' + id + '"></div>'
12
      };
10 13

  
11 14
      // Register a dialog box with CKEditor.
12
      CKEDITOR.dialog.add('token_insert_ckeditor_dialog', function(editor) {
15
      CKEDITOR.dialog.add('token_insert_ckeditor_dialog', function() {
13 16
        return {
14 17
          title: Drupal.t('Insert token'),
15 18
          minWidth: 250,
......
20 23
              label: Drupal.t('Insert a token'),
21 24
              title: Drupal.t('Insert a token'),
22 25
              elements: [
23
                {
24
                  id: 'token_insert_ckeditor',
25
                  type: 'select',
26
                  items: tokens,
27
                  label: Drupal.t('Select a variable to insert:')
28
                }
26
                dialogcontent
29 27
              ]
30 28
            }
31 29
          ],
32
          onOk: function() {
30
          buttons: [CKEDITOR.dialog.cancelButton],
31
          onShow: function () {
33 32
            var editor = this.getParentEditor();
34
            var content = this.getValueOf('info', 'token_insert_ckeditor');
35
            if (content.length > 0) {
36
              editor.insertText('[' + content + ']');
37
            }
33
            var id = 'token-insert-' + editor.id + '-dialog-container';
34
            var $content = $(this.getElement('info', 'token_insert_ckeditor').$);
35
            var ajax_settings = {
36
              url: Drupal.settings.basePath + 'token_insert_ckeditor/insert/' + id,
37
              event: 'dialog.token-insert-ckeditor',
38
              method: 'html'
39
            };
40
            new Drupal.ajax(id, $content[0], ajax_settings);
41
            $content.trigger(ajax_settings.event);
42
            $content.bind('token-insert-table-loaded', function () {
43
              $(this).find('.token-insert-table .token-key').once('token-insert-table', function() {
44
                var $token_link = $(this);
45
                var newThis = $('<a href="javascript:void(0);" title="' + Drupal.t('Insert this token into your form') + '">' + $token_link.html() + '</a>').click(function() {
46
                  var $self = $(this);
47
                  editor.insertText($self.text());
48
                });
49
                $token_link.html(newThis);
50
              });
51
            });
38 52
          }
39 53
        };
40 54
      });
41 55

  
42 56
      // Register a command with CKeditor to launch the dialog box.
43 57
      editor.addCommand('TokenInsert', new CKEDITOR.dialogCommand('token_insert_ckeditor_dialog'));
44

  
45 58
      // Add a button to the CKeditor that executes a CKeditor command.
46 59
      editor.ui.addButton('TokenInsert', {
47 60
        label: Drupal.t('Insert a token'),
......
51 64
    }
52 65
  });
53 66
})(jQuery);
67

  
drupal7/sites/all/modules/token_insert/token_insert_ckeditor/token_insert_ckeditor.info
6 6
dependencies[] = ckeditor
7 7
dependencies[] = token_insert
8 8

  
9
; Information added by drupal.org packaging script on 2012-08-09
10
version = "7.x-2.1"
9
; Information added by Drupal.org packaging script on 2014-07-02
10
version = "7.x-2.4"
11 11
core = "7.x"
12 12
project = "token_insert"
13
datestamp = "1344501143"
13
datestamp = "1404308328"
14 14

  
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
}
drupal7/sites/all/modules/token_insert/token_insert_text/token_insert_text.info
7 7
files[] = token_insert_text.js
8 8
files[] = token_insert_text.module
9 9

  
10
; Information added by drupal.org packaging script on 2012-08-09
11
version = "7.x-2.1"
10
; Information added by Drupal.org packaging script on 2014-07-02
11
version = "7.x-2.4"
12 12
core = "7.x"
13 13
project = "token_insert"
14
datestamp = "1344501143"
14
datestamp = "1404308328"
15 15

  
drupal7/sites/all/modules/token_insert/token_insert_text/token_insert_text.js
1

  
1
/*jshint strict:true, browser:true, curly:true, eqeqeq:true, expr:true, forin:true, latedef:true, newcap:true, noarg:true, trailing: true, undef:true, unused:true */
2
/*global Drupal:true, jQuery: true*/
2 3
/**
3 4
 * Behavior to add "Insert" buttons.
4 5
 */
5
(function ($) {
6
Drupal.behaviors.TokenInsertText = {
7
  attach: function(context) {
8
    // Add the click handler to the insert button.
9
    if(!(typeof(Drupal.settings.token_insert) == 'undefined')){
10
      for(var key in Drupal.settings.token_insert.buttons){
11
        $("#" + key, context).click(insert);
6
(function ($, Drupal) {
7
  "use strict";
8
  Drupal.behaviors.TokenInsertText = {
9
    attach: function(context) {
10
      function insert (e){
11
        var $self = $(this);
12
        e.preventDefault();
13
        var token = $self.text();
14
        var id = $self.closest('.token-insert-text-table').attr('id');
15
        $('#' + Drupal.settings.token_insert.tables[id]).insertAtCursor(token);
16
      }
17
      function bindInsert(id) {
18
        $(context).find("#" + key).find('.token-insert-table .token-key').once('token-insert-table', function() {
19
          var newThis = $('<a href="javascript:void(0);" title="' + Drupal.t('Insert this token into your form') + '">' + $(this).html() + '</a>').click(insert);
20
          $(this).html(newThis);
21
        });
12 22
      }
13
    }
14 23

  
15
    function insert() {
16
      var field = $(this).attr('id');
17
      var selectbox = field.replace('button', 'select');
18
      var content = '[' + $('#' + selectbox ).val() + ']';
19
      $('#' + Drupal.settings.token_insert.buttons[field]).insertAtCursor(content);
20
      return false;
24
      // Add the click handler to the insert button.
25
      if (typeof(Drupal.settings.token_insert) !== 'undefined') {
26
        for (var key in Drupal.settings.token_insert.tables) {
27
          if (Drupal.settings.token_insert.tables.hasOwnProperty(key)) {
28
            bindInsert(key, context);
29
          }
30
        }
31
      }
21 32
    }
22
  }
23
};
24
})(jQuery);
25

  
33
  };
34
})(jQuery, Drupal);
drupal7/sites/all/modules/token_insert/token_insert_text/token_insert_text.module
56 56
}
57 57

  
58 58
function _token_insert_add_token_insert($content, $element) {
59
  module_load_include('inc', 'token_insert', 'token_insert');
60
  drupal_add_js(drupal_get_path('module', 'token_insert') . '/token_insert.js');
61
  drupal_add_js(drupal_get_path('module', 'token_insert_text') . '/token_insert_text.js');
62
  if (!isset($element['summary'])) {
63
    $contentarray = token_insert_text_combobox($element);
64
    $content .= drupal_render($contentarray);
65
  }
66
  if (isset($element['#name'])) {
67
   $content .= drupal_render(drupal_get_form('token_insert_text_combobox', $element['#name']));
68
  }
59
  $contentarray = token_insert_text_table($element);
60
  $content .= drupal_render($contentarray);
69 61
  return $content;
70 62
}
71 63

  
72
function token_insert_text_combobox($element) {
64
function token_insert_text_table($element) {
73 65
  $form = array();
74 66
  if (isset($element['#title'])) {
75
    $options = token_insert_get_tokens();
76
    $name = isset($element['#field_name']) ? $element['#field_name'] : $element['#name'];
77
    $settings['token_insert']['buttons']["token-insert-text-button-$name"] = $element['#id'];
78
    drupal_add_js($settings, array('type' => 'setting')) ;
79
    $form['token_insert_text_combobox'] = array(
80
      '#type' => 'fieldset',
81
      '#collapsible' => TRUE,
82
      '#title' => t('Insert token'),
83
    );
84
    $form['token_insert_text_combobox']['token_insert_text_select'] = array(
85
      '#type' => 'select',
86
      '#options' => $options,
87
      '#attributes' => array(
88
        'id' => array("token-insert-text-select-$name"),
67
    $name = md5(print_r($element, TRUE));
68
    $table_id = drupal_html_id("token-insert-text-table-$name");
69
    $name = md5(print_r($element, TRUE));
70
    $settings = array(
71
      'token_insert' => array(
72
        'tables' => array(
73
          $table_id => $element['#id'],
74
        ),
89 75
      ),
90 76
    );
91

  
92
    $form['token_insert_text_combobox']['token_insert_text_button'] = array(
93
      '#type' => 'button',
94
      '#value' => t('Insert'),
95
      '#executes_submit_callback' => FALSE,
77
    $form['token_insert_text_table_wrapper'] = array(
78
      '#type' => 'container',
96 79
      '#attributes' => array(
97
        'class' => array('token-insert-text-button'),
98
        'rel' => $name,
99
        'id' => array("token-insert-text-button-$name"),
80
        'id' => $table_id,
81
        'class' => array('token-insert-text-table'),
100 82
      ),
83
      '#attached' => array(
84
        'js' => array(
85
          array(
86
            'data' => $settings,
87
            'type' => 'setting',
88
          ),
89
          array(
90
            'data' => drupal_get_path('module', 'token_insert') . '/token_insert.js',
91
          ),
92
          array(
93
            'data' => drupal_get_path('module', 'token_insert_text') . '/token_insert_text.js',
94
          )
95
        ),
96
      ),
97
    );
98
    $form['token_insert_text_table_wrapper']['token_insert_text_table'] = array(
99
      '#theme' => 'token_insert_tree',
101 100
    );
102 101
  }
103 102
  return $form;
drupal7/sites/all/modules/token_insert/token_insert_wysiwyg/plugins/token_insert_wysiwyg.inc
6 6
 */
7 7

  
8 8
/**
9
 * Implementation of hook_wysiwyg_plugin().
9
 * Implementats of hook_wysiwyg_plugin().
10 10
 */
11 11
function token_insert_wysiwyg_token_insert_wysiwyg_plugin() {
12 12
  $plugins['token_insert_wysiwyg'] = array(
drupal7/sites/all/modules/token_insert/token_insert_wysiwyg/plugins/token_insert_wysiwyg/token_insert_wysiwyg.js
1
// $Id
2
(function ($) {
3
function hideShowFieldset(buttonid, action) {
4
  var $fieldset = $('#' + buttonid).closest('fieldset');
5
  $fieldset[action]();
6
}
1
/*jshint strict:true, browser:true, curly:true, eqeqeq:true, expr:true, forin:true, latedef:true, newcap:true, noarg:true, trailing: true, undef:true, unused:true */
2
/*global Drupal:true, jQuery: true*/
3
(function ($, Drupal) {
4
  "use strict";
5
  function hideShowFieldset(buttonid, action) {
6
    var $fieldset = $('#' + buttonid).closest('fieldset');
7
    $fieldset[action]();
8
  }
7 9

  
8
/**
9
 * Wysiwyg plugin button implementation for token_insert plugin.
10
 */
11
Drupal.wysiwyg.plugins.token_insert_wysiwyg = {
12
  /**
13
   * Return whether the passed node belongs to this plugin.
14
   *
15
   * @param node
16
   *   The currently focused DOM element in the editor content.
17
   */
18
  isNode: function(node) {
19
    return ($(node).is('img.token_insert_wysiwyg-token_insert_wysiwyg'));
20
  },
10
  var dialogs = {};
21 11

  
22 12
  /**
23
   * Execute the button.
24
   *
25
   * @param data
26
   *   An object containing data about the current selection:
27
   *   - format: 'html' when the passed data is HTML content, 'text' when the
28
   *     passed data is plain-text content.
29
   *   - node: When 'format' is 'html', the focused DOM element in the editor.
30
   *   - content: The textual representation of the focused/selected editor
31
   *     content.
32
   * @param settings
33
   *   The plugin settings, as provided in the plugin's PHP include file.
34
   * @param instanceId
35
   *   The ID of the current editor instance.
13
   * Wysiwyg plugin button implementation for token_insert plugin.
36 14
   */
37
  invoke: function(data, settings, instanceId) {
38
    Drupal.wysiwyg.plugins.token_insert_wysiwyg.insert_form(data, settings, instanceId);    
39
  },
40
  
41
  
42
  insert_form: function (data, settings, instanceId) {
43
    form_id = Drupal.settings.token_insert_wysiwyg.current_form;
15
  Drupal.wysiwyg.plugins.token_insert_wysiwyg = {
16
    /**
17
     * Return whether the passed node belongs to this plugin.
18
     *
19
     * @param node
20
     *   The currently focused DOM element in the editor content.
21
     */
22
    isNode: function(node) {
23
      return ($(node).is('img.token_insert_wysiwyg-token_insert_wysiwyg'));
24
    },
44 25

  
45
    // Location, where to fetch the dialog.
46
    var aurl = Drupal.settings.basePath + 'index.php?q=token_insert_wysiwyg/insert/' + form_id;
47
    dialogdiv = jQuery('<div id="token-insert-dialog"></div>');
48
    dialogdiv.load(aurl + " #token-insert-wysiwyg-form", function(){
49
      var dialogClose = function () {
50
        try {
51
          dialogdiv.dialog('destroy').remove();
52
        } catch (e) {};
53
      };
54
      btns = {};
55
      btns[Drupal.t('Insert token')] = function () {
26
    /**
27
     * Execute the button.
28
     *
29
     * @param data
30
     *   An object containing data about the current selection:
31
     *   - format: 'html' when the passed data is HTML content, 'text' when the
32
     *     passed data is plain-text content.
33
     *   - node: When 'format' is 'html', the focused DOM element in the editor.
34
     *   - content: The textual representation of the focused/selected editor
35
     *     content.
36
     * @param settings
37
     *   The plugin settings, as provided in the plugin's PHP include file.
38
     * @param instanceId
39
     *   The ID of the current editor instance.
40
     */
41
    invoke: function(data, settings, instanceId) {
42
      Drupal.wysiwyg.plugins.token_insert_wysiwyg.insert_form(data, settings, instanceId);
43
    },
56 44

  
57
        var token = dialogdiv.contents().find('#edit-insert option:selected').val();
58
        var editor_id = instanceId;
59 45

  
60
        token = '[' + token + ']';
61
        Drupal.wysiwyg.plugins.token_insert_wysiwyg.insertIntoEditor(token, editor_id);
62
        jQuery(this).dialog("close");
46
    insert_form: function (data, settings, instanceId) {
47
      if (!dialogs[instanceId]) {
48
        var id = 'token-insert-dialog-' + instanceId;
49
        var $dialogdiv = $('<div id="' + id + '"></div>').appendTo('body');
50
        var ajax_settings = {
51
          url: Drupal.settings.basePath + 'token_insert_wysiwyg/insert/' + instanceId,
52
          event: 'dialog.token-insert-wysiwyg',
53
          method: 'html'
54
        };
55
        new Drupal.ajax(id, $dialogdiv[0], ajax_settings);
56
        $dialogdiv.trigger(ajax_settings.event);
57
      }
58
      else {
59
        dialogs[instanceId].dialog("open");
60
      }
61
    },
63 62

  
64
      };
63
    insertIntoEditor: function (token, editor_id) {
64
      Drupal.wysiwyg.instances[editor_id].insert(token);
65
    },
65 66

  
66
      btns[Drupal.t('Cancel')] = function () {
67
        jQuery(this).dialog("close");
68
      };
67
    /**
68
     * Prepare all plain-text contents of this plugin with HTML representations.
69
     *
70
     * Optional; only required for "inline macro tag-processing" plugins.
71
     *
72
     * @param content
73
     *   The plain-text contents of a textarea.
74
     * @param settings
75
     *   The plugin settings, as provided in the plugin's PHP include file.
76
     * @param instanceId
77
     *   The ID of the current editor instance.
78
     */
79
    attach: function(content, settings) {
80
      content = content.replace(/<!--token_insert_wysiwyg-->/g, this._getPlaceholder(settings));
81
      // hide the token_insert_text fieldset when wysiwyg is enabled,
82
      // token_insert_test won't work then, users should use the
83
      // wysiwyg plugin instead.
84
      if (typeof Drupal.settings.token_insert !== 'undefined') {
85
        for (var index in Drupal.settings.token_insert.buttons) {
86
          if (Drupal.settings.token_insert.buttons.hasOwnProperty(index)) {
87
            hideShowFieldset(index, 'hide');
88
          }
89
        }
90
      }
91
      return content;
92
    },
69 93

  
70
      dialogdiv.dialog({
71
        modal: true,
72
        autoOpen: false,
73
        closeOnEscape: true,
74
        resizable: false,
75
        draggable: false,
76
        autoresize: true,
77
        namespace: 'jquery_ui_dialog_default_ns',
78
        dialogClass: 'jquery_ui_dialog-dialog',
79
        title: Drupal.t('Insert token'),
80
        buttons: btns,
81
        width: 700,
82
        close: dialogClose
83
      });
84
      dialogdiv.dialog("open");
85
    });
86
  },
87
    
88
  insertIntoEditor: function (token, editor_id) {
89
    Drupal.wysiwyg.instances[editor_id].insert(token);
90
  },
94
    /**
95
     * Process all HTML placeholders of this plugin with plain-text contents.
96
     *
97
     * Optional; only required for "inline macro tag-processing" plugins.
98
     *
99
     * @param content
100
     *   The HTML content string of the editor.
101
     * @param settings
102
     *   The plugin settings, as provided in the plugin's PHP include file.
103
     * @param instanceId
104
     *   The ID of the current editor instance.
105
     */
106
    detach: function(content) {
107
      var $content = $('<div>' + content + '</div>');
108
      // show the token_insert_text fieldset when wysiwyg is disabled
109
      if (typeof Drupal.settings.token_insert !== 'undefined') {
110
        for (var index in Drupal.settings.token_insert.buttons) {
111
          if (Drupal.settings.token_insert.buttons.hasOwnProperty(index)) {
112
            hideShowFieldset(index, 'show');
113
          }
114
        }
115
      }
116
      return $content.html();
117
    },
91 118

  
92
  /**
93
   * Prepare all plain-text contents of this plugin with HTML representations.
94
   *
95
   * Optional; only required for "inline macro tag-processing" plugins.
96
   *
97
   * @param content
98
   *   The plain-text contents of a textarea.
99
   * @param settings
100
   *   The plugin settings, as provided in the plugin's PHP include file.
101
   * @param instanceId
102
   *   The ID of the current editor instance.
103
   */
104
  attach: function(content, settings, instanceId) {
105
    content = content.replace(/<!--token_insert_wysiwyg-->/g, this._getPlaceholder(settings));
106
    // hide the token_insert_text fieldset when wysiwyg is enabled,
107
    // token_insert_test won't work then, users should use the
108
    // wysiwyg plugin instead.
109
    if (typeof Drupal.settings.token_insert !== 'undefined') {
110
      $.each(Drupal.settings.token_insert.buttons, function(index, fieldid) {
111
        hideShowFieldset(index, 'hide');
112
      });
119
    /**
120
     * Helper function to return a HTML placeholder.
121
     *
122
     * The 'drupal-content' CSS class is required for HTML elements in the editor
123
     * content that shall not trigger any editor's native buttons (such as the
124
     * image button for this example placeholder markup).
125
     */
126
    _getPlaceholder: function (settings) {
127
      return '<img src="' + settings.path + '/images/spacer.gif" alt="&lt;--token_insert_wysiwyg-&gt;" title="&lt;--token_insert_wysiwyg--&gt;" class="token_insert_wysiwyg-token_insert_wysiwyg drupal-content" />';
113 128
    }
114
    return content;
115
  },
129
  };
116 130

  
117
  /**
118
   * Process all HTML placeholders of this plugin with plain-text contents.
119
   *
120
   * Optional; only required for "inline macro tag-processing" plugins.
121
   *
122
   * @param content
123
   *   The HTML content string of the editor.
124
   * @param settings
125
   *   The plugin settings, as provided in the plugin's PHP include file.
126
   * @param instanceId
127
   *   The ID of the current editor instance.
128
   */
129
  detach: function(content, settings, instanceId) {
130
    var $content = $('<div>' + content + '</div>');
131
    // show the token_insert_text fieldset when wysiwyg is disabled
132
    if (typeof Drupal.settings.token_insert !== 'undefined') {
133
      $.each(Drupal.settings.token_insert.buttons, function(index, fieldid) {
134
        hideShowFieldset(index, 'show');
135
      });
136
    }
137
    $.each($('img.token_insert_wysiwyg-token_insert_wysiwyg', $content), function (i, elem) {
138
      //...
131
  Drupal.ajax.prototype.commands.tokenInsertTable = function (ajax, response, status) {
132
    var $dialogdiv = $(response.selector);
133
    var instanceId = response.instance_id;
134
    $dialogdiv.find('.token-insert-table .token-key').once('token-insert-table', function() {
135
      var newThis = $('<a href="javascript:void(0);" title="' + Drupal.t('Insert this token into your form') + '">' + $(this).html() + '</a>').click(function(e){
136
        e.preventDefault();
137
        var token = $(this).text();
138
        Drupal.wysiwyg.plugins.token_insert_wysiwyg.insertIntoEditor(token, instanceId);
139 139
      });
140
    return $content.html();
141
  },
140
      $(this).html(newThis);
141
    });
142
    var btns = {};
142 143

  
143
  /**
144
   * Helper function to return a HTML placeholder.
145
   *
146
   * The 'drupal-content' CSS class is required for HTML elements in the editor
147
   * content that shall not trigger any editor's native buttons (such as the
148
   * image button for this example placeholder markup).
149
   */
150
  _getPlaceholder: function (settings) {
151
    return '<img src="' + settings.path + '/images/spacer.gif" alt="&lt;--token_insert_wysiwyg-&gt;" title="&lt;--token_insert_wysiwyg--&gt;" class="token_insert_wysiwyg-token_insert_wysiwyg drupal-content" />';
152
  }
153
};
154
})(jQuery);
144
    btns[Drupal.t('Cancel')] = function () {
145
      $dialogdiv.dialog('close');
146
    };
147

  
148
    $dialogdiv.dialog({
149
      modal: false,
150
      autoOpen: false,
151
      closeOnEscape: true,
152
      resizable: false,
153
      draggable: true,
154
      autoresize: true,
155
      namespace: 'jquery_ui_dialog_default_ns',
156
      dialogClass: 'jquery_ui_dialog-dialog',
157
      title: Drupal.t('Insert token'),
158
      buttons: btns,
159
      width: 700
160
    });
161
    $dialogdiv.css({maxHeight: 350});
162
    dialogs[instanceId] = $dialogdiv;
163
    $dialogdiv.dialog("open");
164
  };
165
})(jQuery, Drupal);
drupal7/sites/all/modules/token_insert/token_insert_wysiwyg/token_insert_wysiwyg.info
9 9
files[] = plugins/token_insert_wysiwyg/token_insert_wysiwyg.js
10 10
files[] = plugins/token_insert_wysiwyg/token_insert_wysiwyg.css
11 11

  
12
; Information added by drupal.org packaging script on 2012-08-09
13
version = "7.x-2.1"
12
; Information added by Drupal.org packaging script on 2014-07-02
13
version = "7.x-2.4"
14 14
core = "7.x"
15 15
project = "token_insert"
16
datestamp = "1344501143"
16
datestamp = "1404308328"
17 17

  
drupal7/sites/all/modules/token_insert/token_insert_wysiwyg/token_insert_wysiwyg.module
11 11
  }
12 12
}
13 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');
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;
19 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;
20 37
}
21 38

  
22 39
function token_insert_wysiwyg_menu() {
23 40

  
24 41
  $items = array();
25 42
  $items['token_insert_wysiwyg/insert/%'] = array(
26
    'page callback' => 'drupal_get_form',
27
    'page arguments' => array('token_insert_wysiwyg_form', 3),
43
    'page callback' => 'token_insert_wysiwyg_page',
44
    'page arguments' => array(2),
28 45
    'access callback' => TRUE,
46
    'delivery callback' => 'ajax_deliver',
29 47
    'type' => MENU_CALLBACK,
30 48
  );
31 49

  
32 50
  return $items;
33 51
}
34 52

  
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')
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,
46 61
  );
62
  return array('#type' => 'ajax', '#commands' => $commands);
63
}
47 64

  
48
  return $form;
65
function token_insert_wysiwyg_custom_theme() {
66
  if (strpos(current_path(), 'token_insert_wysiwyg/insert') === 0) {
67
    return 'seven';
68
  }
49 69
}

Formats disponibles : Unified diff