X-Git-Url: http://git.pk910.de/?p=phpgitweb.git;a=blobdiff_plain;f=htdocs%2Fpages%2Fcommit.class.php;fp=htdocs%2Fpages%2Fcommit.class.php;h=17f5678758cf9312409876c3ec94ce5838a1fb4b;hp=0000000000000000000000000000000000000000;hb=394a07ff3e283f94c7ead44e8bd02d44c223314b;hpb=ce9f1b8b05ff571f6922460cf91b45aa5a119d94 diff --git a/htdocs/pages/commit.class.php b/htdocs/pages/commit.class.php new file mode 100644 index 0000000..17f5678 --- /dev/null +++ b/htdocs/pages/commit.class.php @@ -0,0 +1,97 @@ +. + */ + +require_once('pages/shortlog.class.php'); + +class page_commit { + private $page, $phpgitweb; + private $commitid; + + 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"); + + $commit_loader = new CommitLoader($project); + + if(array_key_exists('h', $_GET)) + $commitid = $_GET['h']; + else + $commitid = "HEAD"; + + $commit = $commit_loader->load($commitid); + if(!$commit) + return new ContentProvider('main', 'err404_object'); + + ContentProvider::overall_set('project_head', $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'], 50, 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']))); + } + + $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 : "")); + + return $this->page; + } + +} + +?> \ No newline at end of file