You are here

function _multiple_node_menu_load in Multiple Node Menu 7

Load all menu items associated with a node.

Parameters

$node: The source path to look up.

Return value

Array of paths or NULL if none found.

1 call to _multiple_node_menu_load()
multiple_node_menu_node_prepare in ./multiple_node_menu.module
Implements hook_node_prepare().

File

./multiple_node_menu.module, line 470
Add multiple menu management capabilities to node form.

Code

function _multiple_node_menu_load($node) {
  $type_menus = variable_get('menu_options_' . $node->type, array(
    'main-menu' => 'main-menu',
  ));
  if (empty($type_menus)) {
    return NULL;
  }
  $links = db_select('menu_links')
    ->condition('module', 'menu')
    ->condition('router_path', 'node/%')
    ->condition('link_path', 'node/' . $node->nid)
    ->condition('menu_name', $type_menus, 'IN')
    ->fields('menu_links')
    ->execute()
    ->fetchAll(PDO::FETCH_ASSOC);
  foreach ($links as &$link) {

    // Unserialize options array.
    $link['options'] = unserialize($link['options']);

    // Set values used in the form.
    if (!empty($link['options']['attributes']['title'])) {
      $link['description'] = $link['options']['attributes']['title'];
    }
    $link['enabled'] = !$link['hidden'];
  }
  return $links;
}