1 |
85ad3d82
|
Assos Assos
|
<?php
|
2 |
|
|
|
3 |
|
|
/**
|
4 |
|
|
* @file
|
5 |
|
|
* Install file for l10n remote updates.
|
6 |
|
|
*/
|
7 |
|
|
|
8 |
|
|
/**
|
9 |
|
|
* Implements hook_schema().
|
10 |
|
|
*/
|
11 |
|
|
function l10n_update_schema() {
|
12 |
|
|
$schema['l10n_update_project'] = array(
|
13 |
|
|
'description' => 'Update information for project translations.',
|
14 |
|
|
'fields' => array(
|
15 |
|
|
'name' => array(
|
16 |
|
|
'description' => 'A unique short name to identify the project.',
|
17 |
|
|
'type' => 'varchar',
|
18 |
|
|
'length' => '50',
|
19 |
|
|
'not null' => TRUE,
|
20 |
|
|
),
|
21 |
|
|
'project_type' => array(
|
22 |
|
|
'description' => 'Project type, may be core, module, theme',
|
23 |
|
|
'type' => 'varchar',
|
24 |
|
|
'length' => '50',
|
25 |
|
|
'not null' => TRUE,
|
26 |
|
|
),
|
27 |
|
|
'core' => array(
|
28 |
|
|
'description' => 'Core compatibility string for this project.',
|
29 |
|
|
'type' => 'varchar',
|
30 |
|
|
'length' => '128',
|
31 |
|
|
'not null' => TRUE,
|
32 |
|
|
'default' => '',
|
33 |
|
|
),
|
34 |
|
|
'version' => array(
|
35 |
|
|
'description' => 'Human readable name for project used on the interface.',
|
36 |
|
|
'type' => 'varchar',
|
37 |
|
|
'length' => '128',
|
38 |
|
|
'not null' => TRUE,
|
39 |
|
|
'default' => '',
|
40 |
|
|
),
|
41 |
|
|
'l10n_server' => array(
|
42 |
|
|
'description' => 'Localization server for this project.',
|
43 |
|
|
'type' => 'varchar',
|
44 |
|
|
'length' => '255',
|
45 |
|
|
'not null' => TRUE,
|
46 |
|
|
'default' => '',
|
47 |
|
|
),
|
48 |
|
|
'l10n_path' => array(
|
49 |
|
|
'description' => 'Server path this project updates.',
|
50 |
|
|
'type' => 'varchar',
|
51 |
|
|
'length' => '255',
|
52 |
|
|
'not null' => TRUE,
|
53 |
|
|
'default' => '',
|
54 |
|
|
),
|
55 |
|
|
'status' => array(
|
56 |
|
|
'description' => 'Status flag. TBD',
|
57 |
|
|
'type' => 'int',
|
58 |
|
|
'not null' => TRUE,
|
59 |
|
|
'default' => 1,
|
60 |
|
|
),
|
61 |
|
|
),
|
62 |
|
|
'primary key' => array('name'),
|
63 |
|
|
);
|
64 |
|
|
|
65 |
|
|
$schema['l10n_update_file'] = array(
|
66 |
|
|
'description' => 'File and download information for project translations.',
|
67 |
|
|
'fields' => array(
|
68 |
|
|
'project' => array(
|
69 |
|
|
'description' => 'A unique short name to identify the project.',
|
70 |
|
|
'type' => 'varchar',
|
71 |
|
|
'length' => '50',
|
72 |
|
|
'not null' => TRUE,
|
73 |
|
|
),
|
74 |
|
|
'language' => array(
|
75 |
|
|
'description' => 'Reference to the {languages}.language for this translation.',
|
76 |
|
|
'type' => 'varchar',
|
77 |
|
|
'length' => '12',
|
78 |
|
|
'not null' => TRUE,
|
79 |
|
|
),
|
80 |
|
|
'type' => array(
|
81 |
|
|
'description' => 'File origin: download or localfile',
|
82 |
|
|
'type' => 'varchar',
|
83 |
|
|
'length' => '50',
|
84 |
|
|
'not null' => TRUE,
|
85 |
|
|
'default' => '',
|
86 |
|
|
),
|
87 |
|
|
'filename' => array(
|
88 |
|
|
'description' => 'Link to translation file for download.',
|
89 |
|
|
'type' => 'varchar',
|
90 |
|
|
'length' => 255,
|
91 |
|
|
'not null' => TRUE,
|
92 |
|
|
'default' => '',
|
93 |
|
|
),
|
94 |
|
|
'fileurl' => array(
|
95 |
|
|
'description' => 'Link to translation file for download.',
|
96 |
|
|
'type' => 'varchar',
|
97 |
|
|
'length' => 255,
|
98 |
|
|
'not null' => TRUE,
|
99 |
|
|
'default' => '',
|
100 |
|
|
),
|
101 |
|
|
'uri' => array(
|
102 |
|
|
'description' => 'File system path for importing the file.',
|
103 |
|
|
'type' => 'varchar',
|
104 |
|
|
'length' => 255,
|
105 |
|
|
'not null' => TRUE,
|
106 |
|
|
'default' => '',
|
107 |
|
|
),
|
108 |
|
|
'timestamp' => array(
|
109 |
|
|
'description' => 'Unix timestamp of the time the file was downloaded or saved to disk. Zero if not yet downloaded',
|
110 |
|
|
'type' => 'int',
|
111 |
|
|
'not null' => FALSE,
|
112 |
|
|
'disp-width' => '11',
|
113 |
|
|
'default' => 0,
|
114 |
|
|
),
|
115 |
|
|
'version' => array(
|
116 |
|
|
'description' => 'Version tag of the downloaded file.',
|
117 |
|
|
'type' => 'varchar',
|
118 |
|
|
'length' => '128',
|
119 |
|
|
'not null' => TRUE,
|
120 |
|
|
'default' => '',
|
121 |
|
|
),
|
122 |
|
|
'status' => array(
|
123 |
|
|
'description' => 'Status flag. TBD',
|
124 |
|
|
'type' => 'int',
|
125 |
|
|
'not null' => TRUE,
|
126 |
|
|
'default' => 1,
|
127 |
|
|
),
|
128 |
|
|
'last_checked' => array(
|
129 |
|
|
'description' => 'Unix timestamp of the last time this translation was downloaded from or checked at remote server and confirmed to be the most recent release available.',
|
130 |
|
|
'type' => 'int',
|
131 |
|
|
'not null' => FALSE,
|
132 |
|
|
'disp-width' => '11',
|
133 |
|
|
'default' => 0,
|
134 |
|
|
),
|
135 |
|
|
),
|
136 |
|
|
'primary key' => array('project', 'language'),
|
137 |
|
|
);
|
138 |
|
|
|
139 |
|
|
$schema['cache_l10n_update'] = drupal_get_schema_unprocessed('system', 'cache');
|
140 |
|
|
$schema['cache_l10n_update']['description'] = 'Cache table for the Localization Update module to store information about available releases, fetched from central server.';
|
141 |
|
|
|
142 |
|
|
return $schema;
|
143 |
|
|
}
|
144 |
|
|
|
145 |
|
|
/**
|
146 |
|
|
* Implements hook_schema_alter().
|
147 |
|
|
*/
|
148 |
|
|
function l10n_update_schema_alter(&$schema) {
|
149 |
|
|
$schema['locales_target']['fields']['l10n_status'] = array(
|
150 |
|
|
'type' => 'int',
|
151 |
|
|
'not null' => TRUE,
|
152 |
|
|
'default' => 0,
|
153 |
|
|
);
|
154 |
|
|
}
|
155 |
|
|
|
156 |
|
|
/**
|
157 |
|
|
* Implements hook_install().
|
158 |
|
|
*/
|
159 |
|
|
function l10n_update_install() {
|
160 |
|
|
db_add_field('locales_target', 'l10n_status', array('type' => 'int', 'not null' => TRUE, 'default' => 0));
|
161 |
|
|
variable_set('l10n_update_rebuild_projects', 1);
|
162 |
|
|
}
|
163 |
|
|
|
164 |
|
|
/**
|
165 |
|
|
* Implements hook_uninstall().
|
166 |
|
|
*/
|
167 |
|
|
function l10n_update_uninstall() {
|
168 |
|
|
db_drop_field('locales_target', 'l10n_status');
|
169 |
|
|
|
170 |
|
|
variable_del('l10n_update_check_disabled');
|
171 |
|
|
variable_del('l10n_update_check_frequency');
|
172 |
|
|
variable_del('l10n_update_check_mode');
|
173 |
|
|
variable_del('l10n_update_default_server');
|
174 |
|
|
variable_del('l10n_update_default_update_url');
|
175 |
|
|
variable_del('l10n_update_download_store');
|
176 |
|
|
variable_del('l10n_update_import_mode');
|
177 |
|
|
variable_del('l10n_update_rebuild_projects');
|
178 |
|
|
}
|
179 |
|
|
|
180 |
|
|
/**
|
181 |
|
|
* Implements hook_requirements().
|
182 |
|
|
*/
|
183 |
|
|
function l10n_update_requirements($phase) {
|
184 |
f066bdb5
|
Assos Assos
|
if ($phase == 'runtime') {
|
185 |
|
|
$requirements['l10n_update']['title'] = t('Translation update status');
|
186 |
|
|
if (variable_get('l10n_update_check_frequency', 0)) {
|
187 |
|
|
if (l10n_update_get_projects() && l10n_update_language_list()) {
|
188 |
|
|
if (l10n_update_available_updates()) {
|
189 |
|
|
$requirements['l10n_update']['severity'] = REQUIREMENT_WARNING;
|
190 |
|
|
$requirements['l10n_update']['value'] = t('There are available updates');
|
191 |
|
|
$requirements['l10n_update']['description'] = t('There are new or updated translations available for currently installed modules and themes. To check for updates, you can visit the <a href="@check_manually">translation update page</a>.', array(
|
192 |
|
|
'@check_manually' => url('admin/config/regional/translate/update')
|
193 |
|
|
));
|
194 |
|
|
}
|
195 |
|
|
else {
|
196 |
|
|
$requirements['l10n_update']['severity'] = REQUIREMENT_OK;
|
197 |
|
|
$requirements['l10n_update']['value'] = t('All your translations are up to date');
|
198 |
|
|
}
|
199 |
85ad3d82
|
Assos Assos
|
}
|
200 |
|
|
else {
|
201 |
f066bdb5
|
Assos Assos
|
$requirements['l10n_update']['value'] = t('No update data available');
|
202 |
|
|
$requirements['l10n_update']['severity'] = REQUIREMENT_WARNING;
|
203 |
|
|
$requirements['l10n_update']['description'] = _l10n_update_no_data();
|
204 |
85ad3d82
|
Assos Assos
|
}
|
205 |
|
|
}
|
206 |
|
|
else {
|
207 |
f066bdb5
|
Assos Assos
|
$requirements['l10n_update']['value'] = t('Not enabled');
|
208 |
|
|
$requirements['l10n_update']['severity'] = REQUIREMENT_INFO;
|
209 |
85ad3d82
|
Assos Assos
|
}
|
210 |
|
|
return $requirements;
|
211 |
|
|
}
|
212 |
|
|
// We must always return array, the installer doesn't use module_invoke_all()
|
213 |
|
|
return array();
|
214 |
|
|
}
|
215 |
|
|
|
216 |
|
|
/**
|
217 |
|
|
* Add status field to locales_target.
|
218 |
|
|
*/
|
219 |
|
|
function l10n_update_update_6001() {
|
220 |
|
|
if (!db_field_exists('locales_target', 'l10n_status')) {
|
221 |
|
|
db_add_field('locales_target', 'l10n_status', array('type' => 'int', 'not null' => TRUE, 'default' => 0));
|
222 |
|
|
}
|
223 |
|
|
return t('Added l10n_status field to locales_target.');
|
224 |
|
|
}
|
225 |
|
|
|
226 |
|
|
/**
|
227 |
|
|
* Change status field name to l10n_status.
|
228 |
|
|
*/
|
229 |
|
|
function l10n_update_update_6002() {
|
230 |
|
|
// I18n Strings module adds a 'status' column to 'locales_target' table.
|
231 |
|
|
// L10n Update module previously added a column with the same name. To avoid
|
232 |
|
|
// any collision we change the column name here, but only if it was added by
|
233 |
|
|
// L10n Update module.
|
234 |
|
|
if (!db_field_exists('locales_target', 'l10n_status') && db_field_exists('locales_target', 'status') && !db_table_exists('i18n_strings')) {
|
235 |
|
|
db_change_field('locales_target', 'status', 'l10n_status', array('type' => 'int', 'not null' => TRUE, 'default' => 0));
|
236 |
|
|
}
|
237 |
|
|
// Just in case someone did install I18n Strings, we still need to make sure
|
238 |
|
|
// the 'l10n_status' column gets created.
|
239 |
|
|
elseif (!db_field_exists('locales_target', 'l10n_status')) {
|
240 |
|
|
db_add_field('locales_target', 'l10n_status', array('type' => 'int', 'not null' => TRUE, 'default' => 0));
|
241 |
|
|
}
|
242 |
|
|
return t('Resolved possible l10n_status field conflict in locales_target.');
|
243 |
|
|
}
|
244 |
|
|
|
245 |
|
|
/**
|
246 |
|
|
* Rename filepath to uri in {l10n_update_file} table.
|
247 |
|
|
*/
|
248 |
|
|
function l10n_update_update_7001() {
|
249 |
|
|
// Only do this update if the field exists from D6.
|
250 |
|
|
// If it doesn't, we've got a pure D7 site that doesn't need it.
|
251 |
|
|
if (db_field_exists('l10n_update_file', 'filepath')) {
|
252 |
|
|
db_change_field('l10n_update_file', 'filepath', 'uri', array(
|
253 |
|
|
'description' => 'File system path for importing the file.',
|
254 |
|
|
'type' => 'varchar',
|
255 |
|
|
'length' => 255,
|
256 |
|
|
'not null' => TRUE,
|
257 |
|
|
'default' => '',
|
258 |
|
|
));
|
259 |
|
|
}
|
260 |
|
|
}
|
261 |
|
|
|
262 |
|
|
/**
|
263 |
|
|
* Delete 'last_updated' field from {l10n_update_file} table.
|
264 |
|
|
*/
|
265 |
|
|
function l10n_update_update_7002() {
|
266 |
|
|
db_drop_field('l10n_update_file', 'last_updated');
|
267 |
|
|
}
|
268 |
|
|
|
269 |
|
|
/**
|
270 |
|
|
* Delete 'import_date' field from {l10n_update_file} table.
|
271 |
|
|
*/
|
272 |
|
|
function l10n_update_update_7003() {
|
273 |
|
|
db_drop_field('l10n_update_file', 'import_date');
|
274 |
|
|
}
|
275 |
|
|
|
276 |
|
|
/**
|
277 |
|
|
* Create {cache_l10n_update} table.
|
278 |
|
|
*/
|
279 |
|
|
function l10n_update_update_7004() {
|
280 |
|
|
if (!db_table_exists('cache_l10n_update')) {
|
281 |
|
|
$schema = drupal_get_schema_unprocessed('system', 'cache');
|
282 |
|
|
$schema['description'] = 'Cache table for the Localization Update module to store information about available releases, fetched from central server.';
|
283 |
|
|
db_create_table('cache_l10n_update', $schema);
|
284 |
|
|
}
|
285 |
|
|
}
|
286 |
503b3f7b
|
Assos Assos
|
|
287 |
|
|
/**
|
288 |
|
|
* Rebuild registry for 'translations' stream wrapper.
|
289 |
|
|
*/
|
290 |
|
|
function l10n_update_update_7005() {
|
291 |
|
|
registry_rebuild();
|
292 |
|
|
}
|
293 |
f066bdb5
|
Assos Assos
|
|
294 |
|
|
/**
|
295 |
|
|
* Rebuild registry after removing the stream wrapper.
|
296 |
|
|
*/
|
297 |
|
|
function l10n_update_update_7006() {
|
298 |
|
|
registry_rebuild();
|
299 |
|
|
} |