/[drupal]/contributions/modules/i18n/i18nblocks/i18nblocks.install
ViewVC logotype

Contents of /contributions/modules/i18n/i18nblocks/i18nblocks.install

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.5 - (show annotations) (download) (as text)
Tue Feb 19 19:43:55 2008 UTC (21 months ago) by jareyero
Branch: MAIN
CVS Tags: DRUPAL-6--1-0-BETA2, DRUPAL-6--1-0-BETA1, HEAD
Branch point for: DRUPAL-6--1
Changes since 1.4: +3 -2 lines
File MIME type: text/x-php
Fixed issues in i18nblocks
Reworked i18nmenu for Drupal 6
Fixed i18nstrings so string update returns real status value
1 <?php
2 // $Id: i18nblocks.install,v 1.4 2008/02/19 02:16:12 jareyero Exp $
3
4 // @ TODO Update scripts
5 /**
6 * Implementation of hook_install().
7 */
8 function i18nblocks_install() {
9 // Create database tables
10 drupal_install_schema('i18nblocks');
11 // We dont need to change module weight
12 //db_query("UPDATE {system} SET weight = 20 WHERE name = 'i18nblocks' AND type = 'module'");
13 }
14
15 /**
16 * Implementation of hook_uninstall()
17 */
18 function i18nblocks_uninstall() {
19 drupal_uninstall_schema('i18nblocks');
20 }
21 /**
22 * Implementation of hook_schema().
23 */
24 function i18nblocks_schema() {
25 $schema['i18n_blocks'] = array(
26 'description' => t('Special i18n translatable blocks'),
27 'fields' => array(
28 'ibid' => array(
29 'description' => t('The i18n block identifier.'),
30 'type' => 'serial',
31 'unsigned' => TRUE,
32 'not null' => TRUE),
33 'module' => array(
34 'type' => 'varchar',
35 'length' => 64,
36 'not null' => TRUE,
37 'description' => t("The block's origin module, from {blocks}.module."),
38 ),
39 'delta' => array(
40 'type' => 'varchar',
41 'length' => 32,
42 'not null' => TRUE,
43 'default' => '0',
44 'description' => t('Unique ID for block within a module.'),
45 ),
46 'type' => array(
47 'type' => 'int',
48 'not null' => TRUE,
49 'default' => '0',
50 'description' => t('Block type.'),
51 ),
52 'language' => array(
53 'type' => 'varchar',
54 'length' => 12,
55 'description' => t("Block language"),
56 'not null' => TRUE,
57 'default' => '',
58 ),
59 ),
60 'primary key' => array(
61 'ibid',
62 ),
63 );
64
65 return $schema;
66 }
67
68 /**
69 * Update: move old variable to new tables
70 */
71 function i18nblocks_update_1() {
72 $ret = array();
73 require_once drupal_get_path('module', 'i18nblocks').'/i18nblocks.module';
74 require_once drupal_get_path('module', 'i18n').'/i18n.module';
75 // Create the tables if updating from previous version
76 i18nblocks_install();
77 // Move old data from variables into new tables
78 $languages = i18n_supported_languages();
79 if($number = variable_get('i18nblocks_number', 0)) {
80 for($delta = 1; $delta <= $number; $delta++) {
81 if ($block = variable_get('i18nblocks_'.$delta, NULL)) {
82 $update = update_sql("INSERT INTO {i18n_blocks}(delta) VALUES('".db_escape_string($delta)."')");
83 $ret[] = $update;
84 $metablock = array();
85 if ($update['success']) {
86 $metablock['delta'] = $delta;
87 }
88 $metablock['info'] = isset($block['name']) ? $block['name'] : '';
89 $metablock['i18nblocks'] = array();
90 foreach(array_keys($languages) as $lang) {
91 if(isset($block[$lang]) && isset($block[$lang]['module']) && isset($block[$lang]['delta'])) {
92 $metablock['i18nblocks'][$lang] = $block[$lang]['module'].':'.$block[$lang]['delta'];
93 }
94 }
95 }
96 i18nblocks_save($metablock);
97 }
98 drupal_set_message('The i18nblocks have been updated. Please, review your block settings.');
99 }
100 return $ret;
101 }
102
103 /**
104 * Drupal 6 upgrade script
105 */
106 function i18nblocks_update_2() {
107 $ret = array();
108 // Rename old table and install new schema
109 db_rename_table($ret, 'i18n_blocks', 'i18n_blocks_drupal5');
110 drupal_install_schema('i18nblocks');
111 // Fill in new table with old blocks but only for user defined blocks.
112 // The rest will need manual update
113 $ret = update_sql("INSERT INTO {i18n_blocks}(module, delta, language) SELECT i.module, i.delta, i.language FROM {i18n_blocks_i18n} i WHERE i.module ='block'");
114
115 drupal_set_message(t('Multilingual blocks have been updated. Please, review your blocks configuration.'));
116 return $ret;
117 }
118
119 /**
120 * Drop old tables and fields. Uncomment when the previous one is 100% working
121 */
122 /*
123 function i18nblocks_update_3() {
124 $items = array();
125 $items[] = update_sql('DROP TABLE {i18n_blocks_i18n}');
126 $items[] = update_sql('DROP TABLE {i18n_blocks_drupal5}');
127 return $items;
128 }
129 */
130

  ViewVC Help
Powered by ViewVC 1.1.2