.
*/
class page_commit {
private $page, $phpgitweb;
public function main($phpgitweb, $project) {
$this->phpgitweb = $phpgitweb;
if(!$project)
return new ContentProvider('main', 'err400');
$project['refs'] = $phpgitweb->get_project_loader()->getProjectRefs($project);
$phpgitweb->append_header_nav("commit", null, true);
$phpgitweb->append_title("commit");
CommitLoader::parse();
$commit_loader = new CommitLoader($project);
$commit = $commit_loader->load();
if(!$commit)
return new ContentProvider('main', 'err404_object');
ContentProvider::overall_set('commit_id', $commit['id']);
$this->page = new ContentProvider('commit', 'main');
$this->page->set('hash', $commit['id']);
$this->page->set('author', htmlentities($commit['author']));
$this->page->set('author_mail', htmlentities($commit['author_mail']));
$this->page->set('author_date', gmdate('r', $commit['author_time']));
$author_local_time = $commit['author_time'] + Tools::parseTimeZone($commit['author_timezone']);
if(gmdate('H', $author_local_time) < 6)
$this->page->set('author_local_date', ''.gmdate('H:i', $author_local_time).'');
else
$this->page->set('author_local_date', gmdate('H:i', $author_local_time));
$this->page->set('author_timezone', $commit['author_timezone']);
$this->page->set('committer', htmlentities($commit['committer']));
$this->page->set('committer_mail', htmlentities($commit['committer_mail']));
$this->page->set('committer_date', gmdate('r', $commit['committer_time']));
$committer_local_time = $commit['committer_time'] + Tools::parseTimeZone($commit['committer_timezone']);
if(gmdate('H', $committer_local_time) < 6)
$this->page->set('committer_local_date', ''.gmdate('H:i', $committer_local_time).'');
else
$this->page->set('committer_local_date', gmdate('H:i', $committer_local_time));
$this->page->set('committer_timezone', $commit['committer_timezone']);
$this->page->set('message', htmlentities(Tools::chop_text($commit['text'], 80, 5)));
$this->page->set('full_message', htmlentities($commit['text']));
$this->page->set('tree_hash', $commit['tree']);
foreach($commit['parent'] as $parent) {
$this->page->append('parents', new ContentProvider('commit', 'parent', array('hash' => $parent, 'head' => $commit['id'])));
}
if(count($commit['parent']) == 0)
$this->page->set('parents', '');
$refs = new ContentProvider('commit', 'commit_refs');
$found = false;
foreach($project['refs'] as $ref => $rhash) {
if(strtolower($rhash) == strtolower($commit['id'])) {
$refexp = explode('/', $ref, 3);
$reftype = $refexp[1];
if($reftype == 'heads')
$reftype = 'head';
else if($reftype == 'remotes')
$reftype = 'remote';
else if($reftype == 'tags')
$reftype = 'tag';
$refs->append('refs', new ContentProvider('commit', 'commit_ref_'.$reftype, array("name" => $refexp[2], "ref_link" => $ref)));
$found = true;
}
}
$this->page->set('refs', ($found ? $refs : ""));
$difftree = new difftree();
$this->page->set('difftree', $difftree->generate_difftree($project, $commit, false));
return $this->page;
}
}
?>