Implements hook_url_inbound_alter().
Inbound URL rewrite helper. If host includes subdomain, rewrite URI and internal path if necessary.
1 string reference to 'advagg_url_inbound_alter'
- advagg.module dans ./
advagg.module - Advanced CSS/JS aggregation module.
Fichier
-
./
advagg.module, line 509
Code
function advagg_url_inbound_alter(&$path, $original_path, $path_language) {
// Do nothing if this has been disabled.
if (!variable_get('advagg_url_inbound_alter', ADVAGG_URL_INBOUND_ALTER)) {
return;
}
// Setup static so we only need to run the logic once.
$already_ran =& drupal_static(__FUNCTION__);
if (!isset($already_ran)) {
$already_ran = array();
}
$request_path = request_path();
// Set the path again if we already did this alter.
if (array_key_exists($request_path, $already_ran)) {
$path = $already_ran[$request_path];
return;
}
// If requested path was for an advagg file but now it is something else
// switch is back to the advagg file.
if (!empty($path) && $path != $request_path && advagg_match_file_pattern($request_path)) {
// Get the advagg paths.
$advagg_path = advagg_get_root_files_dir();
// Get the top level path.
$top_level = substr($advagg_path[0][1], 0, strpos($advagg_path[0][1], 'advagg_css'));
// Only change if it's an exact match.
$start = strpos($request_path, $top_level . 'advagg_');
if ($start === 0) {
// Set path to correct advagg path.
$path = substr($request_path, $start);
$already_ran[$request_path] = $path;
}
else {
// Put all languages prefixes into an array.
$language_list = language_list();
$prefixes = array();
foreach ($language_list as $lang) {
if ($lang->enabled && !empty($lang->prefix) && strpos($request_path, $lang->prefix) !== FALSE) {
$prefixes[$lang->prefix] = $lang->prefix;
}
}
if (!empty($prefixes)) {
// Remove all enabled languages prefixes from the beginning of the path.
$substr_to_shrink = substr($request_path, 0, $start);
foreach ($prefixes as $prefix) {
$substr_to_shrink = str_replace($prefix . '/', '', $substr_to_shrink);
}
// Set path to correct advagg path.
$path = $substr_to_shrink . substr($request_path, $start);
$already_ran[$request_path] = $path;
}
}
}
}