i18nblocks.install in Internationalization 5.3
File
i18nblocks/i18nblocks.install
View source
<?php
function i18nblocks_install() {
switch ($GLOBALS['db_type']) {
case 'mysql':
case 'mysqli':
db_query("CREATE TABLE {i18n_blocks} (\n `delta` varchar(32) NOT NULL default '0',\n `info` varchar(64) NOT NULL default '',\n `type` varchar(64) NOT NULL default '',\n `param` int(10) NOT NULL default '0',\n PRIMARY KEY (`delta`)\n) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
db_query("CREATE TABLE {i18n_blocks_i18n} (\n `bid` int(10) NOT NULL auto_increment,\n `language` varchar(12) NOT NULL default '',\n `module` varchar(64) NOT NULL default '',\n `delta` varchar(32) NOT NULL default '0',\n PRIMARY KEY (`bid`,`language`)\n) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
break;
case 'pgsql':
db_query("CREATE TABLE {i18n_blocks} (\n delta varchar(32) NOT NULL DEFAULT '0',\n info varchar(64) NOT NULL DEFAULT '',\n type varchar(64) NOT NULL DEFAULT '',\n param int4 NOT NULL DEFAULT 0,\n PRIMARY KEY (delta))");
db_query("CREATE TABLE {i18n_blocks_i18n} (\n bid serial4 NOT NULL,\n language varchar(12) NOT NULL DEFAULT '',\n module varchar(64) NOT NULL DEFAULT '',\n delta varchar(32) NOT NULL DEFAULT '0',\n PRIMARY KEY (bid,language))");
db_query("CREATE SEQUENCE {i18n_blocks}_delta_seq INCREMENT 1 START 1");
break;
}
db_query("UPDATE {system} SET weight = 20 WHERE name = 'i18nblocks' AND type = 'module'");
}
function i18nblocks_update_1() {
$ret = array();
require_once drupal_get_path('module', 'i18nblocks') . '/i18nblocks.module';
require_once drupal_get_path('module', 'i18n') . '/i18n.module';
i18nblocks_install();
$languages = i18n_supported_languages();
if ($number = variable_get('i18nblocks_number', 0)) {
for ($delta = 1; $delta <= $number; $delta++) {
if ($block = variable_get('i18nblocks_' . $delta, NULL)) {
$update = update_sql("INSERT INTO {i18n_blocks}(delta) VALUES('" . db_escape_string($delta) . "')");
$ret[] = $update;
$metablock = array();
if ($update['success']) {
$metablock['delta'] = $delta;
}
$metablock['info'] = isset($block['name']) ? $block['name'] : '';
$metablock['i18nblocks'] = array();
foreach (array_keys($languages) as $lang) {
if (isset($block[$lang]) && isset($block[$lang]['module']) && isset($block[$lang]['delta'])) {
$metablock['i18nblocks'][$lang] = $block[$lang]['module'] . ':' . $block[$lang]['delta'];
}
}
}
i18nblocks_save($metablock);
}
drupal_set_message('The i18nblocks have been updated. Please, review your block settings.');
}
return $ret;
}
function i18nblocks_uninstall() {
db_query('DROP TABLE {i18n_blocks}');
db_query('DROP TABLE {i18n_blocks_i18n}');
}