Unify commitdiff template
Unify commitdiff template

--- a/include/display.git_commitdiff.php
+++ b/include/display.git_commitdiff.php
@@ -12,7 +12,7 @@
  require_once('gitutil.git_read_commit.php');
  require_once('gitutil.git_diff_tree.php');
  require_once('gitutil.read_info_ref.php');
- require_once('display.git_diff_print.php');
+ require_once('gitutil.git_diff.php');
 
 function git_commitdiff($projectroot,$project,$hash,$hash_parent)
 {
@@ -33,38 +33,33 @@
 	$tpl->assign("hash",$hash);
 	$tpl->assign("tree",$co['tree']);
 	$tpl->assign("hashparent",$hash_parent);
-	$tpl->display("commitdiff_nav.tpl");
 	$tpl->assign("title",$co['title']);
 	if (isset($refs[$co['id']]))
 		$tpl->assign("commitref",$refs[$co['id']]);
 	$tpl->assign("comment",$co['comment']);
-	$tpl->display("commitdiff_header.tpl");
-
+	$difftreelines = array();
 	foreach ($difftree as $i => $line) {
 		if (ereg("^:([0-7]{6}) ([0-7]{6}) ([0-9a-fA-F]{40}) ([0-9a-fA-F]{40}) (.)\t(.*)$",$line,$regs)) {
-			$tpl->clear_all_assign();
-			$tpl->assign("project",$project);
-			$tpl->assign("hash",$hash);
-			$tpl->assign("from_mode",$regs[1]);
-			$tpl->assign("to_mode",$regs[2]);
-			$tpl->assign("from_id",$regs[3]);
-			$tpl->assign("to_id",$regs[4]);
-			$tpl->assign("status",$regs[5]);
-			$tpl->assign("file",$regs[6]);
-			$tpl->assign("from_type",file_type($regs[1]));
-			$tpl->assign("to_type",file_type($regs[2]));
-			$tpl->display("commitdiff_item.tpl");
+			$difftreeline = array();
+			$difftreeline["from_mode"] = $regs[1];
+			$difftreeline["to_mode"] = $regs[2];
+			$difftreeline["from_id"] = $regs[3];
+			$difftreeline["to_id"] = $regs[4];
+			$difftreeline["status"] = $regs[5];
+			$difftreeline["file"] = $regs[6];
+			$difftreeline["from_type"] = file_type($regs[1]);
+			$difftreeline["to_type"] = file_type($regs[2]);
 			if ($regs[5] == "A")
-				git_diff_print($projectroot . $project, null,"/dev/null",$regs[4],"b/" . $regs[6]);
+				$difftreeline['diffout'] = explode("\n",git_diff($projectroot . $project, null,"/dev/null",$regs[4],"b/" . $regs[6]));
 			else if ($regs[5] == "D")
-				git_diff_print($projectroot . $project, $regs[3],"a/" . $regs[6],null,"/dev/null");
+				$difftreeline['diffout'] = explode("\n",git_diff($projectroot . $project, $regs[3],"a/" . $regs[6],null,"/dev/null"));
 			else if (($regs[5] == "M") && ($regs[3] != $regs[4]))
-				git_diff_print($projectroot . $project, $regs[3],"a/" . $regs[6],$regs[4],"b/" . $regs[6]);
+				$difftreeline['diffout'] = explode("\n",git_diff($projectroot . $project, $regs[3],"a/" . $regs[6],$regs[4],"b/" . $regs[6]));
+			$difftreelines[] = $difftreeline;
 		}
 	}
-
-	$tpl->clear_all_assign();
-	$tpl->display("commitdiff_footer.tpl");
+	$tpl->assign("difftreelines",$difftreelines);
+	$tpl->display("commitdiff.tpl");
 }
 
 ?>

--- /dev/null
+++ b/templates/commitdiff.tpl
@@ -1,1 +1,41 @@
+{*
+ *  commitdiff.tpl
+ *  gitphp: A PHP git repository browser
+ *  Component: Commitdiff view template
+ *
+ *  Copyright (C) 2009 Christopher Han <xiphux@gmail.com>
+ *}
+ <div class="page_nav">
+   <a href="{$SCRIPT_NAME}?p={$project}&a=summary">summary</a> | <a href="{$SCRIPT_NAME}?p={$project}&a=shortlog&h={$hash}">shortlog</a> | <a href="{$SCRIPT_NAME}?p={$project}&a=log&h={$hash}">log</a> | <a href="{$SCRIPT_NAME}?p={$project}&a=commit&h={$hash}">commit</a> | commitdiff | <a href="{$SCRIPT_NAME}?p={$project}&a=tree&h={$tree}&hb={$hash}">tree</a><br /><a href="{$SCRIPT_NAME}?p={$project}&a=commitdiff_plain&h={$hash}&hp={$hashparent}">plain</a>
+ </div>
+ <div>
+   <br /><br />
+ </div>
+ <div>
+   <a href="{$SCRIPT_NAME}?p={$project}&a=commit&h={$hash}" class="title">{$title}{if $commitref} <span class="tag">{$commitref}</span>{/if}</a>
+ </div>
+ <div class="page_body">
+   {foreach from=$comment item=line}
+     {$line}<br />
+   {/foreach}
+   <br />
+   {section name=difftree loop=$difftreelines}
+     {if $difftreelines[difftree].status == "A"}
+       <div class="diff_info">
+         {$difftreelines[difftree].to_type}:<a href="{$SCRIPT_NAME}?p={$project}&a=blob&h={$difftreelines[difftree].to_id}&hb={$hash}&f={$difftreelines[difftree].file}">{if $difftreelines[difftree].file}{$difftreelines[difftree].file}{else}{$difftreelines[difftree].to_id}{/if}</a>(new)
+       </div>
+     {elseif $difftreelines[difftree].status == "D"}
+       <div class="diff_info">
+         {$difftreelines[difftree].from_type}:<a href="{$SCRIPT_NAME}?p={$project}&a=blob&h={$difftreelines[difftree].from_id}&hb={$hash}&f={$difftreelines[difftree].file}">{if $difftreelines[difftree].file}{$difftreelines[difftree].file}{else}{$difftreelines[difftree].from_id}{/if}</a>(deleted)
+       </div>
+     {elseif $difftreelines[difftree].status == "M"}
+       {if $difftreelines[difftree].from_id != $difftreelines[difftree].to_id}
+         <div class="diff_info">
+	   {$difftreelines[difftree].from_type}:<a href="{$SCRIPT_NAME}?p={$project}&a=blob&h={$difftreelines[difftree].from_id}&hb={$hash}&f={$difftreelines[difftree].file}">{if $difftreelines[difftree].file}a/{$difftreelines[difftree].file}{else}{$difftreelines[difftree].from_id}{/if}</a> -&gt; {$difftreelines[difftree].to_type}:<a href="{$SCRIPT_NAME}?p={$project}&a=blob&h={$difftreelines[difftree].to_id}&hb={$hash}&f={$difftreelines[difftree].file}">{if $difftreelines[difftree].file}b/{$difftreelines[difftree].file}{else}{$difftreelines[difftree].to_id}{/if}</a>
+	 </div>
+       {/if}
+     {/if}
+     {include file='filediff.tpl' diff=$difftreelines[difftree].diffout}
+   {/section}
+ </div>
 

--- a/templates/commitdiff_footer.tpl
+++ /dev/null
@@ -1,10 +1,1 @@
-{*
- *  commitdiff_footer.tpl
- *  gitphp: A PHP git repository browser
- *  Component: Commitdiff view footer template
- *
- *  Copyright (C) 2006 Christopher Han <xiphux@gmail.com>
- *}
- <br />
- </div>
 

--- a/templates/commitdiff_header.tpl
+++ /dev/null
@@ -1,14 +1,1 @@
-{*
- *  commitdiff_header.tpl
- *  gitphp: A PHP git repository browser
- *  Component: Commitdiff view header template
- *
- *  Copyright (C) 2006 Christopher Han <xiphux@gmail.com>
- *}
- <div><a href="{$SCRIPT_NAME}?p={$project}&a=commit&h={$hash}" class="title">{$title}{if $commitref} <span class="tag">{$commitref}</span>{/if}</a></div>
- <div class="page_body">
- {foreach from=$comment item=line}
- {$line}<br />
- {/foreach}
- <br />
 

--- a/templates/commitdiff_item.tpl
+++ /dev/null
@@ -1,23 +1,1 @@
-{*
- *  commitdiff_item.tpl
- *  gitphp: A PHP git repository browser
- *  Component: Commitdiff view item template
- *
- *  Copyright (C) 2006 Christopher Han <xiphux@gmail.com>
- *}
- {if $status == "A"}
-   <div class="diff_info">
-   {$to_type}:<a href="{$SCRIPT_NAME}?p={$project}&a=blob&h={$to_id}&hb={$hash}&f={$file}">{if $file}{$file}{else}{$to_id}{/if}</a>(new)
-   </div>
- {elseif $status == "D"}
-   <div class="diff_info">
-   {$from_type}:<a href="{$SCRIPT_NAME}?p={$project}&a=blob&h={$from_id}&hb={$hash}&f={$file}">{if $file}{$file}{else}{$from_id}{/if}</a>(deleted)
-   </div>
- {elseif $status == "M"}
-   {if $from_id != $to_id}
-     <div class="diff_info">
-     {$from_type}:<a href="{$SCRIPT_NAME}?p={$project}&a=blob&h={$from_id}&hb={$hash}&f={$file}">{if $file}a/{$file}{else}{$from_id}{/if}</a> -&gt; {$to_type}:<a href="{$SCRIPT_NAME}?p={$project}&a=blob&h={$to_id}&hb={$hash}&f={$file}">{if $file}b/{$file}{else}{$to_id}{/if}</a>
-     </div>
-   {/if}
- {/if}
 

--- a/templates/commitdiff_nav.tpl
+++ /dev/null
@@ -1,13 +1,1 @@
-{*
- *  commitdiff_nav.tpl
- *  gitphp: A PHP git repository browser
- *  Component: Commitdiff view nav template
- *
- *  Copyright (C) 2006 Christopher Han <xiphux@gmail.com>
- *}
- <div class="page_nav">
- <a href="{$SCRIPT_NAME}?p={$project}&a=summary">summary</a> | <a href="{$SCRIPT_NAME}?p={$project}&a=shortlog&h={$hash}">shortlog</a> | <a href="{$SCRIPT_NAME}?p={$project}&a=log&h={$hash}">log</a> | <a href="{$SCRIPT_NAME}?p={$project}&a=commit&h={$hash}">commit</a> | commitdiff | <a href="{$SCRIPT_NAME}?p={$project}&a=tree&h={$tree}&hb={$hash}">tree</a><br /><a href="{$SCRIPT_NAME}?p={$project}&a=commitdiff_plain&h={$hash}&hp={$hashparent}">plain</a>
- </div>
- <br /><br />
- </div>
 

comments