Projet

Général

Profil

Révision da542b7b

Ajouté par Assos Assos il y a plus de 7 ans

Weekly update of contrib modules

Voir les différences:

drupal7/sites/all/modules/media/modules/media_wysiwyg/media_wysiwyg.install
5 5
 * Install, update and uninstall functions for the Media WYSIWYG module.
6 6
 */
7 7

  
8
/**
9
 * Implements hook_install().
10
 */
11
function media_wysiwyg_install() {
12
  media_wysiwyg_update_7204();
13
}
14

  
8 15
/**
9 16
 * Implements hook_uninstall().
10 17
 */
......
17 24
  variable_del('media_wysiwyg_wysiwyg_allowed_types');
18 25
  variable_del('media_wysiwyg_wysiwyg_allowed_attributes');
19 26
  variable_del('media_wysiwyg_wysiwyg_browser_plugins');
27
  variable_del('media_wysiwyg_wysiwyg_override_field_types');
20 28
}
21 29

  
22 30
/**
......
66 74

  
67 75
  return $output;
68 76
}
77
/**
78
 * Whitelists certain fields for WYSIWYG overriding.
79
 */
80
function media_wysiwyg_update_7204() {
81
  $instances = field_read_instances(array('entity_type' => 'file'));
82
  $updated = array();
83
  $set_to_default = array();
84
  foreach ($instances as $instance) {
85
    $field_info = field_info_field($instance['field_name']);
86
    $allowed_field_types = variable_get('media_wysiwyg_wysiwyg_override_field_types', array('text', 'text_long'));
87
    if (in_array($field_info['type'], $allowed_field_types)) {
88
      if (!isset($instance['settings']['wysiwyg_override'])) {
89
        $instance['settings']['wysiwyg_override'] = 1;
90
        field_update_instance($instance);
91
        $set_to_default[] = $instance['field_name'];
92
      }
93
    }
94
    elseif (isset($instance['settings']['wysiwyg_override'])) {
95
      unset($instance['settings']['wysiwyg_override']);
96
      field_update_instance($instance);
97
      $updated[] = $instance['field_name'];
98
    }
99
  }
100
  if (count($updated) || count($set_to_default)) {
101
    $updated_string = implode(', ', $updated);
102
    $default_string = implode(', ', $set_to_default);
103
    return t("Updated the following field instances: @updated_string so they can't be overridden when the file is inserted in the WYSIWYG. Updated the following fields @default_string so that they continue to show up when a file is inserted.", array(
104
      '@updated_string' => $updated_string,
105
      '@default_string' => $default_string,
106
    ));
107
  }
108
}

Formats disponibles : Unified diff