1 |
85ad3d82
|
Assos Assos
|
<?php
|
2 |
|
|
|
3 |
|
|
/**
|
4 |
|
|
* @file
|
5 |
|
|
* Install, update and uninstall functions for the i18n_field module.
|
6 |
|
|
*/
|
7 |
|
|
|
8 |
|
|
/**
|
9 |
|
|
* Implements hook_install().
|
10 |
|
|
*/
|
11 |
|
|
function i18n_field_install() {
|
12 |
|
|
// If updating from D6, module changed name
|
13 |
|
|
if (variable_get('i18n_drupal6_update')) {
|
14 |
|
|
i18n_field_update_7000();
|
15 |
|
|
}
|
16 |
|
|
}
|
17 |
|
|
|
18 |
|
|
|
19 |
|
|
/**
|
20 |
|
|
* Implements hook_update_dependencies()
|
21 |
|
|
*/
|
22 |
|
|
function i18n_field_update_dependencies() {
|
23 |
|
|
$dependencies['i18n_field'][7000] = array(
|
24 |
|
|
'i18n_string' => 7001,
|
25 |
|
|
);
|
26 |
|
|
return $dependencies;
|
27 |
|
|
}
|
28 |
|
|
|
29 |
|
|
/**
|
30 |
|
|
* Implements hook_i18n_drupal6_update().
|
31 |
|
|
*
|
32 |
|
|
* Update old string names
|
33 |
|
|
*/
|
34 |
|
|
function i18n_field_update_7000() {
|
35 |
|
|
// @todo
|
36 |
|
|
module_load_install('i18n_string');
|
37 |
|
|
// Old CCK label and description
|
38 |
|
|
$query = db_select('i18n_string', 's')
|
39 |
|
|
->fields('s')
|
40 |
|
|
->condition('textgroup', 'cck')
|
41 |
|
|
->condition('type', 'field');
|
42 |
|
|
foreach ($query->execute() as $string) {
|
43 |
|
|
$string->textgroup = 'field';
|
44 |
|
|
list($bundle, $field) = explode('-', $string->objectid);
|
45 |
|
|
$string->type = $field;
|
46 |
|
|
$string->objectid = $bundle;
|
47 |
|
|
$string->property = str_replace('widget_', '', $string->property);
|
48 |
|
|
i18n_string_install_update_string($string);
|
49 |
|
|
}
|
50 |
|
|
// @todo Field groups ??
|
51 |
|
|
// Old Profile fields
|
52 |
|
|
$query = db_select('i18n_string', 's')
|
53 |
|
|
->fields('s')
|
54 |
|
|
->condition('textgroup', 'profile')
|
55 |
|
|
->condition('type', 'field');
|
56 |
|
|
foreach ($query->execute() as $string) {
|
57 |
|
|
$string->textgroup = 'field';
|
58 |
|
|
$string->type = $string->property;
|
59 |
|
|
if ($string->objectid == 'options') {
|
60 |
|
|
// @todo Handle field options
|
61 |
|
|
$string->objectid = '#allowed_values';
|
62 |
|
|
}
|
63 |
|
|
else {
|
64 |
|
|
$string->objectid = 'user'; // Bundle for profile fields
|
65 |
|
|
i18n_string_install_update_string($string);
|
66 |
|
|
}
|
67 |
|
|
}
|
68 |
|
|
// @todo Profile categories ??
|
69 |
|
|
}
|
70 |
|
|
|
71 |
|
|
/**
|
72 |
|
|
* Old strings to update. All these will be handled by i18n_field module
|
73 |
|
|
*
|
74 |
|
|
* 'cck:field:'. $content_type .'-'. $field_name .':widget_label'
|
75 |
|
|
* --> 'field:$field_name:$bundle:label' (though not used atm)
|
76 |
|
|
* 'cck:field:'. $content_type .'-'. $field_name .':widget_description'
|
77 |
|
|
* --> 'field:$field_name:$bundle:description'
|
78 |
|
|
* 'cck:fieldgroup:'. $content_type .'-'. $group_name .':display_description'
|
79 |
|
|
* 'cck:fieldgroup:'. $content_type .'-'. $group_name .':form_description', $group['settings']['form']['description']);
|
80 |
|
|
*
|
81 |
|
|
* Profile:
|
82 |
|
|
* profile:field:$field_name:title|explanation|options
|
83 |
|
|
* "profile:category", $field->category
|
84 |
|
|
*
|
85 |
|
|
*/ |