i18n.install 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <?php
  2. /**
  3. * @file
  4. * Installation file for Internationalization (i18n) module.
  5. */
  6. /**
  7. * Implements hook_install().
  8. */
  9. function i18n_install() {
  10. // Set module weight for it to run after core modules
  11. db_query("UPDATE {system} SET weight = 10 WHERE name = 'i18n' AND type = 'module'");
  12. }
  13. /**
  14. * Implements hook_uninstall().
  15. */
  16. function i18n_uninstall() {
  17. variable_del('i18n_drupal6_update');
  18. }
  19. /**
  20. * Add fields to schema if they don't exist
  21. */
  22. function i18n_install_create_fields($table, $fields) {
  23. static $schema;
  24. // Do not force schema refresh more than once per request.
  25. $schema = drupal_get_schema($table, !isset($schema));
  26. foreach ($fields as $field) {
  27. if (!empty($schema['fields'][$field])) {
  28. if (!db_field_exists($table, $field)) {
  29. db_add_field($table, $field, $schema['fields'][$field]);
  30. }
  31. else {
  32. // The field exists, make sure field definition is up to date.
  33. db_change_field($table, $field, $field, $schema['fields'][$field]);
  34. }
  35. }
  36. }
  37. }
  38. /**
  39. * Mark this as updated so all (renamed) modules know they need to update from D6 version when installing
  40. */
  41. function i18n_update_7000() {
  42. variable_set('i18n_drupal6_update', TRUE);
  43. variable_del('i18n_selection_mode');
  44. }
  45. /**
  46. * Refresh caches and rebuild menus.
  47. */
  48. function i18n_update_7001() {
  49. drupal_flush_all_caches();
  50. }