function _themekey_get_path_ancestors in ThemeKey 6
Function _themekey_get_path_ancestors(). (based on menu_get_ancestors() in includes/menu.inc)
1 call to _themekey_get_path_ancestors()
- _themekey_match_paths in ./
themekey_base.inc - Function _themekey_match_paths().
File
- ./
themekey_base.inc, line 27
Code
function _themekey_get_path_ancestors($parts) {
$placeholders = array();
$ancestors = array();
$number_parts = count($parts);
$length = $number_parts - 1;
$end = (1 << $number_parts) - 1;
$masks = variable_get('menu_masks', array());
foreach ($masks as $i) {
if ($i > $end) {
continue;
}
elseif ($i < 1 << $length) {
--$length;
}
$current = '';
for ($j = $length; $j >= 0; $j--) {
if ($i & 1 << $j) {
$current .= $parts[$length - $j];
}
else {
$current .= is_numeric($parts[$length - $j]) ? '#' : '%';
}
if ($j) {
$current .= '/';
}
}
$placeholders[] = "'%s'";
$ancestors[] = $current;
if (stristr($current, '#') !== FALSE) {
$placeholders[] = "'%s'";
$ancestors[] = str_replace('#', '%', $current);
}
}
return array(
$ancestors,
$placeholders,
);
}