summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2009-10-16 19:06:25 +0000
committerDries Buytaert <dries@buytaert.net>2009-10-16 19:06:25 +0000
commit60c5878351cc547dbfda260fefcf378491c958ec (patch)
tree9985db3bf964c09cb8564b54c79f345d773edf21
parent4430d46334127c69d5ff97ce2e15475c0fae2654 (diff)
downloadbrdo-60c5878351cc547dbfda260fefcf378491c958ec.tar.gz
brdo-60c5878351cc547dbfda260fefcf378491c958ec.tar.bz2
- Patch #593746 by #593746 by sun, andypost: prepare Drupal core for dynamic data translation.
-rw-r--r--includes/bootstrap.inc3
-rw-r--r--includes/database/select.inc10
-rw-r--r--includes/menu.inc10
-rw-r--r--install.php7
-rw-r--r--modules/block/block.install2
-rw-r--r--modules/block/block.module1
-rw-r--r--modules/contact/contact.install1
-rw-r--r--modules/contact/contact.pages.inc8
-rw-r--r--modules/filter/filter.install1
-rw-r--r--modules/filter/filter.module7
-rw-r--r--modules/menu/menu.install2
-rw-r--r--modules/menu/menu.module1
-rw-r--r--modules/node/node.install5
-rw-r--r--modules/node/node.module3
-rw-r--r--modules/poll/poll.install1
-rw-r--r--modules/poll/poll.module7
-rw-r--r--modules/poll/poll.pages.inc1
-rw-r--r--modules/system/system.install3
-rw-r--r--modules/taxonomy/taxonomy.install4
-rw-r--r--modules/taxonomy/taxonomy.module16
-rw-r--r--modules/taxonomy/taxonomy.pages.inc1
-rw-r--r--modules/upload/upload.install1
22 files changed, 73 insertions, 22 deletions
diff --git a/includes/bootstrap.inc b/includes/bootstrap.inc
index 83ab8ba0b..ad0186d5d 100644
--- a/includes/bootstrap.inc
+++ b/includes/bootstrap.inc
@@ -1638,6 +1638,9 @@ function drupal_language_initialize() {
foreach ($types as $type) {
$GLOBALS[$type] = language_initialize($type);
}
+ // Allow modules to react on language system initialization in multilingual
+ // environments.
+ module_invoke_all('language_init', $types);
}
}
diff --git a/includes/database/select.inc b/includes/database/select.inc
index cebeef7ad..3eddd3ad7 100644
--- a/includes/database/select.inc
+++ b/includes/database/select.inc
@@ -1285,6 +1285,11 @@ class SelectQuery extends Query implements SelectQueryInterface {
// FIELDS and EXPRESSIONS
$fields = array();
+ foreach ($this->tables as $alias => $table) {
+ if (!empty($table['all_fields'])) {
+ $fields[] = $alias . '.*';
+ }
+ }
foreach ($this->fields as $alias => $field) {
// Always use the AS keyword for field aliases, as some
// databases require it (e.g., PostgreSQL).
@@ -1293,11 +1298,6 @@ class SelectQuery extends Query implements SelectQueryInterface {
foreach ($this->expressions as $alias => $expression) {
$fields[] = $expression['expression'] . ' AS ' . $expression['alias'];
}
- foreach ($this->tables as $alias => $table) {
- if (!empty($table['all_fields'])) {
- $fields[] = $alias . '.*';
- }
- }
$query .= implode(', ', $fields);
diff --git a/includes/menu.inc b/includes/menu.inc
index 05cdf7771..40992d928 100644
--- a/includes/menu.inc
+++ b/includes/menu.inc
@@ -934,8 +934,8 @@ function menu_tree_all_data($menu_name, $link = NULL, $max_depth = NULL) {
// Use $mlid as a flag for whether the data being loaded is for the whole tree.
$mlid = isset($link['mlid']) ? $link['mlid'] : 0;
- // Generate a cache ID (cid) specific for this $menu_name, $item, and depth.
- $cid = 'links:' . $menu_name . ':all-cid:' . $mlid . ':' . (int)$max_depth;
+ // Generate a cache ID (cid) specific for this $menu_name, $link, $language, and depth.
+ $cid = 'links:' . $menu_name . ':all-cid:' . $mlid . ':' . $GLOBALS['language_interface']->language . ':' . (int)$max_depth;
if (!isset($tree[$cid])) {
// If the static variable doesn't have the data, check {cache_menu}.
@@ -953,6 +953,7 @@ function menu_tree_all_data($menu_name, $link = NULL, $max_depth = NULL) {
// Build the query using a LEFT JOIN since there is no match in
// {menu_router} for an external link.
$query = db_select('menu_links', 'ml', array('fetch' => PDO::FETCH_ASSOC));
+ $query->addTag('translatable');
$query->leftJoin('menu_router', 'm', 'm.path = ml.router_path');
$query->fields('ml');
$query->fields('m', array(
@@ -1046,7 +1047,7 @@ function menu_tree_page_data($menu_name, $max_depth = NULL) {
$max_depth = min($max_depth, MENU_MAX_DEPTH);
}
// Generate a cache ID (cid) specific for this page.
- $cid = 'links:' . $menu_name . ':page-cid:' . $item['href'] . ':' . (int)$item['access'] . ':' . (int)$max_depth;
+ $cid = 'links:' . $menu_name . ':page-cid:' . $item['href'] . ':' . $GLOBALS['language_interface']->language . ':' . (int)$item['access'] . ':' . (int)$max_depth;
if (!isset($tree[$cid])) {
// If the static variable doesn't have the data, check {cache_menu}.
@@ -1137,6 +1138,7 @@ function menu_tree_page_data($menu_name, $max_depth = NULL) {
// LEFT JOIN since there is no match in {menu_router} for an external
// link.
$query = db_select('menu_links', 'ml', array('fetch' => PDO::FETCH_ASSOC));
+ $query->addTag('translatable');
$query->leftJoin('menu_router', 'm', 'm.path = ml.router_path');
$query->fields('ml');
$query->fields('m', array(
@@ -1193,7 +1195,7 @@ function menu_tree_page_data($menu_name, $max_depth = NULL) {
* Helper function - compute the real cache ID for menu tree data.
*/
function _menu_tree_cid($menu_name, $data) {
- return 'links:' . $menu_name . ':tree-data:' . md5(serialize($data));
+ return 'links:' . $menu_name . ':tree-data:' . $GLOBALS['language_interface']->language . ':' . md5(serialize($data));
}
/**
diff --git a/install.php b/install.php
index 4f81169da..08271bdec 100644
--- a/install.php
+++ b/install.php
@@ -242,12 +242,13 @@ function install_begin_request(&$install_state) {
require_once DRUPAL_ROOT . '/includes/file.inc';
require_once DRUPAL_ROOT . '/includes/path.inc';
- // Set up $language, so t() caller functions will still work.
- drupal_language_initialize();
-
// Load module basics (needed for hook invokes).
include_once DRUPAL_ROOT . '/includes/module.inc';
include_once DRUPAL_ROOT . '/includes/session.inc';
+
+ // Set up $language, so t() caller functions will still work.
+ drupal_language_initialize();
+
include_once DRUPAL_ROOT . '/includes/entity.inc';
$module_list['system']['filename'] = 'modules/system/system.module';
$module_list['filter']['filename'] = 'modules/filter/filter.module';
diff --git a/modules/block/block.install b/modules/block/block.install
index 33275506b..04fa793d7 100644
--- a/modules/block/block.install
+++ b/modules/block/block.install
@@ -85,6 +85,7 @@ function block_schema() {
'not null' => TRUE,
'default' => '',
'description' => 'Custom title for the block. (Empty string will use block default title, <none> will remove the title, text will cause block to use specified title.)',
+ 'translatable' => TRUE,
),
'cache' => array(
'type' => 'int',
@@ -173,6 +174,7 @@ function block_schema() {
'not null' => FALSE,
'size' => 'big',
'description' => 'Block contents.',
+ 'translatable' => TRUE,
),
'info' => array(
'type' => 'varchar',
diff --git a/modules/block/block.module b/modules/block/block.module
index 4cba11220..5e20b940c 100644
--- a/modules/block/block.module
+++ b/modules/block/block.module
@@ -601,6 +601,7 @@ function _block_load_blocks() {
->orderBy('b.weight')
->orderBy('b.module')
->addTag('block_load')
+ ->addTag('translatable')
->execute();
$block_info = $result->fetchAllAssoc('bid');
diff --git a/modules/contact/contact.install b/modules/contact/contact.install
index ac245d586..42f15272d 100644
--- a/modules/contact/contact.install
+++ b/modules/contact/contact.install
@@ -25,6 +25,7 @@ function contact_schema() {
'not null' => TRUE,
'default' => '',
'description' => 'Category name.',
+ 'translatable' => TRUE,
),
'recipients' => array(
'type' => 'text',
diff --git a/modules/contact/contact.pages.inc b/modules/contact/contact.pages.inc
index 2855bec83..fa5606448 100644
--- a/modules/contact/contact.pages.inc
+++ b/modules/contact/contact.pages.inc
@@ -24,7 +24,13 @@ function contact_site_form($form, &$form_state) {
}
// Get an array of the categories and the current default category.
- $categories = db_query("SELECT cid, category FROM {contact} ORDER BY weight, category")->fetchAllKeyed();
+ $categories = db_select('contact', 'c')
+ ->addTag('translatable')
+ ->fields('c', array('cid', 'category'))
+ ->orderBy('weight')
+ ->orderBy('category')
+ ->execute()
+ ->fetchAllKeyed();
$default_category = db_query("SELECT cid FROM {contact} WHERE selected = 1")->fetchField();
// If there are no categories, do not display the form.
diff --git a/modules/filter/filter.install b/modules/filter/filter.install
index c6efb11f4..3fab5b44f 100644
--- a/modules/filter/filter.install
+++ b/modules/filter/filter.install
@@ -76,6 +76,7 @@ function filter_schema() {
'not null' => TRUE,
'default' => '',
'description' => 'Name of the text format (Filtered HTML).',
+ 'translatable' => TRUE,
),
'cache' => array(
'type' => 'int',
diff --git a/modules/filter/filter.module b/modules/filter/filter.module
index 6d2528062..5afb01a72 100644
--- a/modules/filter/filter.module
+++ b/modules/filter/filter.module
@@ -335,7 +335,12 @@ function filter_formats($account = NULL) {
// Statically cache all existing formats upfront.
if (!isset($formats['all'])) {
- $formats['all'] = db_query('SELECT * FROM {filter_format} ORDER BY weight')->fetchAllAssoc('format');
+ $formats['all'] = db_select('filter_format', 'ff')
+ ->addTag('translatable')
+ ->fields('ff')
+ ->orderBy('weight')
+ ->execute()
+ ->fetchAllAssoc('format');
}
// Build a list of user-specific formats.
diff --git a/modules/menu/menu.install b/modules/menu/menu.install
index e4246d020..d7fa925e7 100644
--- a/modules/menu/menu.install
+++ b/modules/menu/menu.install
@@ -26,11 +26,13 @@ function menu_schema() {
'not null' => TRUE,
'default' => '',
'description' => 'Menu title; displayed at top of block.',
+ 'translatable' => TRUE,
),
'description' => array(
'type' => 'text',
'not null' => FALSE,
'description' => 'Menu description.',
+ 'translatable' => TRUE,
),
),
'primary key' => array('menu_name'),
diff --git a/modules/menu/menu.module b/modules/menu/menu.module
index 76af91d21..ac7c4248f 100644
--- a/modules/menu/menu.module
+++ b/modules/menu/menu.module
@@ -674,6 +674,7 @@ function menu_node_form_submit($form, &$form_state) {
function menu_get_menus($all = TRUE) {
$system_menus = array_keys(menu_list_system_menus());
$query = db_select('menu_custom');
+ $query->addTag('translatable');
$query->addField('menu_custom', 'menu_name', 'menu_name');
$query->addField('menu_custom', 'title', 'title');
if (!$all) {
diff --git a/modules/node/node.install b/modules/node/node.install
index 7a4e156eb..9c4c2201f 100644
--- a/modules/node/node.install
+++ b/modules/node/node.install
@@ -269,6 +269,7 @@ function node_schema() {
'length' => 255,
'not null' => TRUE,
'default' => '',
+ 'translatable' => TRUE,
),
'base' => array(
'description' => 'The base string used to construct callbacks corresponding to this node type.',
@@ -281,12 +282,14 @@ function node_schema() {
'type' => 'text',
'not null' => TRUE,
'size' => 'medium',
+ 'translatable' => TRUE,
),
'help' => array(
'description' => 'Help information shown to the user when creating a {node} of this type.',
'type' => 'text',
'not null' => TRUE,
'size' => 'medium',
+ 'translatable' => TRUE,
),
'has_title' => array(
'description' => 'Boolean indicating whether this type uses the {node}.title field.',
@@ -301,6 +304,7 @@ function node_schema() {
'length' => 255,
'not null' => TRUE,
'default' => '',
+ 'translatable' => TRUE,
),
'has_body' => array(
'description' => 'Boolean indicating whether this type has the body field attached.',
@@ -315,6 +319,7 @@ function node_schema() {
'length' => 255,
'not null' => TRUE,
'default' => '',
+ 'translatable' => TRUE,
),
'custom' => array(
'description' => 'A boolean indicating whether this type is defined by a module (FALSE) or by a user via Add content type (TRUE).',
diff --git a/modules/node/node.module b/modules/node/node.module
index 038a0a175..4c85affad 100644
--- a/modules/node/node.module
+++ b/modules/node/node.module
@@ -674,9 +674,10 @@ function _node_types_build() {
$_node_types->names[$type] = $info['name'];
}
$type_result = db_select('node_type', 'nt')
+ ->addTag('translatable')
+ ->addTag('node_type_access')
->fields('nt')
->orderBy('nt.type', 'ASC')
- ->addTag('node_type_access')
->execute();
foreach ($type_result as $type_object) {
// Check for node types from disabled modules and mark their types for removal.
diff --git a/modules/poll/poll.install b/modules/poll/poll.install
index 4bd7a214f..8bfcd8eef 100644
--- a/modules/poll/poll.install
+++ b/modules/poll/poll.install
@@ -62,6 +62,7 @@ function poll_schema() {
'not null' => TRUE,
'default' => '',
'description' => 'The text for this choice.',
+ 'translatable' => TRUE,
),
'chvotes' => array(
'type' => 'int',
diff --git a/modules/poll/poll.module b/modules/poll/poll.module
index 373ee0d03..56e3d75c4 100644
--- a/modules/poll/poll.module
+++ b/modules/poll/poll.module
@@ -436,7 +436,12 @@ function poll_load($nodes) {
$poll = db_query("SELECT runtime, active FROM {poll} WHERE nid = :nid", array(':nid' => $node->nid))->fetchObject();
// Load the appropriate choices into the $poll object.
- $poll->choice = db_query("SELECT chid, chtext, chvotes, weight FROM {poll_choice} WHERE nid = :nid ORDER BY weight", array(':nid' => $node->nid))->fetchAllAssoc('chid', PDO::FETCH_ASSOC);
+ $poll->choice = db_select('poll_choice', 'c')
+ ->addTag('translatable')
+ ->fields('c', array('chid', 'chtext', 'chvotes', 'weight'))
+ ->condition('c', 'nid', $node->nid)
+ ->orderBy('weight')
+ ->fetchAllAssoc('chid', PDO::FETCH_ASSOC);
// Determine whether or not this user is allowed to vote.
$poll->allowvotes = FALSE;
diff --git a/modules/poll/poll.pages.inc b/modules/poll/poll.pages.inc
index 0b9e255e5..0661944db 100644
--- a/modules/poll/poll.pages.inc
+++ b/modules/poll/poll.pages.inc
@@ -61,6 +61,7 @@ function poll_votes($node) {
$select->join('poll_choice', 'pc', 'pv.chid = pc.chid');
$select->join('users', 'u', 'pv.uid = u.uid');
$queried_votes = $select
+ ->addTag('translatable')
->fields('pv', array('chid', 'uid', 'hostname', 'timestamp', 'nid'))
->fields('pc', array('chtext'))
->fields('u', array('name'))
diff --git a/modules/system/system.install b/modules/system/system.install
index e69bb6e24..f29f45f9d 100644
--- a/modules/system/system.install
+++ b/modules/system/system.install
@@ -568,6 +568,7 @@ function system_schema() {
'type' => 'text',
'not null' => TRUE,
'size' => 'big',
+ 'translatable' => TRUE,
),
),
'primary key' => array('name'),
@@ -1162,11 +1163,13 @@ function system_schema() {
'length' => 255,
'not null' => TRUE,
'default' => '',
+ 'translatable' => TRUE,
),
'options' => array(
'description' => 'A serialized array of options to be passed to the url() or l() function, such as a query string or HTML attributes.',
'type' => 'text',
'not null' => FALSE,
+ 'translatable' => TRUE,
),
'module' => array(
'description' => 'The name of the module that generated this link.',
diff --git a/modules/taxonomy/taxonomy.install b/modules/taxonomy/taxonomy.install
index 736347485..148322000 100644
--- a/modules/taxonomy/taxonomy.install
+++ b/modules/taxonomy/taxonomy.install
@@ -41,12 +41,14 @@ function taxonomy_schema() {
'not null' => TRUE,
'default' => '',
'description' => 'The term name.',
+ 'translatable' => TRUE,
),
'description' => array(
'type' => 'text',
'not null' => FALSE,
'size' => 'big',
'description' => 'A description of the term.',
+ 'translatable' => TRUE,
),
'weight' => array(
'type' => 'int',
@@ -108,6 +110,7 @@ function taxonomy_schema() {
'not null' => TRUE,
'default' => '',
'description' => 'Name of the vocabulary.',
+ 'translatable' => TRUE,
),
'machine_name' => array(
'type' => 'varchar',
@@ -121,6 +124,7 @@ function taxonomy_schema() {
'not null' => FALSE,
'size' => 'big',
'description' => 'Description of the vocabulary.',
+ 'translatable' => TRUE,
),
'relations' => array(
'type' => 'int',
diff --git a/modules/taxonomy/taxonomy.module b/modules/taxonomy/taxonomy.module
index 88d00f546..fb02663bb 100644
--- a/modules/taxonomy/taxonomy.module
+++ b/modules/taxonomy/taxonomy.module
@@ -591,9 +591,9 @@ function taxonomy_get_parents($tid, $key = 'tid') {
if ($tid) {
$query = db_select('taxonomy_term_data', 't');
$query->join('taxonomy_term_hierarchy', 'h', 'h.parent = t.tid');
- $query->addTag('term_access');
-
$result = $query
+ ->addTag('translatable')
+ ->addTag('term_access')
->fields('t')
->condition('h.tid', $tid)
->orderBy('weight')
@@ -632,9 +632,9 @@ function taxonomy_get_parents_all($tid) {
function taxonomy_get_children($tid, $vid = 0, $key = 'tid') {
$query = db_select('taxonomy_term_data', 't');
$query->join('taxonomy_term_hierarchy', 'h', 'h.tid = t.tid');
- $query->addTag('term_access');
-
$query
+ ->addTag('translatable')
+ ->addTag('term_access')
->fields('t')
->condition('parent', $tid)
->orderBy('weight')
@@ -685,9 +685,9 @@ function taxonomy_get_tree($vid, $parent = 0, $max_depth = NULL, $depth = -1) {
$query = db_select('taxonomy_term_data', 't');
$query->join('taxonomy_term_hierarchy', 'h', 'h.tid = t.tid');
- $query->addTag('term_access');
-
$result = $query
+ ->addTag('translatable')
+ ->addTag('term_access')
->fields('t')
->fields('h', array('parent'))
->condition('t.vid', $vid)
@@ -754,6 +754,8 @@ class TaxonomyTermController extends DrupalDefaultEntityController {
protected function buildQuery() {
parent::buildQuery();
+ $this->query->addTag('translatable');
+ $this->query->addTag('term_access');
// When name is passed as a condition use LIKE.
if (isset($this->conditions['name'])) {
$conditions = &$this->query->conditions();
@@ -791,6 +793,7 @@ class TaxonomyTermController extends DrupalDefaultEntityController {
class TaxonomyVocabularyController extends DrupalDefaultEntityController {
protected function buildQuery() {
parent::buildQuery();
+ $this->query->addTag('translatable');
$this->query->orderBy('base.weight');
$this->query->orderBy('base.name');
}
@@ -1149,6 +1152,7 @@ function taxonomy_field_formatter_prepare_view($obj_type, $objects, $field, $ins
$query = db_select('taxonomy_term_data', 't');
$query->fields('t');
$query->condition('t.tid', $tids, 'IN');
+ $query->addTag('translatable');
$query->addTag('term_access');
$terms = $query->execute()->fetchAllAssoc('tid');
diff --git a/modules/taxonomy/taxonomy.pages.inc b/modules/taxonomy/taxonomy.pages.inc
index c62f6e00c..269e8cd37 100644
--- a/modules/taxonomy/taxonomy.pages.inc
+++ b/modules/taxonomy/taxonomy.pages.inc
@@ -97,6 +97,7 @@ function taxonomy_autocomplete($field_name, $bundle, $tags_typed = '') {
}
$query = db_select('taxonomy_term_data', 't');
+ $query->addTag('translatable');
$query->addTag('term_access');
// Do not select already entered terms.
diff --git a/modules/upload/upload.install b/modules/upload/upload.install
index 87f817f81..26924f050 100644
--- a/modules/upload/upload.install
+++ b/modules/upload/upload.install
@@ -45,6 +45,7 @@ function upload_schema() {
'not null' => TRUE,
'default' => '',
'description' => 'Description of the uploaded file.',
+ 'translatable' => TRUE,
),
'list' => array(
'type' => 'int',