| Commit | Line | Data |
|---|---|---|
| 44a2bb67 | 1 | <?php |
| 44a2bb67 JR |
2 | |
| 3 | /** | |
| 4 | * @file | |
| 5 | * Install, update and uninstall functions for the i18n_field module. | |
| 6 | */ | |
| 7 | ||
| 8 | /** | |
| d41933c8 | 9 | * Implements hook_install(). |
| 55429c3e JR |
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(); | |
| d41933c8 | 15 | } |
| 55429c3e JR |
16 | } |
| 17 | ||
| 18 | /** | |
| d41933c8 JR |
19 | * Implements hook_i18n_drupal6_update(). |
| 20 | * | |
| 44a2bb67 JR |
21 | * Update old string names |
| 22 | */ | |
| 55429c3e JR |
23 | function i18n_field_update_7000() { |
| 24 | // @todo | |
| 82d8c45d JARP |
25 | module_load_install('i18n_string'); |
| 26 | // Old CCK label and description | |
| 27 | $query = db_select('i18n_string', 's') | |
| 28 | ->fields('s') | |
| 29 | ->condition('textgroup', 'cck') | |
| 30 | ->condition('type', 'field'); | |
| 2efbf17c | 31 | foreach ($query->execute() as $string) { |
| 82d8c45d JARP |
32 | $string->textgroup = 'field'; |
| 33 | list($bundle, $field) = split('-', $string->objectid); | |
| 34 | $string->type = $field; | |
| 35 | $string->objectid = $bundle; | |
| 36 | $string->property = str_replace('widget_', '', $string->property); | |
| 37 | i18n_string_install_update_string($string); | |
| 38 | } | |
| 39 | // @todo Field groups ?? | |
| 40 | // Old Profile fields | |
| 41 | $query = db_select('i18n_string', 's') | |
| 42 | ->fields('s') | |
| 43 | ->condition('textgroup', 'profile') | |
| 44 | ->condition('type', 'field'); | |
| 2efbf17c | 45 | foreach ($query->execute() as $string) { |
| 82d8c45d JARP |
46 | $string->textgroup = 'field'; |
| 47 | $string->type = $string->property; | |
| 48 | if ($string->objectid == 'options') { | |
| 49 | // @todo Handle field options | |
| 50 | $string->objectid = '#allowed_values'; | |
| 51 | } | |
| d41933c8 | 52 | else { |
| 82d8c45d JARP |
53 | $string->objectid = 'user'; // Bundle for profile fields |
| 54 | i18n_string_install_update_string($string); | |
| 55 | } | |
| 56 | } | |
| 57 | // @todo Profile categories ?? | |
| 44a2bb67 | 58 | } |
| 82d8c45d JARP |
59 | |
| 60 | /** | |
| 61 | * Old strings to update. All these will be handled by i18n_field module | |
| d41933c8 | 62 | * |
| 82d8c45d JARP |
63 | * 'cck:field:'. $content_type .'-'. $field_name .':widget_label' |
| 64 | * --> 'field:$field_name:$bundle:label' (though not used atm) | |
| 65 | * 'cck:field:'. $content_type .'-'. $field_name .':widget_description' | |
| 66 | * --> 'field:$field_name:$bundle:description' | |
| 67 | * 'cck:fieldgroup:'. $content_type .'-'. $group_name .':display_description' | |
| d41933c8 JR |
68 | * 'cck:fieldgroup:'. $content_type .'-'. $group_name .':form_description', $group['settings']['form']['description']); |
| 69 | * | |
| 82d8c45d JARP |
70 | * Profile: |
| 71 | * profile:field:$field_name:title|explanation|options | |
| 72 | * "profile:category", $field->category | |
| d41933c8 | 73 | * |
| 82d8c45d | 74 | */ |