function _hansel_get_rules_tree in Hansel breadcrumbs 8
Same name and namespace in other branches
- 7 hansel.module \_hansel_get_rules_tree()
Get all Hansel rules in a list including depth, sorted by hierarchy, then alphabetically.
Parameters
int $pid:
int $depth:
Return value
array
1 call to _hansel_get_rules_tree()
- hansel_ui_rule_form in hansel_ui/
hansel_ui.module - Generates the form for adding and editing rules.
File
- ./
hansel.module, line 214 - Hansel module
Code
function _hansel_get_rules_tree($pid = 0, $depth = 0) {
$output = array();
if ($pid == -1) {
// Include root element.
$output[0] = '<root>';
$depth = 1;
$pid = 0;
}
foreach (_hansel_get_rules($pid) as $rule) {
$pad_str = '- ';
$name = str_pad('', $depth * drupal_strlen($pad_str), $pad_str) . $rule->name;
$output[$rule->rid] = $name;
foreach (_hansel_get_rules_tree($rule->rid, $depth + 1) as $rid => $name) {
$output[$rid] = $name;
}
}
return $output;
}