Prevent crashes with empty projects
Prevent crashes with empty projects

This disables or hides pretty much all links - shortlog, log, commit,
commitdiff, tree, snapshot, etc - for an empty project with no commits.
None of those actions make any sense if the project is empty. There are
still outstanding crashes if the user crafts a url manually to directly
access a page for a project, but since that won't happen nearly as often
it's not quite as high a priority.

This also extracts the nav links at the top of each page into a shared
template, so we only need to check if a commit exists in one place.

--- a/include/controller/Controller_Heads.class.php
+++ b/include/controller/Controller_Heads.class.php
@@ -94,7 +94,7 @@
 	 */
 	protected function LoadData()
 	{
-		$head = $this->project->GetHeadCommit()->GetHash();
+		$head = $this->project->GetHeadCommit();
 		$this->tpl->assign("head",$head);
 
 		$headlist = $this->project->GetHeads();

--- a/include/controller/Controller_Search.class.php
+++ b/include/controller/Controller_Search.class.php
@@ -134,25 +134,27 @@
 		$this->tpl->assign('commit', $co);
 
 		$results = array();
-		switch ($this->params['searchtype']) {
+		if ($co) {
+			switch ($this->params['searchtype']) {
 
-			case GITPHP_SEARCH_COMMIT:
-				$results = $this->project->SearchCommit($this->params['search'], $co->GetHash(), 101, ($this->params['page'] * 100));
-				break;
+				case GITPHP_SEARCH_COMMIT:
+					$results = $this->project->SearchCommit($this->params['search'], $co->GetHash(), 101, ($this->params['page'] * 100));
+					break;
 
-			case GITPHP_SEARCH_AUTHOR:
-				$results = $this->project->SearchAuthor($this->params['search'], $co->GetHash(), 101, ($this->params['page'] * 100));
-				break;
+				case GITPHP_SEARCH_AUTHOR:
+					$results = $this->project->SearchAuthor($this->params['search'], $co->GetHash(), 101, ($this->params['page'] * 100));
+					break;
 
-			case GITPHP_SEARCH_COMMITTER:
-				$results = $this->project->SearchCommitter($this->params['search'], $co->GetHash(), 101, ($this->params['page'] * 100));
-				break;
-			case GITPHP_SEARCH_FILE:
-				$results = $co->SearchFiles($this->params['search'], 101, ($this->params['page'] * 100));
-				break;
-			default:
-				throw new GitPHP_MessageException(GitPHP_Resource::GetInstance()->GetResource('Invalid search type'));
+				case GITPHP_SEARCH_COMMITTER:
+					$results = $this->project->SearchCommitter($this->params['search'], $co->GetHash(), 101, ($this->params['page'] * 100));
+					break;
+				case GITPHP_SEARCH_FILE:
+					$results = $co->SearchFiles($this->params['search'], 101, ($this->params['page'] * 100));
+					break;
+				default:
+					throw new GitPHP_MessageException(GitPHP_Resource::GetInstance()->GetResource('Invalid search type'));
 
+			}
 		}
 
 		if (count($results) < 1) {

--- a/include/controller/Controller_Tag.class.php
+++ b/include/controller/Controller_Tag.class.php
@@ -105,7 +105,7 @@
 	 */
 	protected function LoadData()
 	{
-		$head = $this->project->GetHeadCommit()->GetHash();
+		$head = $this->project->GetHeadCommit();
 		$this->tpl->assign('head', $head);
 
 		$tag = new GitPHP_Tag($this->project, $this->params['hash']);

--- a/include/controller/Controller_Tags.class.php
+++ b/include/controller/Controller_Tags.class.php
@@ -94,7 +94,7 @@
 	 */
 	protected function LoadData()
 	{
-		$head = $this->project->GetHeadCommit()->GetHash();
+		$head = $this->project->GetHeadCommit();
 		$this->tpl->assign("head",$head);
 
 		$taglist = $this->project->GetTags();

--- a/include/git/Project.class.php
+++ b/include/git/Project.class.php
@@ -538,9 +538,19 @@
 		if ($catCmp !== 0)
 			return $catCmp;
 
-		if ($a->GetHeadCommit()->GetAge() === $b->GetHeadCommit()->GetAge())
+		$aCommit = $a->GetHeadCommit();
+		$bCommit = $b->GetHeadCommit();
+
+		if (($aCommit == null) && ($bCommit == null))
 			return 0;
-		return ($a->GetHeadCommit()->GetAge() < $b->GetHeadCommit()->GetAge() ? -1 : 1);
+		else if ($aCommit == null)
+			return 1;
+		else if ($bCommit == null)
+			return -1;
+
+		if ($aCommit->GetAge() === $bCommit->GetAge())
+			return 0;
+		return ($aCommit->GetAge() < $bCommit->GetAge() ? -1 : 1);
 	}
 
 	/**

--- a/templates/blame.tpl
+++ b/templates/blame.tpl
@@ -9,7 +9,8 @@
  {include file='header.tpl'}
 
  <div class="page_nav">
-   <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=summary">{$resources->GetResource('summary')}</a> | <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=shortlog">{$resources->GetResource('shortlog')}</a> | <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=log">{$resources->GetResource('log')}</a> | <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=commit&h={$commit->GetHash()}">{$resources->GetResource('commit')}</a> | <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=commitdiff&h={$commit->GetHash()}">{$resources->GetResource('commitdiff')}</a> | <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=tree&h={$tree->GetHash()}&hb={$commit->GetHash()}">{$resources->GetResource('tree')}</a><br />
+   {include file='nav.tpl' treecommit=$commit}
+   <br />
    <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=blob_plain&h={$blob->GetHash()}&f={$blob->GetPath()}">{$resources->GetResource('plain')}</a> | 
    {if $commit->GetHash() != $head->GetHash()}
      <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=blame&hb=HEAD&f={$blob->GetPath()}">{$resources->GetResource('HEAD')}</a>

--- a/templates/blob.tpl
+++ b/templates/blob.tpl
@@ -9,7 +9,8 @@
  {include file='header.tpl'}
 
  <div class="page_nav">
-   <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=summary">{$resources->GetResource('summary')}</a> | <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=shortlog">{$resources->GetResource('shortlog')}</a> | <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=log">{$resources->GetResource('log')}</a> | <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=commit&h={$commit->GetHash()}">{$resources->GetResource('commit')}</a> | <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=commitdiff&h={$commit->GetHash()}">{$resources->GetResource('commitdiff')}</a> | <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=tree&h={$tree->GetHash()}&hb={$commit->GetHash()}">{$resources->GetResource('tree')}</a><br />
+   {include file='nav.tpl' treecommit=$commit}
+   <br />
    <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=blob_plain&h={$blob->GetHash()}&f={$blob->GetPath()}">{$resources->GetResource('plain')}</a> | 
    {if ($commit->GetHash() != $head->GetHash()) && ($head->PathToHash($blob->GetPath()))}
      <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=blob&hb=HEAD&f={$blob->GetPath()}">{$resources->GetResource('HEAD')}</a>

--- a/templates/blobdiff.tpl
+++ b/templates/blobdiff.tpl
@@ -8,9 +8,8 @@
 
  {include file='header.tpl'}
 
- {* If we managed to look up commit info, we have enough info to display the full header - othewise just use a simple header *}
  <div class="page_nav">
-   <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=summary">{$resources->GetResource('summary')}</a> | <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=shortlog">{$resources->GetResource('shortlog')}</a> | <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=log">{$resources->GetResource('log')}</a> | <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=commit&h={$commit->GetHash()}">{$resources->GetResource('commit')}</a> | <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=commitdiff&h={$commit->GetHash()}">{$resources->GetResource('commitdiff')}</a> | <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=tree&h={$tree->GetHash()}&hb={$commit->GetHash()}">{$resources->GetResource('tree')}</a>
+   {include file='nav.tpl' treecommit=$commit}
    <br />
    <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=blobdiff_plain&h={$blob->GetHash()}&hp={$blobparent->GetHash()}&f={$file}">{$resources->GetResource('plain')}</a>
  </div>

--- a/templates/commit.tpl
+++ b/templates/commit.tpl
@@ -9,8 +9,7 @@
  {include file='header.tpl'}
 
  <div class="page_nav">
-   {* Nav *}
-   <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=summary">{$resources->GetResource('summary')}</a> | <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=shortlog&h={$commit->GetHash()}">{$resources->GetResource('shortlog')}</a> | <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=log&h={$commit->GetHash()}">{$resources->GetResource('log')}</a> | {$resources->GetResource('commit')} | {if $commit->GetParent()}<a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=commitdiff&h={$commit->GetHash()}">{$resources->GetResource('commitdiff')}</a> | {/if}<a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=tree&h={$tree->GetHash()}&hb={$commit->GetHash()}">{$resources->GetResource('tree')}</a>
+   {include file='nav.tpl' logcommit=$commit treecommit=$commit current='commit'}
    <br /><br />
  </div>
 

--- a/templates/commitdiff.tpl
+++ b/templates/commitdiff.tpl
@@ -10,8 +10,12 @@
 
  {* Nav *}
  <div class="page_nav">
+   {if $commit}
    {assign var=tree value=$commit->GetTree()}
-   <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=summary">{$resources->GetResource('summary')}</a> | <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=shortlog&h={$commit->GetHash()}">{$resources->GetResource('shortlog')}</a> | <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=log&h={$commit->GetHash()}">{$resources->GetResource('log')}</a> | <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=commit&h={$commit->GetHash()}">{$resources->GetResource('commit')}</a> | {$resources->GetResource('commitdiff')} | <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=tree&h={$tree->GetHash()}&hb={$commit->GetHash()}">{$resources->GetResource('tree')}</a><br /><a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=commitdiff_plain&h={$commit->GetHash()}{if $hashparent}&hp={$hashparent}{/if}">{$resources->GetResource('plain')}</a>
+   {/if}
+   {include file='nav.tpl' current='commitdiff' logcommit=$commit treecommit=$commit}
+   <br />
+   <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=commitdiff_plain&h={$commit->GetHash()}{if $hashparent}&hp={$hashparent}{/if}">{$resources->GetResource('plain')}</a>
  </div>
 
  {include file='title.tpl' titlecommit=$commit}

--- a/templates/heads.tpl
+++ b/templates/heads.tpl
@@ -10,7 +10,7 @@
 
  {* Nav *}
  <div class="page_nav">
-   <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=summary">{$resources->GetResource('summary')}</a> | <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=shortlog">{$resources->GetResource('shortlog')}</a> | <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=log">{$resources->GetResource('log')}</a> | <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=commit&h={$head}">{$resources->GetResource('commit')}</a> | <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=commitdiff&h={$head}">{$resources->GetResource('commitdiff')}</a> | <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=tree&hb={$head}">{$resources->GetResource('tree')}</a>
+   {include file='nav.tpl' commit=$head treecommit=$head}
    <br /><br />
  </div>
 

--- a/templates/history.tpl
+++ b/templates/history.tpl
@@ -10,7 +10,7 @@
 
  {* Page header *}
  <div class="page_nav">
-   <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=summary">{$resources->GetResource('summary')}</a> | <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=shortlog">{$resources->GetResource('shortlog')}</a> | <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=log">{$resources->GetResource('log')}</a> | <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=commit&h={$commit->GetHash()}">{$resources->GetResource('commit')}</a> | <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=commitdiff&h={$commit->GetHash()}">{$resources->GetResource('commitdiff')}</a> | <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=tree&h={$tree->GetHash()}&hb={$commit->GetHash()}">{$resources->GetResource('tree')}</a>
+   {include file='nav.tpl' treecommit=$commit}
    <br /><br />
  </div>
 

--- a/templates/log.tpl
+++ b/templates/log.tpl
@@ -10,9 +10,9 @@
 
  {* Nav *}
  <div class="page_nav">
-   <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=summary">{$resources->GetResource('summary')}</a> | <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=shortlog&h={$commit->GetHash()}">{$resources->GetResource('shortlog')}</a> | {$resources->GetResource('log')} | <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=commit&h={$commit->GetHash()}">{$resources->GetResource('commit')}</a> | <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=commitdiff&h={$commit->GetHash()}">{$resources->GetResource('commitdiff')}</a> | <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=tree&h={$commit->GetHash()}&hb={$commit->GetHash()}">{$resources->GetResource('tree')}</a>
+   {include file='nav.tpl' current='log' logcommit=$commit treecommit=$commit}
    <br />
-   {if ($commit->GetHash() != $head->GetHash()) || ($page > 0)}
+   {if ($commit && $head) && (($commit->GetHash() != $head->GetHash()) || ($page > 0))}
      <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=log">{$resources->GetResource('HEAD')}</a>
    {else}
      {$resources->GetResource('HEAD')}
@@ -56,7 +56,11 @@
      <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=summary" class="title">&nbsp</a>
    </div>
    <div class="page_body">
-     Last change {$commit->GetAge()|agestring}.
+     {if $commit}
+     Last change {$commit->GetAge()|agestring}
+     {else}
+     <em>No commits</em>
+     {/if}
      <br /><br />
    </div>
  {/foreach}

file:b/templates/nav.tpl (new)
--- /dev/null
+++ b/templates/nav.tpl
@@ -1,1 +1,47 @@
+{*
+ * Nav
+ *
+ * Nav links template fragment
+ *
+ * @author Christopher Han <xiphux@gmail.com>
+ * @copyright Copyright (c) 2010 Christopher Han
+ * @package GitPHP
+ * @subpackage Template
+ *}
 
+   {if $current=='summary'}
+     {$resources->GetResource('summary')}
+   {else}
+     <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=summary">{$resources->GetResource('summary')}</a>
+   {/if}
+   | 
+   {if $current=='shortlog' || !$commit}
+     {$resources->GetResource('shortlog')}
+   {else}
+     <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=shortlog{if $logcommit}&h={$logcommit->GetHash()}{/if}">{$resources->GetResource('shortlog')}</a>
+   {/if}
+   | 
+   {if $current=='log' || !$commit}
+     {$resources->GetResource('log')}
+   {else}
+     <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=log{if $logcommit}&h={$logcommit->GetHash()}{/if}">{$resources->GetResource('log')}</a>
+   {/if}
+   | 
+   {if $current=='commit' || !$commit}
+     {$resources->GetResource('commit')}
+   {else}
+     <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=commit&h={$commit->GetHash()}">{$resources->GetResource('commit')}</a>
+   {/if}
+   | 
+   {if $current=='commitdiff' || !$commit}
+     {$resources->GetResource('commitdiff')}
+   {else}
+     <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=commitdiff&h={$commit->GetHash()}">{$resources->GetResource('commitdiff')}</a>
+   {/if}
+   | 
+   {if $current=='tree' || !$commit}
+     {$resources->GetResource('tree')}
+   {else}
+     <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=tree{if $treecommit}&hb={$treecommit->GetHash()}{/if}{if $tree}&h={$tree->GetHash()}{/if}">{$resources->GetResource('tree')}</a>
+   {/if}
+

--- a/templates/project.tpl
+++ b/templates/project.tpl
@@ -8,10 +8,9 @@
 
  {include file='header.tpl'}
 
- {* Nav *}
  <div class="page_nav">
-   {$resources->GetResource('summary')} | <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=shortlog">{$resources->GetResource('shortlog')}</a> | <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=log">{$resources->GetResource('log')}</a> | <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=commit&h={$head->GetHash()}">{$resources->GetResource('commit')}</a> | <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=commitdiff&h={$head->GetHash()}">{$resources->GetResource('commitdiff')}</a> | <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=tree">{$resources->GetResource('tree')}</a>
-   <br /><br />
+ {include file='nav.tpl' commit=$head current='summary'}
+ <br /><br />
  </div>
 
  {include file='title.tpl'}
@@ -20,7 +19,9 @@
  <table cellspacing="0">
    <tr><td>{$resources->GetResource('description')}</td><td>{$project->GetDescription()}</td></tr>
    <tr><td>{$resources->GetResource('owner')}</td><td>{$project->GetOwner()}</td></tr>
+   {if $head}
    <tr><td>{$resources->GetResource('last change')}</td><td>{$head->GetCommitterEpoch()|date_format:"%a, %d %b %Y %H:%M:%S %z"}</td></tr>
+   {/if}
    {if $project->GetCloneUrl()}
      <tr><td>{$resources->GetResource('clone url')}</td><td>{$project->GetCloneUrl()}</td></tr>
    {/if}
@@ -29,7 +30,11 @@
    {/if}
  </table>
 
- {include file='title.tpl' target='shortlog'}
+ {if !$head}
+   {include file='title.tpl' target='shortlog' disablelink=true}
+ {else}
+   {include file='title.tpl' target='shortlog'}
+ {/if}
 
  {include file='shortloglist.tpl' source='summary'}
  

--- a/templates/projectlist.tpl
+++ b/templates/projectlist.tpl
@@ -60,20 +60,25 @@
       <td><em>{$proj->GetOwner()}</em></td>
       <td>
         {assign var=projecthead value=$proj->GetHeadCommit()}
-        {if $projecthead->GetAge() < 7200}   {* 60*60*2, or 2 hours *}
-          <span class="agehighlight"><strong><em>{$projecthead->GetAge()|agestring}</em></strong></span>
-        {elseif $projecthead->GetAge() < 172800}   {* 60*60*24*2, or 2 days *}
-          <span class="agehighlight"><em>{$projecthead->GetAge()|agestring}</em></span>
-        {else}
-          <em>{$projecthead->GetAge()|agestring}</em>
-        {/if}
+	{if $projecthead}
+          {if $projecthead->GetAge() < 7200}   {* 60*60*2, or 2 hours *}
+            <span class="agehighlight"><strong><em>{$projecthead->GetAge()|agestring}</em></strong></span>
+          {elseif $projecthead->GetAge() < 172800}   {* 60*60*24*2, or 2 days *}
+            <span class="agehighlight"><em>{$projecthead->GetAge()|agestring}</em></span>
+          {else}
+            <em>{$projecthead->GetAge()|agestring}</em>
+          {/if}
+	{/if}
       </td>
       <td class="link">
-        <a href="{$SCRIPT_NAME}?p={$proj->GetProject()|urlencode}&a=summary">{$resources->GetResource('summary')}</a> | 
+        <a href="{$SCRIPT_NAME}?p={$proj->GetProject()|urlencode}&a=summary">{$resources->GetResource('summary')}</a>
+	{if $projecthead}
+	| 
 	<a href="{$SCRIPT_NAME}?p={$proj->GetProject()|urlencode}&a=shortlog">{$resources->GetResource('shortlog')}</a> | 
 	<a href="{$SCRIPT_NAME}?p={$proj->GetProject()|urlencode}&a=log">{$resources->GetResource('log')}</a> | 
 	<a href="{$SCRIPT_NAME}?p={$proj->GetProject()|urlencode}&a=tree">{$resources->GetResource('tree')}</a> | 
 	<a href="{$SCRIPT_NAME}?p={$proj->GetProject()|urlencode}&a=snapshot&h=HEAD">{$resources->GetResource('snapshot')}</a>
+	{/if}
       </td>
     </tr>
   {foreachelse}

--- a/templates/search.tpl
+++ b/templates/search.tpl
@@ -10,7 +10,7 @@
 
 {* Nav *}
 <div class="page_nav">
-  <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=summary">{$resources->GetResource('summary')}</a> | <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=shortlog&h={$commit->GetHash()}">{$resources->GetResource('shortlog')}</a> | <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=log&h={$commit->GetHash()}">{$resources->GetResource('log')}</a> | <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=commit&h={$commit->GetHash()}">{$resources->GetResource('commit')}</a> | <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=commitdiff&h={$commit->GetHash()}">{$resources->GetResource('commitdiff')}</a> | <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=tree&h={$tree->GetHash()}&hb={$commit->GetHash()}">{$resources->GetResource('tree')}</a>
+  {include file='nav.tpl' logcommit=$commit treecommit=$commit}
   <br />
   {if $page > 0}
     <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=search&h={$commit->GetHash()}&s={$search}&st={$searchtype}">{$resources->GetResource('first')}</a>

--- a/templates/searchfiles.tpl
+++ b/templates/searchfiles.tpl
@@ -10,7 +10,7 @@
 
 {* Nav *}
 <div class="page_nav">
-  <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=summary">{$resources->GetResource('summary')}</a> | <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=shortlog&h={$commit->GetHash()}">{$resources->GetResource('shortlog')}</a> | <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=log&h={$commit->GetHash()}">{$resources->GetResource('log')}</a> | <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=commit&h={$commit->GetHash()}">{$resources->GetResource('commit')}</a> | <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=commitdiff&h={$commit->GetHash()}">{$resources->GetResource('commitdiff')}</a> | <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=tree&h={$tree->GetHash()}&hb={$commit->GetHash()}">{$resources->GetResource('tree')}</a>
+  {include file='nav.tpl' logcommit=$commit treecommit=$commit}
   <br />
   {if $page > 0}
     <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=search&h={$commit->GetHash()}&s={$search}&st={$searchtype}">{$resources->GetResource('first')}</a>

--- a/templates/shortlog.tpl
+++ b/templates/shortlog.tpl
@@ -10,9 +10,9 @@
 
  {* Nav *}
  <div class="page_nav">
-   <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=summary">{$resources->GetResource('summary')}</a> | {$resources->GetResource('shortlog')} | <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=log&h={$commit->GetHash()}">{$resources->GetResource('log')}</a> | <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=commit&h={$commit->GetHash()}">{$resources->GetResource('commit')}</a> | <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=commitdiff&h={$commit->GetHash()}">{$resources->GetResource('commitdiff')}</a> | <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=tree&h={$commit->GetHash()}&hb={$commit->GetHash()}">{$resources->GetResource('tree')}</a>
+   {include file='nav.tpl' current='shortlog' logcommit=$commit treecommit=$commit}
    <br />
-   {if ($commit->GetHash() != $head->GetHash()) || ($page > 0)}
+   {if ($commit && $head) && (($commit->GetHash() != $head->GetHash()) || ($page > 0))}
      <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=shortlog">{$resources->GetResource('HEAD')}</a>
    {else}
      {$resources->GetResource('HEAD')}

--- a/templates/shortloglist.tpl
+++ b/templates/shortloglist.tpl
@@ -21,6 +21,8 @@
        <td class="link"><a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=commit&h={$rev->GetHash()}">{$resources->GetResource('commit')}</a> | <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=commitdiff&h={$rev->GetHash()}">{$resources->GetResource('commitdiff')}</a> | <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=tree&h={$rev->GetHash()}&hb={$rev->GetHash()}">{$resources->GetResource('tree')}</a> | <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=snapshot&h={$rev->GetHash()}">{$resources->GetResource('snapshot')}</a>
        </td>
      </tr>
+   {foreachelse}
+     <tr><td><em>No commits</em></td></tr>
    {/foreach}
 
    {if $hasmorerevs}

--- a/templates/tag.tpl
+++ b/templates/tag.tpl
@@ -10,7 +10,7 @@
 
  {* Nav *}
  <div class="page_nav">
-   <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=summary">{$resources->GetResource('summary')}</a> | <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=shortlog">{$resources->GetResource('shortlog')}</a> | <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=log">{$resources->GetResource('log')}</a> | <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=commit&h={$head}">{$resources->GetResource('commit')}</a> | <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=commitdiff&h={$head}">{$resources->GetResource('commitdiff')}</a> | <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=tree&hb={$head}">{$resources->GetResource('tree')}</a>
+   {include file='nav.tpl' commit=$head treecommit=$head}
    <br /><br />
  </div>
  {* Tag data *}

--- a/templates/tags.tpl
+++ b/templates/tags.tpl
@@ -10,7 +10,7 @@
 
  {* Nav *}
  <div class="page_nav">
-   <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=summary">{$resources->GetResource('summary')}</a> | <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=shortlog">{$resources->GetResource('shortlog')}</a> | <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=log">{$resources->GetResource('log')}</a> | <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=commit&h={$head}">{$resources->GetResource('commit')}</a> | <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=commitdiff&h={$head}">{$resources->GetResource('commitdiff')}</a> | <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=tree&hb={$head}">{$resources->GetResource('tree')}</a>
+   {include file='nav.tpl' commit=$head treecommit=$head}
    <br /><br />
  </div>
 

--- a/templates/title.tpl
+++ b/templates/title.tpl
@@ -23,11 +23,23 @@
 		{if $target == 'summary'}
 			<a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=summary" class="title">&nbsp;</a>
 		{elseif $target == 'shortlog'}
-			<a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=shortlog" class="title">{$resources->GetResource('shortlog')}</a>
+			{if $disablelink}
+			  {$resources->GetResource('shortlog')}
+			{else}
+			  <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=shortlog" class="title">{$resources->GetResource('shortlog')}</a>
+			{/if}
 		{elseif $target == 'tags'}
-			<a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=tags" class="title">{$resources->GetResource('tags')}</a>
+			{if $disablelink}
+			  {$resources->GetResource('tags')}
+			{else}
+			  <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=tags" class="title">{$resources->GetResource('tags')}</a>
+			{/if}
 		{elseif $target == 'heads'}
-			<a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=heads" class="title">{$resources->GetResource('heads')}</a>
+			{if $disablelink}
+			  {$resources->GetResource('heads')}
+			{else}
+			  <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=heads" class="title">{$resources->GetResource('heads')}</a>
+			{/if}
 		{else}
 			&nbsp;
 		{/if}

--- a/templates/tree.tpl
+++ b/templates/tree.tpl
@@ -10,7 +10,8 @@
 
  {* Nav *}
    <div class="page_nav">
-     <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=summary">{$resources->GetResource('summary')}</a> | <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=shortlog&h={$commit->GetHash()}">{$resources->GetResource('shortlog')}</a> | <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=log&h={$commit->GetHash()}">{$resources->GetResource('log')}</a> | <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=commit&h={$commit->GetHash()}">{$resources->GetResource('commit')}</a> | <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=commitdiff&h={$commit->GetHash()}">{$resources->GetResource('commitdiff')}</a> | {$resources->GetResource('tree')}<br /><br />
+     {include file='nav.tpl' current='tree' logcommit=$commit}
+     <br /><br />
    </div>
 
  {include file='title.tpl' titlecommit=$commit}

comments