function themekey_prepare_path in ThemeKey 7
Same name and namespace in other branches
- 6.4 themekey_build.inc \themekey_prepare_path()
- 6.2 themekey_build.inc \themekey_prepare_path()
- 6.3 themekey_build.inc \themekey_prepare_path()
- 7.3 themekey_build.inc \themekey_prepare_path()
- 7.2 themekey_build.inc \themekey_prepare_path()
Extracts named wildcards from ThemeKey paths returned by modules via hook_themekey_paths() and associates a weight and a fit factor to this path.
Parameters
$item: reference to path as string
Return value
array containing three elements:
- fit as integer
- weight as integer
- named wildcards as array
1 call to themekey_prepare_path()
- themekey_path_set in ./
themekey_build.inc - Examines ThemeKey paths created by modules via hook_themekey_paths() in database and assigns a fit factor and a weight.
File
- ./
themekey_build.inc, line 213 - The functions in this file are the back end of ThemeKey which should be used only if you configure something, but not when ThemeKey switches themes.
Code
function themekey_prepare_path(&$path) {
$fit = 0;
$weight = 0;
$wildcards = array();
$parts = explode('/', $path, MENU_MAX_PARTS);
$slashes = count($parts) - 1;
foreach ($parts as $index => $part) {
if (preg_match('/^(\\%|\\#)([a-z0-9_:]*)$/', $part, $matches)) {
$parts[$index] = $matches[1];
if (!empty($matches[2])) {
$wildcards[$index] = $matches[2];
}
if ($matches[1] == '#') {
$weight |= 1 << $slashes - $index;
}
}
else {
$fit |= 1 << $slashes - $index;
}
}
$path = implode('/', $parts);
return array(
$fit,
$weight,
$wildcards,
);
}