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

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

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


Revision 1.6 - (show annotations) (download) (as text)
Sun Feb 17 19:32:12 2008 UTC (21 months, 1 week ago) by jareyero
Branch: MAIN
CVS Tags: HEAD
Branch point for: DRUPAL-6--1
Changes since 1.5: +2 -2 lines
File MIME type: text/x-php
Fixed multiple issues with blocks and taxonomy
1 <?php
2 // $Id: i18nprofile.install,v 1.5 2008/02/17 18:09:01 jareyero Exp $
3
4 /**
5 * Nothing to install for Drupal 6
6 */
7 function i18nprofile_install() {
8 }
9
10 /**
11 * Update table to utf-8
12 */
13 function i18nprofile_update_1() {
14 return _system_update_utf8(array('i18n_profile_fields'));
15 }
16
17 // Drupal 6 updates
18
19 /**
20 * Drop old table and fields
21 */
22 function i18nprofile_update_2() {
23 $items = array();
24
25 // Create source strings for translations
26 $categories = array();
27 $result = db_query("SELECT * FROM {profile_fields}");
28 while ($field = db_fetch_object($result)) {
29 // Store strings to translate: title, explanation, options
30 to("profile:field:$field->name", $field, array('title', 'explanation', 'options'), NULL, TRUE);
31 if (!in_array($field->category, $categories)) {
32 $categories[] = $field->category;
33 tt("profile:category", $field->category, NULL, TRUE);
34 }
35 }
36 // Category translations from variables
37 foreach (array_keys(language_list()) as $lang) {
38 if ($translation = variable_get('i18nprofile_'.$lang, FALSE)) {
39 foreach ($translation as $category => $translation) {
40 if (in_array($category, $categories) && $translation) {
41 $context = i18nstrings_context('profile:category', $category);
42 i18nstrings_update_translation($context, $lang, $translation);
43 }
44 }
45 }
46 }
47 // Move current data into string translations
48 $result = db_query("SELECT * FROM {i18n_profile_fields}");
49 while ($field = db_fetch_object($result)) {
50 foreach (array('title', 'explanation', 'options') as $property) {
51 if (!empty($field->$property)) {
52 i18nstrings_update_translation("profile:field:$field->name:$property", $field->language, $field->$property);
53 }
54 }
55 }
56
57 return $items;
58 }
59
60 // Clean up. Uncomment when it all works
61 /*
62 function i18nprofile_update_3() {
63 $items[] = update_sql("DROP TABLE {i18n_profile_fields};");
64
65 foreach (array_keys(language_list()) as $lang) {
66 variable_del('i18nprofile_'.$lang);
67 }
68 return $items;
69 }
70 */

  ViewVC Help
Powered by ViewVC 1.1.2