Projet

Général

Profil

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

root / drupal7 / sites / all / modules / ds / modules / ds_format / ds_format.install @ bf6fb0ee

1
<?php
2

    
3
/**
4
 * @file
5
 * Display Suite Format install file.
6
 */
7

    
8
/**
9
 * Implements hook_enable().
10
 */
11
function ds_format_enable() {
12
  $format_exists = (bool) db_query_range('SELECT 1 FROM {filter_format} WHERE format = :format', 0, 1, array(':format' => 'ds_code'))->fetchField();
13
  // Add a Display Suite code text format, if it does not exist. Do this only for the
14
  // first install (or if the format has been manually deleted) as there is no
15
  // reliable method to identify the format in an uninstall hook or in
16
  // subsequent clean installs.
17
  if (!$format_exists) {
18
    $ds_format = array(
19
      'format' => 'ds_code',
20
      'name' => 'Display Suite code',
21
      // 'Plain text' format is installed with a weight of 10 by default. Use a
22
      // higher weight here to ensure that this format will not be the default
23
      // format for anyone.
24
      'weight' => 12,
25
      'filters' => array(
26
        // Enable the DS evaluator filter.
27
        'ds_code' => array(
28
          'weight' => 0,
29
          'status' => 1,
30
        ),
31
      ),
32
    );
33
    $ds_format = (object) $ds_format;
34
    filter_format_save($ds_format);
35

    
36
    drupal_set_message(t('A <a href="@ds-code">Display Suite code</a> text format has been created.', array('@ds-code' => url('admin/config/content/formats/' . $ds_format->format))));
37
  }
38
}
39

    
40
/**
41
 * Implements hook_disable().
42
 */
43
function ds_format_disable() {
44
  drupal_set_message(t('The Display Suite Format module has been disabled. Any existing content that was using the Display Suite filter will now be visible in plain text. This might pose a security risk by exposing sensitive information, if any, used in the PHP code.'));
45
}
46