i18n.install 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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 the schema if they don't exist.
  21. *
  22. * @param string $table
  23. * The name of the database table.
  24. * @param array $fields
  25. * The list of database fields to create.
  26. * @param boolean $force_rebuild_schema
  27. * Whether to force drupal_get_schema() to rebuild the schema. This may be
  28. * necessary when additional implementations of hook_schema_alter() have
  29. * become available since the schema was originally built.
  30. */
  31. function i18n_install_create_fields($table, $fields, $force_rebuild_schema = FALSE) {
  32. static $schema;
  33. $rebuild_schema = !isset($schema) || $force_rebuild_schema;
  34. $schema = drupal_get_schema($table, $rebuild_schema);
  35. foreach ($fields as $field) {
  36. if (!empty($schema['fields'][$field])) {
  37. if (!db_field_exists($table, $field)) {
  38. db_add_field($table, $field, $schema['fields'][$field]);
  39. }
  40. else {
  41. // The field exists, make sure field definition is up to date.
  42. db_change_field($table, $field, $field, $schema['fields'][$field]);
  43. }
  44. }
  45. }
  46. }
  47. /**
  48. * Mark this as updated so all (renamed) modules know they need to update from D6 version when installing
  49. */
  50. function i18n_update_7000() {
  51. variable_set('i18n_drupal6_update', TRUE);
  52. variable_del('i18n_selection_mode');
  53. }
  54. /**
  55. * Refresh caches and rebuild menus.
  56. */
  57. function i18n_update_7001() {
  58. drupal_flush_all_caches();
  59. }