function _quickbar_expanded_item_links in Quickbar 7.2
Add expanded item links
1 call to _quickbar_expanded_item_links()
- quickbar_menu_tree in ./
quickbar.module - Retrieve a hierarchy of links representing select portions of the menu.
File
- ./
quickbar.module, line 310
Code
function _quickbar_expanded_item_links(&$links, $settings) {
// Loop thru each link section
foreach ($links[0] as $section_name => $link_section) {
// and then loop thru each item in the section
foreach ($link_section as $item_machine_name => $item) {
// check if the item has a href of one of the supported expanded items
switch ($item['href']) {
case 'node/add':
// check if the quickbar config settings are set to have 'node/add' expanded
if (!empty($settings['settings']['expanded_items']['expand_node_add'])) {
// get the menu links for 'node/add'
$result = db_query("SELECT DISTINCT link_path, link_title FROM {menu_links} WHERE link_path like 'node/add/%'" . " AND module = 'system' ORDER BY link_title ASC");
foreach ($result as $link) {
// add each link as an item to the second level ($links[1]) menu
$parent_path = 'node/add';
// but only add if the user has access
if (drupal_valid_path($link->link_path)) {
$links[1][$parent_path][$link->link_title] = array(
'title' => $link->link_title,
'href' => $link->link_path,
'attributes' => array(
'classes' => array(
drupal_html_class($link->link_title),
),
),
);
}
}
if (!empty($links[1][$parent_path])) {
$links[0][$section_name][$item_machine_name]['attributes']['classes'][] = 'primary-nofollow';
}
}
break;
case 'admin/structure/menu':
// check if the quickbar config settings are set to have 'admin/structure/menu' expanded
if (!empty($settings['settings']['expanded_items']['expand_structure_menu'])) {
$result = db_query("SELECT * FROM {menu_custom} ORDER BY title");
foreach ($result as $link) {
// add each link as an item to the second level ($links[1]) menu
$link_path = 'admin/structure/menu/manage/' . $link->menu_name;
$parent_path = 'admin/structure/menu';
// but only add if the user has access
if (drupal_valid_path($link_path)) {
$links[1][$parent_path][$link->title] = array(
'title' => $link->title,
'href' => $link_path,
'attributes' => array(
'classes' => array(
drupal_html_class($link->title),
),
),
);
}
}
}
break;
}
}
}
}