You are here

function spaces_features_order_menu in Spaces 7.3

Same name and namespace in other branches
  1. 6.3 spaces.module \spaces_features_order_menu()
  2. 7 spaces.module \spaces_features_order_menu()

Order a navigation links menu according to the order customized for this space.

1 call to spaces_features_order_menu()
spaces_preprocess_page in ./spaces.module
Reorder primary menu links.

File

./spaces.module, line 998

Code

function spaces_features_order_menu(&$links) {
  $weights = variable_get('space_menu_items', array());

  // Mark the first link with a class that will allow the spaces menu editor
  // to find the menu in the DOM.
  $first = TRUE;
  foreach ($links as $k => $v) {
    if ($first) {
      $first = FALSE;
      if (isset($links[$k]['attributes']['class'])) {
        $links[$k]['attributes']['class'][] = 'spaces-menu-editable';
      }
      else {
        $links[$k]['attributes']['class'] = array(
          'spaces-menu-editable',
        );
      }
    }
    if (isset($weights[$v['href']])) {
      $links[$k]['#weight'] = $weights[$v['href']];
    }
  }
  if (!empty($weights)) {
    uasort($links, 'element_sort');
  }
}