function advanced_help_get_topic_hierarchy in Advanced Help 5
Same name and namespace in other branches
- 6 advanced_help.module \advanced_help_get_topic_hierarchy()
- 7 advanced_help.module \advanced_help_get_topic_hierarchy()
Build a hierarchy for a single module's topics.
2 calls to advanced_help_get_topic_hierarchy()
- advanced_help_index_page in ./
advanced_help.module - Page callback to view the advanced help topic index.
- advanced_help_view_topic in ./
advanced_help.module - Load and render a help topic.
File
- ./
advanced_help.module, line 229 - advanced_help.module
Code
function advanced_help_get_topic_hierarchy(&$topics) {
foreach ($topics as $module => $module_topics) {
foreach ($module_topics as $topic => $info) {
$parent_module = $module;
// We have a blank topic that we don't want parented to
// itself.
if (!$topic) {
continue;
}
if (empty($info['parent'])) {
$parent = '';
}
else {
if (strpos($info['parent'], '%')) {
list($parent, $parent_module) = explode($info['parent'], '%');
if (empty($topics[$parent_module][$parent])) {
// If it doesn't exist, top level.
$parent = '';
}
}
else {
$parent = $info['parent'];
if (empty($module_topics[$parent])) {
// If it doesn't exist, top level.
$parent = '';
}
}
}
if (!isset($topics[$parent_module][$parent]['children'])) {
$topics[$parent_module][$parent]['children'] = array();
}
$topics[$parent_module][$parent]['children'][] = array(
$module,
$topic,
);
$topics[$module][$topic]['_parent'] = array(
$parent_module,
$parent,
);
}
}
}