function i18n_db_rewrite_where in Internationalization 6
Same name and namespace in other branches
- 5.3 i18n.module \i18n_db_rewrite_where()
- 5 i18n.module \i18n_db_rewrite_where()
- 5.2 i18n.module \i18n_db_rewrite_where()
Rewrites queries depending on rewriting mode.
3 calls to i18n_db_rewrite_where()
- i18nblocks_db_rewrite_sql in i18nblocks/
i18nblocks.module - Implementation of hook_db_rewrite_sql().
- i18ntaxonomy_db_rewrite_sql in i18ntaxonomy/
i18ntaxonomy.module - Implementation of hook_db_rewrite_sql().
- i18n_db_rewrite_sql in ./
i18n.module - Implementation of hook_db_rewrite_sql().
File
- ./
i18n.module, line 477 - Internationalization (i18n) module.
Code
function i18n_db_rewrite_where($alias, $type, $mode = NULL) {
if (!$mode) {
// Some exceptions for query rewrites.
$mode = i18n_selection_mode();
}
// Get languages to simplify query building.
$current = i18n_get_lang();
$default = i18n_default_language();
if ($mode == 'strict' && $type != 'node') {
// Special case. Selection mode is 'strict' but this should be only for node queries.
$mode = 'simple';
}
elseif ($mode == 'mixed' && $current == $default) {
// If mode is mixed but current = default, is the same as 'simple'.
$mode = 'simple';
}
switch ($mode) {
case 'off':
return '';
case 'simple':
return "{$alias}.language ='{$current}' OR {$alias}.language ='' OR {$alias}.language IS NULL";
case 'mixed':
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'));
}
}