~spreadubuntu/spreadubuntu/devel-drupal6

« back to all changes in this revision

Viewing changes to modules/i18n/i18nstrings/i18nstrings.install

  • Committer: ruben
  • Date: 2009-06-08 09:38:49 UTC
  • Revision ID: ruben@captive-20090608093849-s1qtsyctv2vwp1x1
SpreadUbuntu moving to Drupal6. Based on ubuntu-drupal theme and adding our modules

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?php
 
2
// $Id: i18nstrings.install,v 1.2.2.10 2009/01/14 18:20:08 snpower Exp $
 
3
 
 
4
/**
 
5
 * @file
 
6
 * Installation file for i18nstrings module.
 
7
 */
 
8
 
 
9
function i18nstrings_install() {
 
10
  // Create database tables.
 
11
  drupal_install_schema('i18nstrings');
 
12
 
 
13
  // Set module weight for it to run after core modules.
 
14
  db_query("UPDATE {system} SET weight = 10 WHERE name = 'i18nstrings' AND type = 'module'");
 
15
 
 
16
  $ret = array();
 
17
 
 
18
  // Add a field to track whether a translation needs updating.
 
19
  db_add_field($ret, 'locales_target', 'status', array('type' => 'int', 'not null' => TRUE, 'default' => 0));
 
20
 
 
21
  // Add custom index to locales_source table.
 
22
  db_add_index($ret, 'locales_source', 'textgroup_location', array(array('textgroup', 30), 'location'));
 
23
}
 
24
 
 
25
function i18nstrings_uninstall() {
 
26
  $ret = array();
 
27
 
 
28
  // Create database tables.
 
29
  drupal_uninstall_schema('i18nstrings');
 
30
  // @TODO locale table cleanup, think about it.
 
31
  // Should we drop all strings for groups other than 'default' ?
 
32
 
 
33
  // Drop custom field.
 
34
  db_drop_field($ret, 'locales_target', 'status');
 
35
  // Drop custom index.
 
36
  db_drop_index($ret, 'locales_source', 'textgroup_location');
 
37
}
 
38
 
 
39
/**
 
40
 * Implementation of hook_schema().
 
41
 */
 
42
function i18nstrings_schema() {
 
43
  $schema['i18n_strings'] = array(
 
44
    'description' => t('Metadata for source strings.'),
 
45
    'fields' => array(
 
46
      'lid' => array(
 
47
        'type' => 'int',
 
48
        'not null' => TRUE,
 
49
        'default' => 0,
 
50
        'description' => t('Source string ID. References {locales_source}.lid.'),
 
51
      ),
 
52
      'objectid' => array(
 
53
        'type' => 'int',
 
54
        'not null' => TRUE,
 
55
        'default' => 0,
 
56
        'description' => t('Object ID.'),
 
57
      ),
 
58
      'type' => array(
 
59
        'type' => 'varchar',
 
60
        'length' => 255,
 
61
        'not null' => TRUE,
 
62
        'default' => '',
 
63
        'description' => t('Object type for this string.'),
 
64
      ),
 
65
      'property' => array(
 
66
        'type' => 'varchar',
 
67
        'length' => 255,
 
68
        'not null' => TRUE,
 
69
        'default' => 'default',
 
70
        'description' => t('Object property for this string.'),
 
71
      ),
 
72
    ),
 
73
    'primary key' => array('lid'),
 
74
  );
 
75
  return $schema;
 
76
}
 
77
 
 
78
/**
 
79
 * Implementation of hook_schema_alter().
 
80
 */
 
81
function i18nstrings_schema_alter(&$schema) {
 
82
  // Add index for textgroup and location to {locales_source}.
 
83
  $schema['locales_source']['indexes']['textgroup_location'] = array(array('textgroup', 30), 'location');
 
84
  // Add field for tracking whether translations need updating.
 
85
  $schema['locales_target']['status'] = array(
 
86
    'description' => t('A boolean indicating whether this translation needs to be updated.'),
 
87
    'type' => 'int',
 
88
    'not null' => TRUE,
 
89
    'default' => 0,
 
90
  );
 
91
}
 
92
 
 
93
/**
 
94
 * Update from 5.x version
 
95
 */
 
96
/*
 
97
function i18nstrings_update_5900() {
 
98
  i18nstrings_install();
 
99
  // Mark next update to be skipped
 
100
  variable_set('i18nstrings_update_skip', 1);
 
101
  return array();
 
102
}
 
103
*/
 
104
 
 
105
/**
 
106
 * Drupal 6 update. Change field name, 'oid' was psql reserved name.
 
107
 *
 
108
 * ALTER TABLE `drupal6_i18n`.`i18n_strings` CHANGE COLUMN `oid` `objectid` INTEGER  NOT NULL DEFAULT 0;
 
109
 */
 
110
function i18nstrings_update_6001() {
 
111
  $ret = array();
 
112
  if (!variable_get('i18nstrings_update_skip', 0)) {
 
113
    db_change_field($ret, 'i18n_strings', 'oid', 'objectid', array('type' => 'int', 'not null' => TRUE, 'default' => 0));
 
114
  } else {
 
115
    variable_del('i18nstrings_update_skip');
 
116
  }
 
117
  return $ret;
 
118
}
 
119
 
 
120
/**
 
121
 * Add index to {locales_source}.
 
122
 */
 
123
function i18nstrings_update_6002() {
 
124
  $ret = array();
 
125
  db_add_index($ret, 'locales_source', 'textgroup_location', array(array('textgroup', 30), 'location'));
 
126
  return $ret;
 
127
}
 
128
 
 
129
/**
 
130
 * Create i18n_strings_status schema.
 
131
 * Add a field to track whether a translation needs updating.
 
132
 */
 
133
function i18nstrings_update_6003() {
 
134
  $ret = array();
 
135
  db_add_field($ret, 'locales_target', 'status', array('type' => 'int', 'not null' => TRUE, 'default' => 0));
 
136
  return $ret;
 
137
}
 
138