You are here

function _menu_views_parents_recurse in Menu Views 7.2

Same name and namespace in other branches
  1. 8.3 menu_views.admin.inc \_menu_views_parents_recurse()

Recursive helper function for menu_parent_options().

1 call to _menu_views_parents_recurse()
_menu_views_get_options in ./menu_views.admin.inc
Helper function to get the items of the given menu.

File

./menu_views.admin.inc, line 717
Form hooks for the menu_views module.

Code

function _menu_views_parents_recurse($tree, $menu_name, $indent, &$options, $exclude, $depth_limit) {
  foreach ($tree as $data) {
    if ($data['link']['depth'] > $depth_limit) {

      // Don't iterate through any links on this level.
      break;
    }
    if ($data['link']['mlid'] != $exclude && $data['link']['hidden'] >= 0) {
      $item = _menu_views_get_item($data['link']);
      _menu_views_tokenize($item);
      if ($item['type'] == 'view' && $item['view']['name'] && $item['view']['display']) {
        $title = t($item['view']['name']) . '-' . t($item['view']['display']);
        $view_title = filter_xss_admin($item['view']['settings']['title_override']);
        if (empty($view_title) && ($view = views_get_view($item['view']['name']))) {
          if ($view
            ->access($item['view']['display']) && $view
            ->set_display($item['view']['display'])) {
            $view
              ->set_arguments(explode('/', $item['view']['arguments']));
            $view_title = filter_xss_admin($view
              ->get_title());
          }
          $view
            ->destroy();
        }
        if (!empty($view_title)) {
          $title = $view_title . ' (' . $title . ')';
        }
        $title = $indent . ' [view] ' . truncate_utf8($title, 30, TRUE, FALSE);
      }
      else {
        $title = $indent . ' ' . truncate_utf8($data['link']['title'], 30, TRUE, FALSE);
      }
      if ($data['link']['hidden']) {
        $title .= ' (' . t('disabled') . ')';
      }
      $options[$menu_name . ':' . $data['link']['mlid']] = $title;
      if ($data['below']) {
        _menu_views_parents_recurse($data['below'], $menu_name, $indent . '--', $options, $exclude, $depth_limit);
      }
    }
  }
}