i18n_field.install 2.3 KB

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