1
|
<?php
|
2
|
|
3
|
/**
|
4
|
* @file
|
5
|
* Install, update and uninstall functions for the text module.
|
6
|
*/
|
7
|
|
8
|
/**
|
9
|
* Implements hook_field_schema().
|
10
|
*/
|
11
|
function text_field_schema($field) {
|
12
|
switch ($field['type']) {
|
13
|
case 'text':
|
14
|
$columns = array(
|
15
|
'value' => array(
|
16
|
'type' => 'varchar',
|
17
|
'length' => $field['settings']['max_length'],
|
18
|
'not null' => FALSE,
|
19
|
),
|
20
|
);
|
21
|
break;
|
22
|
|
23
|
case 'text_long':
|
24
|
$columns = array(
|
25
|
'value' => array(
|
26
|
'type' => 'text',
|
27
|
'size' => 'big',
|
28
|
'not null' => FALSE,
|
29
|
),
|
30
|
);
|
31
|
break;
|
32
|
|
33
|
case 'text_with_summary':
|
34
|
$columns = array(
|
35
|
'value' => array(
|
36
|
'type' => 'text',
|
37
|
'size' => 'big',
|
38
|
'not null' => FALSE,
|
39
|
),
|
40
|
'summary' => array(
|
41
|
'type' => 'text',
|
42
|
'size' => 'big',
|
43
|
'not null' => FALSE,
|
44
|
),
|
45
|
);
|
46
|
break;
|
47
|
}
|
48
|
$columns += array(
|
49
|
'format' => array(
|
50
|
'type' => 'varchar',
|
51
|
'length' => 255,
|
52
|
'not null' => FALSE,
|
53
|
),
|
54
|
);
|
55
|
return array(
|
56
|
'columns' => $columns,
|
57
|
'indexes' => array(
|
58
|
'format' => array('format'),
|
59
|
),
|
60
|
'foreign keys' => array(
|
61
|
'format' => array(
|
62
|
'table' => 'filter_format',
|
63
|
'columns' => array('format' => 'format'),
|
64
|
),
|
65
|
),
|
66
|
);
|
67
|
}
|
68
|
|
69
|
/**
|
70
|
* Change text field 'format' columns into varchar.
|
71
|
*/
|
72
|
function text_update_7000() {
|
73
|
$spec = array(
|
74
|
'type' => 'varchar',
|
75
|
'length' => 255,
|
76
|
'not null' => FALSE,
|
77
|
);
|
78
|
$fields = _update_7000_field_read_fields(array(
|
79
|
'module' => 'text',
|
80
|
'storage_type' => 'field_sql_storage',
|
81
|
));
|
82
|
foreach ($fields as $field) {
|
83
|
if ($field['deleted']) {
|
84
|
$table = "field_deleted_data_{$field['id']}";
|
85
|
$revision_table = "field_deleted_revision_{$field['id']}";
|
86
|
}
|
87
|
else {
|
88
|
$table = "field_data_{$field['field_name']}";
|
89
|
$revision_table = "field_revision_{$field['field_name']}";
|
90
|
}
|
91
|
$column = $field['field_name'] . '_' . 'format';
|
92
|
db_change_field($table, $column, $column, $spec);
|
93
|
db_change_field($revision_table, $column, $column, $spec);
|
94
|
}
|
95
|
}
|