function purl_language_strip in Persistent URL 6
Same name and namespace in other branches
- 7 purl.module \purl_language_strip()
Remove the language prefix for a given path. PURL implements this itself as language_initialize() directly affects $_GET['q'] and cannot be reused.
1 call to purl_language_strip()
- purl_init in ./
purl.module - Implementation of hook_init() Checks for any valid persistent urls in request string and fire callback appropriately
File
- ./
purl.module, line 142
Code
function purl_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;
}