You are here

function rules_link_menu_breadcrumb_alter in Rules Link 7

Same name and namespace in other branches
  1. 7.2 rules_link.module \rules_link_menu_breadcrumb_alter()

Alter the breadcrumb trail of the rules components.

File

./rules_link.module, line 520
Rules Link - module file.

Code

function rules_link_menu_breadcrumb_alter(&$active_trail, $item) {
  if (substr($item['href'], 22, 34) == 'rules/components/manage/rules_link') {

    // Parse the name out of the link.
    if (substr($item['href'], 57, 3) == 'set') {
      $start = 61;
    }
    elseif (substr($item['href'], 57, 3) == 'con') {
      $start = 67;
    }
    $link_name = substr($item['href'], $start, strlen($item['href']));
    $pos = strpos($link_name, '/');
    if ($pos !== FALSE) {
      $link_name = substr($link_name, 0, $pos);
    }
    $rules_link = rules_link_load($link_name);
    if ($rules_link) {

      // Replace the link to Rules with a link to Rules Link.
      $active_trail[4]['title'] = 'Rules Links';
      $active_trail[4]['href'] = 'admin/config/workflow/rules_links';
      $active_trail[4]['options']['attributes']['title'] = 'Manage links that triggers rules.';
      $active_trail[4]['localized_options'] = array();

      // Replace component link with link to the current rules link.
      $active_trail[5]['title'] = $rules_link->label;
      $active_trail[5]['href'] = "admin/config/workflow/rules_links/manage/{$link_name}/components";
      $active_trail[5]['options']['attributes']['title'] = 'Edit the current link.';
      $active_trail[5]['localized_options'] = array();
    }
  }
}