summaryrefslogtreecommitdiff
path: root/kolab.org/www/drupal-7.26/sites/all/modules/pathologic/pathologic.install
blob: 9179d16ddcf827c075ea9e79927dd207afc2a6eb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
<?php

/**
 * @file
 * .install file for Pathologic.
 */

/**
 * Re-enable Pathologic under Drupal 7, preserving settings from Drupal 6.
 */
function pathologic_update_7000($sandbox) {
  // Make sure {d6_upgrade_filter} exists. It won't exist for people upgrading
  // from beta versions of the D7 version of Pathologic on native D7 sites (not
  // upgraded from D6).
  if (db_table_exists('d6_upgrade_filter')) {
    // Get all Pathologic data from {d6_upgrade_filter}.
    $rez = db_select('d6_upgrade_filter', 'dup')
      ->fields('dup')
      ->condition('module', 'pathologic')
      ->execute();
    while ($instance = $rez->fetchObject()) {
      // Load the format
      if ($format = filter_format_load($instance->format)) {
        // Load filters.
        $format->filters = array();
        // Add the filters
        foreach (filter_list_format($instance->format) as $filter_name => $filter) {
          $format->filters[$filter_name] = (array)$filter;
        }
        // Add Pathologic
        $format->filters['pathologic'] = array(
          'weight' => $instance->weight,
          'status' => 1,
          'settings' => array(
            'absolute' => variable_get('filter_pathologic_absolute_' . $instance->format, TRUE),
            'local_paths' => variable_get('filter_pathologic_local_paths_' . $instance->format, ''),
          ),
        );
        // Save the format
        filter_format_save($format);
        // Unset old variables
        variable_del('filter_pathologic_absolute_' . $instance->format);
        variable_del('filter_pathologic_local_paths_' . $instance->format);
      }
    }
    // Delete Pathologic data from {d6_upgrade_filter}…?
    // No, maybe we don't want to actually do that…?
  }
}

/**
 * Convert obsolete "absolute" setting to modern "protocol_style" setting for
 * each filter instance.
 */
function pathologic_update_7200(&$sandbox) {
  foreach (filter_formats() as $format) {
    // @see http://drupal.org/node/1304930
    if (empty($format->filters)) {
      $format->filters = array();
      // Add the filters
      foreach (filter_list_format($format->format) as $filter_name => $filter) {
        $format->filters[$filter_name] = (array)$filter;
      }
    }
    if (isset($format->filters['pathologic'])) {
      $format->filters['pathologic']['settings']['protocol_style'] = $format->filters['pathologic']['settings']['absolute'] ? 'full' : 'path';
      unset($format->filters['pathologic']['settings']['absolute']);
      filter_format_save($format);
    }
  }
}