You are here

class _crumbs_TrailFinder in Crumbs, the Breadcrumbs suite 6.2

Hierarchy

Expanded class hierarchy of _crumbs_TrailFinder

File

./crumbs.trail.inc, line 73

View source
class _crumbs_TrailFinder {
  protected $_parent_finder;
  protected $_front_menu_path;
  protected $_front_menu_item;
  function __construct($parent_finder) {
    $this->_parent_finder = $parent_finder;
    $this->_front_normal_path = drupal_get_normal_path(variable_get('site_frontpage', 'node'));
    $this->_front_menu_item = menu_get_item($front_normal_path);
  }

  /**
   * Build the raw trail,
   * with no respect to title, access check, or skip-in-breadcrumb.
   */
  function buildTrail($path) {
    $path = drupal_get_normal_path($path);
    $trail_reverse = array();
    $front_normal_path = drupal_get_normal_path(variable_get('site_frontpage', 'node'));
    $front_menu_item = crumbs_get_router_item($front_normal_path);
    while (strlen($path) && $path !== '<front>' && $path !== $front_normal_path) {
      if (isset($trail_reverse[$path])) {

        // We found a loop! To prevent infinite recursion, we
        // remove the loopy paths from the trail and finish directly with <front>.
        while (isset($trail_reverse[$path])) {
          array_pop($trail_reverse);
        }
        break;
      }
      $item = crumbs_get_router_item($path);

      // if menu_get_item() does not resolve as a valid router item,
      // we skip this path.
      if ($item) {
        $trail_reverse[$path] = $item;
      }
      $parent_path = $this->_parent_finder
        ->getParentPath($path, $item);
      if ($parent_path === $path) {

        // This is again a loop, but with just one step.
        // Not as evil as the other kind of loop.
        break;
      }
      $path = $parent_path;
    }
    unset($trail_reverse['<front>']);
    $trail_reverse[$front_normal_path] = $front_menu_item;
    return array_reverse($trail_reverse);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
_crumbs_TrailFinder::$_front_menu_item protected property
_crumbs_TrailFinder::$_front_menu_path protected property
_crumbs_TrailFinder::$_parent_finder protected property
_crumbs_TrailFinder::buildTrail function Build the raw trail, with no respect to title, access check, or skip-in-breadcrumb.
_crumbs_TrailFinder::__construct function