/** * Internal function used to add a bug to the given graph. * @todo duplicate or not - bug / bugid? * @param Graph &$p_graph Graph object. * @param integer $p_bug_id A bug identifier. * @param BugData $p_bug A BugData object. * @param string $p_url URL. * @param boolean $p_highlight Highlight. * @return void */ function relgraph_add_bug_to_graph(Graph &$p_graph, $p_bug_id, BugData $p_bug, $p_url = null, $p_highlight = false) { $t_node_attributes = array(); $t_node_attributes['label'] = $p_bug_id; if ($p_highlight) { $t_node_attributes['color'] = '#0000FF'; $t_node_attributes['style'] = 'bold, filled'; } else { $t_node_attributes['color'] = 'black'; $t_node_attributes['style'] = 'filled'; } $t_node_attributes['fillcolor'] = get_status_color($p_bug->status); if (null !== $p_url) { $t_node_attributes['URL'] = $p_url; } $t_summary = string_display_line_links($p_bug->summary); $t_status = get_enum_element('status', $p_bug->status); $t_node_attributes['tooltip'] = '[' . $t_status . '] ' . $t_summary; $p_graph->add_node($p_bug_id, $t_node_attributes); }
function handle_render_request($request) { $graph = new Graph(); /* Assign the requested graph direction and export format */ $graph->set_direction($request["direction"]); $graph->set_export_format($request["export"]); /* Add each node and set its shape */ foreach ($request["nodes"] as $node) { $graph->add_node($node["name"]); $graph->set_node_shape($node["name"], $node["shape"]); } /* Add each edge */ foreach ($request["edges"] as $edge) { $graph->add_edge($edge["origin"], $edge["destination"], $edge["label"]); } /* Export each graph and lookup it's mediatype */ error_log($graph->compile()); $binary = $graph->export(); $mediatype = export_media_type($request); $encoding = base64_encode($binary); $response = array("mediatype" => $mediatype, "encoding" => $encoding); return $response; }