function i18n_db_rewrite_where in Internationalization 5.3
Same name and namespace in other branches
- 5 i18n.module \i18n_db_rewrite_where()
- 5.2 i18n.module \i18n_db_rewrite_where()
- 6 i18n.module \i18n_db_rewrite_where()
Rewrites queries depending on rewriting mode
1 call to i18n_db_rewrite_where()
- i18n_db_rewrite_sql in ./
i18n.module - Implementation of hook_db_rewrite_sql()
File
- ./
i18n.module, line 823 - Internationalization (i18n) module
Code
function i18n_db_rewrite_where($alias, $mode) {
// Get languages to simplify query building.
$current = i18n_get_lang();
$default = i18n_default_language();
// If mode is mixed but current = default, it is the same as 'simple'.
if ($mode == 'mixed' && $current == $default) {
$mode = 'simple';
}
switch ($mode) {
case 'simple':
return "{$alias}.language ='{$current}' OR {$alias}.language ='' OR {$alias}.language IS NULL";
case 'mixed':
// This will be only for objects other than nodes
return "{$alias}.language = '{$current}' OR {$alias}.language = '{$default}' OR {$alias}.language = '' OR {$alias}.language IS NULL";
case 'strict':
return "{$alias}.language ='{$current}'";
case 'node':
case 'translation':
return "{$alias}.language ='" . i18n_selection_mode('params') . "' OR {$alias}.language ='' OR {$alias}.language IS NULL";
case 'default':
return "{$alias}.language ='{$default}' OR {$alias}.language ='' OR {$alias}.language IS NULL";
case 'custom':
return str_replace('%alias', $alias, i18n_selection_mode('params'));
}
}