*/
class CommitLoader {
+ public static $commit_id, $commit_base_id;
private $project;
+ public static function parse($log_page = false) {
+ if(array_key_exists('h', $_GET) && Validation::validate_hash($_GET['h']))
+ $commit_id = $_GET['h'];
+ else
+ $commit_id = "all";
+
+ if(array_key_exists('hb', $_GET) && Validation::validate_hash($_GET['hb']))
+ $commit_base_id = $_GET['hb'];
+ else if(!$log_page && $_SESSION['hb'])
+ $commit_base_id = $_SESSION['hb'];
+ else
+ $commit_base_id = $commit_id;
+
+ if($log_page)
+ $_SESSION['hb'] = $commit_base_id;
+
+ ContentProvider::overall_set('commit_base_id', $commit_base_id);
+ ContentProvider::overall_set('commit_id', $commit_id);
+
+ self::$commit_id = $commit_id;
+ self::$commit_base_id = $commit_base_id;
+ return array('id' => $commit_id, 'base_id' => $commit_base_id);
+ }
+
public function __construct($project) {
$this->project = $project;
}
- public function load($id) {
- if(!Validation::validate_hash($id)) {
+ public function load($id = null) {
+ if(!$id && self::$commit_id)
+ $id = self::$commit_id;
+ else if(!Validation::validate_hash($id)) {
trigger_error("Invalid hash parameter", E_USER_ERROR);
return false;
}
+ if(strtolower($id) == 'all')
+ $id = null;
$commit = GitCommand::get_commit($this->project['path'], $id);
return $commit;
}
$template_html = $this->load_template($this->template, $subtemplate);
}
$template_html = preg_replace_callback('/%([^%]*)%/', array($this, "replace_placeholder"), $template_html);
+ $template_html = preg_replace_callback('/%([^%]*)%/', array($this, "replace_placeholder"), $template_html);
return $template_html;
}
}
public static function get_commit($git_path, $commit_id) {
- $args = array("rev-list", "--header", "--max-count=1", $commit_id, "--");
+ $args = array("rev-list", "--header", "--max-count=1", ($commit_id ? $commit_id : "--all"), "--");
$commit_data = self::git_execute($args, $git_path);
$commit = self::parse_commit($commit_data);
return $commit;
public function __construct() {
$this->rendertime = microtime(true);
+ session_start();
$this->page = new ContentProvider('main', 'main');
set_error_handler(array($this, "error_handler"));
$this->append_header_nav('projects', '?a=projects', false);
$this->page->append('content', new ContentProvider('main', 'err404_project'));
else {
ContentProvider::overall_set('project', $this->project['name']);
- ContentProvider::overall_set('project_head', "HEAD");
+ ContentProvider::overall_set('commit_base_id', "all");
+ ContentProvider::overall_set('commit_id', "HEAD");
$this->append_header_nav($this->project['name'], '?p='.$this->project['name'].'&a=summary', true);
$this->append_title(" - ".$this->project['name'], false);
$this->project_header = new ContentProvider('main', 'project_header');
} else
$this->page->append('content', file_get_contents('pages/404.html'));
if($this->project_header) {
- $this->project_header->set('nav_summary', new ContentProvider('main', ($page == 'summary' ? 'project_header_nav_active' : 'project_header_nav_link'), array('name' => "summary", 'link' => "summary")));
- $this->project_header->set('nav_shortlog', new ContentProvider('main', ($page == 'shortlog' ? 'project_header_nav_active' : 'project_header_nav_link'), array('name' => "shortlog", 'link' => "shortlog")));
- $this->project_header->set('nav_log', new ContentProvider('main', ($page == 'log' ? 'project_header_nav_active' : 'project_header_nav_link'), array('name' => "log", 'link' => "log")));
- $this->project_header->set('nav_commit', new ContentProvider('main', ($page == 'commit' ? 'project_header_nav_active' : 'project_header_nav_link'), array('name' => "commit", 'link' => "commit")));
- $this->project_header->set('nav_commitdiff', new ContentProvider('main', ($page == 'commitdiff' ? 'project_header_nav_active' : 'project_header_nav_link'), array('name' => "commitdiff", 'link' => "commitdiff")));
- $this->project_header->set('nav_tree', new ContentProvider('main', ($page == 'tree' ? 'project_header_nav_active' : 'project_header_nav_link'), array('name' => "tree", 'link' => "tree")));
+ $this->project_header->set('nav_summary', new ContentProvider('main', ($page == 'summary' ? 'project_header_nav_active' : 'project_header_nav_link'), array('name' => "summary", 'link' => "summary", 'link_add' => "")));
+ $this->project_header->set('nav_shortlog', new ContentProvider('main', ($page == 'shortlog' ? 'project_header_nav_active' : 'project_header_nav_link'), array('name' => "shortlog", 'link' => "shortlog", 'link_add' => "&h=%commit_base_id%")));
+ $this->project_header->set('nav_log', new ContentProvider('main', ($page == 'log' ? 'project_header_nav_active' : 'project_header_nav_link'), array('name' => "log", 'link' => "log", 'link_add' => "&h=%commit_base_id%")));
+ $this->project_header->set('nav_commit', new ContentProvider('main', ($page == 'commit' ? 'project_header_nav_active' : 'project_header_nav_link'), array('name' => "commit", 'link' => "commit", 'link_add' => "&h=%commit_id%")));
+ $this->project_header->set('nav_commitdiff', new ContentProvider('main', ($page == 'commitdiff' ? 'project_header_nav_active' : 'project_header_nav_link'), array('name' => "commitdiff", 'link' => "commitdiff", 'link_add' => "&h=%commit_id%")));
+ $this->project_header->set('nav_tree', new ContentProvider('main', ($page == 'tree' ? 'project_header_nav_active' : 'project_header_nav_link'), array('name' => "tree", 'link' => "tree", 'link_add' => "&h=%commit_id%")));
}
}
class page_commit {
private $page, $phpgitweb;
- private $commitid;
public function main($phpgitweb, $project) {
$this->phpgitweb = $phpgitweb;
$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);
-
- if(array_key_exists('h', $_GET))
- $commitid = $_GET['h'];
- else
- $commitid = "HEAD";
-
- $commit = $commit_loader->load($commitid);
+ $commit = $commit_loader->load();
if(!$commit)
return new ContentProvider('main', 'err404_object');
- ContentProvider::overall_set('project_head', $commit['id']);
+ ContentProvider::overall_set('commit_id', $commit['id']);
$this->page = new ContentProvider('commit', 'main');
class page_commitdiff {
private $page, $phpgitweb;
- private $commitid;
public function main($phpgitweb, $project) {
$this->phpgitweb = $phpgitweb;
$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);
-
- if(array_key_exists('h', $_GET))
- $commitid = $_GET['h'];
- else
- $commitid = "HEAD";
-
- $commit = $commit_loader->load($commitid);
+ $commit = $commit_loader->load();
if(!$commit)
return new ContentProvider('main', 'err404_object');
public function generate_shortlog($project, $head, $max, $skip, $file = null, $pages = true, $next_page = 0) {
$this->project = $project;
+ if($head && strtolower($head) == 'all')
+ $head = null;
$content = new ContentProvider('shortlog', 'shortlog');
if(GitConfig::GITGRAPH_ENABLE) {
$project['refs'] = $phpgitweb->get_project_loader()->getProjectRefs($project);
$phpgitweb->append_header_nav("shortlog", null, true);
$phpgitweb->append_title("shortlog");
+ CommitLoader::parse(true);
$this->page = new ContentProvider('shortlog', 'main');
}
$shortlog = new shortlog();
- $this->page->set('shortlog', $shortlog->generate_shortlog($project, null, 100, $skip, null, true, $next_page));
+ $this->page->set('shortlog', $shortlog->generate_shortlog($project, CommitLoader::$commit_base_id, 100, $skip, null, true, $next_page));
if($shortlog->get_have_more())
$subnav->set('next', new ContentProvider('shortlog', 'shortlog_subnav_next_link', array('page' => ($pg + 1))));
$project['refs'] = $phpgitweb->get_project_loader()->getProjectRefs($project);
$phpgitweb->append_header_nav("summary", null, true);
$phpgitweb->append_title("summary");
+ CommitLoader::parse(true);
$this->page = new ContentProvider('summary', 'main');
<tr>
<td>commit</td>
<td class="sha1">%hash%</td>
+ <td class="link">
+ <a href="?p=%project%&a=shortlog&h=%hash%">shortlog</a> | <a href="?p=%project%&a=log&h=%hash%">log</a>
+ </td>
</tr>
<tr>
<td>tree</td>
<div class="search">
<input name="p" type="hidden" value="%project%" />
<input name="a" type="hidden" value="search" />
-<input name="h" type="hidden" value="%project_head%" />
+<input name="h" type="hidden" value="%commit_base_id%" />
<select name="st" >
<option selected="selected" value="commit">commit</option>
<option value="grep">grep</option>
</div>
# [project_header_nav_link]
-<a href="/?p=%project%&a=%link%&h=%project_head%">%name%</a>
+<a href="/?p=%project%&a=%link%%link_add%">%name%</a>
# [project_header_nav_active]
%name%
</tr>
# [shortlog_page]
-<td colspan="4"><a title="Alt-n" accesskey="n" href="?p=%project%&a=shortlog&pg=%page%">next</a></td>
+<td colspan="4"><a title="Alt-n" accesskey="n" href="?p=%project%&a=shortlog&h=%commit_base_id%&pg=%page%">next</a></td>
# [shortlog_refs]
<span class="refs"> %refs%</span>
%first% ⋅ %prev% ⋅ %next%
# [shortlog_subnav_first_link]
-<a href="?p=%project%&a=shortlog">first</a>
+<a href="?p=%project%&a=shortlog&h=%commit_base_id%">first</a>
# [shortlog_subnav_first]
first
# [shortlog_subnav_prev_link]
-<a title="Alt-p" accesskey="p" href="?p=%project%&a=shortlog&pg=%page%">prev</a>
+<a title="Alt-p" accesskey="p" href="?p=%project%&a=shortlog&h=%commit_base_id%&pg=%page%">prev</a>
# [shortlog_subnav_prev]
prev
# [shortlog_subnav_next_link]
-<a title="Alt-n" accesskey="n" href="?p=%project%&a=shortlog&pg=%page%">next</a>
+<a title="Alt-n" accesskey="n" href="?p=%project%&a=shortlog&h=%commit_base_id%&pg=%page%">next</a>
# [shortlog_subnav_next]
next