You are here

function _hansel_export_dot_node in Hansel breadcrumbs 7

Same name and namespace in other branches
  1. 8 export/hansel_export.module \_hansel_export_dot_node()

Prepare for graphviz node and link strings

A rule is like:

stdClass Object ( [rid] => 21 [pid] => 62 [name] => <default> [crumb_action] => [crumb_action_arguments] => Array ( )

[action] => switch [handler] => node type [arguments] => Array ( ) )

We color the node depending on it's kind

Parameters

$rule:

1 call to _hansel_export_dot_node()
hansel_export_dot in export/hansel_export.module
Generete an export to dot format for the current configuration.

File

export/hansel_export.module, line 221

Code

function _hansel_export_dot_node($rule) {
  $fields = array();
  $fields[] = $rule->name . '\\n';

  // We first gather the crumb settings
  if (!empty($rule->crumb_action)) {
    $fields[] = $rule->crumb_action;
    foreach ($rule->crumb_action_arguments as $key => $value) {
      $fields[] = 'crumb-' . $key . ': ' . $value;
    }
  }

  // Next we add the action settings
  $fields[] = '\\n\\<\\<' . $rule->action . '\\>\\>';
  switch ($rule->action) {
    case 'switch':
      $fields[] = $rule->handler;
      $fields[] = join('\\n-', $rule->arguments);
      $color = 'green';
      break;
    case 'leave':
      $color = 'blue';
      break;
    default:
      $color = 'red';
      break;
  }

  // Root nodes get different color
  if ($rule->pid == 0) {
    $color = "grey";
  }
  $label = join('\\n', $fields);
  $result = _hansel_dot_node($rule->rid, $label, $color);
  return $result;
}