Projet

Général

Profil

Paste
Télécharger (3,61 ko) Statistiques
| Branche: | Révision:

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

1
<?php
2

    
3
/**
4
 * @file
5
 * Install file.
6
 */
7

    
8
 /**
9
 * Implements hook_install().
10
 */
11
function ds_extras_install() {
12
  db_update('system')
13
    ->fields(array('weight' => 2))
14
    ->condition('name', 'ds_extras')
15
    ->execute();
16

    
17
  $schema['node_revision'] = array();
18
  ds_extras_schema_alter($schema);
19
  foreach ($schema['node_revision']['fields'] as $name => $spec) {
20
    db_add_field('node_revision', $name, $spec);
21
  }
22
}
23

    
24
/**
25
 * Implements hook_schema().
26
 */
27
function ds_extras_schema() {
28

    
29
  $schema['ds_vd'] = array(
30
    'description' => 'The base table for views displays.',
31

    
32
    // CTools export definitions.
33
    'export' => array(
34
      'key' => 'vd',
35
      'identifier' => 'ds_vd',
36
      'default hook' => 'ds_vd_info',
37
      'can disable' => FALSE,
38
      'api' => array(
39
        'owner' => 'ds_extras',
40
        'api' => 'ds_extras',
41
        'minimum_version' => 1,
42
        'current_version' => 1,
43
      ),
44
    ),
45

    
46
    'fields' => array(
47
      'vd' => array(
48
        'description' => 'The primary identifier for the views display.',
49
        'type' => 'varchar',
50
        'length' => 128,
51
        'not null' => TRUE,
52
        'default' => '',
53
      ),
54
      'label' => array(
55
        'description' => 'The label for the views display.',
56
        'type' => 'varchar',
57
        'length' => 132,
58
        'not null' => TRUE,
59
        'default' => '',
60
      ),
61
    ),
62
    'primary key' => array('vd'),
63
  );
64

    
65
  return $schema;
66
}
67

    
68

    
69
/**
70
 * Implements hook_schema_alter().
71
 */
72
function ds_extras_schema_alter(&$schema) {
73

    
74
  // Add a field ds_switch to the node_revision table in order
75
  // to store the name of view mode to switch to.
76
  if (isset($schema['node_revision'])) {
77
    $schema['node_revision']['fields']['ds_switch'] = array(
78
      'type' => 'varchar',
79
      'length' => 255,
80
      'not null' => TRUE,
81
      'default' => '',
82
    );
83
  }
84
}
85

    
86
/**
87
 * Implements hook_uninstall().
88
 */
89
function ds_extras_uninstall() {
90
  variable_del('ds_extras_region_to_block');
91
  variable_del('ds_extras_region_blocks');
92
  variable_del('ds_extras_switch_view_mode');
93
  variable_del('ds_extras_vd');
94
  variable_del('ds_extras_hide_page_title');
95
  variable_del('ds_extras_field_template');
96
  variable_del('ds_classes_fields');
97
  variable_del('ds_extras_fields_extra');
98
  variable_del('ds_extras_fields_extra_list');
99
  variable_del('ds_extras_switch_field');
100
  variable_del('ds_extras_editor_switch');
101
  variable_del('ft-default');
102
  variable_del('ft-kill-colon');
103
  variable_del('ds_extras_flag');
104
  variable_del('ds_extras_hidden_region');
105
  variable_del('ds_extras_hide_page_sidebars');
106
  db_drop_field('node_revision', 'ds_switch');
107
}
108

    
109
/**
110
 * Fix storage of formatter settings in ds_field_settings table.
111
 */
112
function ds_extras_update_7200() {
113
  ctools_include('export');
114
  $ds_field_settings = ctools_export_crud_load_all('ds_field_settings');
115
  db_truncate('ds_field_settings')->execute();
116
  foreach ($ds_field_settings as $layout => $field_settings) {
117
    $record = $field_settings;
118
    foreach ($field_settings->settings as $field => $settings) {
119
      // Move any field template settings to 'formatter_settings' key.
120
      if (isset($settings['ft'])) {
121
        $settings['formatter_settings']['ft'] = $settings['ft'];
122
        unset($settings['ft']);
123
      }
124

    
125
      // Inspect the classes key, in case it's an array, something went
126
      // wrong during saving, simply unset the array completely.
127
      if (isset($settings['formatter_settings']['ft']['classes']) && is_array($settings['formatter_settings']['ft']['classes'])) {
128
        unset($settings['formatter_settings']['ft']['classes']);
129
      }
130

    
131
      $record->settings[$field] = $settings;
132
    }
133
    drupal_write_record('ds_field_settings', $record);
134
  }
135
}