class shortlog {
private $project;
- private $graph_data;
+ private $graph_data, $graph_gen;
private $first_commit;
private $have_more = false;
}
}
$this->graph_data->parse($commits);
- $content->set('graph_data', $this->graph_data->get_header_graph());
+
+ $graph = $this->graph_data->get_header_graph();
+ if(GitConfig::GITGRAPH_DATA_URL) {
+ $this->graph_gen = new graph_image_generator();
+ $graph = $this->graph_gen->generate($graph, true);
+ $graph = base64_encode($graph);
+ $graph = "data:image/png;base64,".$graph;
+ } else
+ $graph = "?e=graph&gd=".$graph;
+ $content->set('graph_data', $graph);
}
$commit_counter = 0;
$entry->set('date', $date_str);
$entry->set('age', $age_str);
}
- if(GitConfig::GITGRAPH_ENABLE)
- $entry->set('graph_data', $this->graph_data->get_graph($commit['id']));
+ if(GitConfig::GITGRAPH_ENABLE) {
+ $graph = $this->graph_data->get_graph($commit['id']);
+ if(GitConfig::GITGRAPH_DATA_URL) {
+ $graph = $this->graph_gen->generate($graph, true);
+ $graph = base64_encode($graph);
+ $graph = "data:image/png;base64,".$graph;
+ } else
+ $graph = "?e=graph&gd=".$graph;
+ $entry->set('graph_data', $graph);
+ }
$entry->set('refs', $this->shortlog_commit_refs($this->project, $commit['id']));
);
}
- public function generate($data) {
+ public function generate($data, $return = false) {
if(!GitConfig::GITGRAPH_ENABLE)
return;
$data = $this->parse_data($data);
if(!$data) {
+ if($return)
+ return null;
header('Content-Type: text/plain');
die(base64_decode("ICAgIC0tLS0tLS0tOi0tLS0tLS0tDQogICAgICAgICAgLC0iLC5fX19fX19fIC8NCiAgICAgICAgIC8gKSB8ICAgLC0tLS0nXA0KICAgICAgICAgXC9fX3wuLSINCiAgICAgICAgLl8vL19cXF8NCk5vdCB3aGF0IHlvdSBleHBlY3RlZCwgZWVlaD8="));
}
+ if($data['header']) {
+ return $this->display_header($data['data'], $return);
+ }
$count = $data['count'];
if($count > $this->max_branches)
imagecolortransparent($this->image, $transparentIndex);
- header('Content-Type: image/png');
- imagepng($this->image);
+ if($return) {
+ ob_start();
+ imagepng($this->image);
+ $ret = ob_get_contents();
+ ob_end_clean();
+ } else {
+ header('Content-Type: image/png');
+ imagepng($this->image);
+ $ret = null;
+ }
imagedestroy($this->image);
+ return $ret;
}
- private function display_header($header) {
+ private function display_header($header, $return = false) {
$header = explode("//",$header);
$count = $header[0];
$header = array_slice($header, 1);
$color = imagecolorallocatealpha($image, $color[0], $color[1], $color[2], 0);
imagettftext($image, 8, 28, ($head[0]-1) * $this->size + 10, $this->header_height-2, $color, realpath(dirname(__FILE__)."/../")."/res/arial.ttf", $name);
}
- if(!$branches) die();
+ if(!$branches) return null;
imagecolortransparent($image, $transparentIndex);
- header('Content-Type: image/png');
- imagepng($image);
+
+ if($return) {
+ ob_start();
+ imagepng($image);
+ $ret = ob_get_contents();
+ ob_end_clean();
+ } else {
+ header('Content-Type: image/png');
+ imagepng($image);
+ $ret = null;
+ }
imagedestroy($image);
- die();
+ return $ret;
}
private function parse_data($data) {
$data = base64_decode($data);
if(!preg_match("/^([0-9]+)([abc]{1})([0-9]+)\(([^\)]*)\)([a-z0-9,\|]*)(\(([^\)]*)\)|)/i", $data, $matches)) {
if(preg_match("/head:(.*)/i", $data, $matches)) {
- $this->display_header(substr($data, strlen("head:")));
+ $cdata = array();
+ $cdata['header'] = true;
+ $cdata['data'] = substr($data, strlen("head:"));
+ return $cdata;
}
return null;
}
$data = array();
+ $data['header'] = false;
$data['dot'] = array();
$data['dot']['pos'] = $matches[1];
$data['dot']['type'] = $matches[2];
# [shortlog]
<table class="shortlog" cellspacing="0" cellpadding="0">
<tr class="header">
- <td colspan="2"><img class="graph" src="?e=graph&gd=%graph_data%" /></td>
+ <td colspan="2"><img class="graph" src="%graph_data%" /></td>
<td valign="bottom"><b>Author</b></td>
<td valign="bottom"><b>Commit</b></td>
<td></td>
# [shortlog_entry]
<tr class="%class%">
- <td><img class="graph" src="?e=graph&gd=%graph_data%" /></td>
+ <td><img class="graph" src="%graph_data%" /></td>
<td title="%date%"><i>%age%</i></td>
<td class="author"><a title="Search for commits authored by %author%" class="list" href="?p=%project%&a=search&h=%project_head%&s=%author%&st=author">%author%</a></td>
<td><a class="list subject" href="?p=%project%&a=commit&h=%hash%">%message%</a> %refs%</td>