| 1 |
<?php
|
| 2 |
// $Id: i18ntaxonomy.install,v 1.2 2007/10/24 18:06:16 jareyero Exp $
|
| 3 |
/**
|
| 4 |
* Set language field in its own table
|
| 5 |
* Do not drop node.language now, just in case
|
| 6 |
* TO-DO: Drop old tables, fields
|
| 7 |
*/
|
| 8 |
function i18ntaxonomy_install() {
|
| 9 |
$ret = array();
|
| 10 |
db_add_field($ret, 'vocabulary', 'language', array('type' => 'varchar', 'length' => 12, 'not null' => TRUE, 'default' => ''));
|
| 11 |
db_add_field($ret, 'term_data', 'language', array('type' => 'varchar', 'length' => 12, 'not null' => TRUE, 'default' => ''));
|
| 12 |
db_add_field($ret, 'term_data', 'trid', array('type' => 'int', 'not null' => TRUE, 'default' => 0));
|
| 13 |
// Set module weight for it to run after core modules
|
| 14 |
db_query("UPDATE {system} SET weight = 10 WHERE name = 'i18ntaxonomy' AND type = 'module'");
|
| 15 |
}
|
| 16 |
|
| 17 |
/**
|
| 18 |
* Drupal 6 update
|
| 19 |
*
|
| 20 |
* Move i18n vocabulary options to new variables
|
| 21 |
*/
|
| 22 |
function i18ntaxonomy_update_1() {
|
| 23 |
$items = array();
|
| 24 |
$options = variable_get('i18ntaxonomy_vocabulary', array());
|
| 25 |
$translate = variable_get('i18ntaxonomy_vocabularies', array());
|
| 26 |
foreach (taxonomy_get_vocabularies() as $vid => $vocabulary) {
|
| 27 |
if ($vocabulary->language) {
|
| 28 |
$options[$vid] = I18N_TAXONOMY_LANGUAGE;
|
| 29 |
} elseif (isset($translate[$vid]) && $translate[$vid]) {
|
| 30 |
$options[$vid] = I18N_TAXONOMY_LOCALIZE;
|
| 31 |
} else {
|
| 32 |
// Search for terms with language
|
| 33 |
$count = db_result(db_query("SELECT COUNT(language) FROM {term_data} WHERE vid = %d AND NOT language = ''", $vid));
|
| 34 |
if ($count) {
|
| 35 |
$options[$vid] = I18N_TAXONOMY_TRANSLATE;
|
| 36 |
} elseif (!isset($options[$vid])) {
|
| 37 |
$options[$vid] = I18N_TAXONOMY_NONE;
|
| 38 |
}
|
| 39 |
}
|
| 40 |
}
|
| 41 |
variable_set('i18ntaxonomy_vocabulary', $options);
|
| 42 |
drupal_set_message(t('The multilingual vocabulary settings have been updated. Please review them in the !taxonomy_admin page.', array('!taxonomy_admin' => l(t('taxonomy administration'), 'admin/content/taxonomy'))));
|
| 43 |
// @ TODO Update strings in localization tables
|
| 44 |
return $items;
|
| 45 |
}
|