Projet

Général

Profil

Paste
Télécharger (8,07 ko) Statistiques
| Branche: | Révision:

root / drupal7 / sites / all / modules / ds / ds.install @ 6e9292aa

1
<?php
2

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

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

    
18
/**
19
 * Implements hook_uninstall().
20
 */
21
function ds_uninstall() {
22
  variable_del('ds_classes_regions');
23
}
24

    
25
/**
26
 * Implements hook_schema().
27
 */
28
function ds_schema() {
29

    
30
  $schema['ds_field_settings'] = array(
31
    'description' => 'The table that holds Display Suite field settings per display.',
32

    
33
    // CTools export definitions.
34
    'export' => array(
35
      'key' => 'id',
36
      'identifier' => 'ds_fieldsetting',
37
      'default hook' => 'ds_field_settings_info',
38
      'can disable' => FALSE,
39
      'api' => array(
40
        'owner' => 'ds',
41
        'api' => 'ds',
42
        'minimum_version' => 1,
43
        'current_version' => 1,
44
      ),
45
    ),
46

    
47
    'fields' => array(
48
      'id' => array(
49
        'description' => 'The unique id this setting.',
50
        'type' => 'varchar',
51
        'length' => 255,
52
        'not null' => TRUE,
53
        'default' => '',
54
      ),
55
      'entity_type' => array(
56
        'description' => 'The name of the entity.',
57
        'type' => 'varchar',
58
        'length' => 32,
59
        'not null' => TRUE,
60
        'default' => '',
61
      ),
62
      'bundle' => array(
63
        'description' => 'The name of the entity.',
64
        'type' => 'varchar',
65
        'length' => 64,
66
        'not null' => TRUE,
67
        'default' => '',
68
      ),
69
      'view_mode' => array(
70
        'description' => 'The name of the view_mode.',
71
        'type' => 'varchar',
72
        'length' => 64,
73
        'not null' => TRUE,
74
        'default' => '',
75
      ),
76
      'settings' => array(
77
        'description' => 'The Display Suite field settings for this layout.',
78
        'type' => 'blob',
79
        'not null' => FALSE,
80
        'size' => 'big',
81
        'serialize' => TRUE,
82
      ),
83
    ),
84
    'primary key' => array('id'),
85
    'indexes' => array(
86
      'ds_entity'       => array('entity_type'),
87
      'ds_bundle'       => array('bundle'),
88
      'ds_view_mode'    => array('view_mode'),
89
    ),
90
  );
91

    
92
  $schema['ds_layout_settings'] = array(
93
    'description' => 'The table that holds the layouts configuration.',
94

    
95
    // CTools export definitions.
96
    'export' => array(
97
      'key' => 'id',
98
      'identifier' => 'ds_layout',
99
      'default hook' => 'ds_layout_settings_info',
100
      'can disable' => FALSE,
101
      'api' => array(
102
        'owner' => 'ds',
103
        'api' => 'ds',
104
        'minimum_version' => 1,
105
        'current_version' => 1,
106
      ),
107
    ),
108

    
109
    'fields' => array(
110
      'id' => array(
111
        'description' => 'The unique id the layout.',
112
        'type' => 'varchar',
113
        'length' => 255,
114
        'not null' => TRUE,
115
        'default' => '',
116
      ),
117
      'entity_type' => array(
118
        'description' => 'The name of the entity.',
119
        'type' => 'varchar',
120
        'length' => 32,
121
        'not null' => TRUE,
122
        'default' => '',
123
      ),
124
      'bundle' => array(
125
        'description' => 'The name of the entity.',
126
        'type' => 'varchar',
127
        'length' => 64,
128
        'not null' => TRUE,
129
        'default' => '',
130
      ),
131
      'view_mode' => array(
132
        'description' => 'The name of the view_mode.',
133
        'type' => 'varchar',
134
        'length' => 64,
135
        'not null' => TRUE,
136
        'default' => '',
137
      ),
138
      'layout' => array(
139
        'description' => 'The name of the layout.',
140
        'type' => 'varchar',
141
        'length' => 64,
142
        'not null' => TRUE,
143
        'default' => '',
144
      ),
145
      'settings' => array(
146
        'description' => 'The settings for this layout.',
147
        'type' => 'blob',
148
        'not null' => FALSE,
149
        'size' => 'big',
150
        'serialize' => TRUE,
151
      ),
152
    ),
153
    'primary key' => array('id'),
154
    'indexes' => array(
155
      'ds_entity'       => array('entity_type'),
156
      'ds_bundle'       => array('bundle'),
157
      'ds_view_mode'    => array('view_mode'),
158
    ),
159
  );
160

    
161
  $schema['ds_view_modes'] = array(
162
    'description' => 'The table that holds custom view modes managed by Display Suite.',
163

    
164
    // CTools export definitions.
165
    'export' => array(
166
      'key' => 'view_mode',
167
      'identifier' => 'ds_view_mode',
168
      'default hook' => 'ds_view_modes_info',
169
      'can disable' => FALSE,
170
      'api' => array(
171
        'owner' => 'ds',
172
        'api' => 'ds',
173
        'minimum_version' => 1,
174
        'current_version' => 1,
175
      ),
176
    ),
177

    
178
    'fields' => array(
179
      'view_mode' => array(
180
        'description' => 'The machine name of the view mode.',
181
        'type' => 'varchar',
182
        'length' => 64,
183
        'not null' => TRUE,
184
        'default' => '',
185
      ),
186
      'label' => array(
187
        'description' => 'The label of the view mode.',
188
        'type' => 'varchar',
189
        'length' => 32,
190
        'not null' => TRUE,
191
        'default' => '',
192
      ),
193
      'entities' => array(
194
        'description' => 'The entities for this view mode.',
195
        'type' => 'blob',
196
        'not null' => FALSE,
197
        'size' => 'big',
198
        'serialize' => TRUE,
199
      ),
200
    ),
201
    'primary key' => array('view_mode'),
202
  );
203

    
204
  $schema['ds_fields'] = array(
205
    'description' => 'The table that holds custom fields managed by Display Suite.',
206

    
207
    // CTools export definitions.
208
    'export' => array(
209
      'key' => 'field',
210
      'identifier' => 'ds_field',
211
      'default hook' => 'ds_custom_fields_info',
212
      'can disable' => FALSE,
213
      'api' => array(
214
        'owner' => 'ds',
215
        'api' => 'ds',
216
        'minimum_version' => 1,
217
        'current_version' => 1,
218
      ),
219
    ),
220

    
221
    'fields' => array(
222
      'field' => array(
223
        'description' => 'The machine name of the field.',
224
        'type' => 'varchar',
225
        'length' => 32,
226
        'not null' => TRUE,
227
        'default' => '',
228
      ),
229
      'label' => array(
230
        'description' => 'The label of the field.',
231
        'type' => 'varchar',
232
        'length' => 128,
233
        'not null' => TRUE,
234
        'default' => '',
235
      ),
236
      'field_type' => array(
237
        'description' => 'The type of of the field',
238
        'type' => 'int',
239
        'size' => 'small',
240
        'not null' => TRUE,
241
        'default' => 0,
242
      ),
243
      'entities' => array(
244
        'description' => 'The entities for this field.',
245
        'type' => 'blob',
246
        'not null' => FALSE,
247
        'size' => 'big',
248
        'serialize' => TRUE,
249
      ),
250
      'ui_limit' => array(
251
        'description' => 'The UI limit for this field.',
252
        'type' => 'blob',
253
        'not null' => FALSE,
254
        'size' => 'big',
255
        'serialize' => TRUE,
256
      ),
257
      'properties' => array(
258
        'description' => 'The properties for this field.',
259
        'type' => 'blob',
260
        'not null' => FALSE,
261
        'size' => 'big',
262
        'serialize' => TRUE,
263
      ),
264
    ),
265
    'primary key' => array('field'),
266
  );
267

    
268
  return $schema;
269
}
270

    
271
/**
272
 * Add the ui_limit table to the fields table.
273
 */
274
function ds_update_7201() {
275
  $schema = ds_schema();
276
  if (!db_field_exists('ds_fields', 'ui_limit')) {
277
    db_add_field('ds_fields', 'ui_limit', $schema['ds_fields']['fields']['ui_limit']);
278
  }
279
}
280

    
281
/**
282
 * Increase the label storage length to 128.
283
 */
284
function ds_update_7202() {
285
  db_change_field('ds_fields', 'label', 'label',
286
    array(
287
      'description' => 'The label of the field.',
288
      'type' => 'varchar',
289
      'length' => 128,
290
      'not null' => TRUE,
291
      'default' => '',
292
    ));
293
}
294

    
295

    
296
/**
297
 * Increase the view_mode storage length to 64
298
 */
299
function ds_update_7203() {
300
  db_change_field('ds_field_settings', 'view_mode', 'view_mode',
301
    array(
302
      'description' => 'The name of the view_mode.',
303
      'type' => 'varchar',
304
      'length' => 64,
305
      'not null' => TRUE,
306
      'default' => '',
307
    )
308
  );
309
  db_change_field('ds_layout_settings', 'view_mode', 'view_mode',
310
    array(
311
      'description' => 'The name of the view_mode.',
312
      'type' => 'varchar',
313
      'length' => 64,
314
      'not null' => TRUE,
315
      'default' => '',
316
    )
317
  );
318
  db_change_field('ds_view_modes', 'view_mode', 'view_mode',
319
    array(
320
      'description' => 'The machine name of the view mode.',
321
      'type' => 'varchar',
322
      'length' => 64,
323
      'not null' => TRUE,
324
      'default' => '',
325
    )
326
  );
327
}