Commit 3232900b authored by young hahn's avatar young hahn
Browse files

Ensuring that site_frontpage exception respects language prefix when making check

parent baced8fc
......@@ -13,7 +13,7 @@ function strongarm_init() {
// 'site_frontpage' is used. Note that this may be too late if other modules
// weighted even lower than strongarm (which is a superlightweight -1000)
// rely on $_GET['q'] or 'site_frontpage' in hook_init().
$_GET['q'] = $_REQUEST['q'];
$_GET['q'] = strongarm_language_strip($_REQUEST['q']);
drupal_init_path();
}
......@@ -47,6 +47,32 @@ function strongarm_set_conf($reset = FALSE) {
$conf = array_merge($var_conf, $conf);
}
/**
* Remove the language prefix for a given path.
* Strongarm implements this itself as language_initialize() directly affects
* $_GET['q'] and cannot be reused.
*/
function strongarm_language_strip($path) {
// Configured presentation language mode.
$mode = variable_get('language_negotiation', LANGUAGE_NEGOTIATION_NONE);
// Get a list of enabled languages.
$languages = language_list('enabled');
$languages = $languages[1];
if (in_array($mode, array(LANGUAGE_NEGOTIATION_PATH_DEFAULT, LANGUAGE_NEGOTIATION_PATH))) {
$args = explode('/', $path);
$prefix = array_shift($args);
// Search prefix within enabled languages.
foreach ($languages as $language) {
if (!empty($language->prefix) && $language->prefix == $prefix) {
return implode('/', $args);
}
}
}
return $path;
}
/**
* Implementation of hook_menu().
*/
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment