Projet

Général

Profil

Paste
Télécharger (2,03 ko) Statistiques
| Branche: | Révision:

root / drupal7 / sites / all / modules / media_ckeditor / media_ckeditor.module @ da542b7b

1
<?php
2

    
3
/**
4
 * @file
5
 * Primarily Drupal hooks.
6
 */
7

    
8
/**
9
 * Implements hook_element_info_alter().
10
 */
11
function media_ckeditor_element_info_alter(&$types) {
12
  $types['text_format']['#pre_render'][] = 'media_ckeditor_pre_render_text_format';
13
}
14

    
15
/**
16
 * Adds CKEditor-specific JavaScript.
17
 */
18
function media_ckeditor_pre_render_text_format($element) {
19
  // filter_process_format() copies properties to the expanded 'value' child
20
  // element.
21
  if (!isset($element['format'])) {
22
    return $element;
23
  }
24

    
25
  $field = &$element['value'];
26
  $settings = array(
27
    'field' => $field['#id'],
28
  );
29

    
30
  if (!isset($field['#value'])) {
31
    return $element;
32
  }
33

    
34
  // Add CKEditor-specific JS.
35
  $element['#attached']['js'][] = array(
36
    'data' => drupal_get_path('module', 'media_ckeditor') . '/js/plugins/media/library.js',
37
    'type' => 'file',
38
    'scope' => 'footer',
39
    'weight' => -20,
40
  );
41

    
42
  return $element;
43
}
44

    
45
/**
46
 * Implements hook_form_ID_alter().
47
 */
48
function media_ckeditor_form_media_wysiwyg_format_form_alter(&$form, $form_state) {
49
  // Add our overrides to the media format form javascript.
50
  $form['#attached']['js'][] = drupal_get_path('module', 'media_ckeditor') . '/js/media_ckeditor.format_form.js';
51
}
52

    
53
/**
54
 * Implements hook_media_browser_params_alter().
55
 */
56
function media_ckeditor_media_browser_params_alter(&$stored_params) {
57
  // We add this custom param when the media dialog is invoked in library.js
58
  if (isset($stored_params['id']) && $stored_params['id'] == 'media_wysiwyg') {
59
    // Set the default browser params from settings form if not already set.
60
    if (empty($stored_params['enabledPlugins'])) {
61
      $stored_params['enabledPlugins'] = variable_get('media_wysiwyg_wysiwyg_browser_plugins', array());
62
    }
63
    if (empty($stored_params['file_directory'])) {
64
      $stored_params['file_directory'] = variable_get('media_wysiwyg_wysiwyg_upload_directory', '');
65
    }
66
    if (empty($stored_params['types'])) {
67
      $stored_params['types'] = variable_get('media_wysiwyg_wysiwyg_allowed_types', array('audio', 'image', 'video', 'document'));
68
    }
69
  }
70
}
71