You are here

class menu_CrumbsMultiPlugin_hierarchy in Crumbs, the Breadcrumbs suite 7

Same name and namespace in other branches
  1. 7.2 plugins/crumbs.menu.inc \menu_CrumbsMultiPlugin_hierarchy

Hierarchy

Expanded class hierarchy of menu_CrumbsMultiPlugin_hierarchy

File

plugins/crumbs.menu.inc, line 13

View source
class menu_CrumbsMultiPlugin_hierarchy implements crumbs_MultiPlugin {
  function describe($api) {
    return menu_get_menus();
  }
  function disabledByDefault() {
    return array(
      '*',
    );
  }
  function findParent($path, $item) {
    $q = db_select('menu_links', 'parent');
    $q
      ->innerJoin('menu_links', 'child', 'parent.mlid = child.plid');
    $q
      ->addExpression('parent.link_path', 'parent_path');
    $q
      ->addExpression('parent.menu_name', 'menu_name');
    $q
      ->condition('child.link_path', $path);

    // Top-level links have higher priority.
    $q
      ->orderBy('parent.depth', 'ASC');

    // Ignore placeholder or separator menu items added by special_menu_items.
    $q
      ->condition('parent.link_path', array(
      '<nolink>',
      '<separator>',
    ), 'NOT IN');

    // Collect candidates for the parent path, keyed by menu name.
    $candidates = array();
    foreach ($q
      ->execute() as $row) {
      if (!isset($candidates[$row->menu_name])) {
        $candidates[$row->menu_name] = $row->parent_path;
      }
    }
    return $candidates;
  }

}

Members