i18n_path.install 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. <?php
  2. /**
  3. * @file
  4. * Install, update and uninstall functions for the text module.
  5. */
  6. /**
  7. * Implements hook_install().
  8. */
  9. function i18n_path_install() {
  10. // Set module weight for it to run after core modules, but before views.
  11. db_update('system')
  12. ->fields(array('weight' => 5))
  13. ->condition('name', 'i18n_path', '=')
  14. ->condition('type', 'module', '=')
  15. ->execute();
  16. }
  17. /**
  18. * Implements hook_schema().
  19. */
  20. function i18n_path_schema() {
  21. $schema['i18n_path'] = array(
  22. 'description' => 'Path translation',
  23. 'fields' => array(
  24. 'tpid' => array(
  25. 'description' => 'The primary identifier for a path in the translation set.',
  26. 'type' => 'serial',
  27. 'unsigned' => TRUE,
  28. 'not null' => TRUE,
  29. ),
  30. 'tsid' => array(
  31. 'description' => 'The primary identifier for a translation set.',
  32. 'type' => 'int',
  33. 'unsigned' => TRUE,
  34. 'not null' => TRUE,
  35. ),
  36. 'path' => array(
  37. 'description' => 'The Drupal path this alias is for; e.g. node/12.',
  38. 'type' => 'varchar',
  39. 'length' => 255,
  40. 'not null' => TRUE,
  41. 'default' => '',
  42. ),
  43. 'language' => array(
  44. 'description' => "The language for which this path is a translation.",
  45. 'type' => 'varchar',
  46. 'length' => 12,
  47. 'not null' => TRUE,
  48. 'default' => '',
  49. ),
  50. 'pid' => array(
  51. 'description' => 'A unique path alias identifier if the path has an alias.',
  52. 'type' => 'int',
  53. 'unsigned' => TRUE,
  54. 'not null' => TRUE,
  55. 'default' => 0,
  56. ),
  57. ),
  58. 'indexes' => array(
  59. 'path' => array('path'),
  60. ),
  61. 'unique keys' => array(
  62. 'set_language' => array('tsid', 'language'),
  63. ),
  64. 'foreign keys' => array(
  65. 'path_language' => array(
  66. 'table' => 'languages',
  67. 'columns' => array('language' => 'language'),
  68. ),
  69. 'translation_set' => array(
  70. 'table' => 'i18n_translation',
  71. 'columns' => array('tsid' => 'tsid'),
  72. ),
  73. ),
  74. 'primary key' => array('tpid'),
  75. );
  76. return $schema;
  77. }
  78. /**
  79. * Set module weight.
  80. */
  81. function i18n_path_update_7000(&$sandbox) {
  82. // Set module weight for it to run after core modules, but before views.
  83. db_update('system')
  84. ->fields(array('weight' => 5))
  85. ->condition('name', 'i18n_path', '=')
  86. ->condition('type', 'module', '=')
  87. ->execute();
  88. }