. */ require_once("pages/commit.class.php"); class page_commitdiff { 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('project_head', $commit['id']); $this->page = new ContentProvider('commitdiff', '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))); $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(); $diff_data = GitCommand::get_commit_diff($project['path'], $commit['id'], $commit['parent']); $difftree->push_difftree_data($diff_data['tree']); $this->page->set('difftree', $difftree->generate_difftree($project, $commit, true)); return $this->page; } } ?>